mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-08 07:57:28 +00:00
close #717 and fix looper toast issue
This commit is contained in:
parent
60ec1f5936
commit
20d9a3935b
@ -94,17 +94,12 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
|
||||
commentsViewModel.getList().postValue(list);
|
||||
}
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
stopCurrentExecutor();
|
||||
stopCurrentExecutor(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
try {
|
||||
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
stopCurrentExecutor();
|
||||
}
|
||||
catch(Throwable e) {}
|
||||
stopCurrentExecutor(true);
|
||||
}
|
||||
};
|
||||
|
||||
@ -227,7 +222,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
|
||||
endCursor = null;
|
||||
lazyLoader.resetState();
|
||||
commentsViewModel.getList().postValue(Collections.emptyList());
|
||||
stopCurrentExecutor();
|
||||
stopCurrentExecutor(false);
|
||||
currentlyRunning = new CommentsFetcher(shortCode, "", fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
@ -276,7 +271,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
|
||||
endCursor = null;
|
||||
});
|
||||
binding.rvComments.addOnScrollListener(lazyLoader);
|
||||
stopCurrentExecutor();
|
||||
stopCurrentExecutor(false);
|
||||
onRefresh();
|
||||
}
|
||||
|
||||
@ -462,7 +457,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
|
||||
NavHostFragment.findNavController(this).navigate(action);
|
||||
}
|
||||
|
||||
private void stopCurrentExecutor() {
|
||||
private void stopCurrentExecutor(@NonNull final boolean failed) {
|
||||
if (currentlyRunning != null) {
|
||||
try {
|
||||
currentlyRunning.cancel(true);
|
||||
@ -470,6 +465,13 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
|
||||
if (BuildConfig.DEBUG) Log.e(TAG, "", e);
|
||||
}
|
||||
}
|
||||
if (failed) {
|
||||
try {
|
||||
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
catch(Throwable e) {}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -348,16 +348,17 @@ public final class FollowViewerFragment extends Fragment implements SwipeRefresh
|
||||
loading = false;
|
||||
final ArrayList<ExpandableGroup> groups = new ArrayList<>(1);
|
||||
|
||||
if (isCompare) {
|
||||
if (isCompare && followingModels != null && followersModels != null && allFollowing != null) {
|
||||
if (followingModels != null && followingModels.size() > 0)
|
||||
groups.add(new ExpandableGroup(resources.getString(R.string.followers_not_following, username), followingModels));
|
||||
if (followersModels != null && followersModels.size() > 0)
|
||||
groups.add(new ExpandableGroup(resources.getString(R.string.followers_not_follower, namePost), followersModels));
|
||||
if (allFollowing != null && allFollowing.size() > 0)
|
||||
groups.add(new ExpandableGroup(resources.getString(R.string.followers_both_following), allFollowing));
|
||||
} else {
|
||||
} else if (followModels != null) {
|
||||
groups.add(new ExpandableGroup(type, followModels));
|
||||
}
|
||||
else return;
|
||||
adapter = new FollowAdapter(clickListener, groups);
|
||||
adapter.toggleGroup(0);
|
||||
binding.rvFollow.setAdapter(adapter);
|
||||
|
@ -91,7 +91,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
private boolean hasStories = false;
|
||||
private boolean opening = false;
|
||||
private String hashtag;
|
||||
private HashtagModel hashtagModel;
|
||||
private HashtagModel hashtagModel = null;
|
||||
private ActionMode actionMode;
|
||||
private StoriesService storiesService;
|
||||
private AsyncTask<?, ?, ?> currentlyExecuting;
|
||||
@ -373,22 +373,12 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
public void onResult(final HashtagModel result) {
|
||||
hashtagModel = result;
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
if (hashtagModel == null) {
|
||||
Toast.makeText(context, R.string.error_loading_hashtag, Toast.LENGTH_SHORT).show();
|
||||
binding.swipeRefreshLayout.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
setTitle();
|
||||
setHashtagDetails();
|
||||
setupPosts();
|
||||
fetchStories();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
setHashtagDetails();
|
||||
}
|
||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
@ -406,6 +396,17 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
}
|
||||
|
||||
private void setHashtagDetails() {
|
||||
if (hashtagModel == null) {
|
||||
try {
|
||||
Toast.makeText(getContext(), R.string.error_loading_hashtag, Toast.LENGTH_SHORT).show();
|
||||
binding.swipeRefreshLayout.setEnabled(false);
|
||||
}
|
||||
catch (Exception ignored) {}
|
||||
return;
|
||||
}
|
||||
setTitle();
|
||||
setupPosts();
|
||||
fetchStories();
|
||||
if (isLoggedIn) {
|
||||
hashtagDetailsBinding.btnFollowTag.setVisibility(View.VISIBLE);
|
||||
hashtagDetailsBinding.btnFollowTag.setText(hashtagModel.getFollowing() ? R.string.unfollow : R.string.follow);
|
||||
|
Loading…
Reference in New Issue
Block a user