pull/143/head
21561 9 months ago
parent bd99b61098
commit e5aa0e4da1
  1. 6
      app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java
  2. 6
      app/src/main/java/com/github/tvbox/osc/ui/activity/HomeActivity.java
  3. 4
      app/src/main/java/com/github/tvbox/osc/ui/fragment/ModelSettingFragment.java

@ -428,15 +428,17 @@ public class ApiConfig {
sb.setPlayerType(DefaultConfig.safeJsonInt(obj, "playerType", -1)); sb.setPlayerType(DefaultConfig.safeJsonInt(obj, "playerType", -1));
sb.setCategories(DefaultConfig.safeJsonStringList(obj, "categories")); sb.setCategories(DefaultConfig.safeJsonStringList(obj, "categories"));
sb.setClickSelector(DefaultConfig.safeJsonString(obj, "click", "")); sb.setClickSelector(DefaultConfig.safeJsonString(obj, "click", ""));
if (firstSite == null) if (firstSite == null && sb.getFilterable()==1)
firstSite = sb; firstSite = sb;
sourceBeanList.put(siteKey, sb); sourceBeanList.put(siteKey, sb);
} }
if (sourceBeanList != null && sourceBeanList.size() > 0) { if (sourceBeanList != null && sourceBeanList.size() > 0) {
String home = Hawk.get(HawkConfig.HOME_API, ""); String home = Hawk.get(HawkConfig.HOME_API, "");
SourceBean sh = getSource(home); SourceBean sh = getSource(home);
if (sh == null) if (sh == null) {
assert firstSite != null;
setSourceBean(firstSite); setSourceBean(firstSite);
}
else else
setSourceBean(sh); setSourceBean(sh);
} }

@ -623,13 +623,15 @@ public class HomeActivity extends BaseActivity {
SelectDialog<SourceBean> dialog = new SelectDialog<>(HomeActivity.this); SelectDialog<SourceBean> dialog = new SelectDialog<>(HomeActivity.this);
TvRecyclerView tvRecyclerView = dialog.findViewById(R.id.list); TvRecyclerView tvRecyclerView = dialog.findViewById(R.id.list);
int spanCount; int spanCount;
spanCount = (int)Math.floor(sites.size() / 20); spanCount = (int)Math.floor(sites.size()/20);
spanCount = Math.min(spanCount, 2); spanCount = Math.min(spanCount, 2);
tvRecyclerView.setLayoutManager(new V7GridLayoutManager(dialog.getContext(), spanCount+1)); tvRecyclerView.setLayoutManager(new V7GridLayoutManager(dialog.getContext(), spanCount+1));
ConstraintLayout cl_root = dialog.findViewById(R.id.cl_root); ConstraintLayout cl_root = dialog.findViewById(R.id.cl_root);
ViewGroup.LayoutParams clp = cl_root.getLayoutParams(); ViewGroup.LayoutParams clp = cl_root.getLayoutParams();
clp.width = AutoSizeUtils.mm2px(dialog.getContext(), 380+200*spanCount); clp.width = AutoSizeUtils.mm2px(dialog.getContext(), 380+200*spanCount);
dialog.setTip("请选择首页数据源"); dialog.setTip("请选择首页数据源");
int select = sites.indexOf(ApiConfig.get().getHomeSourceBean());
if (select<0) select = 0;
dialog.setAdapter(new SelectDialogAdapter.SelectDialogInterface<SourceBean>() { dialog.setAdapter(new SelectDialogAdapter.SelectDialogInterface<SourceBean>() {
@Override @Override
public void click(SourceBean value, int pos) { public void click(SourceBean value, int pos) {
@ -656,7 +658,7 @@ public class HomeActivity extends BaseActivity {
public boolean areContentsTheSame(@NonNull @NotNull SourceBean oldItem, @NonNull @NotNull SourceBean newItem) { public boolean areContentsTheSame(@NonNull @NotNull SourceBean oldItem, @NonNull @NotNull SourceBean newItem) {
return oldItem.getKey().equals(newItem.getKey()); return oldItem.getKey().equals(newItem.getKey());
} }
}, sites, sites.indexOf(ApiConfig.get().getHomeSourceBean())); }, sites, select);
dialog.show(); dialog.show();
} }
} }

@ -213,6 +213,8 @@ public class ModelSettingFragment extends BaseLazyFragment {
if (sites.size() > 0) { if (sites.size() > 0) {
SelectDialog<SourceBean> dialog = new SelectDialog<>(mActivity); SelectDialog<SourceBean> dialog = new SelectDialog<>(mActivity);
dialog.setTip("请选择首页数据源"); dialog.setTip("请选择首页数据源");
int select = sites.indexOf(ApiConfig.get().getHomeSourceBean());
if (select<0) select = 0;
dialog.setAdapter(new SelectDialogAdapter.SelectDialogInterface<SourceBean>() { dialog.setAdapter(new SelectDialogAdapter.SelectDialogInterface<SourceBean>() {
@Override @Override
public void click(SourceBean value, int pos) { public void click(SourceBean value, int pos) {
@ -241,7 +243,7 @@ public class ModelSettingFragment extends BaseLazyFragment {
public boolean areContentsTheSame(@NonNull @NotNull SourceBean oldItem, @NonNull @NotNull SourceBean newItem) { public boolean areContentsTheSame(@NonNull @NotNull SourceBean oldItem, @NonNull @NotNull SourceBean newItem) {
return oldItem.getKey().equals(newItem.getKey()); return oldItem.getKey().equals(newItem.getKey());
} }
}, sites, sites.indexOf(ApiConfig.get().getHomeSourceBean())); }, sites, select);
dialog.show(); dialog.show();
} }
} }

Loading…
Cancel
Save