From 30ce4285c9126ac24b6de3e1342735786204c750 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Sat, 22 Feb 2020 14:32:47 +0800 Subject: Show a error message in toast for voting things. --- .../Adapter/CommentAndPostRecyclerViewAdapter.java | 8 ++++---- .../Adapter/CommentsListingRecyclerViewAdapter.java | 4 ++-- .../infinityforreddit/Adapter/PostRecyclerViewAdapter.java | 8 ++++---- .../infinityforreddit/Okhttp3DebugInterceptor.java | 10 ++++++---- .../java/ml/docilealligator/infinityforreddit/VoteThing.java | 11 +++++++++-- 5 files changed, 25 insertions(+), 16 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java index 450c3486..1ddcf537 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -900,7 +900,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter call, @NonNull Throwable t) { voteThingListener.onVoteThingFail(position); + Toast.makeText(context, "Network error " + "Body: " + t.getMessage(), Toast.LENGTH_LONG).show(); } }); } - public static void voteThing(final Retrofit retrofit, String accessToken, + public static void voteThing(Context context, final Retrofit retrofit, String accessToken, final VoteThingWithoutPositionListener voteThingWithoutPositionListener, final String fullName, final String point) { RedditAPI api = retrofit.create(RedditAPI.class); @@ -62,12 +67,14 @@ public class VoteThing { voteThingWithoutPositionListener.onVoteThingSuccess(); } else { voteThingWithoutPositionListener.onVoteThingFail(); + Toast.makeText(context, "Code " + response.code() + " Body: " + response.body(), Toast.LENGTH_LONG).show(); } } @Override public void onFailure(@NonNull Call call, @NonNull Throwable t) { voteThingWithoutPositionListener.onVoteThingFail(); + Toast.makeText(context, "Network error " + "Body: " + t.getMessage(), Toast.LENGTH_LONG).show(); } }); } -- cgit v1.2.3