mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 12:47:26 +01:00
Anonymous subscriptions page is available.
This commit is contained in:
parent
b54e9aabb1
commit
dd98dd879d
@ -32,6 +32,10 @@
|
||||
android:theme="@style/AppTheme"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:replace="android:label">
|
||||
<activity android:name=".activities.AnonymousSubscriptionsActivity"
|
||||
android:label="@string/subscriptions"
|
||||
android:parentActivityName=".activities.MainActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name=".activities.WebViewActivity"
|
||||
android:label=""
|
||||
@ -408,7 +412,6 @@
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
|
||||
<provider
|
||||
android:name="androidx.startup.InitializationProvider"
|
||||
android:authorities="${applicationId}.androidx-startup"
|
||||
|
@ -5,6 +5,7 @@ import javax.inject.Singleton;
|
||||
import dagger.Component;
|
||||
import ml.docilealligator.infinityforreddit.activities.AccountPostsActivity;
|
||||
import ml.docilealligator.infinityforreddit.activities.AccountSavedThingActivity;
|
||||
import ml.docilealligator.infinityforreddit.activities.AnonymousSubscriptionsActivity;
|
||||
import ml.docilealligator.infinityforreddit.activities.CommentActivity;
|
||||
import ml.docilealligator.infinityforreddit.activities.CreateMultiRedditActivity;
|
||||
import ml.docilealligator.infinityforreddit.activities.CustomThemeListingActivity;
|
||||
@ -260,4 +261,6 @@ public interface AppComponent {
|
||||
void inject(WebViewActivity webViewActivity);
|
||||
|
||||
void inject(CrashReportsFragment crashReportsFragment);
|
||||
|
||||
void inject(AnonymousSubscriptionsActivity anonymousSubscriptionsActivity);
|
||||
}
|
||||
|
@ -23,50 +23,60 @@ public class FavoriteThing {
|
||||
RedditDataRoomDatabase redditDataRoomDatabase,
|
||||
String accessToken, SubscribedSubredditData subscribedSubredditData,
|
||||
FavoriteThingListener favoriteThingListener) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put(APIUtils.SR_NAME_KEY, subscribedSubredditData.getName());
|
||||
params.put(APIUtils.MAKE_FAVORITE_KEY, "true");
|
||||
oauthRetrofit.create(RedditAPI.class).favoriteThing(APIUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
InsertSubscribedThings.insertSubscribedThings(executor, handler, redditDataRoomDatabase, subscribedSubredditData,
|
||||
favoriteThingListener::success);
|
||||
} else {
|
||||
if (accessToken == null) {
|
||||
InsertSubscribedThings.insertSubscribedThings(executor, handler, redditDataRoomDatabase, subscribedSubredditData,
|
||||
favoriteThingListener::success);
|
||||
} else {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put(APIUtils.SR_NAME_KEY, subscribedSubredditData.getName());
|
||||
params.put(APIUtils.MAKE_FAVORITE_KEY, "true");
|
||||
oauthRetrofit.create(RedditAPI.class).favoriteThing(APIUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
InsertSubscribedThings.insertSubscribedThings(executor, handler, redditDataRoomDatabase, subscribedSubredditData,
|
||||
favoriteThingListener::success);
|
||||
} else {
|
||||
favoriteThingListener.failed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
favoriteThingListener.failed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
favoriteThingListener.failed();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void unfavoriteSubreddit(Executor executor, Handler handler, Retrofit oauthRetrofit,
|
||||
RedditDataRoomDatabase redditDataRoomDatabase,
|
||||
String accessToken, SubscribedSubredditData subscribedSubredditData,
|
||||
FavoriteThingListener favoriteThingListener) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put(APIUtils.SR_NAME_KEY, subscribedSubredditData.getName());
|
||||
params.put(APIUtils.MAKE_FAVORITE_KEY, "false");
|
||||
oauthRetrofit.create(RedditAPI.class).favoriteThing(APIUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
InsertSubscribedThings.insertSubscribedThings(executor, handler, redditDataRoomDatabase,
|
||||
subscribedSubredditData, favoriteThingListener::success);
|
||||
} else {
|
||||
if (accessToken == null) {
|
||||
InsertSubscribedThings.insertSubscribedThings(executor, handler, redditDataRoomDatabase,
|
||||
subscribedSubredditData, favoriteThingListener::success);
|
||||
} else {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put(APIUtils.SR_NAME_KEY, subscribedSubredditData.getName());
|
||||
params.put(APIUtils.MAKE_FAVORITE_KEY, "false");
|
||||
oauthRetrofit.create(RedditAPI.class).favoriteThing(APIUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
InsertSubscribedThings.insertSubscribedThings(executor, handler, redditDataRoomDatabase,
|
||||
subscribedSubredditData, favoriteThingListener::success);
|
||||
} else {
|
||||
favoriteThingListener.failed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
favoriteThingListener.failed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
favoriteThingListener.failed();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void favoriteUser(Executor executor, Handler handler, Retrofit oauthRetrofit,
|
||||
|
@ -0,0 +1,102 @@
|
||||
package ml.docilealligator.infinityforreddit.activities;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.r0adkll.slidr.Slidr;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.fragments.SubscribedSubredditsListingFragment;
|
||||
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
|
||||
|
||||
public class AnonymousSubscriptionsActivity extends BaseActivity {
|
||||
|
||||
@BindView(R.id.coordinator_layout_anonymous_subscriptions_activity)
|
||||
CoordinatorLayout coordinatorLayout;
|
||||
@BindView(R.id.appbar_layout_anonymous_subscriptions_activity)
|
||||
AppBarLayout appBarLayout;
|
||||
@BindView(R.id.toolbar_anonymous_subscriptions_activity)
|
||||
Toolbar toolbar;
|
||||
@Inject
|
||||
@Named("default")
|
||||
SharedPreferences mSharedPreferences;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||
|
||||
setImmersiveModeNotApplicable();
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_anonymous_subscriptions);
|
||||
|
||||
ButterKnife.bind(this);
|
||||
|
||||
applyCustomTheme();
|
||||
|
||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
||||
Slidr.attach(this);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
Window window = getWindow();
|
||||
|
||||
if (isChangeStatusBarIconColor()) {
|
||||
addOnOffsetChangedListener(appBarLayout);
|
||||
}
|
||||
|
||||
if (isImmersiveInterface()) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
coordinatorLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
|
||||
} else {
|
||||
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
|
||||
}
|
||||
adjustToolbar(toolbar);
|
||||
}
|
||||
}
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
SubscribedSubredditsListingFragment mFragment = new SubscribedSubredditsListingFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_NAME, "-");
|
||||
mFragment.setArguments(bundle);
|
||||
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_anonymous_subscriptions_activity, mFragment).commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SharedPreferences getDefaultSharedPreferences() {
|
||||
return mSharedPreferences;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CustomThemeWrapper getCustomThemeWrapper() {
|
||||
return mCustomThemeWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyCustomTheme() {
|
||||
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
|
||||
}
|
||||
}
|
@ -733,7 +733,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
intent = new Intent(MainActivity.this, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
|
||||
} else if (stringId == R.string.subscriptions) {
|
||||
intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
|
||||
if (mAccessToken != null) {
|
||||
intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
|
||||
} else {
|
||||
intent = new Intent(MainActivity.this, AnonymousSubscriptionsActivity.class);
|
||||
}
|
||||
} else if (stringId == R.string.multi_reddit) {
|
||||
intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
|
||||
intent.putExtra(SubscribedThingListingActivity.EXTRA_SHOW_MULTIREDDITS, true);
|
||||
|
@ -483,6 +483,10 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
|
||||
} else {
|
||||
switch (position) {
|
||||
case 1:
|
||||
stringId = R.string.subscriptions;
|
||||
drawableId = R.drawable.ic_subscritptions_bottom_app_bar_24dp;
|
||||
break;
|
||||
case 2:
|
||||
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;
|
||||
@ -491,7 +495,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
|
||||
drawableId = R.drawable.ic_light_theme_24dp;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
setOnClickListener = false;
|
||||
if (isNSFWEnabled) {
|
||||
stringId = R.string.disable_nsfw;
|
||||
@ -515,7 +519,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
stringId = R.string.settings;
|
||||
drawableId = R.drawable.ic_settings_24dp;
|
||||
}
|
||||
@ -681,7 +685,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
|
||||
- (collapsePostSection ? POST_SECTION_ITEMS : 0)
|
||||
- (collapsePreferencesSection ? PREFERENCES_SECTION_ITEMS : 0);
|
||||
} else {
|
||||
return 4;
|
||||
return 5;
|
||||
}
|
||||
} else {
|
||||
if (isLoggedIn) {
|
||||
@ -742,7 +746,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
|
||||
if (isLoggedIn) {
|
||||
notifyItemChanged(CURRENT_MENU_ITEMS - 3);
|
||||
} else {
|
||||
notifyItemChanged(2);
|
||||
notifyItemChanged(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -150,17 +150,17 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
||||
String name;
|
||||
String iconUrl;
|
||||
|
||||
if (hasClearSelectionRow && viewHolder.getAdapterPosition() == 0) {
|
||||
if (hasClearSelectionRow && viewHolder.getBindingAdapterPosition() == 0) {
|
||||
((SubredditViewHolder) viewHolder).subredditNameTextView.setText(R.string.all_subreddits);
|
||||
((SubredditViewHolder) viewHolder).favoriteImageView.setVisibility(View.GONE);
|
||||
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(null, null, false));
|
||||
return;
|
||||
} else if (itemClickListener != null && !hasClearSelectionRow && viewHolder.getAdapterPosition() == 0) {
|
||||
} else if (itemClickListener != null && !hasClearSelectionRow && viewHolder.getBindingAdapterPosition() == 0) {
|
||||
((SubredditViewHolder) viewHolder).favoriteImageView.setVisibility(View.GONE);
|
||||
name = username;
|
||||
iconUrl = userIconUrl;
|
||||
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(name, iconUrl, true));
|
||||
} else if (hasClearSelectionRow && viewHolder.getAdapterPosition() == 1) {
|
||||
} else if (hasClearSelectionRow && viewHolder.getBindingAdapterPosition() == 1) {
|
||||
((SubredditViewHolder) viewHolder).favoriteImageView.setVisibility(View.GONE);
|
||||
name = username;
|
||||
iconUrl = userIconUrl;
|
||||
@ -182,24 +182,24 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
||||
mFavoriteSubscribedSubredditData.size() + 2 : 0;
|
||||
}
|
||||
|
||||
name = mSubscribedSubredditData.get(viewHolder.getAdapterPosition() - offset).getName();
|
||||
iconUrl = mSubscribedSubredditData.get(viewHolder.getAdapterPosition() - offset).getIconUrl();
|
||||
if(mSubscribedSubredditData.get(viewHolder.getAdapterPosition() - offset).isFavorite()) {
|
||||
name = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getName();
|
||||
iconUrl = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl();
|
||||
if(mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).isFavorite()) {
|
||||
((SubredditViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
||||
} else {
|
||||
((SubredditViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
||||
}
|
||||
|
||||
((SubredditViewHolder) viewHolder).favoriteImageView.setOnClickListener(view -> {
|
||||
if(mSubscribedSubredditData.get(viewHolder.getAdapterPosition() - offset).isFavorite()) {
|
||||
if(mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).isFavorite()) {
|
||||
((SubredditViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
||||
mSubscribedSubredditData.get(viewHolder.getAdapterPosition() - offset).setFavorite(false);
|
||||
mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).setFavorite(false);
|
||||
FavoriteThing.unfavoriteSubreddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase, accessToken,
|
||||
mSubscribedSubredditData.get(viewHolder.getAdapterPosition() - offset),
|
||||
mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset),
|
||||
new FavoriteThing.FavoriteThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
int position = viewHolder.getAdapterPosition() - offset;
|
||||
int position = viewHolder.getBindingAdapterPosition() - offset;
|
||||
if(position >= 0 && mSubscribedSubredditData.size() > position) {
|
||||
mSubscribedSubredditData.get(position).setFavorite(false);
|
||||
}
|
||||
@ -209,7 +209,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
||||
@Override
|
||||
public void failed() {
|
||||
Toast.makeText(mContext, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show();
|
||||
int position = viewHolder.getAdapterPosition() - offset;
|
||||
int position = viewHolder.getBindingAdapterPosition() - offset;
|
||||
if(position >= 0 && mSubscribedSubredditData.size() > position) {
|
||||
mSubscribedSubredditData.get(position).setFavorite(true);
|
||||
}
|
||||
@ -218,14 +218,14 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
||||
});
|
||||
} else {
|
||||
((SubredditViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
||||
mSubscribedSubredditData.get(viewHolder.getAdapterPosition() - offset).setFavorite(true);
|
||||
mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).setFavorite(true);
|
||||
FavoriteThing.favoriteSubreddit(mExecutor, new Handler(), mOauthRetrofit,
|
||||
mRedditDataRoomDatabase, accessToken,
|
||||
mSubscribedSubredditData.get(viewHolder.getAdapterPosition() - offset),
|
||||
mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset),
|
||||
new FavoriteThing.FavoriteThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
int position = viewHolder.getAdapterPosition() - offset;
|
||||
int position = viewHolder.getBindingAdapterPosition() - offset;
|
||||
if(position >= 0 && mSubscribedSubredditData.size() > position) {
|
||||
mSubscribedSubredditData.get(position).setFavorite(true);
|
||||
}
|
||||
@ -235,7 +235,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
||||
@Override
|
||||
public void failed() {
|
||||
Toast.makeText(mContext, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show();
|
||||
int position = viewHolder.getAdapterPosition() - offset;
|
||||
int position = viewHolder.getBindingAdapterPosition() - offset;
|
||||
if(position >= 0 && mSubscribedSubredditData.size() > position) {
|
||||
mSubscribedSubredditData.get(position).setFavorite(false);
|
||||
}
|
||||
@ -281,24 +281,24 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
||||
} else {
|
||||
offset = 1;
|
||||
}
|
||||
String name = mFavoriteSubscribedSubredditData.get(viewHolder.getAdapterPosition() - offset).getName();
|
||||
String iconUrl = mFavoriteSubscribedSubredditData.get(viewHolder.getAdapterPosition() - offset).getIconUrl();
|
||||
if(mFavoriteSubscribedSubredditData.get(viewHolder.getAdapterPosition() - offset).isFavorite()) {
|
||||
String name = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getName();
|
||||
String iconUrl = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl();
|
||||
if(mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).isFavorite()) {
|
||||
((FavoriteSubredditViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
||||
} else {
|
||||
((FavoriteSubredditViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
||||
}
|
||||
|
||||
((FavoriteSubredditViewHolder) viewHolder).favoriteImageView.setOnClickListener(view -> {
|
||||
if(mFavoriteSubscribedSubredditData.get(viewHolder.getAdapterPosition() - offset).isFavorite()) {
|
||||
if(mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).isFavorite()) {
|
||||
((FavoriteSubredditViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
||||
mFavoriteSubscribedSubredditData.get(viewHolder.getAdapterPosition() - offset).setFavorite(false);
|
||||
mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).setFavorite(false);
|
||||
FavoriteThing.unfavoriteSubreddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase, accessToken,
|
||||
mFavoriteSubscribedSubredditData.get(viewHolder.getAdapterPosition() - offset),
|
||||
mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset),
|
||||
new FavoriteThing.FavoriteThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
int position = viewHolder.getAdapterPosition() - 1;
|
||||
int position = viewHolder.getBindingAdapterPosition() - 1;
|
||||
if(position >= 0 && mFavoriteSubscribedSubredditData.size() > position) {
|
||||
mFavoriteSubscribedSubredditData.get(position).setFavorite(false);
|
||||
}
|
||||
@ -308,7 +308,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
||||
@Override
|
||||
public void failed() {
|
||||
Toast.makeText(mContext, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show();
|
||||
int position = viewHolder.getAdapterPosition() - 1;
|
||||
int position = viewHolder.getBindingAdapterPosition() - 1;
|
||||
if(position >= 0 && mFavoriteSubscribedSubredditData.size() > position) {
|
||||
mFavoriteSubscribedSubredditData.get(position).setFavorite(true);
|
||||
}
|
||||
@ -317,13 +317,13 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
||||
});
|
||||
} else {
|
||||
((FavoriteSubredditViewHolder) viewHolder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
||||
mFavoriteSubscribedSubredditData.get(viewHolder.getAdapterPosition() - offset).setFavorite(true);
|
||||
mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).setFavorite(true);
|
||||
FavoriteThing.favoriteSubreddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase, accessToken,
|
||||
mFavoriteSubscribedSubredditData.get(viewHolder.getAdapterPosition() - offset),
|
||||
mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset),
|
||||
new FavoriteThing.FavoriteThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
int position = viewHolder.getAdapterPosition() - 1;
|
||||
int position = viewHolder.getBindingAdapterPosition() - 1;
|
||||
if(position >= 0 && mFavoriteSubscribedSubredditData.size() > position) {
|
||||
mFavoriteSubscribedSubredditData.get(position).setFavorite(true);
|
||||
}
|
||||
@ -333,7 +333,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
||||
@Override
|
||||
public void failed() {
|
||||
Toast.makeText(mContext, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show();
|
||||
int position = viewHolder.getAdapterPosition() - 1;
|
||||
int position = viewHolder.getBindingAdapterPosition() - 1;
|
||||
if(position >= 0 && mFavoriteSubscribedSubredditData.size() > position) {
|
||||
mFavoriteSubscribedSubredditData.get(position).setFavorite(false);
|
||||
}
|
||||
|
@ -146,7 +146,9 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
|
||||
mGlide.clear(mImageView);
|
||||
}
|
||||
|
||||
adapter.addUser(accountName, getArguments().getString(EXTRA_ACCOUNT_PROFILE_IMAGE_URL));
|
||||
if (accessToken != null) {
|
||||
adapter.addUser(accountName, getArguments().getString(EXTRA_ACCOUNT_PROFILE_IMAGE_URL));
|
||||
}
|
||||
adapter.setSubscribedSubreddits(subscribedSubredditData);
|
||||
});
|
||||
|
||||
|
41
app/src/main/res/layout/activity_anonymous_subscriptions.xml
Normal file
41
app/src/main/res/layout/activity_anonymous_subscriptions.xml
Normal file
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/coordinator_layout_anonymous_subscriptions_activity"
|
||||
tools:context=".activities.AnonymousSubscriptionsActivity">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appbar_layout_anonymous_subscriptions_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_scrollFlags="scroll|enterAlways"
|
||||
app:titleEnabled="false"
|
||||
app:toolbarId="@+id/toolbar_subreddit_selection_activity">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar_anonymous_subscriptions_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||
app:navigationIcon="?attr/homeAsUpIndicator" />
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/frame_layout_anonymous_subscriptions_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
Loading…
Reference in New Issue
Block a user