mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-26 08:37:29 +00:00
add many fetch failure checks, close #486
This commit is contained in:
parent
b790f85d6e
commit
251228dcc4
@ -145,6 +145,7 @@ public final class CommentsFetcher extends AsyncTask<Void, Void, List<CommentMod
|
||||
"getChildComments",
|
||||
new Pair<>("commentModels.size", commentModels.size()));
|
||||
if (BuildConfig.DEBUG) Log.e(TAG, "", e);
|
||||
if (fetchListener != null) fetchListener.onFailure(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -284,6 +285,7 @@ public final class CommentsFetcher extends AsyncTask<Void, Void, List<CommentMod
|
||||
logCollector.appendException(e, LogCollector.LogFile.ASYNC_COMMENTS_FETCHER, "getParentComments",
|
||||
new Pair<>("commentModelsList.size", commentModels.size()));
|
||||
if (BuildConfig.DEBUG) Log.e("AWAISKING_APP", "", e);
|
||||
if (fetchListener != null) fetchListener.onFailure(e);
|
||||
return null;
|
||||
}
|
||||
return commentModels;
|
||||
|
@ -89,6 +89,7 @@ public final class HashtagFetcher extends AsyncTask<Void, Void, HashtagModel> {
|
||||
if (logCollector != null)
|
||||
logCollector.appendException(e, LogCollector.LogFile.ASYNC_HASHTAG_FETCHER, "doInBackground");
|
||||
if (BuildConfig.DEBUG) Log.e(TAG, "", e);
|
||||
if (fetchListener != null) fetchListener.onFailure(e);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -97,6 +97,13 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
stopCurrentExecutor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
stopCurrentExecutor();
|
||||
}
|
||||
};
|
||||
|
||||
private final CommentsAdapter.CommentCallback commentCallback = new CommentsAdapter.CommentCallback() {
|
||||
|
@ -80,6 +80,7 @@ public final class FollowViewerFragment extends Fragment implements SwipeRefresh
|
||||
@Override
|
||||
public void onFailure(final Throwable t) {
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
Log.e(TAG, "Error fetching list (double, following)", t);
|
||||
}
|
||||
};
|
||||
@ -105,6 +106,7 @@ public final class FollowViewerFragment extends Fragment implements SwipeRefresh
|
||||
@Override
|
||||
public void onFailure(final Throwable t) {
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
Log.e(TAG, "Error fetching list (double, follower)", t);
|
||||
}
|
||||
};
|
||||
@ -219,6 +221,7 @@ public final class FollowViewerFragment extends Fragment implements SwipeRefresh
|
||||
@Override
|
||||
public void onFailure(final Throwable t) {
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
Log.e(TAG, "Error fetching list (single)", t);
|
||||
}
|
||||
};
|
||||
|
@ -54,6 +54,7 @@ import awais.instagrabber.db.entities.Favorite;
|
||||
import awais.instagrabber.db.repositories.FavoriteRepository;
|
||||
import awais.instagrabber.db.repositories.RepositoryCallback;
|
||||
import awais.instagrabber.dialogs.PostsLayoutPreferencesDialogFragment;
|
||||
import awais.instagrabber.interfaces.FetchListener;
|
||||
import awais.instagrabber.models.FeedModel;
|
||||
import awais.instagrabber.models.HashtagModel;
|
||||
import awais.instagrabber.models.PostsLayoutPreferences;
|
||||
@ -363,19 +364,27 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
private void fetchHashtagModel() {
|
||||
stopCurrentExecutor();
|
||||
binding.swipeRefreshLayout.setRefreshing(true);
|
||||
currentlyExecuting = new HashtagFetcher(hashtag.substring(1), 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_profile, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
currentlyExecuting = new HashtagFetcher(hashtag.substring(1), new FetchListener<HashtagModel>() {
|
||||
@Override
|
||||
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_profile, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
setTitle();
|
||||
setHashtagDetails();
|
||||
setupPosts();
|
||||
fetchStories();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
setTitle();
|
||||
setHashtagDetails();
|
||||
setupPosts();
|
||||
fetchStories();
|
||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
@ -524,7 +533,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
public void onSuccess(final Void result) {
|
||||
hashtagDetailsBinding.favChip.setText(R.string.favorite_short);
|
||||
hashtagDetailsBinding.favChip.setChipIconResource(R.drawable.ic_star_check_24);
|
||||
showSnackbar(getString(R.string.added_to_favs));
|
||||
showSnackbar(getString(R.string.added_to_favs_short));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -97,9 +97,7 @@ public final class LikesViewerFragment extends BottomSheetDialogFragment impleme
|
||||
NavHostFragment.findNavController(LikesViewerFragment.this).navigate(R.id.action_global_profileFragment, bundle);
|
||||
}
|
||||
});
|
||||
layoutManager = new LinearLayoutManager(getContext());
|
||||
binding.rvLikes.setAdapter(likesAdapter);
|
||||
binding.rvLikes.setLayoutManager(layoutManager);
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
|
||||
@ -158,6 +156,8 @@ public final class LikesViewerFragment extends BottomSheetDialogFragment impleme
|
||||
binding.swipeRefreshLayout.setRefreshing(true);
|
||||
resources = getResources();
|
||||
if (isComment && !isLoggedIn) {
|
||||
layoutManager = new LinearLayoutManager(getContext());
|
||||
binding.rvLikes.setLayoutManager(layoutManager);
|
||||
lazyLoader = new RecyclerLazyLoader(layoutManager, (page, totalItemsCount) -> {
|
||||
if (!TextUtils.isEmpty(endCursor))
|
||||
graphQLService.fetchCommentLikers(postId, endCursor, acb);
|
||||
|
@ -36,6 +36,7 @@ import awais.instagrabber.asyncs.PostFetcher;
|
||||
import awais.instagrabber.databinding.FragmentNotificationsViewerBinding;
|
||||
import awais.instagrabber.dialogs.ProfilePicDialogFragment;
|
||||
import awais.instagrabber.fragments.settings.MorePreferencesFragmentDirections;
|
||||
import awais.instagrabber.interfaces.FetchListener;
|
||||
import awais.instagrabber.interfaces.MentionClickListener;
|
||||
import awais.instagrabber.models.FeedModel;
|
||||
import awais.instagrabber.models.NotificationModel;
|
||||
@ -267,9 +268,18 @@ public final class NotificationsViewerFragment extends Fragment implements Swipe
|
||||
binding.swipeRefreshLayout.setRefreshing(true);
|
||||
switch (type) {
|
||||
case "notif":
|
||||
new NotificationsFetcher(true, notificationModels -> {
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
notificationViewModel.getList().postValue(notificationModels);
|
||||
new NotificationsFetcher(true, new FetchListener<List<NotificationModel>>() {
|
||||
@Override
|
||||
public void onResult(final List<NotificationModel> notificationModels) {
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
notificationViewModel.getList().postValue(notificationModels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
break;
|
||||
case "ayml":
|
||||
@ -284,7 +294,7 @@ public final class NotificationsViewerFragment extends Fragment implements Swipe
|
||||
@Override
|
||||
public void onFailure(final Throwable t) {
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user