Support logo for txt

pull/123/head
FongMi 3 years ago
parent bc6caf6610
commit 6b4ae2cd14
  1. 5
      app/src/main/java/com/fongmi/android/tv/api/LiveParser.java
  2. 10
      app/src/main/java/com/fongmi/android/tv/bean/Channel.java

@ -49,7 +49,8 @@ public class LiveParser {
if (line.startsWith("#EXTINF:")) { if (line.startsWith("#EXTINF:")) {
Group group = live.find(Group.create(extract(line, GROUP))); Group group = live.find(Group.create(extract(line, GROUP)));
channel = group.find(Channel.create(extract(line, NAME))); channel = group.find(Channel.create(extract(line, NAME)));
channel.epg(live).setLogo(extract(line, LOGO)); channel.setLogo(extract(line, LOGO));
channel.epg(live).logo(live);
} else if (line.contains("://")) { } else if (line.contains("://")) {
channel.getUrls().add(line); channel.getUrls().add(line);
} }
@ -64,7 +65,7 @@ public class LiveParser {
if (live.getGroups().isEmpty()) live.getGroups().add(Group.create(R.string.live_group)); if (live.getGroups().isEmpty()) live.getGroups().add(Group.create(R.string.live_group));
if (split[1].contains("://")) { if (split[1].contains("://")) {
Group group = live.getGroups().get(live.getGroups().size() - 1); Group group = live.getGroups().get(live.getGroups().size() - 1);
group.find(Channel.create(split[0]).epg(live)).addUrls(split[1].split("#")); group.find(Channel.create(split[0]).epg(live).logo(live)).addUrls(split[1].split("#"));
} }
} }
} }

@ -161,7 +161,7 @@ public class Channel {
} }
public void loadLogo(ImageView view) { public void loadLogo(ImageView view) {
if (!getLogo().isEmpty()) Glide.with(App.get()).load(getLogo()).into(view); if (!getLogo().isEmpty()) Glide.with(App.get()).load(getLogo()).placeholder(R.drawable.ic_img_loading).error(R.drawable.ic_img_error).into(view);
} }
public void addUrls(String... urls) { public void addUrls(String... urls) {
@ -199,11 +199,17 @@ public class Channel {
} }
public Channel epg(Live live) { public Channel epg(Live live) {
if (live.getEpg().isEmpty()) return this; if (live.getEpg().isEmpty() || getEpg().startsWith("http")) return this;
setEpg(live.getEpg().replace("{name}", getName()).replace("{epg}", getEpg())); setEpg(live.getEpg().replace("{name}", getName()).replace("{epg}", getEpg()));
return this; return this;
} }
public Channel logo(Live live) {
if (live.getLogo().isEmpty() || getLogo().startsWith("http")) return this;
setLogo(live.getLogo().replace("{name}", getName()).replace("{logo}", getLogo()));
return this;
}
public String getScheme() { public String getScheme() {
return Uri.parse(getUrls().get(getLine())).getScheme().toLowerCase(); return Uri.parse(getUrls().get(getLine())).getScheme().toLowerCase();
} }

Loading…
Cancel
Save