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() { + Call 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 call, @NonNull Response 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 submitGalleryPost(@HeaderMap Map headers, @Body String body); @GET("/api/trending_searches_v1.json?withAds=0&raw_json=1&gilding_detail=1") - Call getTrendingSearches(@HeaderMap Map headers); + Call getTrendingSearches(); + + @GET("/api/trending_searches_v1.json?withAds=0&raw_json=1&gilding_detail=1") + Call getTrendingSearchesOauth(@HeaderMap Map headers); default Call getWiki(@Path("subredditName") String subredditName) { return getWikiPage(subredditName, "index");