pull/137/head
FongMi 2 years ago
parent 4673d0f4c5
commit 0cf5e8c7e0
  1. 3
      app/src/main/java/com/fongmi/android/tv/bean/Vod.java
  2. 14
      app/src/mobile/java/com/fongmi/android/tv/Product.java
  3. 5
      app/src/mobile/java/com/fongmi/android/tv/ui/base/ViewType.java
  4. 2
      app/src/mobile/java/com/fongmi/android/tv/ui/fragment/TypeFragment.java

@ -207,7 +207,8 @@ public class Vod {
if (getVodShow().equals("land")) return ViewType.LAND;
if (getVodShow().equals("oval")) return ViewType.OVAL;
if (getVodShow().equals("full")) return ViewType.FULL;
if (getVodShow().equals("list")) return ViewType.FOLDER;
if (getVodShow().equals("list")) return ViewType.LIST;
if (getVodShow().equals("folder")) return ViewType.FOLDER;
return ViewType.GRID;
}

@ -15,6 +15,10 @@ public class Product {
return Math.abs(Setting.getSize() - 5);
}
public static int getColumn(int viewType) {
return viewType == ViewType.LAND ? getColumn() - 1 : getColumn();
}
public static void bootLive() {
}
@ -23,22 +27,24 @@ public class Product {
}
public static int[] getSpec(Context context, int viewType) {
return getSpec(context, ResUtil.dp2px(32) + ResUtil.dp2px(16 * (getColumn() - 1)), getColumn(), viewType);
int column = getColumn(viewType);
int space = ResUtil.dp2px(32) + ResUtil.dp2px(16 * (column - 1));
return getSpec(context, space, column, viewType);
}
public static int[] getSpec(Context context, int space, int column) {
return getSpec(context, space, column, ViewType.GRID);
}
public static int[] getSpec(Context context, int space, int column, int viewType) {
private static int[] getSpec(Context context, int space, int column, int viewType) {
int base = ResUtil.getScreenWidth(context) - space;
int width = base / column;
return new int[]{width, getHeight(viewType, width)};
}
private static int getHeight(int viewType, int value) {
if (viewType == ViewType.GRID) return (int) (value / 0.75f);
if (viewType == ViewType.LAND) return (int) (value * 0.75f);
return value;
if (viewType == ViewType.OVAL) return value;
return (int) (value / 0.75f);
}
}

@ -6,9 +6,8 @@ public class ViewType {
public static final int LAND = 1;
public static final int OVAL = 2;
public static final int FULL = 3;
public static final int LIST = 98;
public static final int FOLDER = 99;
public static final int LIST = 4;
public static final int FOLDER = 5;
public static final int DARK = 0;
public static final int LIGHT = 1;

@ -119,7 +119,7 @@ public class TypeFragment extends BaseFragment implements CustomScroller.Callbac
private void setViewType(int viewType) {
mAdapter.setViewType(viewType);
mAdapter.setSize(Product.getSpec(getActivity(), viewType));
mBinding.recycler.setLayoutManager(mAdapter.isList() ? new LinearLayoutManager(getActivity()) : new GridLayoutManager(getContext(), Product.getColumn()));
mBinding.recycler.setLayoutManager(mAdapter.isList() ? new LinearLayoutManager(getActivity()) : new GridLayoutManager(getContext(), Product.getColumn(viewType)));
}
private void setViewModel() {

Loading…
Cancel
Save