Add live load progress

pull/123/head
FongMi 4 years ago
parent e98622b112
commit 4116d699d1
  1. 20
      app/src/leanback/java/com/fongmi/android/tv/ui/activity/LiveActivity.java
  2. 10
      app/src/main/java/com/fongmi/android/tv/api/LiveParser.java
  3. 1
      app/src/main/java/com/fongmi/android/tv/bean/Channel.java
  4. 6
      app/src/main/java/com/fongmi/android/tv/bean/Group.java
  5. 2
      app/src/main/java/com/fongmi/android/tv/model/LiveViewModel.java
  6. 1
      app/src/main/res/values-zh-rCN/strings.xml
  7. 1
      app/src/main/res/values-zh-rTW/strings.xml
  8. 1
      app/src/main/res/values/strings.xml

@ -162,6 +162,7 @@ public class LiveActivity extends BaseActivity implements GroupPresenter.OnClick
private void getLive() {
mViewModel.getLive(LiveConfig.get().getHome());
showProgress();
}
private void setVideoView() {
@ -177,12 +178,12 @@ public class LiveActivity extends BaseActivity implements GroupPresenter.OnClick
private void setGroup(Live home) {
List<Group> items = new ArrayList<>();
items.add(Group.create(ResUtil.getString(R.string.keep)));
items.add(Group.create(R.string.keep));
for (Group group : home.getGroups()) (group.isHidden() ? mHides : items).add(group);
mGroupAdapter.setItems(items, null);
setPosition(LiveConfig.get().find(items));
mControl.home.setText(home.getName());
Notify.dismiss();
hideProgress();
}
private void setPosition(int[] position) {
@ -271,6 +272,14 @@ public class LiveActivity extends BaseActivity implements GroupPresenter.OnClick
setPosition();
}
private void showProgress() {
mBinding.widget.progress.getRoot().setVisibility(View.VISIBLE);
}
private void hideProgress() {
mBinding.widget.progress.getRoot().setVisibility(View.GONE);
}
private void hideInfo() {
mBinding.widget.info.setVisibility(View.GONE);
}
@ -376,8 +385,8 @@ public class LiveActivity extends BaseActivity implements GroupPresenter.OnClick
}
private void getUrl() {
mBinding.widget.progress.getRoot().setVisibility(View.VISIBLE);
mViewModel.getUrl(mChannel);
showProgress();
}
private void prevLine(boolean show) {
@ -518,7 +527,6 @@ public class LiveActivity extends BaseActivity implements GroupPresenter.OnClick
public void setLive(Live item) {
getPlayerView().hideController();
LiveConfig.get().setHome(item);
Notify.progress(this);
mHides.clear();
getLive();
}
@ -532,12 +540,12 @@ public class LiveActivity extends BaseActivity implements GroupPresenter.OnClick
case Player.STATE_IDLE:
break;
case Player.STATE_BUFFERING:
mBinding.widget.progress.getRoot().setVisibility(View.VISIBLE);
showProgress();
break;
case Player.STATE_READY:
hideProgress();
mPlayers.reset();
App.removeCallbacks(mR4);
mBinding.widget.progress.getRoot().setVisibility(View.GONE);
TrackSelectionDialog.setVisible(mPlayers.exo(), mControl.tracks);
break;
case Player.STATE_ENDED:

@ -2,6 +2,7 @@ package com.fongmi.android.tv.api;
import android.util.Base64;
import com.fongmi.android.tv.R;
import com.fongmi.android.tv.bean.Channel;
import com.fongmi.android.tv.bean.Group;
import com.fongmi.android.tv.bean.Live;
@ -32,7 +33,8 @@ public class LiveParser {
public static void start(Live live, String text) {
int number = 0;
if (live.getGroups().size() > 0) return;
if (text.trim().startsWith("#EXTM3U")) m3u(live, text); else txt(live, text);
if (text.trim().startsWith("#EXTM3U")) m3u(live, text);
else txt(live, text);
for (Group group : live.getGroups()) {
for (Channel channel : group.getChannel()) {
channel.setNumber(++number);
@ -55,11 +57,11 @@ public class LiveParser {
private static void txt(Live live, String text) {
for (String line : text.split("\n")) {
System.out.println(line);
String[] split = line.split(",");
if (split.length < 2) continue;
if (line.contains("#genre#")) {
live.getGroups().add(Group.create(split[0]));
}
if (line.contains("#genre#")) live.getGroups().add(Group.create(split[0]));
if (live.getGroups().isEmpty()) live.getGroups().add(Group.create(R.string.live_group));
if (split[1].contains("://")) {
Group group = live.getGroups().get(live.getGroups().size() - 1);
group.find(Channel.create(split[0]).epg(live)).addUrls(split[1].split("#"));

@ -199,6 +199,7 @@ public class Channel {
}
public Channel epg(Live live) {
if (live.getEpg().isEmpty()) return this;
setEpg(live.getEpg().replace("{name}", getName()).replace("{epg}", getEpg()));
return this;
}

@ -4,6 +4,8 @@ import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import androidx.annotation.StringRes;
import com.bumptech.glide.Glide;
import com.fongmi.android.tv.App;
import com.fongmi.android.tv.R;
@ -30,6 +32,10 @@ public class Group {
return new Group(name);
}
public static Group create(@StringRes int resId) {
return new Group(ResUtil.getString(resId));
}
public Group(String name) {
this.name = name;
if (!name.contains("_")) return;

@ -43,7 +43,7 @@ public class LiveViewModel extends ViewModel {
executor = Executors.newFixedThreadPool(2);
executor.execute(() -> {
try {
if (!Thread.interrupted()) result.postValue(executor.submit(callable).get(10, TimeUnit.SECONDS));
if (!Thread.interrupted()) result.postValue(executor.submit(callable).get(30, TimeUnit.SECONDS));
} catch (Throwable e) {
e.printStackTrace();
}

@ -12,6 +12,7 @@
<!-- Live -->
<string name="live_pass">密码</string>
<string name="live_group">未分类</string>
<string name="live_setting">设定</string>
<string name="live_epg_now">正在播放:<xliff:g name="name">%s</xliff:g></string>
<string name="live_line">线路 <xliff:g name="name">%s</xliff:g></string>

@ -12,6 +12,7 @@
<!-- Live -->
<string name="live_pass">密碼</string>
<string name="live_group">未分類</string>
<string name="live_setting">設定</string>
<string name="live_epg_now">正在播放:<xliff:g name="name">%s</xliff:g></string>
<string name="live_line">來源 <xliff:g name="name">%s</xliff:g></string>

@ -12,6 +12,7 @@
<!-- Live -->
<string name="live_pass">Pass</string>
<string name="live_group">Group</string>
<string name="live_setting">Setting</string>
<string name="live_epg_now">Playing: <xliff:g name="name">%s</xliff:g></string>
<string name="live_line">Line <xliff:g name="name">%s</xliff:g></string>

Loading…
Cancel
Save