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,16 +232,18 @@ public class ChannelActivity extends AppCompatActivity {
// start processing // start processing
isLoading = true; isLoading = true;
if(!onlyVideos) {
//delete already displayed content //delete already displayed content
progressBar.setVisibility(View.VISIBLE); progressBar.setVisibility(View.VISIBLE);
infoListAdapter.clearSteamItemList(); infoListAdapter.clearSteamItemList();
if(SDK_INT >= 21) { if (SDK_INT >= 21) {
channelBanner.setImageDrawable(getDrawable(R.drawable.channel_banner)); channelBanner.setImageDrawable(getDrawable(R.drawable.channel_banner));
avatarView.setImageDrawable(getDrawable(R.drawable.buddy)); avatarView.setImageDrawable(getDrawable(R.drawable.buddy));
subscriberLayout.setVisibility(View.GONE); subscriberLayout.setVisibility(View.GONE);
titleView.setText(""); titleView.setText("");
getSupportActionBar().setTitle(""); getSupportActionBar().setTitle("");
} }
}
Thread channelExtractorThread = new Thread(new Runnable() { Thread channelExtractorThread = new Thread(new Runnable() {

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