~/Projects/TVBoxOSC
git clone https://code.lsong.org/TVBoxOSC
Commit
- Commit
- a78e2e4babb26d9e6cbc3dd5b89c8c79d00f9cff
- Author
- haha459862 <[email protected]>
- Date
- 2022-06-25 13:43:49 +0800 +0800
- Diffstat
.idea/jarRepositories.xml | 10 .idea/misc.xml | 3 .idea/runConfigurations.xml | 13 app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java | 82 app/src/main/java/com/github/tvbox/osc/bean/ChannelGroup.java | 49 app/src/main/java/com/github/tvbox/osc/bean/LiveChannel.java | 10 app/src/main/java/com/github/tvbox/osc/ui/activity/LivePlayActivity.java | 398 app/src/main/java/com/github/tvbox/osc/ui/adapter/ChannelGroupAdapter.java | 35 app/src/main/java/com/github/tvbox/osc/ui/adapter/LiveChannelAdapter.java | 6 app/src/main/res/layout/activity_live_play.xml | 92 app/src/main/res/layout/item_channel_group_layout.xml | 23
add live channel group support
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml index 14164b64fec3795af28342e19208eb292572c4f9..047baf83430dd467beec73d8cd6714cdaf78bab7 100644 --- a/.idea/jarRepositories.xml +++ b/.idea/jarRepositories.xml @@ -31,5 +31,15 @@ <option name="name" value="maven2" /> <option name="url" value="https://download.01.org/crosswalk/releases/crosswalk/android/maven2" /> </remote-repository> + <remote-repository> + <option name="id" value="MavenRepo" /> + <option name="name" value="MavenRepo" /> + <option name="url" value="https://repo.maven.apache.org/maven2/" /> + </remote-repository> + <remote-repository> + <option name="id" value="Gradle Central Plugin Repository" /> + <option name="name" value="Gradle Central Plugin Repository" /> + <option name="url" value="https://plugins.gradle.org/m2" /> + </remote-repository> </component> </project> \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 860da66a5ea990f8e3c36fcdb0e2e05dacadf880..5c9f89fee71360989ca8a39d7324e4a12762142d 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> - <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> + <component name="ExternalStorageConfigurationManager" enabled="true" /> + <component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/build/classes" /> </component> <component name="ProjectType"> diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index e497da999824b5c5629039f2e74794dd96b6c419..0000000000000000000000000000000000000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="RunConfigurationProducerService"> - <option name="ignoredProducers"> - <set> - <option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" /> - <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" /> - <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" /> - <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" /> - </set> - </option> - </component> -</project> \ No newline at end of file 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 81bd216fdff6fe9159740291de934ce34eb28451..c3789c17a509da8b82175a1976ff5a8df30826a1 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 @@ -7,6 +7,7 @@ import android.util.Base64; import com.github.catvod.crawler.JarLoader; import com.github.catvod.crawler.Spider; +import com.github.tvbox.osc.bean.ChannelGroup; import com.github.tvbox.osc.base.App; import com.github.tvbox.osc.bean.IJKCode; import com.github.tvbox.osc.bean.LiveChannel; @@ -20,6 +21,7 @@ import com.github.tvbox.osc.util.DefaultConfig; import com.github.tvbox.osc.util.HawkConfig; import com.github.tvbox.osc.util.MD5; import com.google.gson.Gson; +import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.lzy.okgo.OkGo; @@ -50,7 +52,7 @@ private static ApiConfig instance; private List<SourceBean> sourceBeanList; private SourceBean mHomeSource; private ParseBean mDefaultParse; -import android.net.Uri; +import java.io.InputStreamReader; import com.github.tvbox.osc.base.App; private List<ParseBean> parseBeanList; private List<String> vipParseFlags; @@ -64,7 +66,7 @@ private ApiConfig() { sourceBeanList = new ArrayList<>(); - channelList = new ArrayList<>(); + channelGroupList = new ArrayList<>(); parseBeanList = new ArrayList<>(); } @@ -275,63 +277,56 @@ setDefaultParse(parseBeanList.get(0)); } // 直播源 try { - int lcIdx = 0; -import com.google.gson.JsonElement; +import java.util.ArrayList; package com.github.tvbox.osc.api; -import com.google.gson.JsonElement; +import java.util.ArrayList; -import com.google.gson.JsonElement; +import java.util.ArrayList; import android.app.Activity; -import com.google.gson.JsonElement; +import java.util.ArrayList; import android.net.Uri; -import com.google.gson.JsonElement; +import java.util.ArrayList; import android.text.TextUtils; -import com.google.gson.JsonElement; +import java.util.ArrayList; import android.util.Base64; - +import java.util.ArrayList; import com.github.catvod.crawler.JarLoader; -import com.google.gson.JsonElement; +import java.util.ArrayList; import com.github.catvod.crawler.Spider; -import com.google.gson.JsonElement; +import java.util.ArrayList; import com.github.tvbox.osc.base.App; - import android.app.Activity; +import android.text.TextUtils; - import android.app.Activity; +import android.text.TextUtils; package com.github.tvbox.osc.api; - import android.app.Activity; +import android.text.TextUtils; - import android.app.Activity; +import android.text.TextUtils; import android.app.Activity; - import android.app.Activity; +import android.text.TextUtils; import android.net.Uri; - + } + } import android.app.Activity; +import android.text.TextUtils; import android.text.TextUtils; - import android.app.Activity; +import android.text.TextUtils; import android.util.Base64; - import android.app.Activity; +import android.text.TextUtils; import com.github.catvod.crawler.JarLoader; - urls.set(0, fix); + } - import android.app.Activity; -import com.github.tvbox.osc.base.App; -import com.github.tvbox.osc.bean.IJKCode; import android.text.TextUtils; - } - } - lc.setUrls(urls); - // 暂时不考虑分组问题 - lc.setChannelNum(lcIdx++); +import com.github.catvod.crawler.Spider; -import com.lzy.okgo.OkGo; import android.app.Activity; - } + parseBeanList = new ArrayList<>(); } } catch (Throwable th) { th.printStackTrace(); @@ -368,6 +363,27 @@ ijkCodes.add(codec); } if (!foundOldSelect && ijkCodes.size() > 0) { ijkCodes.get(0).selected(true); + } + } + + public void loadLives(JsonArray livesArray) + { + int groupIndex = 0; + int channelIndex = 0; + for (JsonElement groupElement : livesArray) { + ChannelGroup channelGroup = new ChannelGroup(); + channelGroup.setGroupNum(groupIndex++); + channelGroup.setGroupName(((JsonObject) groupElement).get("Group").getAsString().trim()); + for (JsonElement channelElement : ((JsonObject) groupElement).get("channels").getAsJsonArray()) { + JsonObject obj = (JsonObject) channelElement; + LiveChannel liveChannel = new LiveChannel(); + liveChannel.setChannelName(obj.get("name").getAsString().trim()); + liveChannel.setChannelNum(channelIndex++); + ArrayList<String> urls = DefaultConfig.safeJsonStringList(obj, "urls"); + liveChannel.setUrls(urls); + channelGroup.getLiveChannels().add(liveChannel); + } + channelGroupList.add(channelGroup); } } @@ -449,10 +465,10 @@ return mHomeSource == null ? emptyHome : mHomeSource; } import android.app.Activity; -import com.github.tvbox.osc.server.ControlManager; + try { import android.app.Activity; -package com.github.tvbox.osc.api; import com.github.catvod.crawler.JarLoader; +import com.github.catvod.crawler.Spider; } public List<IJKCode> getIjkCodes() { diff --git a/app/src/main/java/com/github/tvbox/osc/bean/ChannelGroup.java b/app/src/main/java/com/github/tvbox/osc/bean/ChannelGroup.java new file mode 100644 index 0000000000000000000000000000000000000000..6ad642995a274d0843b909fb4740f08a6f11ce03 --- /dev/null +++ b/app/src/main/java/com/github/tvbox/osc/bean/ChannelGroup.java @@ -0,0 +1,49 @@ +package com.github.tvbox.osc.bean; + +import java.util.ArrayList; + +public class ChannelGroup { + /** + * num : 1 + * name : 央视频道 + * password : 频道密码 + */ + private int groupNum; + private String groupName; + private String groupPassword; + private ArrayList<LiveChannel> liveChannels; + private boolean isDefault; + + + public int getGroupNum() { + return groupNum; + } + + public void setGroupNum(int groupNum) { + this.groupNum = groupNum; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public ArrayList<LiveChannel> getLiveChannels() { + return liveChannels; + } + + public void setLiveChannels(ArrayList<LiveChannel> liveChannels) { + this.liveChannels = liveChannels; + } + + public boolean isDefault() { + return isDefault; + } + + public void setDefault(boolean aDefault) { + isDefault = aDefault; + } +} diff --git a/app/src/main/java/com/github/tvbox/osc/bean/LiveChannel.java b/app/src/main/java/com/github/tvbox/osc/bean/LiveChannel.java index bd06c2e036cfe0a7fc5219a9c8b9ebf42d375921..949e0cb95d7ddc6bdf407eb8d7334ed1fcf57e37 100644 --- a/app/src/main/java/com/github/tvbox/osc/bean/LiveChannel.java +++ b/app/src/main/java/com/github/tvbox/osc/bean/LiveChannel.java @@ -16,8 +16,8 @@ * channelLogo : https://upload.wikimedia.org/wikipedia/zh/6/65/CCTV-1_Logo.png */ private int channelNum; +/** package com.github.tvbox.osc.bean; - * @description: private ArrayList<String> urls; private boolean isDefault; public int sourceIdx = 0; @@ -30,13 +30,13 @@ public int getChannelNum() { return channelNum; } +/** - * @date :2021/1/12 - this.name = name; + this.channelName = channelName; } - public String getName() { + public String getChannelName() { - return name; + return channelName; } public String getUrls() { diff --git a/app/src/main/java/com/github/tvbox/osc/ui/activity/LivePlayActivity.java b/app/src/main/java/com/github/tvbox/osc/ui/activity/LivePlayActivity.java index 935a3fe52710475c0aeb2916f40e3a7e4786e664..c56b40035f53d0dce45650c8c33ed3fc40947cb7 100644 --- a/app/src/main/java/com/github/tvbox/osc/ui/activity/LivePlayActivity.java +++ b/app/src/main/java/com/github/tvbox/osc/ui/activity/LivePlayActivity.java @@ -9,6 +9,7 @@ import android.text.TextUtils; import android.view.KeyEvent; import android.view.View; import android.view.ViewGroup; +import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; @@ -21,9 +22,12 @@ import com.github.tvbox.osc.R; import com.github.tvbox.osc.api.ApiConfig; import com.github.tvbox.osc.base.BaseActivity; + } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT && mGridView.getVisibility() == View.INVISIBLE) { + package com.github.tvbox.osc.ui.activity; import com.github.tvbox.osc.player.controller.BoxVideoController; import com.github.tvbox.osc.ui.adapter.LiveChannelAdapter; +import com.github.tvbox.osc.ui.adapter.ChannelGroupAdapter; import com.github.tvbox.osc.ui.tv.widget.ViewObj; import com.github.tvbox.osc.util.DefaultConfig; import com.github.tvbox.osc.util.FastClickCheckUtil; @@ -51,12 +55,21 @@ */ public class LivePlayActivity extends BaseActivity { private VideoView mVideoView; private TextView tvHint; - private TextView tvUrl; private TextView tvChannel; -import android.animation.IntEvaluator; +import com.google.gson.JsonArray; package com.github.tvbox.osc.ui.activity; + private TvRecyclerView mGroupGridView; + private TvRecyclerView mChannelGridView; + private ChannelGroupAdapter groupAdapter; private LiveChannelAdapter channelAdapter; private Handler mHandler = new Handler(); + + private List<ChannelGroup> channelGroupList = new ArrayList<>(); + private int selectedGroupIndex = 0; + private int currentGroupIndex = 0; + private int currentChannelIndex = 0; + private LiveChannel currentChannel = null; + @Override protected int getLayoutResID() { @@ -72,14 +85,19 @@ // ViewGroup.LayoutParams layoutParams = mVideoView.getLayoutParams(); // layoutParams.width = 100; // layoutParams.height = 50; // mVideoView.setLayoutParams(layoutParams); - mGridView = findViewById(R.id.mGridView); + tvLeftLinearLayout = findViewById(R.id.tvLeftlinearLayout); + mGroupGridView = findViewById(R.id.mGroupGridView); + mChannelGridView = findViewById(R.id.mChannelGridView); tvChannel = findViewById(R.id.tvChannel); tvHint = findViewById(R.id.tvHint); - tvUrl = findViewById(R.id.tvUrl); + +import com.google.gson.JsonElement; - mGridView.setHasFixedSize(true); + mGroupGridView.setLayoutManager(new V7LinearLayoutManager(this.mContext, 1, false)); + mChannelGridView.setHasFixedSize(true); -import android.os.Handler; +import android.animation.Animator; package com.github.tvbox.osc.ui.activity; +import android.animation.IntEvaluator; BoxVideoController controller = new BoxVideoController(this); controller.setScreenTapListener(new BoxVideoController.OnScreenTapListener() { @Override @@ -94,17 +112,66 @@ controller.setGestureEnabled(true); mVideoView.setVideoController(controller); mVideoView.setProgressManager(null); + groupAdapter = new ChannelGroupAdapter(); + mGroupGridView.setAdapter(groupAdapter); +import com.google.gson.JsonElement; import android.text.TextUtils; + @Override +package com.github.tvbox.osc.ui.activity; import android.animation.IntEvaluator; +package com.github.tvbox.osc.ui.activity; import android.animation.IntEvaluator; +package com.github.tvbox.osc.ui.activity; + mHandler.removeCallbacks(mHideChannelListRun); + mHandler.postDelayed(mHideChannelListRun, 5000); +import android.os.Handler; import android.os.Handler; + }); + groupAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() { + @Override + public void onItemClick(BaseQuickAdapter adapter, View view, int position) { + FastClickCheckUtil.check(view); +import android.animation.Animator; + groupAdapter.notifyItemChanged(selectedGroupIndex); + selectedGroupIndex = position; + channelGroupList.get(selectedGroupIndex).setDefault(true); + groupAdapter.notifyItemChanged(selectedGroupIndex); + channelAdapter.setNewData(channelGroupList.get(position).getLiveChannels()); + } + }); + + channelAdapter = new LiveChannelAdapter(); +import com.google.gson.JsonObject; import android.animation.IntEvaluator; + mChannelGridView.addOnScrollListener(new RecyclerView.OnScrollListener() { +import android.os.Handler; import android.animation.AnimatorListenerAdapter; + public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) { + super.onScrollStateChanged(recyclerView, newState); + mHandler.removeCallbacks(mHideChannelListRun); + mHandler.postDelayed(mHideChannelListRun, 5000); + } +import android.os.Handler; import android.text.TextUtils; -import android.animation.ObjectAnimator; + channelAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() { + @Override + public void onItemClick(BaseQuickAdapter adapter, View view, int position) { + FastClickCheckUtil.check(view); + if (playChannel(selectedGroupIndex, position, false)) { + mHandler.post(mHideChannelListRun); + } + } +import android.os.Handler; import android.text.TextUtils; + + initChannelListView(); +import android.animation.IntEvaluator; import android.os.Handler; + + @Override + public void onBackPressed() { + if (tvLeftLinearLayout.getVisibility() == View.VISIBLE) { mHandler.post(mHideChannelListRun); } else { super.onBackPressed(); @@ -115,18 +180,19 @@ @Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { int keyCode = event.getKeyCode(); - if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN && mGridView.getVisibility() == View.INVISIBLE) { + if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN && tvLeftLinearLayout.getVisibility() == View.INVISIBLE) { playNext(); - } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP && mGridView.getVisibility() == View.INVISIBLE) { + } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP && tvLeftLinearLayout.getVisibility() == View.INVISIBLE) { playPrevious(); - } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT && mGridView.getVisibility() == View.INVISIBLE) { + } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT && tvLeftLinearLayout.getVisibility() == View.INVISIBLE) { preSourceUrl(); - } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT && mGridView.getVisibility() == View.INVISIBLE) { + } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT && tvLeftLinearLayout.getVisibility() == View.INVISIBLE) { nextSourceUrl(); -import android.view.View; +import android.animation.Animator; import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; showChannelList(); - } else if (mGridView.getVisibility() == View.INVISIBLE) { + } else if (tvLeftLinearLayout.getVisibility() == View.INVISIBLE) { switch (keyCode) { case KeyEvent.KEYCODE_0: inputChannelNum("0"); @@ -161,7 +227,7 @@ break; } } } else if (event.getAction() == KeyEvent.ACTION_UP) { - if (mGridView.getVisibility() == View.VISIBLE) { + if (tvLeftLinearLayout.getVisibility() == View.VISIBLE) { mHandler.postDelayed(mHideChannelListRun, 5000); } } @@ -174,7 +240,7 @@ super.onResume(); if (mVideoView != null) { mVideoView.resume(); } - if (mGridView.getVisibility() == View.VISIBLE) { + if (tvLeftLinearLayout.getVisibility() == View.VISIBLE) { mHandler.postDelayed(mHideChannelListRun, 5000); } } @@ -196,192 +262,202 @@ mVideoView.release(); } } + private void initChannelListView() { + List<ChannelGroup> list = ApiConfig.get().getChannelGroupList(); package com.github.tvbox.osc.ui.activity; - * @description: + setLoadSir(findViewById(R.id.live_root)); package com.github.tvbox.osc.ui.activity; - */ + mVideoView = findViewById(R.id.mVideoView); + if (list.size() == 1 && list.get(0).getGroupName().startsWith("http://127.0.0.1")) { package com.github.tvbox.osc.ui.activity; -import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; + -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; import android.animation.AnimatorListenerAdapter; -import android.os.Handler; +import android.view.KeyEvent; package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; import android.animation.AnimatorListenerAdapter; -import android.text.TextUtils; +package com.github.tvbox.osc.ui.activity; -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; import android.animation.AnimatorListenerAdapter; -import android.view.KeyEvent; + -import android.os.Handler; +import android.animation.Animator; import android.animation.AnimatorListenerAdapter; +import android.animation.Animator; package com.github.tvbox.osc.ui.activity; -import android.animation.IntEvaluator; +import android.view.KeyEvent; + initLiveState(); +import android.view.KeyEvent; package com.github.tvbox.osc.ui.activity; import android.animation.IntEvaluator; -package com.github.tvbox.osc.ui.activity; +import android.os.Handler; + -package com.github.tvbox.osc.ui.activity; +import com.lzy.okgo.callback.AbsCallback; import android.animation.IntEvaluator; + OkGo.<String>get(url).execute(new AbsCallback<String>() { -package com.github.tvbox.osc.ui.activity; + @Override + public String convertResponse(okhttp3.Response response) throws Throwable { import android.animation.Animator; + private TextView tvHint; } + import android.os.Handler; -import android.text.TextUtils; +import android.animation.AnimatorListenerAdapter; -package com.github.tvbox.osc.ui.activity; + public void onSuccess(Response<String> response) { +import android.animation.Animator; import android.animation.IntEvaluator; import android.animation.Animator; + private TvRecyclerView mGridView; - @Override + loadLives(livesArray); + + mHandler.post(new Runnable() { + package com.github.tvbox.osc.ui.activity; +import android.view.KeyEvent; +import android.animation.Animator; @Override -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; protected int getLayoutResID() { -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; return R.layout.activity_live_play; package com.github.tvbox.osc.ui.activity; - } + controller.setGestureEnabled(true); -package com.github.tvbox.osc.ui.activity; + +import android.animation.AnimatorListenerAdapter; +import android.os.Handler; import android.os.Handler; import android.os.Handler; +import android.text.TextUtils; +import android.animation.IntEvaluator; import android.os.Handler; + +import com.lzy.okgo.model.Response; import android.os.Handler; -import android.text.TextUtils; -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; protected void init() { -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; setLoadSir(findViewById(R.id.live_root)); -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; mVideoView = findViewById(R.id.mVideoView); -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; PlayerHelper.updateCfg(mVideoView); -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; // ViewGroup.LayoutParams layoutParams = mVideoView.getLayoutParams(); -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; // layoutParams.width = 100; -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; // layoutParams.height = 50; - -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; // mVideoView.setLayoutParams(layoutParams); -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; mGridView = findViewById(R.id.mGridView); -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; tvChannel = findViewById(R.id.tvChannel); - } - - @Override -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; tvHint = findViewById(R.id.tvHint); -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; tvUrl = findViewById(R.id.tvUrl); -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; mGridView.setHasFixedSize(true); -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; mGridView.setLayoutManager(new V7LinearLayoutManager(this.mContext, 1, false)); -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; BoxVideoController controller = new BoxVideoController(this); -package com.github.tvbox.osc.ui.activity; + } +import android.animation.Animator; controller.setScreenTapListener(new BoxVideoController.OnScreenTapListener() { +import android.view.KeyEvent; package com.github.tvbox.osc.ui.activity; + } + +import android.animation.Animator; @Override package com.github.tvbox.osc.ui.activity; + int keyCode = event.getKeyCode(); + +import android.animation.Animator; public void tap() { -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; showChannelList(); -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; } -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; }); -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; controller.addControlComponent(new GestureView(this)); -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; controller.setCanChangePosition(false); -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; controller.setEnableInNormal(true); -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; controller.setGestureEnabled(true); package com.github.tvbox.osc.ui.activity; +import com.github.tvbox.osc.util.HawkConfig; +import android.animation.Animator; mVideoView.setVideoController(controller); -package com.github.tvbox.osc.ui.activity; + } +import android.animation.Animator; mVideoView.setProgressManager(null); -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; initChannelList(); -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; public void onBackPressed() { -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; if (mGridView.getVisibility() == View.VISIBLE) { - } + break; - }); -import android.widget.TextView; +import android.os.Handler; import android.os.Handler; -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; import android.text.TextUtils; -import android.view.KeyEvent; +import android.text.TextUtils; +import android.animation.Animator; } else { - showSuccess(); - initList(list); } - } -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; import android.view.KeyEvent; - if (list.isEmpty()) -import com.dueeeke.videocontroller.component.GestureView; +import android.animation.AnimatorListenerAdapter; -import com.github.tvbox.osc.api.ApiConfig; import android.animation.Animator; -package com.github.tvbox.osc.ui.activity; import android.view.KeyEvent; -import android.animation.AnimatorListenerAdapter; package com.github.tvbox.osc.ui.activity; - if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN && mGridView.getVisibility() == View.INVISIBLE) { - channelList.addAll(list); + -package com.github.tvbox.osc.ui.activity; +import android.animation.Animator; import android.view.KeyEvent; -import android.os.Handler; - if (lc.getName().equals(lastChannelName)) { - lastChannel = lc; - } +import android.animation.Animator; import android.view.KeyEvent; -package com.github.tvbox.osc.ui.activity; - if (lastChannel == null) - lastChannel = channelList.get(0); - +import android.animation.Animator; -import com.github.tvbox.osc.base.BaseActivity; import android.animation.Animator; -import com.github.tvbox.osc.base.BaseActivity; +import android.view.KeyEvent; import android.animation.AnimatorListenerAdapter; - tvUrl.setVisibility(Hawk.get(HawkConfig.DEBUG_OPEN, false) ? View.VISIBLE : View.INVISIBLE); - - channelAdapter.setNewData(channelList); - playChannel(lastChannel, false); } private void refreshTextInfo() { -import android.view.KeyEvent; - import android.view.View; } private Runnable mHideChannelListRun = new Runnable() { @Override public void run() { - ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mGridView.getLayoutParams(); -import android.widget.TextView; +import android.animation.Animator; import android.view.KeyEvent; -import com.github.tvbox.osc.bean.LiveChannel; import android.animation.IntEvaluator; -import com.github.tvbox.osc.bean.LiveChannel; + if (tvLeftLinearLayout.getVisibility() == View.VISIBLE) { +import java.util.ArrayList; import android.animation.ObjectAnimator; + ObjectAnimator animator = ObjectAnimator.ofObject(viewObj, "marginLeft", new IntEvaluator(), 0, -tvLeftLinearLayout.getLayoutParams().width); animator.setDuration(200); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); - mGridView.setVisibility(View.INVISIBLE); + tvLeftLinearLayout.setVisibility(View.INVISIBLE); tvHint.setVisibility(View.INVISIBLE); } }); @@ -410,14 +484,13 @@ private Runnable showListAfterScrollOk = new Runnable() { @Override public void run() { - import android.animation.Animator; -import android.animation.ObjectAnimator; + } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT && mGridView.getVisibility() == View.INVISIBLE) { mHandler.postDelayed(this, 100); } else { - ViewObj viewObj = new ViewObj(mGridView, (ViewGroup.MarginLayoutParams) mGridView.getLayoutParams()); + ViewObj viewObj = new ViewObj(tvLeftLinearLayout, (ViewGroup.MarginLayoutParams) tvLeftLinearLayout.getLayoutParams()); - import java.util.List; +package com.github.tvbox.osc.ui.activity; animator.setDuration(200); animator.start(); animator.addListener(new AnimatorListenerAdapter() { @@ -433,16 +506,16 @@ } }; private void showChannelList() { - import android.animation.AnimatorListenerAdapter; tvHint.setVisibility(View.VISIBLE); - import android.animation.AnimatorListenerAdapter; +import android.animation.Animator; +import java.util.List; import android.animation.AnimatorListenerAdapter; - import android.animation.AnimatorListenerAdapter; import android.animation.IntEvaluator; + mChannelGridView.setSelection(currentChannelIndex); mHandler.postDelayed(showListAfterScrollOk, 100); } } @@ -466,94 +537,125 @@ tvChannel.setVisibility(View.VISIBLE); mHandler.postDelayed(mHideChannelNumRun, 4000); } + private boolean playChannel(int groupIndex, int channelIndex, boolean changeSource) { + if (groupIndex < 0 || groupIndex >= channelGroupList.size() + || channelIndex < 0 || channelIndex >= channelGroupList.get(groupIndex).getLiveChannels().size()) import com.github.tvbox.osc.util.FastClickCheckUtil; + + +/** + channelGroupList.get(currentGroupIndex).setDefault(false); +/** + } + if (channelIndex != currentChannelIndex) { + channelGroupList.get(currentGroupIndex).getLiveChannels().get(currentChannelIndex).setDefault(false); + channelAdapter.notifyItemChanged(currentChannelIndex); + } + +/** import android.animation.ObjectAnimator; +import android.animation.AnimatorListenerAdapter; package com.github.tvbox.osc.ui.activity; +import android.os.Handler; + if ((liveChannel == currentChannel)) + return false; -import android.animation.ObjectAnimator; +import android.animation.AnimatorListenerAdapter; +import android.animation.AnimatorListenerAdapter; -// layoutParams.width = 100; +package com.github.tvbox.osc.ui.activity; +import android.animation.AnimatorListenerAdapter; -import android.animation.ObjectAnimator; + import android.animation.AnimatorListenerAdapter; +import com.github.tvbox.osc.ui.adapter.LiveChannelAdapter; +/** -// mVideoView.setLayoutParams(layoutParams); +import android.animation.AnimatorListenerAdapter; - mGridView = findViewById(R.id.mGridView); +import android.animation.AnimatorListenerAdapter; + channelAdapter.notifyItemChanged(currentChannelIndex); - tvChannel = findViewById(R.id.tvChannel); +import android.animation.AnimatorListenerAdapter; -import android.animation.ObjectAnimator; import android.animation.IntEvaluator; +import android.animation.AnimatorListenerAdapter; import com.github.tvbox.osc.util.FastClickCheckUtil; -import android.text.TextUtils; -import com.github.tvbox.osc.util.FastClickCheckUtil; import android.view.KeyEvent; +package com.github.tvbox.osc.ui.activity; mVideoView.release(); +import android.animation.AnimatorListenerAdapter; import com.github.tvbox.osc.util.HawkConfig; -package com.github.tvbox.osc.ui.activity; mVideoView.start(); return true; } private boolean playChannelByNum(int channelNum) { - +import android.animation.Animator; public void tap() { - +import android.animation.Animator; showChannelList(); - +import android.animation.Animator; } - +import android.animation.Animator; }); - +import android.animation.Animator; controller.addControlComponent(new GestureView(this)); +import android.animation.AnimatorListenerAdapter; +import android.text.TextUtils; - } + return playChannel(groupIndex, channelIndex, false); -import android.view.KeyEvent; package com.github.tvbox.osc.ui.activity; +import com.github.tvbox.osc.util.HawkConfig; - +import android.animation.Animator; import android.text.TextUtils; +import android.animation.Animator; - return false; + } - +import android.animation.Animator; import android.text.TextUtils; +import android.text.TextUtils; + channelIndex = 0; +import android.view.KeyEvent; package com.github.tvbox.osc.ui.activity; + return false; } private void playNext() { -import com.github.tvbox.osc.util.PlayerHelper; +import android.animation.AnimatorListenerAdapter; import android.animation.Animator; +package com.github.tvbox.osc.ui.activity; -import com.github.tvbox.osc.util.PlayerHelper; import android.animation.AnimatorListenerAdapter; +import android.animation.Animator; - initChannelList(); - playIndex = 0; + currentChannelIndex = 0; } - playChannel(channelList.get(playIndex), false); + playChannel(currentGroupIndex, currentChannelIndex, false); } private void playPrevious() { -import com.github.tvbox.osc.util.PlayerHelper; +import android.animation.AnimatorListenerAdapter; import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; - playIndex--; + currentChannelIndex--; + if (currentChannelIndex < 0) { - if (playIndex < 0) { + currentChannelIndex = channelGroupList.get(currentGroupIndex).getLiveChannels().size() - 1; - } +import android.animation.Animator; import android.view.KeyEvent; -package com.github.tvbox.osc.ui.activity; - playChannel(channelList.get(playIndex), false); +import android.animation.AnimatorListenerAdapter; } public void preSourceUrl() { currentChannel.sourceIdx--; -import com.google.gson.Gson; import android.animation.AnimatorListenerAdapter; +import com.owen.tvrecyclerview.widget.V7LinearLayoutManager; } public void nextSourceUrl() { currentChannel.sourceIdx++; -import com.google.gson.Gson; import android.animation.AnimatorListenerAdapter; +import com.owen.tvrecyclerview.widget.V7LinearLayoutManager; } } \ No newline at end of file diff --git a/app/src/main/java/com/github/tvbox/osc/ui/adapter/ChannelGroupAdapter.java b/app/src/main/java/com/github/tvbox/osc/ui/adapter/ChannelGroupAdapter.java new file mode 100644 index 0000000000000000000000000000000000000000..3588036dfa29ebbd8dfc42fee0fd9113621ffa56 --- /dev/null +++ b/app/src/main/java/com/github/tvbox/osc/ui/adapter/ChannelGroupAdapter.java @@ -0,0 +1,35 @@ +package com.github.tvbox.osc.ui.adapter; + +import android.graphics.Color; +import android.widget.TextView; + +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.bean.ChannelGroup; + + +import java.util.ArrayList; + + +/** + * @author pj567 + * @date :2021/1/12 + * @description: + */ +public class ChannelGroupAdapter extends BaseQuickAdapter<ChannelGroup, BaseViewHolder> { + public ChannelGroupAdapter() { + super(R.layout.item_channel_group_layout, new ArrayList<>()); + } + + @Override + protected void convert(BaseViewHolder helper, ChannelGroup item) { + TextView tvGroupName = helper.getView(R.id.tvGroupName); + tvGroupName.setText(item.getGroupName()); + if (item.isDefault()) { + tvGroupName.setTextColor(mContext.getResources().getColor(R.color.color_1890FF)); + } else { + tvGroupName.setTextColor(Color.WHITE); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/tvbox/osc/ui/adapter/LiveChannelAdapter.java b/app/src/main/java/com/github/tvbox/osc/ui/adapter/LiveChannelAdapter.java index 96e59e1253429ffed076da8462bf257828894a24..7ae6076c3f5fd058a904e730830b093397750123 100644 --- a/app/src/main/java/com/github/tvbox/osc/ui/adapter/LiveChannelAdapter.java +++ b/app/src/main/java/com/github/tvbox/osc/ui/adapter/LiveChannelAdapter.java @@ -25,10 +25,10 @@ protected void convert(BaseViewHolder helper, LiveChannel item) { TextView tvChannelNum = helper.getView(R.id.tvChannelNum); TextView tvChannel = helper.getView(R.id.tvChannel); tvChannelNum.setText(String.format("%s", item.getChannelNum())); - tvChannel.setText(String.format("%s", item.getName())); + tvChannel.setText(item.getChannelName()); if (item.isDefault()) { - tvChannelNum.setTextColor(mContext.getResources().getColor(R.color.color_02F8E1)); + tvChannelNum.setTextColor(mContext.getResources().getColor(R.color.color_1890FF)); - tvChannel.setTextColor(mContext.getResources().getColor(R.color.color_02F8E1)); + tvChannel.setTextColor(mContext.getResources().getColor(R.color.color_1890FF)); } else { tvChannelNum.setTextColor(Color.WHITE); tvChannel.setTextColor(Color.WHITE); diff --git a/app/src/main/res/layout/activity_live_play.xml b/app/src/main/res/layout/activity_live_play.xml index eade1dc7359e74b1e089b26a28d3075400dfd636..2a91f372deabad93fca7068e5a6231e68e1fb181 100644 --- a/app/src/main/res/layout/activity_live_play.xml +++ b/app/src/main/res/layout/activity_live_play.xml @@ -9,84 +9,94 @@ android:id="@+id/mVideoView" android:layout_width="match_parent" android:layout_height="match_parent" /> - <com.owen.tvrecyclerview.widget.TvRecyclerView + <LinearLayout - android:id="@+id/mGridView" + android:id="@+id/tvLeftlinearLayout" - android:layout_width="220mm" + android:layout_width="421mm" android:layout_height="match_parent" -<?xml version="1.0" encoding="utf-8"?> android:layout_height="match_parent"> -<?xml version="1.0" encoding="utf-8"?> -<?xml version="1.0" encoding="utf-8"?> + android:layout_height="match_parent"> <com.dueeeke.videoplayer.player.VideoView -<?xml version="1.0" encoding="utf-8"?> + android:layout_height="match_parent"> android:id="@+id/mVideoView" -<?xml version="1.0" encoding="utf-8"?> + android:layout_height="match_parent"> android:layout_width="match_parent" -<FrameLayout android:id="@+id/live_root" xmlns:android="http://schemas.android.com/apk/res/android" + + -<FrameLayout android:id="@+id/live_root" xmlns:android="http://schemas.android.com/apk/res/android" + <?xml version="1.0" encoding="utf-8"?> -<FrameLayout android:id="@+id/live_root" xmlns:android="http://schemas.android.com/apk/res/android" + <FrameLayout android:id="@+id/live_root" xmlns:android="http://schemas.android.com/apk/res/android" -<FrameLayout android:id="@+id/live_root" xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" -<FrameLayout android:id="@+id/live_root" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" -<FrameLayout android:id="@+id/live_root" xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_height="match_parent"> -<FrameLayout android:id="@+id/live_root" xmlns:android="http://schemas.android.com/apk/res/android" + -<FrameLayout android:id="@+id/live_root" xmlns:android="http://schemas.android.com/apk/res/android" + <com.dueeeke.videoplayer.player.VideoView -<FrameLayout android:id="@+id/live_root" xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/mVideoView" -<FrameLayout android:id="@+id/live_root" xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" - xmlns:app="http://schemas.android.com/apk/res-auto" + <com.dueeeke.videoplayer.player.VideoView - xmlns:app="http://schemas.android.com/apk/res-auto" + <com.dueeeke.videoplayer.player.VideoView <?xml version="1.0" encoding="utf-8"?> - xmlns:app="http://schemas.android.com/apk/res-auto" + + <com.dueeeke.videoplayer.player.VideoView <FrameLayout android:id="@+id/live_root" xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" + <com.dueeeke.videoplayer.player.VideoView xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:app="http://schemas.android.com/apk/res-auto" + <com.dueeeke.videoplayer.player.VideoView android:layout_width="match_parent" - xmlns:app="http://schemas.android.com/apk/res-auto" + <com.dueeeke.videoplayer.player.VideoView android:layout_height="match_parent"> - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:app="http://schemas.android.com/apk/res-auto" + <com.owen.tvrecyclerview.widget.TvRecyclerView <com.dueeeke.videoplayer.player.VideoView + - android:visibility="gone" /> + android:layout_width="240mm" + android:layout_height="match_parent" +<?xml version="1.0" encoding="utf-8"?> - <TextView + android:paddingLeft="10mm" + android:paddingTop="20mm" - xmlns:app="http://schemas.android.com/apk/res-auto" +<?xml version="1.0" encoding="utf-8"?> android:layout_width="match_parent" - android:layout_width="match_parent" +<FrameLayout android:id="@+id/live_root" xmlns:android="http://schemas.android.com/apk/res/android" + android:visibility="visible" +<FrameLayout android:id="@+id/live_root" xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout android:id="@+id/live_root" xmlns:android="http://schemas.android.com/apk/res/android" <com.dueeeke.videoplayer.player.VideoView + android:layout_width="match_parent" - android:layout_gravity="right|bottom" + </LinearLayout> - android:layout_marginRight="30mm" + +<FrameLayout android:id="@+id/live_root" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" - xmlns:app="http://schemas.android.com/apk/res-auto" - android:background="@drawable/channel_num_shape" + android:id="@+id/tvChannel" - xmlns:app="http://schemas.android.com/apk/res-auto" <FrameLayout android:id="@+id/live_root" xmlns:android="http://schemas.android.com/apk/res/android" + -<?xml version="1.0" encoding="utf-8"?> +<FrameLayout android:id="@+id/live_root" xmlns:android="http://schemas.android.com/apk/res/android" <com.dueeeke.videoplayer.player.VideoView - xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_gravity="right" + android:layout_marginTop="30mm" xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:app="http://schemas.android.com/apk/res-auto" <?xml version="1.0" encoding="utf-8"?> - android:layout_width="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" - android:layout_width="match_parent" +<FrameLayout android:id="@+id/live_root" xmlns:android="http://schemas.android.com/apk/res/android" - android:singleLine="true" + android:paddingTop="5mm" + xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" - android:layout_height="match_parent"> android:textColor="@android:color/white" - android:layout_width="match_parent" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:textStyle="bold" + android:visibility="gone" /> <TextView android:id="@+id/tvHint" diff --git a/app/src/main/res/layout/item_channel_group_layout.xml b/app/src/main/res/layout/item_channel_group_layout.xml new file mode 100644 index 0000000000000000000000000000000000000000..170659a127c3e027490d96aa3091af3a94bb6d97 --- /dev/null +++ b/app/src/main/res/layout/item_channel_group_layout.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="10mm" + android:layout_marginBottom="10mm" + android:background="@drawable/live_focus" + android:focusable="true" + android:focusableInTouchMode="true" + android:orientation="horizontal"> + + <TextView + android:id="@+id/tvGroupName" + android:layout_width="0mm" + android:layout_height="60mm" + android:layout_weight="1" + android:ellipsize="marquee" + android:gravity="center" + android:marqueeRepeatLimit="marquee_forever" + android:singleLine="true" + android:textColor="@android:color/white" + android:textSize="22mm" /> +</LinearLayout> \ No newline at end of file