mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-28 11:58:23 +01:00
RPAN and trending available to anonymous mode.
This commit is contained in:
parent
f5f6213733
commit
5b5bc1c5b8
@ -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()) {
|
||||
|
@ -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) {
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user