diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-09-29 11:41:58 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-09-29 11:41:58 +0000 |
commit | 5b5bc1c5b83ceaffb0d20aae1f4d3f51ebfb4623 (patch) | |
tree | 5f09c61702cb5650aa3d9b31b18f2dcb56984111 /app/src | |
parent | f5f6213733a0d7e5d4351c8454c657c1d7475603 (diff) | |
download | infinity-for-reddit-5b5bc1c5b83ceaffb0d20aae1f4d3f51ebfb4623.tar infinity-for-reddit-5b5bc1c5b83ceaffb0d20aae1f4d3f51ebfb4623.tar.gz infinity-for-reddit-5b5bc1c5b83ceaffb0d20aae1f4d3f51ebfb4623.tar.bz2 infinity-for-reddit-5b5bc1c5b83ceaffb0d20aae1f4d3f51ebfb4623.tar.lz infinity-for-reddit-5b5bc1c5b83ceaffb0d20aae1f4d3f51ebfb4623.tar.xz infinity-for-reddit-5b5bc1c5b83ceaffb0d20aae1f4d3f51ebfb4623.tar.zst infinity-for-reddit-5b5bc1c5b83ceaffb0d20aae1f4d3f51ebfb4623.zip |
RPAN and trending available to anonymous mode.
Diffstat (limited to '')
3 files changed, 27 insertions, 5 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java index ca1a5887..7f0282f3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/TrendingActivity.java @@ -81,6 +81,9 @@ public class TrendingActivity extends BaseActivity { @BindView(R.id.fetch_trending_search_text_view_trending_activity) TextView errorTextView; @Inject + @Named("no_oauth") + Retrofit mRetrofit; + @Inject @Named("oauth") Retrofit mOauthRetrofit; @Inject @@ -178,6 +181,8 @@ public class TrendingActivity extends BaseActivity { swipeRefreshLayout.setEnabled(mSharedPreferences.getBoolean(SharedPreferencesUtils.PULL_TO_REFRESH, true)); swipeRefreshLayout.setOnRefreshListener(this::fetchTrendingSearches); + errorLinearLayout.setOnClickListener(view -> fetchTrendingSearches()); + if (savedInstanceState != null) { trendingSearches = savedInstanceState.getParcelableArrayList(TRENDING_SEARCHES_STATE); } @@ -200,7 +205,13 @@ public class TrendingActivity extends BaseActivity { trendingSearches = null; adapter.setTrendingSearches(null); Handler handler = new Handler(); - mOauthRetrofit.create(RedditAPI.class).getTrendingSearches(APIUtils.getOAuthHeader(mAccessToken)).enqueue(new Callback<String>() { + Call<String> trendingCall; + if (mAccessToken == null) { + trendingCall = mRetrofit.create(RedditAPI.class).getTrendingSearches(); + } else { + trendingCall = mOauthRetrofit.create(RedditAPI.class).getTrendingSearchesOauth(APIUtils.getOAuthHeader(mAccessToken)); + } + trendingCall.enqueue(new Callback<>() { @Override public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) { if (response.isSuccessful()) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java index bf9dea5b..3fa436b4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/NavigationDrawerRecyclerViewAdapter.java @@ -555,6 +555,14 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re drawableId = R.drawable.ic_subscritptions_bottom_app_bar_24dp; break; case 2: + stringId = R.string.rpan; + drawableId = R.drawable.ic_rpan_24dp; + break; + case 3: + stringId = R.string.trending; + drawableId = R.drawable.ic_trending_24dp; + break; + case 4: if ((resources.getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { stringId = R.string.dark_theme; drawableId = R.drawable.ic_dark_theme_24dp; @@ -563,7 +571,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re drawableId = R.drawable.ic_light_theme_24dp; } break; - case 3: + case 5: setOnClickListener = false; if (isNSFWEnabled) { stringId = R.string.disable_nsfw; @@ -587,7 +595,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re } }); break; - case 4: + case 6: stringId = R.string.settings; drawableId = R.drawable.ic_settings_24dp; } @@ -761,7 +769,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re - (collapsePostSection ? POST_SECTION_ITEMS : 0) - (collapsePreferencesSection ? PREFERENCES_SECTION_ITEMS : 0); } else { - return 5; + return 7; } } else { if (isLoggedIn) { 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 a7c67893..dd9efb33 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/apis/RedditAPI.java @@ -292,7 +292,10 @@ public interface RedditAPI { Call<String> submitGalleryPost(@HeaderMap Map<String, String> headers, @Body String body); @GET("/api/trending_searches_v1.json?withAds=0&raw_json=1&gilding_detail=1") - Call<String> getTrendingSearches(@HeaderMap Map<String, String> headers); + Call<String> getTrendingSearches(); + + @GET("/api/trending_searches_v1.json?withAds=0&raw_json=1&gilding_detail=1") + Call<String> getTrendingSearchesOauth(@HeaderMap Map<String, String> headers); default Call<String> getWiki(@Path("subredditName") String subredditName) { return getWikiPage(subredditName, "index"); |