mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 21:07:11 +01:00
Favorite anonymous multireddits.
This commit is contained in:
parent
9a0067d714
commit
39835c587a
@ -25,6 +25,7 @@ import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
|||||||
import me.zhanghai.android.fastscroll.PopupTextProvider;
|
import me.zhanghai.android.fastscroll.PopupTextProvider;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
|
import ml.docilealligator.infinityforreddit.asynctasks.InsertMultireddit;
|
||||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.multireddit.FavoriteMultiReddit;
|
import ml.docilealligator.infinityforreddit.multireddit.FavoriteMultiReddit;
|
||||||
import ml.docilealligator.infinityforreddit.multireddit.MultiReddit;
|
import ml.docilealligator.infinityforreddit.multireddit.MultiReddit;
|
||||||
@ -129,6 +130,12 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
|
|||||||
if(multiReddit.isFavorite()) {
|
if(multiReddit.isFavorite()) {
|
||||||
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
||||||
multiReddit.setFavorite(false);
|
multiReddit.setFavorite(false);
|
||||||
|
if (mAccessToken == null) {
|
||||||
|
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
|
||||||
|
() -> {
|
||||||
|
//Do nothing
|
||||||
|
});
|
||||||
|
} else {
|
||||||
FavoriteMultiReddit.favoriteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
|
FavoriteMultiReddit.favoriteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
|
||||||
mAccessToken, false, multiReddit,
|
mAccessToken, false, multiReddit,
|
||||||
new FavoriteMultiReddit.FavoriteMultiRedditListener() {
|
new FavoriteMultiReddit.FavoriteMultiRedditListener() {
|
||||||
@ -152,9 +159,16 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
||||||
multiReddit.setFavorite(true);
|
multiReddit.setFavorite(true);
|
||||||
|
if (mAccessToken == null) {
|
||||||
|
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
|
||||||
|
() -> {
|
||||||
|
//Do nothing
|
||||||
|
});
|
||||||
|
} else {
|
||||||
FavoriteMultiReddit.favoriteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
|
FavoriteMultiReddit.favoriteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
|
||||||
mAccessToken, true, multiReddit,
|
mAccessToken, true, multiReddit,
|
||||||
new FavoriteMultiReddit.FavoriteMultiRedditListener() {
|
new FavoriteMultiReddit.FavoriteMultiRedditListener() {
|
||||||
@ -179,6 +193,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
holder.itemView.setOnClickListener(view -> {
|
holder.itemView.setOnClickListener(view -> {
|
||||||
mOnItemClickListener.onClick(multiReddit);
|
mOnItemClickListener.onClick(multiReddit);
|
||||||
@ -215,6 +230,12 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
|
|||||||
if(multiReddit.isFavorite()) {
|
if(multiReddit.isFavorite()) {
|
||||||
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
||||||
multiReddit.setFavorite(false);
|
multiReddit.setFavorite(false);
|
||||||
|
if (mAccessToken == null) {
|
||||||
|
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
|
||||||
|
() -> {
|
||||||
|
//Do nothing
|
||||||
|
});
|
||||||
|
} else {
|
||||||
FavoriteMultiReddit.favoriteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
|
FavoriteMultiReddit.favoriteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
|
||||||
mAccessToken, false, multiReddit,
|
mAccessToken, false, multiReddit,
|
||||||
new FavoriteMultiReddit.FavoriteMultiRedditListener() {
|
new FavoriteMultiReddit.FavoriteMultiRedditListener() {
|
||||||
@ -238,9 +259,16 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
||||||
multiReddit.setFavorite(true);
|
multiReddit.setFavorite(true);
|
||||||
|
if (mAccessToken == null) {
|
||||||
|
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
|
||||||
|
() -> {
|
||||||
|
//Do nothing
|
||||||
|
});
|
||||||
|
} else {
|
||||||
FavoriteMultiReddit.favoriteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
|
FavoriteMultiReddit.favoriteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
|
||||||
mAccessToken, true, multiReddit,
|
mAccessToken, true, multiReddit,
|
||||||
new FavoriteMultiReddit.FavoriteMultiRedditListener() {
|
new FavoriteMultiReddit.FavoriteMultiRedditListener() {
|
||||||
@ -265,6 +293,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
holder.itemView.setOnClickListener(view -> {
|
holder.itemView.setOnClickListener(view -> {
|
||||||
mOnItemClickListener.onClick(multiReddit);
|
mOnItemClickListener.onClick(multiReddit);
|
||||||
|
@ -50,4 +50,12 @@ public class FavoriteMultiReddit {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void anonymousFavoriteMultiReddit(Executor executor, Handler handler,
|
||||||
|
RedditDataRoomDatabase redditDataRoomDatabase,
|
||||||
|
MultiReddit multiReddit,
|
||||||
|
FavoriteMultiRedditListener favoriteMultiRedditListener) {
|
||||||
|
InsertMultireddit.insertMultireddit(executor, handler, redditDataRoomDatabase, multiReddit,
|
||||||
|
favoriteMultiRedditListener::success);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user