aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator/infinityforreddit
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-04-15 14:35:24 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-04-15 14:35:24 +0000
commit784d57933ddcc0db075092e4ae9f5da455a66230 (patch)
treec4585a06a839a128347e34d6fb21410f427da472 /app/src/main/java/ml/docilealligator/infinityforreddit
parent90fa50f5d1f89b544cc519c439ad3dca5bddb879 (diff)
downloadinfinity-for-reddit-784d57933ddcc0db075092e4ae9f5da455a66230.tar
infinity-for-reddit-784d57933ddcc0db075092e4ae9f5da455a66230.tar.gz
infinity-for-reddit-784d57933ddcc0db075092e4ae9f5da455a66230.tar.bz2
infinity-for-reddit-784d57933ddcc0db075092e4ae9f5da455a66230.tar.lz
infinity-for-reddit-784d57933ddcc0db075092e4ae9f5da455a66230.tar.xz
infinity-for-reddit-784d57933ddcc0db075092e4ae9f5da455a66230.tar.zst
infinity-for-reddit-784d57933ddcc0db075092e4ae9f5da455a66230.zip
Add fast scroller for MultiRedditListingActivity and FollowedUsersListingFragment.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FollowedUsersRecyclerViewAdapter.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MultiRedditListingRecyclerViewAdapter.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FollowedUsersListingFragment.java2
4 files changed, 38 insertions, 2 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java
index b1d2890d..2ef1d14f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java
@@ -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))
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FollowedUsersRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FollowedUsersRecyclerViewAdapter.java
index dd5c8be1..a60cf1e1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FollowedUsersRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FollowedUsersRecyclerViewAdapter.java
@@ -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;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MultiRedditListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MultiRedditListingRecyclerViewAdapter.java
index 8d99220e..7ededb6d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MultiRedditListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MultiRedditListingRecyclerViewAdapter.java
@@ -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;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FollowedUsersListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FollowedUsersListingFragment.java
index acee318a..f34dee6c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FollowedUsersListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FollowedUsersListingFragment.java
@@ -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)))