Skip to content

Commit

Permalink
Merge pull request CatVodTVOfficial#135 from CatVodTVOfficial/dev
Browse files Browse the repository at this point in the history
Autosize fix. Mix parse fix. Add call mxplayer with subtitle support。
  • Loading branch information
lite-cucumber authored Jul 5, 2022
2 parents b7c47f9 + 08f8056 commit d908313
Show file tree
Hide file tree
Showing 8 changed files with 656 additions and 36 deletions.
3 changes: 2 additions & 1 deletion app/src/main/java/com/github/tvbox/osc/base/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.kingja.loadsir.core.LoadSir;
import com.orhanobut.hawk.Hawk;

import me.jessyan.autosize.AutoSize;
import me.jessyan.autosize.AutoSizeConfig;
import me.jessyan.autosize.unit.Subunits;

Expand All @@ -38,7 +39,7 @@ public void onCreate() {
.addCallback(new EmptyCallback())
.addCallback(new LoadingCallback())
.commit();
AutoSizeConfig.getInstance().getUnitsManager()
AutoSizeConfig.getInstance().setCustomFragment(true).getUnitsManager()
.setSupportDP(false)
.setSupportSP(false)
.setSupportSubunits(Subunits.MM);
Expand Down
30 changes: 28 additions & 2 deletions app/src/main/java/com/github/tvbox/osc/base/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Looper;
import android.util.DisplayMetrics;
import android.view.View;

import androidx.annotation.Nullable;
Expand All @@ -25,18 +26,32 @@
import java.io.InputStreamReader;

import me.jessyan.autosize.AutoSizeCompat;
import me.jessyan.autosize.internal.CustomAdapt;

/**
* @author pj567
* @date :2020/12/17
* @description:
*/
public abstract class BaseActivity extends AppCompatActivity {
public abstract class BaseActivity extends AppCompatActivity implements CustomAdapt {
protected Context mContext;
private LoadService mLoadService;

private static float screenRatio = -100.0f;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
try {
if (screenRatio < 0) {
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int screenWidth = dm.widthPixels;
int screenHeight = dm.heightPixels;
screenRatio = (float) Math.max(screenWidth, screenHeight) / (float) Math.min(screenWidth, screenHeight);
}
} catch (Throwable th) {
th.printStackTrace();
}
super.onCreate(savedInstanceState);
setContentView(getLayoutResID());
mContext = this;
Expand Down Expand Up @@ -66,7 +81,7 @@ public void hideSysBar() {
@Override
public Resources getResources() {
if (Looper.myLooper() == Looper.getMainLooper()) {
AutoSizeCompat.autoConvertDensityOfGlobal(super.getResources());
AutoSizeCompat.autoConvertDensityOfCustomAdapt(super.getResources(), this);
}
return super.getResources();
}
Expand Down Expand Up @@ -145,4 +160,15 @@ protected String getAssetText(String fileName) {
}
return "";
}

@Override
public float getSizeInDp() {
return 0;
}

@Override
public boolean isBaseOnWidth() {
return !(screenRatio >= 2.0f);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void onAttach(@NonNull Context context) {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
AutoSize.autoConvertDensity(getActivity(), getSizeInDp(), true);
AutoSize.autoConvertDensity(getActivity(), getSizeInDp(), isBaseOnWidth());
if (null == rootView) {
rootView = inflater.inflate(getLayoutResID(), container, false);
}
Expand Down Expand Up @@ -198,7 +198,7 @@ private boolean isSupportVisible() {
*/
@Override
public void onResume() {
AutoSize.autoConvertDensity(getActivity(), getSizeInDp(), true);
AutoSize.autoConvertDensity(getActivity(), getSizeInDp(), isBaseOnWidth());
super.onResume();
// 如果不是第一次可见
if (!mIsFirstVisible) {
Expand Down Expand Up @@ -286,11 +286,15 @@ public void jumpActivity(Class<? extends BaseActivity> clazz, Bundle bundle) {

@Override
public float getSizeInDp() {
return 1280;
if (getActivity() != null && getActivity() instanceof CustomAdapt)
return ((CustomAdapt) getActivity()).getSizeInDp();
return 0;
}

@Override
public boolean isBaseOnWidth() {
if (getActivity() != null && getActivity() instanceof CustomAdapt)
return ((CustomAdapt) getActivity()).isBaseOnWidth();
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,10 @@ public void onClick(View view) {
try {
int playerType = mPlayerConfig.getInt("pl");
playerType++;
if (playerType > 2)
if (playerType > 10)
playerType = 0;
if (playerType > 2)
playerType = 10;
mPlayerConfig.put("pl", playerType);
updatePlayerCfgView();
listener.updatePlayerCfg();
Expand Down
Loading

0 comments on commit d908313

Please sign in to comment.