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