集数动态分组; 首页换源动态列数; 指定搜索源逻辑优化; 内置ijk配置更新;

pull/70/head
于俊 3 years ago
parent 579a61d878
commit 2cfb82f509
  1. 2
      app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java
  2. 108
      app/src/main/java/com/github/tvbox/osc/ui/activity/DetailActivity.java
  3. 36
      app/src/main/java/com/github/tvbox/osc/ui/activity/HomeActivity.java
  4. 11
      app/src/main/java/com/github/tvbox/osc/ui/activity/PlayActivity.java
  5. 13
      app/src/main/java/com/github/tvbox/osc/ui/activity/SearchActivity.java
  6. 13
      app/src/main/java/com/github/tvbox/osc/ui/adapter/CheckboxSearchAdapter.java
  7. 3
      app/src/main/java/com/github/tvbox/osc/ui/adapter/SelectDialogAdapter.java
  8. 29
      app/src/main/java/com/github/tvbox/osc/ui/dialog/SearchCheckboxDialog.java
  9. 65
      app/src/main/java/com/github/tvbox/osc/util/SearchHelper.java
  10. 14
      app/src/main/res/layout/activity_detail.xml
  11. 2
      app/src/main/res/layout/dialog_select.xml
  12. 6
      app/src/main/res/layout/item_series.xml

@ -432,7 +432,7 @@ public class ApiConfig {
}
}
String defaultIJKADS="{\"ijk\":[{\"options\":[{\"name\":\"opensles\",\"category\":4,\"value\":\"0\"},{\"name\":\"overlay-format\",\"category\":4,\"value\":\"842225234\"},{\"name\":\"framedrop\",\"category\":4,\"value\":\"1\"},{\"name\":\"soundtouch\",\"category\":4,\"value\":\"1\"},{\"name\":\"start-on-prepared\",\"category\":4,\"value\":\"1\"},{\"name\":\"http-detect-rangeupport\",\"category\":1,\"value\":\"0\"},{\"name\":\"fflags\",\"category\":1,\"value\":\"fastseek\"},{\"name\":\"skip_loop_filter\",\"category\":2,\"value\":\"48\"},{\"name\":\"reconnect\",\"category\":4,\"value\":\"1\"},{\"name\":\"enable-accurateeek\",\"category\":4,\"value\":\"0\"},{\"name\":\"mediacodec\",\"category\":4,\"value\":\"0\"},{\"name\":\"mediacodec-auto-rotate\",\"category\":4,\"value\":\"0\"},{\"name\":\"mediacodec-handle-resolution-change\",\"category\":4,\"value\":\"0\"},{\"name\":\"mediacodec-hevc\",\"category\":4,\"value\":\"0\"},{\"name\":\"dns_cache_timeout\",\"category\":1,\"value\":\"600000000\"}],\"group\":\"软解码\"},{\"options\":[{\"name\":\"opensles\",\"category\":4,\"value\":\"0\"},{\"name\":\"overlay-format\",\"category\":4,\"value\":\"842225234\"},{\"name\":\"framedrop\",\"category\":4,\"value\":\"1\"},{\"name\":\"soundtouch\",\"category\":4,\"value\":\"1\"},{\"name\":\"start-on-prepared\",\"category\":4,\"value\":\"1\"},{\"name\":\"http-detect-rangeupport\",\"category\":1,\"value\":\"0\"},{\"name\":\"fflags\",\"category\":1,\"value\":\"fastseek\"},{\"name\":\"skip_loop_filter\",\"category\":2,\"value\":\"48\"},{\"name\":\"reconnect\",\"category\":4,\"value\":\"1\"},{\"name\":\"enable-accurateeek\",\"category\":4,\"value\":\"0\"},{\"name\":\"mediacodec\",\"category\":4,\"value\":\"1\"},{\"name\":\"mediacodec-auto-rotate\",\"category\":4,\"value\":\"1\"},{\"name\":\"mediacodec-handle-resolution-change\",\"category\":4,\"value\":\"1\"},{\"name\":\"mediacodec-hevc\",\"category\":4,\"value\":\"1\"},{\"name\":\"dns_cache_timeout\",\"category\":1,\"value\":\"600000000\"}],\"group\":\"硬解码\"}],\"ads\":[\"mimg.0c1q0l.cn\",\"www.googletagmanager.com\",\"www.google-analytics.com\",\"mc.usihnbcq.cn\",\"mg.g1mm3d.cn\",\"mscs.svaeuzh.cn\",\"cnzz.hhttm.top\",\"tp.vinuxhome.com\",\"cnzz.mmstat.com\",\"www.baihuillq.com\",\"s23.cnzz.com\",\"z3.cnzz.com\",\"c.cnzz.com\",\"stj.v1vo.top\",\"z12.cnzz.com\",\"img.mosflower.cn\",\"tips.gamevvip.com\",\"ehwe.yhdtns.com\",\"xdn.cqqc3.com\",\"www.jixunkyy.cn\",\"sp.chemacid.cn\",\"hm.baidu.com\",\"s9.cnzz.com\",\"z6.cnzz.com\",\"um.cavuc.com\",\"mav.mavuz.com\",\"wofwk.aoidf3.com\",\"z5.cnzz.com\",\"xc.hubeijieshikj.cn\",\"tj.tianwenhu.com\",\"xg.gars57.cn\",\"k.jinxiuzhilv.com\",\"cdn.bootcss.com\",\"ppl.xunzhuo123.com\",\"xomk.jiangjunmh.top\",\"img.xunzhuo123.com\",\"z1.cnzz.com\",\"s13.cnzz.com\",\"xg.huataisangao.cn\",\"z7.cnzz.com\",\"xg.huataisangao.cn\",\"z2.cnzz.com\",\"s96.cnzz.com\",\"q11.cnzz.com\",\"thy.dacedsfa.cn\",\"xg.whsbpw.cn\",\"s19.cnzz.com\",\"z8.cnzz.com\",\"s4.cnzz.com\",\"f5w.as12df.top\",\"ae01.alicdn.com\",\"www.92424.cn\",\"k.wudejia.com\",\"vivovip.mmszxc.top\",\"qiu.xixiqiu.com\",\"cdnjs.hnfenxun.com\",\"cms.qdwght.com\"]}";
String defaultIJKADS="{\"ijk\":[{\"options\":[{\"name\":\"opensles\",\"category\":4,\"value\":\"0\"},{\"name\":\"overlay-format\",\"category\":4,\"value\":\"842225234\"},{\"name\":\"framedrop\",\"category\":4,\"value\":\"1\"},{\"name\":\"soundtouch\",\"category\":4,\"value\":\"1\"},{\"name\":\"start-on-prepared\",\"category\":4,\"value\":\"1\"},{\"name\":\"http-detect-rangeupport\",\"category\":1,\"value\":\"0\"},{\"name\":\"fflags\",\"category\":1,\"value\":\"fastseek\"},{\"name\":\"skip_loop_filter\",\"category\":2,\"value\":\"48\"},{\"name\":\"reconnect\",\"category\":4,\"value\":\"1\"},{\"name\":\"enable-accurate-seek\",\"category\":4,\"value\":\"1\"},{\"name\":\"probesize\",\"category\":1,\"value\":\"10240\"},{\"name\":\"mediacodec\",\"category\":4,\"value\":\"0\"},{\"name\":\"mediacodec-auto-rotate\",\"category\":4,\"value\":\"0\"},{\"name\":\"mediacodec-handle-resolution-change\",\"category\":4,\"value\":\"0\"},{\"name\":\"mediacodec-hevc\",\"category\":4,\"value\":\"0\"},{\"name\":\"dns_cache_timeout\",\"category\":1,\"value\":\"600000000\"}],\"group\":\"软解码\"},{\"options\":[{\"name\":\"opensles\",\"category\":4,\"value\":\"0\"},{\"name\":\"overlay-format\",\"category\":4,\"value\":\"842225234\"},{\"name\":\"framedrop\",\"category\":4,\"value\":\"1\"},{\"name\":\"soundtouch\",\"category\":4,\"value\":\"1\"},{\"name\":\"start-on-prepared\",\"category\":4,\"value\":\"1\"},{\"name\":\"http-detect-rangeupport\",\"category\":1,\"value\":\"0\"},{\"name\":\"fflags\",\"category\":1,\"value\":\"fastseek\"},{\"name\":\"skip_loop_filter\",\"category\":2,\"value\":\"48\"},{\"name\":\"reconnect\",\"category\":4,\"value\":\"1\"},{\"name\":\"enable-accurate-seek\",\"category\":4,\"value\":\"1\"},{\"name\":\"probesize\",\"category\":1,\"value\":\"10240\"},{\"name\":\"mediacodec\",\"category\":4,\"value\":\"1\"},{\"name\":\"mediacodec-auto-rotate\",\"category\":4,\"value\":\"1\"},{\"name\":\"mediacodec-handle-resolution-change\",\"category\":4,\"value\":\"1\"},{\"name\":\"mediacodec-hevc\",\"category\":4,\"value\":\"1\"},{\"name\":\"dns_cache_timeout\",\"category\":1,\"value\":\"600000000\"}],\"group\":\"硬解码\"}],\"ads\":[\"mimg.0c1q0l.cn\",\"www.googletagmanager.com\",\"www.google-analytics.com\",\"mc.usihnbcq.cn\",\"mg.g1mm3d.cn\",\"mscs.svaeuzh.cn\",\"cnzz.hhttm.top\",\"tp.vinuxhome.com\",\"cnzz.mmstat.com\",\"www.baihuillq.com\",\"s23.cnzz.com\",\"z3.cnzz.com\",\"c.cnzz.com\",\"stj.v1vo.top\",\"z12.cnzz.com\",\"img.mosflower.cn\",\"tips.gamevvip.com\",\"ehwe.yhdtns.com\",\"xdn.cqqc3.com\",\"www.jixunkyy.cn\",\"sp.chemacid.cn\",\"hm.baidu.com\",\"s9.cnzz.com\",\"z6.cnzz.com\",\"um.cavuc.com\",\"mav.mavuz.com\",\"wofwk.aoidf3.com\",\"z5.cnzz.com\",\"xc.hubeijieshikj.cn\",\"tj.tianwenhu.com\",\"xg.gars57.cn\",\"k.jinxiuzhilv.com\",\"cdn.bootcss.com\",\"ppl.xunzhuo123.com\",\"xomk.jiangjunmh.top\",\"img.xunzhuo123.com\",\"z1.cnzz.com\",\"s13.cnzz.com\",\"xg.huataisangao.cn\",\"z7.cnzz.com\",\"xg.huataisangao.cn\",\"z2.cnzz.com\",\"s96.cnzz.com\",\"q11.cnzz.com\",\"thy.dacedsfa.cn\",\"xg.whsbpw.cn\",\"s19.cnzz.com\",\"z8.cnzz.com\",\"s4.cnzz.com\",\"f5w.as12df.top\",\"ae01.alicdn.com\",\"www.92424.cn\",\"k.wudejia.com\",\"vivovip.mmszxc.top\",\"qiu.xixiqiu.com\",\"cdnjs.hnfenxun.com\",\"cms.qdwght.com\"]}";
JsonObject defaultJson=new Gson().fromJson(defaultIJKADS, JsonObject.class);
// 广告地址
if(AdBlocker.isEmpty()){

@ -3,6 +3,7 @@ package com.github.tvbox.osc.ui.activity;
import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Bundle;
import android.text.Html;
@ -24,6 +25,7 @@ import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.github.tvbox.osc.R;
import com.github.tvbox.osc.api.ApiConfig;
import com.github.tvbox.osc.base.App;
@ -69,6 +71,7 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ExecutorService;
@ -111,11 +114,13 @@ public class DetailActivity extends BaseActivity {
private TextView tvCollect;
private TvRecyclerView mGridViewFlag;
private TvRecyclerView mGridView;
private TvRecyclerView mSeriesGroupView;
private LinearLayout mEmptyPlayList;
private SourceViewModel sourceViewModel;
private Movie.Video mVideo;
private VodInfo vodInfo;
private SeriesFlagAdapter seriesFlagAdapter;
private BaseQuickAdapter<String, BaseViewHolder> seriesGroupAdapter;
private SeriesAdapter seriesAdapter;
public String vodId;
public String sourceKey;
@ -126,6 +131,9 @@ public class DetailActivity extends BaseActivity {
private boolean firstReverse;
private V7GridLayoutManager mGridViewLayoutMgr = null;
private HashMap<String, String> mCheckSources = null;
private final ArrayList<String> seriesGroupOptions = new ArrayList<>();
private View currentSeriesGroupView;
private int GroupCount = 24 ;
@Override
protected int getLayoutResID() {
@ -184,8 +192,22 @@ public class DetailActivity extends BaseActivity {
getSupportFragmentManager().beginTransaction().show(playFragment).commitAllowingStateLoss();
tvPlay.setText("全屏");
}
mSeriesGroupView = findViewById(R.id.mSeriesGroupView);
mSeriesGroupView.setHasFixedSize(true);
mSeriesGroupView.setLayoutManager(new V7LinearLayoutManager(this.mContext, 0, false));
seriesGroupAdapter = new BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_series_group, seriesGroupOptions) {
@Override
protected void convert(BaseViewHolder helper, String item) {
TextView tvSeries = helper.getView(R.id.tvSeriesFlag);
tvSeries.setText(item);
}
};
mSeriesGroupView.setAdapter(seriesGroupAdapter);
//禁用播放地址焦点
tvPlayUrl.setFocusable(false);
tvSort.setOnClickListener(new View.OnClickListener() {
@SuppressLint("NotifyDataSetChanged")
@Override
@ -197,6 +219,7 @@ public class DetailActivity extends BaseActivity {
vodInfo.playIndex=(vodInfo.seriesMap.get(vodInfo.playFlag).size()-1)-vodInfo.playIndex;
// insertVod(sourceKey, vodInfo);
firstReverse = true;
Collections.reverse(seriesGroupOptions);
seriesAdapter.notifyDataSetChanged();
}
}
@ -364,6 +387,49 @@ public class DetailActivity extends BaseActivity {
}
}
});
mSeriesGroupView.setOnItemListener(new TvRecyclerView.OnItemListener() {
@Override
public void onItemPreSelected(TvRecyclerView parent, View itemView, int position) {
TextView txtView = itemView.findViewById(R.id.tvSeriesFlag);
txtView.setTextColor(Color.WHITE);
currentSeriesGroupView = null;
}
@Override
public void onItemSelected(TvRecyclerView parent, View itemView, int position) {
TextView txtView = itemView.findViewById(R.id.tvSeriesFlag);
txtView.setTextColor(mContext.getResources().getColor(R.color.color_02F8E1));
if (vodInfo != null && vodInfo.seriesMap.get(vodInfo.playFlag).size() > 0) {
int targetPos = position * GroupCount;
mGridView.smoothScrollToPosition(targetPos);
}
currentSeriesGroupView = itemView;
currentSeriesGroupView.isSelected();
}
@Override
public void onItemClick(TvRecyclerView parent, View itemView, int position) { }
});
seriesGroupAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
FastClickCheckUtil.check(view);
if(currentSeriesGroupView != null) {
TextView txtView = currentSeriesGroupView.findViewById(R.id.tvSeriesFlag);
txtView.setTextColor(Color.WHITE);
}
TextView newTxtView = view.findViewById(R.id.tvSeriesFlag);
newTxtView.setTextColor(mContext.getResources().getColor(R.color.color_02F8E1));
if (vodInfo != null && vodInfo.seriesMap.get(vodInfo.playFlag).size() > 0) {
int targetPos = position * GroupCount;
mGridView.smoothScrollToPosition(targetPos);
}
currentSeriesGroupView = view;
currentSeriesGroupView.isSelected();
}
});
setLoadSir(llLayout);
}
@ -413,6 +479,7 @@ public class DetailActivity extends BaseActivity {
}
}
@SuppressLint("NotifyDataSetChanged")
void refreshList() {
if (vodInfo.seriesMap.get(vodInfo.playFlag).size() <= vodInfo.playIndex) {
vodInfo.playIndex = 0;
@ -421,7 +488,7 @@ public class DetailActivity extends BaseActivity {
if (vodInfo.seriesMap.get(vodInfo.playFlag) != null) {
boolean canSelect = true;
for (int j = 0; j < vodInfo.seriesMap.get(vodInfo.playFlag).size(); j++) {
if(vodInfo.seriesMap.get(vodInfo.playFlag).get(j).selected == true){
if(vodInfo.seriesMap.get(vodInfo.playFlag).get(j).selected){
canSelect = false;
break;
}
@ -434,8 +501,9 @@ public class DetailActivity extends BaseActivity {
Rect rect = new Rect();
List<VodInfo.VodSeries> list = vodInfo.seriesMap.get(vodInfo.playFlag);
int listSize = list.size();
int w = 1;
for(int i =0; i < list.size(); ++i){
for(int i =0; i < listSize; ++i){
String name = list.get(i).name;
pFont.getTextBounds(name, 0, name.length(), rect);
if(w < rect.width()){
@ -445,15 +513,41 @@ public class DetailActivity extends BaseActivity {
w += 32;
int screenWidth = getWindowManager().getDefaultDisplay().getWidth()/3;
int offset = screenWidth/w;
if(offset <=1) offset =1;
if(offset <=2) offset =2;
if(offset > 6) offset =6;
this.mGridViewLayoutMgr.setSpanCount(offset);
mGridViewLayoutMgr.setSpanCount(offset);
seriesAdapter.setNewData(vodInfo.seriesMap.get(vodInfo.playFlag));
seriesGroupOptions.clear();
if(listSize>100 && listSize<=400)GroupCount=50;
if(listSize>400)GroupCount=200;
if(listSize > GroupCount) {
mSeriesGroupView.setVisibility(View.VISIBLE);
int remainedOptionSize = listSize % GroupCount;
int optionSize = listSize / GroupCount;
for(int i = 0; i < optionSize; i++) {
if(vodInfo.reverseSort)
seriesGroupOptions.add(String.format("%d - %d", i * GroupCount + GroupCount, i * GroupCount + 1));
else
seriesGroupOptions.add(String.format("%d - %d", i * GroupCount + 1, i * GroupCount + GroupCount));
}
if(remainedOptionSize > 0) {
if(vodInfo.reverseSort)
seriesGroupOptions.add(String.format("%d - %d", optionSize * GroupCount + remainedOptionSize, optionSize * GroupCount + 1));
else
seriesGroupOptions.add(String.format("%d - %d", optionSize * GroupCount + 1, optionSize * GroupCount + remainedOptionSize));
}
if(vodInfo.reverseSort) Collections.reverse(seriesGroupOptions);
seriesGroupAdapter.notifyDataSetChanged();
}else {
mSeriesGroupView.setVisibility(View.GONE);
}
mGridView.postDelayed(new Runnable() {
@Override
public void run() {
mGridView.scrollToPosition(vodInfo.playIndex);
mGridView.smoothScrollToPosition(vodInfo.playIndex);
}
}, 100);
}
@ -558,6 +652,7 @@ public class DetailActivity extends BaseActivity {
// startQuickSearch();
} else {
mGridViewFlag.setVisibility(View.GONE);
mSeriesGroupView.setVisibility(View.GONE);
mGridView.setVisibility(View.GONE);
tvPlay.setVisibility(View.GONE);
mEmptyPlayList.setVisibility(View.VISIBLE);
@ -839,6 +934,7 @@ public class DetailActivity extends BaseActivity {
llPlayerFragmentContainerBlock.setVisibility(fullWindows ? View.GONE : View.VISIBLE);
mGridView.setVisibility(fullWindows ? View.GONE : View.VISIBLE);
mGridViewFlag.setVisibility(fullWindows ? View.GONE : View.VISIBLE);
mSeriesGroupView.setVisibility(fullWindows ? View.GONE : View.VISIBLE);
//全屏下禁用详情页几个按键的焦点 防止上键跑过来
tvPlay.setFocusable(!fullWindows);

@ -20,6 +20,7 @@ import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.DiffUtil;
@ -52,6 +53,7 @@ import com.github.tvbox.osc.util.LOG;
import com.github.tvbox.osc.viewmodel.SourceViewModel;
import com.orhanobut.hawk.Hawk;
import com.owen.tvrecyclerview.widget.TvRecyclerView;
import com.owen.tvrecyclerview.widget.V7GridLayoutManager;
import com.owen.tvrecyclerview.widget.V7LinearLayoutManager;
import org.greenrobot.eventbus.EventBus;
@ -586,8 +588,15 @@ public class HomeActivity extends BaseActivity {
void showSiteSwitch() {
List<SourceBean> sites = ApiConfig.get().getSourceBeanList();
if (sites.size() > 0) {
String homeSourceKey = ApiConfig.get().getHomeSourceBean().getKey();
SelectDialog<SourceBean> dialog = new SelectDialog<>(HomeActivity.this);
TvRecyclerView tvRecyclerView = dialog.findViewById(R.id.list);
int spanCount;
spanCount = (int)Math.floor(sites.size()/60);
spanCount = Math.min(spanCount, 2);
tvRecyclerView.setLayoutManager(new V7GridLayoutManager(dialog.getContext(), spanCount+1));
ConstraintLayout cl_root = dialog.findViewById(R.id.cl_root);
ViewGroup.LayoutParams clp = cl_root.getLayoutParams();
clp.width = AutoSizeUtils.mm2px(dialog.getContext(), 380+200*spanCount);
dialog.setTip("请选择首页数据源");
dialog.setAdapter(new SelectDialogAdapter.SelectDialogInterface<SourceBean>() {
@Override
@ -616,31 +625,6 @@ public class HomeActivity extends BaseActivity {
return oldItem.getKey().equals(newItem.getKey());
}
}, sites, sites.indexOf(ApiConfig.get().getHomeSourceBean()));
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
// if (homeSourceKey != null && !homeSourceKey.equals(Hawk.get(HawkConfig.HOME_API, ""))) {
// Intent intent = getApplicationContext().getPackageManager().getLaunchIntentForPackage(getApplication().getPackageName());
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP
// | Intent.FLAG_ACTIVITY_CLEAR_TASK);
// Bundle bundle = new Bundle();
// bundle.putBoolean("useCache", true);
// intent.putExtras(bundle);
// getApplicationContext().startActivity(intent);
// System.exit(0);
// Intent intent =new Intent(getApplicationContext(), HomeActivity.class);
// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
// Bundle bundle = new Bundle();
// bundle.putBoolean("useCache", true);
// intent.putExtras(bundle);
// HomeActivity.this.startActivity(intent);
// }
}
});
dialog.show();
}
}

@ -90,6 +90,7 @@ import org.xwalk.core.XWalkWebResourceResponse;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
@ -941,6 +942,14 @@ public class PlayActivity extends BaseActivity {
ExecutorService parseThreadPool;
private String encodeUrl(String url) {
try {
return URLEncoder.encode(url, "UTF-8");
} catch (Exception e) {
return url;
}
}
private void doParse(ParseBean pb) {
stopParse();
initParseLoadFound();
@ -988,7 +997,7 @@ public class PlayActivity extends BaseActivity {
} catch (Throwable e) {
e.printStackTrace();
}
OkGo.<String>get(pb.getUrl() + webUrl)
OkGo.<String>get(pb.getUrl() + encodeUrl(webUrl))
.tag("json_jx")
.headers(reqHeaders)
.execute(new AbsCallback<String>() {

@ -2,6 +2,7 @@ package com.github.tvbox.osc.ui.activity;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
@ -84,7 +85,7 @@ public class SearchActivity extends BaseActivity {
private String searchTitle = "";
private TextView tvSearchCheckboxBtn;
private HashMap<String, String> mCheckSources = null;
private static HashMap<String, String> mCheckSources = null;
private SearchCheckboxDialog mSearchCheckboxDialog = null;
@Override
@ -271,6 +272,12 @@ public class SearchActivity extends BaseActivity {
}
mSearchCheckboxDialog = new SearchCheckboxDialog(SearchActivity.this, searchAbleSource, mCheckSources);
}
mSearchCheckboxDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
dialog.dismiss();
}
});
mSearchCheckboxDialog.show();
}
});
@ -411,6 +418,10 @@ public class SearchActivity extends BaseActivity {
mCheckSources = SearchHelper.getSourcesForSearch();
}
public static void setCheckedSourcesForSearch(HashMap<String,String> checkedSources) {
mCheckSources = checkedSources;
}
private void search(String title) {
cancel();
showLoading();

@ -1,6 +1,7 @@
package com.github.tvbox.osc.ui.adapter;
import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -15,6 +16,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.github.tvbox.osc.R;
import com.github.tvbox.osc.bean.SourceBean;
import com.github.tvbox.osc.util.LOG;
import com.github.tvbox.osc.util.SearchHelper;
import org.jetbrains.annotations.NotNull;
@ -32,7 +34,6 @@ public class CheckboxSearchAdapter extends ListAdapter<SourceBean, CheckboxSearc
@Override
public ViewHolder onCreateViewHolder(@NonNull @NotNull ViewGroup parent, int viewType) {
return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_dialog_checkbox_search, parent, false));
}
private void setCheckedSource(HashMap<String, String> checkedSources) {
@ -42,14 +43,18 @@ public class CheckboxSearchAdapter extends ListAdapter<SourceBean, CheckboxSearc
private ArrayList<SourceBean> data = new ArrayList<>();
public HashMap<String, String> mCheckedSources = new HashMap<>();
@SuppressLint("NotifyDataSetChanged")
public void setData(List<SourceBean> newData, HashMap<String, String> checkedSources) {
data.clear();
data.addAll(newData);
setCheckedSource(checkedSources);
notifyDataSetChanged();
SearchHelper.putCheckedSources(checkedSources);
}
public void setMCheckedSources() {
// LOG.i(data.size()+"size----size"+mCheckedSources.size());
SearchHelper.putCheckedSources(mCheckedSources,data.size()==mCheckedSources.size());
}
@Override
public int getItemCount() {
@ -60,8 +65,8 @@ public class CheckboxSearchAdapter extends ListAdapter<SourceBean, CheckboxSearc
public void onBindViewHolder(ViewHolder holder, int position) {
int pos = holder.getAdapterPosition();
SourceBean sourceBean = data.get(pos);
holder.oneSearchSource.setOnCheckedChangeListener(null);
holder.oneSearchSource.setText(sourceBean.getName());
holder.oneSearchSource.setOnCheckedChangeListener(null);
if (mCheckedSources != null) {
holder.oneSearchSource.setChecked(mCheckedSources.containsKey(sourceBean.getKey()));
}
@ -74,10 +79,10 @@ public class CheckboxSearchAdapter extends ListAdapter<SourceBean, CheckboxSearc
} else {
mCheckedSources.remove(sourceBean.getKey());
}
SearchHelper.putCheckedSource(sourceBean.getKey(), isChecked);
notifyItemChanged(pos);
}
});
}
public class ViewHolder extends RecyclerView.ViewHolder {

@ -1,5 +1,6 @@
package com.github.tvbox.osc.ui.adapter;
import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -77,7 +78,7 @@ public class SelectDialogAdapter<T> extends ListAdapter<T, SelectDialogAdapter.S
}
@Override
public void onBindViewHolder(@NonNull @NotNull SelectDialogAdapter.SelectViewHolder holder, int position) {
public void onBindViewHolder(@NonNull @NotNull SelectDialogAdapter.SelectViewHolder holder, @SuppressLint("RecyclerView") int position) {
T value = data.get(position);
String name = dialogInterface.getDisplay(value);
if (position == select)

@ -6,6 +6,7 @@ import android.view.View;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.DiffUtil;
import com.github.tvbox.osc.R;
@ -24,11 +25,11 @@ public class SearchCheckboxDialog extends BaseDialog{
private TvRecyclerView mGridView;
private CheckboxSearchAdapter checkboxSearchAdapter;
private TextView checkAll;
private TextView clearAll;
private List<SourceBean> mSourceList;
private final List<SourceBean> mSourceList;
TextView checkAll;
TextView clearAll;
public HashMap<String, String> mCheckSourcees = new HashMap<>();
public HashMap<String, String> mCheckSourcees;
public SearchCheckboxDialog(@NonNull @NotNull Context context, List<SourceBean> sourceList, HashMap<String, String> checkedSources) {
super(context);
@ -43,6 +44,11 @@ public class SearchCheckboxDialog extends BaseDialog{
initView(context);
}
@Override
public void dismiss() {
checkboxSearchAdapter.setMCheckedSources();
super.dismiss();
}
protected void initView(Context context) {
mGridView = findViewById(R.id.mGridView);
@ -84,10 +90,10 @@ public class SearchCheckboxDialog extends BaseDialog{
@Override
public void onClick(View view) {
FastClickCheckUtil.check(view);
mCheckSourcees = new HashMap<>();
assert mSourceList != null;
for(SourceBean sourceBean : mSourceList) {
if (!mCheckSourcees.containsKey(sourceBean.getKey())) {
mCheckSourcees.put(sourceBean.getKey(), "1");
}
mCheckSourcees.put(sourceBean.getKey(), "1");
}
checkboxSearchAdapter.setData(mSourceList, mCheckSourcees);
}
@ -96,14 +102,7 @@ public class SearchCheckboxDialog extends BaseDialog{
@Override
public void onClick(View view) {
FastClickCheckUtil.check(view);
if (mCheckSourcees.size() <= 0) {
return;
}
for(SourceBean sourceBean : mSourceList) {
if (mCheckSourcees.containsKey(sourceBean.getKey())) {
mCheckSourcees.remove(sourceBean.getKey());
}
}
mCheckSourcees = new HashMap<>();
checkboxSearchAdapter.setData(mSourceList, mCheckSourcees);
}
});

@ -2,6 +2,7 @@ package com.github.tvbox.osc.util;
import com.github.tvbox.osc.api.ApiConfig;
import com.github.tvbox.osc.bean.SourceBean;
import com.github.tvbox.osc.ui.activity.SearchActivity;
import com.orhanobut.hawk.Hawk;
import java.util.HashMap;
@ -9,64 +10,46 @@ import java.util.HashMap;
public class SearchHelper {
public static HashMap<String, String> getSourcesForSearch() {
String api = Hawk.get(HawkConfig.API_URL, "");
if (api.isEmpty()) {
return null;
}
HashMap<String, String> mCheckSources = new HashMap<>();
HashMap<String, String> mCheckSources;
try {
HashMap<String, HashMap<String, String>> mCheckSourcesForApi = Hawk.get(HawkConfig.SOURCES_FOR_SEARCH, new HashMap<String, HashMap<String, String>>());
String api = Hawk.get(HawkConfig.API_URL, "");
if(api.isEmpty())return null;
HashMap<String, HashMap<String, String>> mCheckSourcesForApi = Hawk.get(HawkConfig.SOURCES_FOR_SEARCH, new HashMap<>());
mCheckSources = mCheckSourcesForApi.get(api);
} catch (Exception e) {
}
if (mCheckSources == null || mCheckSources.size() <= 0) {
if (mCheckSources == null) {
mCheckSources = new HashMap<String, String>();
}
for (SourceBean bean : ApiConfig.get().getSourceBeanList()) {
if (!bean.isSearchable()) {
continue;
}
mCheckSources.put(bean.getKey(), "1");
}
return null;
}
if (mCheckSources == null || mCheckSources.isEmpty()) mCheckSources = getSources();
return mCheckSources;
}
public static void putCheckedSources(HashMap<String, String> mCheckSources) {
public static void putCheckedSources(HashMap<String, String> mCheckSources,boolean isAll) {
String api = Hawk.get(HawkConfig.API_URL, "");
if (api.isEmpty()) {
return;
}
HashMap<String, HashMap<String, String>> mCheckSourcesForApi = Hawk.get(HawkConfig.SOURCES_FOR_SEARCH, new HashMap<String, HashMap<String, String>>());
if (mCheckSourcesForApi == null || mCheckSourcesForApi.isEmpty()) {
mCheckSourcesForApi = new HashMap<String, HashMap<String, String>>();
HashMap<String, HashMap<String, String>> mCheckSourcesForApi = Hawk.get(HawkConfig.SOURCES_FOR_SEARCH,null);
if(isAll){
if (mCheckSourcesForApi == null) return;
if (mCheckSourcesForApi.containsKey(api)) mCheckSourcesForApi.remove(api);
}else {
if (mCheckSourcesForApi == null) mCheckSourcesForApi = new HashMap<>();
mCheckSourcesForApi.put(api, mCheckSources);
}
mCheckSourcesForApi.put(api, mCheckSources);
SearchActivity.setCheckedSourcesForSearch(mCheckSources);
Hawk.put(HawkConfig.SOURCES_FOR_SEARCH, mCheckSourcesForApi);
}
public static void putCheckedSource(String siteKey, boolean checked) {
String api = Hawk.get(HawkConfig.API_URL, "");
if (api.isEmpty()) {
return;
}
HashMap<String, HashMap<String, String>> mCheckSourcesForApi = Hawk.get(HawkConfig.SOURCES_FOR_SEARCH, new HashMap<String, HashMap<String, String>>());
if (mCheckSourcesForApi == null || mCheckSourcesForApi.isEmpty()) {
mCheckSourcesForApi = new HashMap<String, HashMap<String, String>>();
}
if (mCheckSourcesForApi.get(api) == null) {
mCheckSourcesForApi.put(api, new HashMap<>());
}
if (checked) {
mCheckSourcesForApi.get(api).put(siteKey, "1");
} else {
if (mCheckSourcesForApi.get(api).containsKey(siteKey)) {
mCheckSourcesForApi.get(api).remove(siteKey);
public static HashMap<String, String> getSources(){
HashMap<String, String> mCheckSources = new HashMap<>();
for (SourceBean bean : ApiConfig.get().getSourceBeanList()) {
if (!bean.isSearchable()) {
continue;
}
mCheckSources.put(bean.getKey(), "1");
}
Hawk.put(HawkConfig.SOURCES_FOR_SEARCH, mCheckSourcesForApi);
return mCheckSources;
}
}

@ -254,6 +254,18 @@
android:layout_width="match_parent"
android:layout_height="@dimen/vs_45"
android:layout_marginLeft="@dimen/vs_50"
android:layout_marginTop="@dimen/vs_0"
android:layout_marginRight="@dimen/vs_50"
android:clipChildren="false"
android:clipToPadding="false"
app:tv_horizontalSpacingWithMargins="@dimen/vs_10"
app:tv_selectedItemIsCentered="true" />
<com.owen.tvrecyclerview.widget.TvRecyclerView
android:id="@+id/mSeriesGroupView"
android:layout_width="match_parent"
android:layout_height="@dimen/vs_45"
android:layout_marginLeft="@dimen/vs_50"
android:layout_marginTop="@dimen/vs_10"
android:layout_marginRight="@dimen/vs_50"
android:clipChildren="false"
@ -268,7 +280,7 @@
android:layout_marginLeft="@dimen/vs_50"
android:layout_marginTop="@dimen/vs_10"
android:layout_marginRight="@dimen/vs_50"
android:layout_marginBottom="@dimen/vs_30"
android:layout_marginBottom="@dimen/vs_10"
android:clipChildren="false"
android:clipToPadding="false"
app:tv_horizontalSpacingWithMargins="@dimen/vs_10"

@ -6,6 +6,7 @@
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_root"
android:layout_width="@dimen/vs_480"
android:layout_height="wrap_content"
android:layout_gravity="center"
@ -41,6 +42,7 @@
app:layout_constraintTop_toBottomOf="@+id/title"
app:tv_layoutManager="V7LinearLayoutManager"
app:tv_selectedItemIsCentered="true"
app:tv_horizontalSpacingWithMargins="@dimen/vs_10"
app:tv_verticalSpacingWithMargins="@dimen/vs_10" />
<View

@ -11,11 +11,13 @@
android:id="@+id/tvSeries"
android:layout_width="match_parent"
android:layout_height="@dimen/vs_50"
android:singleLine="true"
android:ellipsize="marquee"
android:gravity="center"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:gravity="center"
android:padding="@dimen/vs_10"
android:singleLine="true"
android:textColor="@android:color/white"
android:textSize="@dimen/ts_20" />
</LinearLayout>
Loading…
Cancel
Save