fix channel load more videos error

This commit is contained in:
Christian Schabesberger 2017-02-27 21:31:20 +01:00
parent 5923663e08
commit 2002234d86
2 changed files with 20 additions and 12 deletions

View file

@ -232,15 +232,17 @@ public class ChannelActivity extends AppCompatActivity {
// start processing // start processing
isLoading = true; isLoading = true;
//delete already displayed content if(!onlyVideos) {
progressBar.setVisibility(View.VISIBLE); //delete already displayed content
infoListAdapter.clearSteamItemList(); progressBar.setVisibility(View.VISIBLE);
if(SDK_INT >= 21) { infoListAdapter.clearSteamItemList();
channelBanner.setImageDrawable(getDrawable(R.drawable.channel_banner)); if (SDK_INT >= 21) {
avatarView.setImageDrawable(getDrawable(R.drawable.buddy)); channelBanner.setImageDrawable(getDrawable(R.drawable.channel_banner));
subscriberLayout.setVisibility(View.GONE); avatarView.setImageDrawable(getDrawable(R.drawable.buddy));
titleView.setText(""); subscriberLayout.setVisibility(View.GONE);
getSupportActionBar().setTitle(""); titleView.setText("");
getSupportActionBar().setTitle("");
}
} }

View file

@ -55,6 +55,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
private static String avatarUrl = ""; private static String avatarUrl = "";
private static String bannerUrl = ""; private static String bannerUrl = "";
private static String feedUrl = ""; private static String feedUrl = "";
private static long subscriberCount = -1;
// the fist page is html all other pages are ajax. Every new page can be requested by sending // the fist page is html all other pages are ajax. Every new page can be requested by sending
// this request url. // this request url.
private static String nextPageUrl = ""; private static String nextPageUrl = "";
@ -296,9 +297,14 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
@Override @Override
public long getSubscriberCount() throws ParsingException { public long getSubscriberCount() throws ParsingException {
String countRaw = doc.select("span[class*=\"yt-subscription-button-subscriber-count\"]").first() Element el = doc.select("span[class*=\"yt-subscription-button-subscriber-count\"]")
.text(); .first();
return Long.parseLong(countRaw.replaceAll("\\D+","")); if(el != null) {
subscriberCount = Long.parseLong(el.text().replaceAll("\\D+",""));
} else if(el == null && subscriberCount == -1) {
throw new ParsingException("Could not get subscriber count");
}
return subscriberCount;
} }
@Override @Override