From 36c7cfcc6bd9b3be1eb51303d2c3448e85401eac Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Tue, 2 Feb 2021 23:33:14 +0800 Subject: Prepare to add quarantined subreddit support. --- .../infinityforreddit/activities/ViewPostDetailActivity.java | 2 +- .../infinityforreddit/activities/ViewSubredditDetailActivity.java | 2 +- .../java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java | 3 +++ .../infinityforreddit/asynctasks/LoadSubredditIconAsyncTask.java | 2 +- .../infinityforreddit/fragments/SidebarFragment.java | 2 +- .../infinityforreddit/subreddit/FetchSubredditData.java | 8 ++++---- .../infinityforreddit/subreddit/SubredditSubscription.java | 2 +- 7 files changed, 12 insertions(+), 9 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java index 30100d86..145fdadc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java @@ -935,7 +935,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS } @Override - public void onFetchSubredditDataFail() { + public void onFetchSubredditDataFail(boolean isQuarantined) { mRespectSubredditRecommendedSortType = false; ViewPostDetailActivity.this.sortType = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT, SortType.Type.BEST.value.toUpperCase()); if (ViewPostDetailActivity.this.sortType != null) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java index 3bf7fdf8..cd514c0f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java @@ -519,7 +519,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp } @Override - public void onFetchSubredditDataFail() { + public void onFetchSubredditDataFail(boolean isQuarantined) { makeSnackbar(R.string.cannot_fetch_subreddit_info, true); mFetchSubredditInfoSuccess = false; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java index 1799ff57..67da922d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java @@ -346,4 +346,7 @@ public interface RedditAPI { Call addSubredditToMultiReddit(@HeaderMap Map headers, @FieldMap Map params, @Path(value = "multipath", encoded = true) String multipath, @Path("subredditName") String subredditName); + @FormUrlEncoded + @POST("/api/quarantine_optin?raw_json=1") + Call optInQuarantinedSubreddit(@HeaderMap Map headers, @FieldMap Map params); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/LoadSubredditIconAsyncTask.java b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/LoadSubredditIconAsyncTask.java index 7092bae7..695e4e46 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/LoadSubredditIconAsyncTask.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/LoadSubredditIconAsyncTask.java @@ -57,7 +57,7 @@ public class LoadSubredditIconAsyncTask extends AsyncTask { } @Override - public void onFetchSubredditDataFail() { + public void onFetchSubredditDataFail(boolean isQuarantined) { loadSubredditIconAsyncTaskListener.loadIconSuccess(null); } }); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java index 571350ce..b6fb5795 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java @@ -193,7 +193,7 @@ public class SidebarFragment extends Fragment { } @Override - public void onFetchSubredditDataFail() { + public void onFetchSubredditDataFail(boolean isQuarantined) { swipeRefreshLayout.setRefreshing(false); Toast.makeText(activity, R.string.cannot_fetch_sidebar, Toast.LENGTH_SHORT).show(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/FetchSubredditData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/FetchSubredditData.java index 37587ede..b5e9b553 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/FetchSubredditData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/FetchSubredditData.java @@ -31,17 +31,17 @@ public class FetchSubredditData { @Override public void onParseSubredditDataFail() { - fetchSubredditDataListener.onFetchSubredditDataFail(); + fetchSubredditDataListener.onFetchSubredditDataFail(false); } }); } else { - fetchSubredditDataListener.onFetchSubredditDataFail(); + fetchSubredditDataListener.onFetchSubredditDataFail(response.code() == 403); } } @Override public void onFailure(@NonNull Call call, @NonNull Throwable t) { - fetchSubredditDataListener.onFetchSubredditDataFail(); + fetchSubredditDataListener.onFetchSubredditDataFail(false); } }); } @@ -84,7 +84,7 @@ public class FetchSubredditData { public interface FetchSubredditDataListener { void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers); - void onFetchSubredditDataFail(); + void onFetchSubredditDataFail(boolean isQuarantined); } interface FetchSubredditListingDataListener { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditSubscription.java b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditSubscription.java index 52664234..31615903 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditSubscription.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditSubscription.java @@ -56,7 +56,7 @@ public class SubredditSubscription { } @Override - public void onFetchSubredditDataFail() { + public void onFetchSubredditDataFail(boolean isQuarantined) { } }); -- cgit v1.2.3