[mobile] fix bug

pull/142/head
FongMi 2 years ago
parent 0326c64f95
commit 30c1c5ef27
  1. 8
      app/src/main/java/com/fongmi/android/tv/utils/ResUtil.java
  2. 10
      app/src/mobile/java/com/fongmi/android/tv/Product.java
  3. 2
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/CollectActivity.java
  4. 2
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/HistoryActivity.java
  5. 2
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/KeepActivity.java
  6. 2
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/LiveActivity.java
  7. 8
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java
  8. 2
      app/src/mobile/java/com/fongmi/android/tv/ui/custom/dialog/EpisodeGridDialog.java
  9. 2
      app/src/mobile/java/com/fongmi/android/tv/ui/fragment/TypeFragment.java

@ -85,12 +85,8 @@ public class ResUtil {
return e.getRawX() < edge || e.getRawX() > getScreenWidthNav() - edge || e.getRawY() < edge || e.getRawY() > getScreenHeightNav() - edge;
}
public static int getOrient() {
return App.get().getResources().getConfiguration().orientation;
}
public static boolean isLand() {
return getOrient() == Configuration.ORIENTATION_LANDSCAPE;
public static boolean isLand(Context context) {
return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
}
public static boolean isPad() {

@ -11,14 +11,14 @@ public class Product {
return 1;
}
public static int getColumn() {
int count = ResUtil.isLand() ? 7 : 5;
public static int getColumn(Context context) {
int count = ResUtil.isLand(context) ? 7 : 5;
count = count + (ResUtil.isPad() ? 1 : 0);
return Math.abs(Setting.getSize() - count);
}
public static int getColumn(Style style) {
return style.isLand() ? getColumn() - 1 : getColumn();
public static int getColumn(Context context, Style style) {
return style.isLand() ? getColumn(context) - 1 : getColumn(context);
}
public static int[] getSpec(Context context) {
@ -26,7 +26,7 @@ public class Product {
}
public static int[] getSpec(Context context, Style style) {
int column = getColumn(style);
int column = getColumn(context, style);
int space = ResUtil.dp2px(32) + ResUtil.dp2px(16 * (column - 1));
if (style.isOval()) space += ResUtil.dp2px(column * 16);
return getSpec(context, space, column, style);

@ -140,7 +140,7 @@ public class CollectActivity extends BaseActivity implements CustomScroller.Call
}
private void setViewType(int viewType) {
int count = Product.getColumn() - 1;
int count = Product.getColumn(this) - 1;
mSearchAdapter.setViewType(viewType, count);
mSearchAdapter.setSize(Product.getSpec(this, ResUtil.dp2px((count + 2) * 16), count + 1));
((GridLayoutManager) mBinding.recycler.getLayoutManager()).setSpanCount(mSearchAdapter.isGrid() ? count : 1);

@ -50,7 +50,7 @@ public class HistoryActivity extends BaseActivity implements HistoryAdapter.OnCl
private void setRecyclerView() {
mBinding.recycler.setHasFixedSize(true);
mBinding.recycler.getItemAnimator().setChangeDuration(0);
mBinding.recycler.setLayoutManager(new GridLayoutManager(this, Product.getColumn()));
mBinding.recycler.setLayoutManager(new GridLayoutManager(this, Product.getColumn(this)));
mBinding.recycler.setAdapter(mAdapter = new HistoryAdapter(this));
mAdapter.setSize(Product.getSpec(getActivity()));
}

@ -54,7 +54,7 @@ public class KeepActivity extends BaseActivity implements KeepAdapter.OnClickLis
private void setRecyclerView() {
mBinding.recycler.setHasFixedSize(true);
mBinding.recycler.getItemAnimator().setChangeDuration(0);
mBinding.recycler.setLayoutManager(new GridLayoutManager(this, Product.getColumn()));
mBinding.recycler.setLayoutManager(new GridLayoutManager(this, Product.getColumn(this)));
mBinding.recycler.setAdapter(mAdapter = new KeepAdapter(this));
mAdapter.setSize(Product.getSpec(getActivity()));
}

@ -301,7 +301,7 @@ public class LiveActivity extends BaseActivity implements CustomKeyDownLive.List
private void onRotate() {
setR1Callback();
setRotate(!isRotate());
setRequestedOrientation(ResUtil.isLand() ? ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
setRequestedOrientation(ResUtil.isLand(this) ? ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
}
private void onTrack(View view) {

@ -371,7 +371,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
private void setVideoView() {
mPlayers.set(getExo(), getIjk());
if (isPort() && ResUtil.isLand()) enterFullscreen();
if (isPort() && ResUtil.isLand(this)) enterFullscreen();
getExo().getSubtitleView().setStyle(ExoUtil.getCaptionStyle());
getIjk().getSubtitleView().setStyle(ExoUtil.getCaptionStyle());
setSubtitle(14);
@ -666,7 +666,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
private void onRotate() {
setR1Callback();
setRotate(!isRotate());
setRequestedOrientation(ResUtil.isLand() ? ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
setRequestedOrientation(ResUtil.isLand(this) ? ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
}
private void onSetting() {
@ -830,13 +830,13 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
private int getLockOrient() {
if (isLock()) {
return ResUtil.isLand() ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
return ResUtil.isLand(this) ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
} else if (isRotate()) {
return ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT;
} else if (isPort() && Utils.isAutoRotate()) {
return ActivityInfo.SCREEN_ORIENTATION_FULL_USER;
} else {
return ResUtil.isLand() ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT;
return ResUtil.isLand(this) ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT;
}
}

@ -67,7 +67,7 @@ public class EpisodeGridDialog extends BaseDialog {
private void setSpanCount() {
int total = 0;
int row = ResUtil.isLand() ? 5 : 10;
int row = ResUtil.isLand(getActivity()) ? 5 : 10;
for (Episode item : episodes) total += item.getName().length();
int offset = (int) Math.ceil((double) total / episodes.size());
if (offset >= 12) spanCount = 1;

@ -125,7 +125,7 @@ public class TypeFragment extends BaseFragment implements CustomScroller.Callbac
private void setStyle(Style style) {
mBinding.recycler.setAdapter(mAdapter = new VodAdapter(this, style, Product.getSpec(getActivity(), style)));
mBinding.recycler.setLayoutManager(style.isList() ? new LinearLayoutManager(getActivity()) : new GridLayoutManager(getContext(), Product.getColumn(style)));
mBinding.recycler.setLayoutManager(style.isList() ? new LinearLayoutManager(getActivity()) : new GridLayoutManager(getContext(), Product.getColumn(getActivity(), style)));
}
private void setViewModel() {

Loading…
Cancel
Save