From 2cfb82f5096310fff195fc9ea46188cc0079891c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E4=BF=8A?= <215613905@qq.com> Date: Fri, 11 Nov 2022 17:13:52 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9B=86=E6=95=B0=E5=8A=A8=E6=80=81=E5=88=86?= =?UTF-8?q?=E7=BB=84;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=E9=A6=96=E9=A1=B5=E6=8D=A2=E6=BA=90=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=88=97=E6=95=B0;=20=20=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=E6=8C=87=E5=AE=9A=E6=90=9C=E7=B4=A2=E6=BA=90=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BC=98=E5=8C=96;=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=E5=86=85=E7=BD=AEijk=E9=85=8D=E7=BD=AE=E6=9B=B4?= =?UTF-8?q?=E6=96=B0;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/tvbox/osc/api/ApiConfig.java | 2 +- .../tvbox/osc/ui/activity/DetailActivity.java | 108 +++++++++++++++++- .../tvbox/osc/ui/activity/HomeActivity.java | 36 ++---- .../tvbox/osc/ui/activity/PlayActivity.java | 11 +- .../tvbox/osc/ui/activity/SearchActivity.java | 13 ++- .../osc/ui/adapter/CheckboxSearchAdapter.java | 13 ++- .../osc/ui/adapter/SelectDialogAdapter.java | 3 +- .../osc/ui/dialog/SearchCheckboxDialog.java | 29 +++-- .../github/tvbox/osc/util/SearchHelper.java | 65 ++++------- app/src/main/res/layout/activity_detail.xml | 14 ++- app/src/main/res/layout/dialog_select.xml | 2 + app/src/main/res/layout/item_series.xml | 6 +- 12 files changed, 203 insertions(+), 99 deletions(-) diff --git a/app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java b/app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java index 282ae1f3..b94a2c8f 100644 --- a/app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java +++ b/app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java @@ -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()){ diff --git a/app/src/main/java/com/github/tvbox/osc/ui/activity/DetailActivity.java b/app/src/main/java/com/github/tvbox/osc/ui/activity/DetailActivity.java index a2005005..02970c91 100644 --- a/app/src/main/java/com/github/tvbox/osc/ui/activity/DetailActivity.java +++ b/app/src/main/java/com/github/tvbox/osc/ui/activity/DetailActivity.java @@ -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 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 mCheckSources = null; + private final ArrayList 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(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 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); diff --git a/app/src/main/java/com/github/tvbox/osc/ui/activity/HomeActivity.java b/app/src/main/java/com/github/tvbox/osc/ui/activity/HomeActivity.java index 48737666..e1607d93 100644 --- a/app/src/main/java/com/github/tvbox/osc/ui/activity/HomeActivity.java +++ b/app/src/main/java/com/github/tvbox/osc/ui/activity/HomeActivity.java @@ -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 sites = ApiConfig.get().getSourceBeanList(); if (sites.size() > 0) { - String homeSourceKey = ApiConfig.get().getHomeSourceBean().getKey(); SelectDialog 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() { @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(); } } diff --git a/app/src/main/java/com/github/tvbox/osc/ui/activity/PlayActivity.java b/app/src/main/java/com/github/tvbox/osc/ui/activity/PlayActivity.java index 006c044f..fdd9bfbc 100644 --- a/app/src/main/java/com/github/tvbox/osc/ui/activity/PlayActivity.java +++ b/app/src/main/java/com/github/tvbox/osc/ui/activity/PlayActivity.java @@ -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.get(pb.getUrl() + webUrl) + OkGo.get(pb.getUrl() + encodeUrl(webUrl)) .tag("json_jx") .headers(reqHeaders) .execute(new AbsCallback() { diff --git a/app/src/main/java/com/github/tvbox/osc/ui/activity/SearchActivity.java b/app/src/main/java/com/github/tvbox/osc/ui/activity/SearchActivity.java index 25d253e9..38e87be8 100644 --- a/app/src/main/java/com/github/tvbox/osc/ui/activity/SearchActivity.java +++ b/app/src/main/java/com/github/tvbox/osc/ui/activity/SearchActivity.java @@ -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 mCheckSources = null; + private static HashMap 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 checkedSources) { + mCheckSources = checkedSources; + } + private void search(String title) { cancel(); showLoading(); diff --git a/app/src/main/java/com/github/tvbox/osc/ui/adapter/CheckboxSearchAdapter.java b/app/src/main/java/com/github/tvbox/osc/ui/adapter/CheckboxSearchAdapter.java index 2c7d0e91..f2e5152d 100644 --- a/app/src/main/java/com/github/tvbox/osc/ui/adapter/CheckboxSearchAdapter.java +++ b/app/src/main/java/com/github/tvbox/osc/ui/adapter/CheckboxSearchAdapter.java @@ -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 checkedSources) { @@ -42,14 +43,18 @@ public class CheckboxSearchAdapter extends ListAdapter data = new ArrayList<>(); public HashMap mCheckedSources = new HashMap<>(); + @SuppressLint("NotifyDataSetChanged") public void setData(List newData, HashMap 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 extends ListAdapter mSourceList; + private final List mSourceList; + TextView checkAll; + TextView clearAll; - public HashMap mCheckSourcees = new HashMap<>(); + public HashMap mCheckSourcees; public SearchCheckboxDialog(@NonNull @NotNull Context context, List sourceList, HashMap 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); } }); diff --git a/app/src/main/java/com/github/tvbox/osc/util/SearchHelper.java b/app/src/main/java/com/github/tvbox/osc/util/SearchHelper.java index bd42c873..83eda62b 100644 --- a/app/src/main/java/com/github/tvbox/osc/util/SearchHelper.java +++ b/app/src/main/java/com/github/tvbox/osc/util/SearchHelper.java @@ -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 getSourcesForSearch() { - String api = Hawk.get(HawkConfig.API_URL, ""); - if (api.isEmpty()) { - return null; - } - HashMap mCheckSources = new HashMap<>(); + HashMap mCheckSources; try { - HashMap> mCheckSourcesForApi = Hawk.get(HawkConfig.SOURCES_FOR_SEARCH, new HashMap>()); + String api = Hawk.get(HawkConfig.API_URL, ""); + if(api.isEmpty())return null; + HashMap> 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(); - } - 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 mCheckSources) { + public static void putCheckedSources(HashMap mCheckSources,boolean isAll) { String api = Hawk.get(HawkConfig.API_URL, ""); if (api.isEmpty()) { return; } - HashMap> mCheckSourcesForApi = Hawk.get(HawkConfig.SOURCES_FOR_SEARCH, new HashMap>()); - if (mCheckSourcesForApi == null || mCheckSourcesForApi.isEmpty()) { - mCheckSourcesForApi = new HashMap>(); + HashMap> 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> mCheckSourcesForApi = Hawk.get(HawkConfig.SOURCES_FOR_SEARCH, new HashMap>()); - if (mCheckSourcesForApi == null || mCheckSourcesForApi.isEmpty()) { - mCheckSourcesForApi = new HashMap>(); - } - 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 getSources(){ + HashMap 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; } } diff --git a/app/src/main/res/layout/activity_detail.xml b/app/src/main/res/layout/activity_detail.xml index 0f371c51..9c5cd5c1 100644 --- a/app/src/main/res/layout/activity_detail.xml +++ b/app/src/main/res/layout/activity_detail.xml @@ -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" /> + + \ No newline at end of file