diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-03-31 14:25:08 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-03-31 14:25:08 +0000 |
commit | 2e59daa9cd607670e19f245d6c2c363df6f35d27 (patch) | |
tree | 20eefd70f6993aaff855a3fc4221716768feedde /app/src/main/java/ml | |
parent | 07bca6d6356ef51ce38a9190bf7be9d51bdd89f7 (diff) | |
download | infinity-for-reddit-2e59daa9cd607670e19f245d6c2c363df6f35d27.tar infinity-for-reddit-2e59daa9cd607670e19f245d6c2c363df6f35d27.tar.gz infinity-for-reddit-2e59daa9cd607670e19f245d6c2c363df6f35d27.tar.bz2 infinity-for-reddit-2e59daa9cd607670e19f245d6c2c363df6f35d27.tar.lz infinity-for-reddit-2e59daa9cd607670e19f245d6c2c363df6f35d27.tar.xz infinity-for-reddit-2e59daa9cd607670e19f245d6c2c363df6f35d27.tar.zst infinity-for-reddit-2e59daa9cd607670e19f245d6c2c363df6f35d27.zip |
Fix issues of searching in a specific subreddit. Minor bugs fixed.
Diffstat (limited to 'app/src/main/java/ml')
5 files changed, 32 insertions, 10 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java index 0a768805..0c1989c3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java @@ -1004,7 +1004,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb } else { switch (position) { case 0: - return "Best"; + return "Home"; case 1: return "Popular"; case 2: diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java index 4cd8035d..b34ce856 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java @@ -615,6 +615,12 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp @Override public void onPageSelected(int position) { + if (mAccessToken != null) { + if (showBottomAppBar) { + bottomNavigationView.performShow(); + } + fab.show(); + } if (isInLazyMode) { if (viewPager.getCurrentItem() == 0) { sectionsPagerAdapter.resumeLazyMode(); @@ -782,7 +788,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp sectionsPagerAdapter.changePostLayout(postLayout); } - public void postScrollUp() { + public void contentScrollUp() { if (mAccessToken != null) { if (showBottomAppBar && !lockBottomAppBar) { bottomNavigationView.performShow(); @@ -793,7 +799,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp } } - public void postScrollDown() { + public void contentScrollDown() { if (mAccessToken != null) { if (!(showBottomAppBar && lockBottomAppBar)) { fab.hide(); @@ -829,7 +835,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp public Fragment getItem(int position) { if (position == 0) { PostFragment fragment = new PostFragment(); - fragment = new PostFragment(); Bundle bundle = new Bundle(); bundle.putString(PostFragment.EXTRA_NAME, subredditName); bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubscribedSubredditsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubscribedSubredditsRecyclerViewAdapter.java index a9500914..18662781 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubscribedSubredditsRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubscribedSubredditsRecyclerViewAdapter.java @@ -158,6 +158,9 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte ((SubredditViewHolder) viewHolder).favoriteImageView.setVisibility(View.GONE); name = username; iconUrl = userIconUrl; + if (itemClickListener != null) { + viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(name, iconUrl, true)); + } } else { int offset; if (itemClickListener != null) { @@ -234,11 +237,13 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte }); } }); + + if (itemClickListener != null) { + viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(name, iconUrl, false)); + } } - if (itemClickListener != null) { - viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(name, iconUrl, true)); - } else { + if (itemClickListener == null) { viewHolder.itemView.setOnClickListener(view -> { Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class); intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, name); @@ -332,7 +337,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte }); if (itemClickListener != null) { - viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(name, iconUrl, true)); + viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(name, iconUrl, false)); } else { viewHolder.itemView.setOnClickListener(view -> { Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java index 4b464944..07ef965a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java @@ -309,9 +309,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator { @Override public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { if (dy > 0) { - ((ViewSubredditDetailActivity) activity).postScrollDown(); + ((ViewSubredditDetailActivity) activity).contentScrollDown(); } else if (dy < 0) { - ((ViewSubredditDetailActivity) activity).postScrollUp(); + ((ViewSubredditDetailActivity) activity).contentScrollUp(); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SidebarFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SidebarFragment.java index 3e2aea9c..cb87a956 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SidebarFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SidebarFragment.java @@ -39,6 +39,7 @@ import io.noties.markwon.recycler.table.TableEntryPlugin; import io.noties.markwon.simple.ext.SimpleExtPlugin; import io.noties.markwon.urlprocessor.UrlProcessorRelativeToAbsolute; import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity; +import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity; import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubredditDataAsyncTask; import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.FetchSubredditData; @@ -134,6 +135,17 @@ public class SidebarFragment extends Fragment { recyclerView.setLayoutManager(new LinearLayoutManager(activity)); recyclerView.setAdapter(markwonAdapter); + recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { + @Override + public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { + if (dy > 0) { + ((ViewSubredditDetailActivity) activity).contentScrollDown(); + } else if (dy < 0) { + ((ViewSubredditDetailActivity) activity).contentScrollUp(); + } + + } + }); mSubredditViewModel = new ViewModelProvider(this, new SubredditViewModel.Factory(activity.getApplication(), mRedditDataRoomDatabase, subredditName)) |