handling error while loading comments

This commit is contained in:
Ritvik Saraf 2018-09-27 00:53:36 +05:30
parent 515be677a9
commit a29e2116a7
3 changed files with 8 additions and 3 deletions

View file

@ -55,7 +55,7 @@ dependencies {
exclude module: 'support-annotations' exclude module: 'support-annotations'
} }
implementation 'com.github.yausername:NewPipeExtractor:c1199c8' implementation 'com.github.yausername:NewPipeExtractor:fb14196'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.8.9' testImplementation 'org.mockito:mockito-core:2.8.9'

View file

@ -997,7 +997,6 @@ public class VideoDetailFragment
protected void prepareAndLoadInfo() { protected void prepareAndLoadInfo() {
parallaxScrollRootView.smoothScrollTo(0, 0); parallaxScrollRootView.smoothScrollTo(0, 0);
pushToStack(serviceId, url, name); pushToStack(serviceId, url, name);
//clearComments();
startLoading(false); startLoading(false);
} }
@ -1027,6 +1026,7 @@ public class VideoDetailFragment
private void loadComments(boolean forceLoad) { private void loadComments(boolean forceLoad) {
if(isCommentsSupported && showComments){ if(isCommentsSupported && showComments){
clearComments();
commentsInfo = null; commentsInfo = null;
if (commentsDisposable != null) commentsDisposable.dispose(); if (commentsDisposable != null) commentsDisposable.dispose();
@ -1038,7 +1038,7 @@ public class VideoDetailFragment
showCommentsWithAnimation(120, 0,0); showCommentsWithAnimation(120, 0,0);
initComments(commentsInfo); initComments(commentsInfo);
}, (@NonNull Throwable throwable) -> { }, (@NonNull Throwable throwable) -> {
onError(throwable); onCommentsError(throwable);
}); });
} }
} }
@ -1495,4 +1495,8 @@ public class VideoDetailFragment
showError(getString(R.string.blocked_by_gema), false, R.drawable.gruese_die_gema); showError(getString(R.string.blocked_by_gema), false, R.drawable.gruese_die_gema);
} }
public void onCommentsError(Throwable exception) {
showSnackBarError(exception, UserAction.REQUESTED_COMMENTS, NewPipe.getNameOfService(serviceId), url, R.string.error_unable_to_load_comments);
}
} }

View file

@ -389,6 +389,7 @@
<string name="could_not_import_all_files">Warning: Could not import all files.</string> <string name="could_not_import_all_files">Warning: Could not import all files.</string>
<string name="override_current_data">This will override your current setup.</string> <string name="override_current_data">This will override your current setup.</string>
<string name="import_settings">Do you want to also import settings?</string> <string name="import_settings">Do you want to also import settings?</string>
<string name="error_unable_to_load_comments">Could not load comments</string>
<!-- Kiosk Names --> <!-- Kiosk Names -->
<string name="kiosk">Kiosk</string> <string name="kiosk">Kiosk</string>