解决扫码设置配置地址时直播配置未变动的问题;

解决因直播频道过多导致的频道列表卡顿的问题;
pull/142/head
于俊 1 year ago
parent 5cc4604117
commit ba60fca04f
  1. 2
      app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java
  2. 15
      app/src/main/java/com/github/tvbox/osc/bean/LiveChannelItem.java
  3. 45
      app/src/main/java/com/github/tvbox/osc/ui/activity/LivePlayActivity.java
  4. 1
      app/src/main/java/com/github/tvbox/osc/ui/dialog/ApiDialog.java
  5. 2
      gradle.properties

@ -171,7 +171,7 @@ public class ApiConfig {
String liveApiUrl = Hawk.get(HawkConfig.LIVE_API_URL, "");
String liveApiConfigUrl=configUrl(liveApiUrl);
if(!liveApiUrl.isEmpty() && !liveApiUrl.equals(apiUrl)){
if(liveApiUrl.contains(".txt") || liveApiUrl.contains(".m3u")){
if(liveApiUrl.contains(".txt") || liveApiUrl.contains(".m3u") || liveApiUrl.contains("=txt") || liveApiUrl.contains("=m3u")){
initLiveSettings();
defaultLiveObjString = defaultLiveObjString.replace("txt_m3u_url",liveApiConfigUrl);
parseLiveJson(liveApiUrl,defaultLiveObjString);

@ -1,6 +1,7 @@
package com.github.tvbox.osc.bean;
import java.util.ArrayList;
import java.util.Objects;
/**
* @author pj567
@ -101,4 +102,18 @@ public class LiveChannelItem {
public String getSourceName() {
return channelSourceNames.get(sourceIndex);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
LiveChannelItem that = (LiveChannelItem) o;
return Objects.equals(channelName, that.channelName)
&& Objects.equals(channelUrls.get(sourceIndex), that.getUrl());
}
@Override
public int hashCode() {
return Objects.hash(channelName, channelUrls.get(sourceIndex));
}
}

@ -676,20 +676,49 @@ public class LivePlayActivity extends BaseActivity {
return;
}
if (tvLeftChannelListLayout.getVisibility() == View.INVISIBLE) {
//重新载入上一次状态
liveChannelItemAdapter.setNewData(getLiveChannels(currentChannelGroupIndex));
if (currentLiveChannelIndex > -1)
refreshChannelList(currentChannelGroupIndex);
if (currentLiveChannelIndex > -1){
mLiveChannelView.scrollToPosition(currentLiveChannelIndex);
mLiveChannelView.setSelection(currentLiveChannelIndex);
mChannelGroupView.scrollToPosition(currentChannelGroupIndex);
mChannelGroupView.setSelection(currentChannelGroupIndex);
mHandler.postDelayed(mFocusCurrentChannelAndShowChannelList, 200);
mLiveChannelView.setSelection(currentLiveChannelIndex);
}
// mChannelGroupView.scrollToPosition(currentChannelGroupIndex);
// mChannelGroupView.setSelection(currentChannelGroupIndex);
mHandler.postDelayed(mFocusCurrentChannelAndShowChannelList, 50);
} else {
mHandler.removeCallbacks(mHideChannelListRun);
mHandler.post(mHideChannelListRun);
}
}
private int mLastChannelGroupIndex = -1;
private List<LiveChannelItem> mLastChannelList = new ArrayList<>();
private void refreshChannelList(int currentChannelGroupIndex) {
// 1. 获取新数据
List<LiveChannelItem> newChannels = getLiveChannels(currentChannelGroupIndex);
// 2. 判断数据是否变化(相同组索引且数据内容未变)
if (currentChannelGroupIndex == mLastChannelGroupIndex
&& isSameData(newChannels, mLastChannelList)) {
return; // 数据未变化,跳过刷新 解决部分直播频道过多时卡顿
}
mLastChannelGroupIndex = currentChannelGroupIndex;
mLastChannelList = new ArrayList<>(newChannels);
liveChannelItemAdapter.setNewData(newChannels);
}
// 对比两个列表内容是否相同
private boolean isSameData(List<LiveChannelItem> list1, List<LiveChannelItem> list2) {
// return list1.size() == list2.size();
if (list1 == list2) return true;
if (list1 == null || list2 == null || list1.size() != list2.size()) return false;
for (int i = 0; i < list1.size(); i++) {
if (!list1.get(i).equals(list2.get(i))) {
return false;
}
}
return true;
}
private Runnable mFocusCurrentChannelAndShowChannelList = new Runnable() {
@Override
public void run() {
@ -840,7 +869,7 @@ public class LivePlayActivity extends BaseActivity {
selectSettingGroup(0, false);
mSettingGroupView.scrollToPosition(0);
mSettingItemView.scrollToPosition(currentLiveChannelItem.getSourceIndex());
mHandler.postDelayed(mFocusAndShowSettingGroup, 200);
mHandler.postDelayed(mFocusAndShowSettingGroup, 50);
} else {
mHandler.removeCallbacks(mHideSettingLayoutRun);
mHandler.post(mHideSettingLayoutRun);

@ -48,6 +48,7 @@ public class ApiDialog extends BaseDialog {
public void refresh(RefreshEvent event) {
if (event.type == RefreshEvent.TYPE_API_URL_CHANGE) {
inputApi.setText((String) event.obj);
inputApiLive.setText((String) event.obj);
}
}

@ -18,4 +18,4 @@ android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
IsDebug=true
org.gradle.jvmargs=-Xmx2048m --add-opens java.base/java.io=ALL-UNNAMED
#org.gradle.jvmargs=-Xmx2048m --add-opens java.base/java.io=ALL-UNNAMED

Loading…
Cancel
Save