mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 11:17:25 +01:00
Add fast scroller for MultiRedditListingActivity and FollowedUsersListingFragment.
This commit is contained in:
parent
90fa50f5d1
commit
784d57933d
@ -36,6 +36,7 @@ import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder;
|
||||
import ml.docilealligator.infinityforreddit.Adapter.MultiRedditListingRecyclerViewAdapter;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
|
||||
import ml.docilealligator.infinityforreddit.AsyncTask.InsertMultiRedditAsyncTask;
|
||||
@ -179,6 +180,7 @@ public class MultiRedditListingActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
});
|
||||
new FastScrollerBuilder(mRecyclerView).build();
|
||||
|
||||
mMultiRedditViewModel = new ViewModelProvider(this,
|
||||
new MultiRedditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, mAccountName))
|
||||
|
@ -21,6 +21,7 @@ import java.util.List;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import me.zhanghai.android.fastscroll.PopupTextProvider;
|
||||
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
|
||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.FavoriteThing;
|
||||
@ -30,7 +31,7 @@ import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUse
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements PopupTextProvider {
|
||||
private static final int VIEW_TYPE_FAVORITE_USER_DIVIDER = 0;
|
||||
private static final int VIEW_TYPE_FAVORITE_USER = 1;
|
||||
private static final int VIEW_TYPE_USER_DIVIDER = 2;
|
||||
@ -289,6 +290,21 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getPopupText(int position) {
|
||||
switch (getItemViewType(position)) {
|
||||
case VIEW_TYPE_USER_DIVIDER:
|
||||
int offset = (mFavoriteSubscribedUserData != null && mFavoriteSubscribedUserData.size() > 0) ?
|
||||
mFavoriteSubscribedUserData.size() + 2 : 0;
|
||||
return mSubscribedUserData.get(position - offset).getName().substring(0, 1).toUpperCase();
|
||||
case VIEW_TYPE_FAVORITE_USER:
|
||||
return mFavoriteSubscribedUserData.get(position - 1).getName().substring(0, 1).toUpperCase();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
class FavoriteUserViewHolder extends RecyclerView.ViewHolder {
|
||||
@BindView(R.id.thing_icon_gif_image_view_item_subscribed_thing)
|
||||
GifImageView iconGifImageView;
|
||||
|
@ -22,6 +22,7 @@ import java.util.List;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import me.zhanghai.android.fastscroll.PopupTextProvider;
|
||||
import ml.docilealligator.infinityforreddit.Activity.ViewMultiRedditDetailActivity;
|
||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||
import ml.docilealligator.infinityforreddit.Fragment.MultiRedditOptionsBottomSheetFragment;
|
||||
@ -32,7 +33,7 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements PopupTextProvider {
|
||||
|
||||
private static final int VIEW_TYPE_FAVORITE_MULTI_REDDIT_DIVIDER = 0;
|
||||
private static final int VIEW_TYPE_FAVORITE_MULTI_REDDIT = 1;
|
||||
@ -328,6 +329,21 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getPopupText(int position) {
|
||||
switch (getItemViewType(position)) {
|
||||
case VIEW_TYPE_MULTI_REDDIT:
|
||||
int offset = (mFavoriteMultiReddits != null && mFavoriteMultiReddits.size() > 0) ?
|
||||
mFavoriteMultiReddits.size() + 2 : 0;
|
||||
return mMultiReddits.get(position - offset).getDisplayName().substring(0, 1).toUpperCase();
|
||||
case VIEW_TYPE_FAVORITE_MULTI_REDDIT:
|
||||
return mFavoriteMultiReddits.get(position - 1).getDisplayName().substring(0, 1).toUpperCase();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
class MultiRedditViewHolder extends RecyclerView.ViewHolder {
|
||||
@BindView(R.id.multi_reddit_icon_gif_image_view_item_multi_reddit)
|
||||
GifImageView iconImageView;
|
||||
|
@ -29,6 +29,7 @@ import javax.inject.Named;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder;
|
||||
import ml.docilealligator.infinityforreddit.Activity.BaseActivity;
|
||||
import ml.docilealligator.infinityforreddit.Activity.SubscribedThingListingActivity;
|
||||
import ml.docilealligator.infinityforreddit.Adapter.FollowedUsersRecyclerViewAdapter;
|
||||
@ -108,6 +109,7 @@ public class FollowedUsersListingFragment extends Fragment implements FragmentCo
|
||||
mOauthRetrofit, mRedditDataRoomDatabase, customThemeWrapper,
|
||||
getArguments().getString(EXTRA_ACCESS_TOKEN));
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
new FastScrollerBuilder(mRecyclerView).build();
|
||||
|
||||
mSubscribedUserViewModel = new ViewModelProvider(this,
|
||||
new SubscribedUserViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, getArguments().getString(EXTRA_ACCOUNT_NAME)))
|
||||
|
Loading…
Reference in New Issue
Block a user