1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 14:47:29 +00:00
This commit is contained in:
Austin Huang 2021-02-23 22:34:50 -05:00
parent 20d9a3935b
commit 605ddd3635
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F

View File

@ -94,12 +94,12 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
commentsViewModel.getList().postValue(list);
}
binding.swipeRefreshLayout.setRefreshing(false);
stopCurrentExecutor(false);
stopCurrentExecutor(null);
}
@Override
public void onFailure(Throwable t) {
stopCurrentExecutor(true);
stopCurrentExecutor(t);
}
};
@ -222,7 +222,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
endCursor = null;
lazyLoader.resetState();
commentsViewModel.getList().postValue(Collections.emptyList());
stopCurrentExecutor(false);
stopCurrentExecutor(null);
currentlyRunning = new CommentsFetcher(shortCode, "", fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
@ -271,7 +271,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
endCursor = null;
});
binding.rvComments.addOnScrollListener(lazyLoader);
stopCurrentExecutor(false);
stopCurrentExecutor(null);
onRefresh();
}
@ -457,7 +457,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
NavHostFragment.findNavController(this).navigate(action);
}
private void stopCurrentExecutor(@NonNull final boolean failed) {
private void stopCurrentExecutor(final Throwable t) {
if (currentlyRunning != null) {
try {
currentlyRunning.cancel(true);
@ -465,7 +465,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
if (BuildConfig.DEBUG) Log.e(TAG, "", e);
}
}
if (failed) {
if (t != null) {
try {
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
binding.swipeRefreshLayout.setRefreshing(false);