diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-08-04 06:49:33 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-08-04 06:49:33 +0000 |
commit | d0341f9be1ccf349181b89d2af0f3cbfb8d9c3fd (patch) | |
tree | 2398e9d8ee7875f60763c720f595905b3bcb55f0 /app/src/main | |
parent | eca3d91c8b1bee7979da168da89f537f0bd9d21f (diff) | |
download | infinity-for-reddit-d0341f9be1ccf349181b89d2af0f3cbfb8d9c3fd.tar infinity-for-reddit-d0341f9be1ccf349181b89d2af0f3cbfb8d9c3fd.tar.gz infinity-for-reddit-d0341f9be1ccf349181b89d2af0f3cbfb8d9c3fd.tar.bz2 infinity-for-reddit-d0341f9be1ccf349181b89d2af0f3cbfb8d9c3fd.tar.lz infinity-for-reddit-d0341f9be1ccf349181b89d2af0f3cbfb8d9c3fd.tar.xz infinity-for-reddit-d0341f9be1ccf349181b89d2af0f3cbfb8d9c3fd.tar.zst infinity-for-reddit-d0341f9be1ccf349181b89d2af0f3cbfb8d9c3fd.zip |
Set title to bottom app bar in other media fragments and activities.
Diffstat (limited to 'app/src/main')
6 files changed, 47 insertions, 16 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImgurMediaActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImgurMediaActivity.java index 86c47adb..57a8be8b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImgurMediaActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewImgurMediaActivity.java @@ -274,14 +274,16 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa } private void setupViewPager() { - setToolbarTitle(0); + if (!useBottomAppBar) { + setToolbarTitle(0); + viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { + @Override + public void onPageSelected(int position) { + setToolbarTitle(position); + } + }); + } sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); - viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { - @Override - public void onPageSelected(int position) { - setToolbarTitle(position); - } - }); viewPager.setAdapter(sectionsPagerAdapter); viewPager.setOffscreenPageLimit(3); } @@ -389,12 +391,16 @@ public class ViewImgurMediaActivity extends AppCompatActivity implements SetAsWa ViewImgurVideoFragment fragment = new ViewImgurVideoFragment(); Bundle bundle = new Bundle(); bundle.putParcelable(ViewImgurVideoFragment.EXTRA_IMGUR_VIDEO, imgurMedia); + bundle.putInt(ViewImgurVideoFragment.EXTRA_INDEX, position); + bundle.putInt(ViewImgurVideoFragment.EXTRA_MEDIA_COUNT, images.size()); fragment.setArguments(bundle); return fragment; } else { ViewImgurImageFragment fragment = new ViewImgurImageFragment(); Bundle bundle = new Bundle(); bundle.putParcelable(ViewImgurImageFragment.EXTRA_IMGUR_IMAGES, imgurMedia); + bundle.putInt(ViewImgurImageFragment.EXTRA_INDEX, position); + bundle.putInt(ViewImgurImageFragment.EXTRA_MEDIA_COUNT, images.size()); fragment.setArguments(bundle); return fragment; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java index 15737bbf..75e91d33 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewRedditGalleryActivity.java @@ -104,8 +104,6 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA getSupportActionBar().hide(); } - setTitle(" "); - gallery = getIntent().getParcelableArrayListExtra(EXTRA_REDDIT_GALLERY); if (gallery == null || gallery.isEmpty()) { finish(); @@ -131,14 +129,16 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA } private void setupViewPager() { - setToolbarTitle(0); + if (!useBottomAppBar) { + setToolbarTitle(0); + viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { + @Override + public void onPageSelected(int position) { + setToolbarTitle(position); + } + }); + } sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); - viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { - @Override - public void onPageSelected(int position) { - setToolbarTitle(position); - } - }); viewPager.setAdapter(sectionsPagerAdapter); viewPager.setOffscreenPageLimit(3); } @@ -243,6 +243,8 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA Bundle bundle = new Bundle(); bundle.putParcelable(ViewRedditGalleryVideoFragment.EXTRA_REDDIT_GALLERY_VIDEO, media); bundle.putString(ViewRedditGalleryVideoFragment.EXTRA_SUBREDDIT_NAME, subredditName); + bundle.putInt(ViewRedditGalleryVideoFragment.EXTRA_INDEX, position); + bundle.putInt(ViewRedditGalleryVideoFragment.EXTRA_MEDIA_COUNT, gallery.size()); fragment.setArguments(bundle); return fragment; } else { @@ -250,6 +252,8 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA Bundle bundle = new Bundle(); bundle.putParcelable(ViewRedditGalleryImageOrGifFragment.EXTRA_REDDIT_GALLERY_MEDIA, media); bundle.putString(ViewRedditGalleryImageOrGifFragment.EXTRA_SUBREDDIT_NAME, subredditName); + bundle.putInt(ViewRedditGalleryImageOrGifFragment.EXTRA_INDEX, position); + bundle.putInt(ViewRedditGalleryImageOrGifFragment.EXTRA_MEDIA_COUNT, gallery.size()); fragment.setArguments(bundle); return fragment; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurImageFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurImageFragment.java index e9fe350a..2b6e9ea9 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurImageFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurImageFragment.java @@ -60,6 +60,8 @@ import ml.docilealligator.infinityforreddit.services.DownloadMediaService; public class ViewImgurImageFragment extends Fragment { public static final String EXTRA_IMGUR_IMAGES = "EII"; + public static final String EXTRA_INDEX = "EI"; + public static final String EXTRA_MEDIA_COUNT = "EMC"; private static final int PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 0; @BindView(R.id.progress_bar_view_imgur_image_fragment) @@ -142,6 +144,8 @@ public class ViewImgurImageFragment extends Fragment { if (activity.isUseBottomAppBar()) { bottomAppBar.setVisibility(View.VISIBLE); + titleTextView.setText(getString(R.string.view_imgur_media_activity_image_label, + getArguments().getInt(EXTRA_INDEX) + 1, getArguments().getInt(EXTRA_MEDIA_COUNT))); downloadImageView.setOnClickListener(view -> { if (isDownloading) { return; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java index e2b7ba17..65b283e1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewImgurVideoFragment.java @@ -59,6 +59,8 @@ public class ViewImgurVideoFragment extends Fragment { public static final String EXTRA_IMGUR_VIDEO = "EIV"; private static final String IS_MUTE_STATE = "IMS"; private static final String POSITION_STATE = "PS"; + public static final String EXTRA_INDEX = "EI"; + public static final String EXTRA_MEDIA_COUNT = "EMC"; private static final int PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 0; @BindView(R.id.player_view_view_imgur_video_fragment) PlayerView videoPlayerView; @@ -147,6 +149,8 @@ public class ViewImgurVideoFragment extends Fragment { if (activity.isUseBottomAppBar()) { bottomAppBar.setVisibility(View.VISIBLE); + titleTextView.setText(getString(R.string.view_imgur_media_activity_video_label, + getArguments().getInt(EXTRA_INDEX) + 1, getArguments().getInt(EXTRA_MEDIA_COUNT))); downloadImageView.setOnClickListener(view -> { if (isDownloading) { return; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java index a0aa1476..cee6d404 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryImageOrGifFragment.java @@ -67,6 +67,8 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { public static final String EXTRA_REDDIT_GALLERY_MEDIA = "ERGM"; public static final String EXTRA_SUBREDDIT_NAME = "ESN"; + public static final String EXTRA_INDEX = "EI"; + public static final String EXTRA_MEDIA_COUNT = "EMC"; private static final int PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 0; @BindView(R.id.progress_bar_view_reddit_gallery_image_or_gif_fragment) @@ -231,6 +233,13 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment { if (activity.isUseBottomAppBar()) { bottomAppBar.setVisibility(View.VISIBLE); + if (media.mediaType == Post.Gallery.TYPE_GIF) { + titleTextView.setText(getString(R.string.view_reddit_gallery_activity_gif_label, + getArguments().getInt(EXTRA_INDEX) + 1, getArguments().getInt(EXTRA_MEDIA_COUNT))); + } else { + titleTextView.setText(getString(R.string.view_reddit_gallery_activity_image_label, + getArguments().getInt(EXTRA_INDEX) + 1, getArguments().getInt(EXTRA_MEDIA_COUNT))); + } downloadImageView.setOnClickListener(view -> { if (isDownloading) { return; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java index bceee6d1..de1e5566 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewRedditGalleryVideoFragment.java @@ -60,6 +60,8 @@ public class ViewRedditGalleryVideoFragment extends Fragment { public static final String EXTRA_SUBREDDIT_NAME = "ESN"; private static final String IS_MUTE_STATE = "IMS"; private static final String POSITION_STATE = "PS"; + public static final String EXTRA_INDEX = "EI"; + public static final String EXTRA_MEDIA_COUNT = "EMC"; private static final int PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 0; @BindView(R.id.player_view_view_reddit_gallery_video_fragment) PlayerView videoPlayerView; @@ -150,6 +152,8 @@ public class ViewRedditGalleryVideoFragment extends Fragment { if (activity.isUseBottomAppBar()) { bottomAppBar.setVisibility(View.VISIBLE); + titleTextView.setText(getString(R.string.view_reddit_gallery_activity_video_label, + getArguments().getInt(EXTRA_INDEX) + 1, getArguments().getInt(EXTRA_MEDIA_COUNT))); downloadImageView.setOnClickListener(view -> { if (isDownloading) { return; |