Prepare to add quarantined subreddit support.

This commit is contained in:
Alex Ning 2021-02-02 23:33:14 +08:00
parent b7b9a7f3bd
commit 36c7cfcc6b
7 changed files with 12 additions and 9 deletions

View File

@ -935,7 +935,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
} }
@Override @Override
public void onFetchSubredditDataFail() { public void onFetchSubredditDataFail(boolean isQuarantined) {
mRespectSubredditRecommendedSortType = false; mRespectSubredditRecommendedSortType = false;
ViewPostDetailActivity.this.sortType = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT, SortType.Type.BEST.value.toUpperCase()); ViewPostDetailActivity.this.sortType = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT, SortType.Type.BEST.value.toUpperCase());
if (ViewPostDetailActivity.this.sortType != null) { if (ViewPostDetailActivity.this.sortType != null) {

View File

@ -519,7 +519,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
} }
@Override @Override
public void onFetchSubredditDataFail() { public void onFetchSubredditDataFail(boolean isQuarantined) {
makeSnackbar(R.string.cannot_fetch_subreddit_info, true); makeSnackbar(R.string.cannot_fetch_subreddit_info, true);
mFetchSubredditInfoSuccess = false; mFetchSubredditInfoSuccess = false;
} }

View File

@ -346,4 +346,7 @@ public interface RedditAPI {
Call<String> addSubredditToMultiReddit(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params, Call<String> addSubredditToMultiReddit(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params,
@Path(value = "multipath", encoded = true) String multipath, @Path("subredditName") String subredditName); @Path(value = "multipath", encoded = true) String multipath, @Path("subredditName") String subredditName);
@FormUrlEncoded
@POST("/api/quarantine_optin?raw_json=1")
Call<String> optInQuarantinedSubreddit(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params);
} }

View File

@ -57,7 +57,7 @@ public class LoadSubredditIconAsyncTask extends AsyncTask<Void, Void, Void> {
} }
@Override @Override
public void onFetchSubredditDataFail() { public void onFetchSubredditDataFail(boolean isQuarantined) {
loadSubredditIconAsyncTaskListener.loadIconSuccess(null); loadSubredditIconAsyncTaskListener.loadIconSuccess(null);
} }
}); });

View File

@ -193,7 +193,7 @@ public class SidebarFragment extends Fragment {
} }
@Override @Override
public void onFetchSubredditDataFail() { public void onFetchSubredditDataFail(boolean isQuarantined) {
swipeRefreshLayout.setRefreshing(false); swipeRefreshLayout.setRefreshing(false);
Toast.makeText(activity, R.string.cannot_fetch_sidebar, Toast.LENGTH_SHORT).show(); Toast.makeText(activity, R.string.cannot_fetch_sidebar, Toast.LENGTH_SHORT).show();
} }

View File

@ -31,17 +31,17 @@ public class FetchSubredditData {
@Override @Override
public void onParseSubredditDataFail() { public void onParseSubredditDataFail() {
fetchSubredditDataListener.onFetchSubredditDataFail(); fetchSubredditDataListener.onFetchSubredditDataFail(false);
} }
}); });
} else { } else {
fetchSubredditDataListener.onFetchSubredditDataFail(); fetchSubredditDataListener.onFetchSubredditDataFail(response.code() == 403);
} }
} }
@Override @Override
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) { public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
fetchSubredditDataListener.onFetchSubredditDataFail(); fetchSubredditDataListener.onFetchSubredditDataFail(false);
} }
}); });
} }
@ -84,7 +84,7 @@ public class FetchSubredditData {
public interface FetchSubredditDataListener { public interface FetchSubredditDataListener {
void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers); void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers);
void onFetchSubredditDataFail(); void onFetchSubredditDataFail(boolean isQuarantined);
} }
interface FetchSubredditListingDataListener { interface FetchSubredditListingDataListener {

View File

@ -56,7 +56,7 @@ public class SubredditSubscription {
} }
@Override @Override
public void onFetchSubredditDataFail() { public void onFetchSubredditDataFail(boolean isQuarantined) {
} }
}); });