This commit is contained in:
tarsin committed 2023-01-15 13:17:13 +08:00
1 parent bc70824b57
commit b4b38e27f3
4 files changed
+24 -10

No files matched your search

@@ -393,7 +393,8 @@ class GalleryDetailScene : CollapsingToolbarScene(), View.OnClickListener, Downl
} else {
binding.content.comments.comments.visibility = View.GONE
}
binding.content.previews.previews.setOnClickListener(this)
binding.content.previews.previews.setOnClickListener { navigateToPreview() }
binding.content.previews.previewText.setOnClickListener { navigateToPreview(true) }
mViewTransition2 = ViewTransition(binding.content.belowHeader, binding.content.progress)
if (prepareData()) {
if (mGalleryDetail != null) {
@@ -776,6 +777,15 @@ class GalleryDetailScene : CollapsingToolbarScene(), View.OnClickListener, Downl
}
}
fun navigateToPreview(nextPage: Boolean = false) {
mGalleryDetail?.let {
val args = Bundle()
args.putParcelable(GalleryPreviewsScene.KEY_GALLERY_INFO, it)
args.putBoolean(GalleryPreviewsScene.KEY_NEXT_PAGE, nextPage)
navigate(R.id.galleryPreviewsScene, args)
}
}
override fun onClick(v: View) {
val context = context
val activity = mainActivity
@@ -963,12 +973,6 @@ class GalleryDetailScene : CollapsingToolbarScene(), View.OnClickListener, Downl
args.putParcelable(GalleryCommentsScene.KEY_COMMENT_LIST, mGalleryDetail!!.comments)
args.putParcelable(GalleryCommentsScene.KEY_GALLERY_DETAIL, mGalleryDetail)
navigate(R.id.galleryCommentsScene, args)
} else if (binding.content.previews.previews === v) {
if (null != mGalleryDetail) {
val args = Bundle()
args.putParcelable(GalleryPreviewsScene.KEY_GALLERY_INFO, mGalleryDetail)
navigate(R.id.galleryPreviewsScene, args)
}
} else {
var o = v.getTag(R.id.tag)
if (o is String) {
@@ -59,6 +59,7 @@ class GalleryPreviewsScene : BaseToolbarScene() {
private var mAdapter: GalleryPreviewAdapter? = null
private var mHelper: GalleryPreviewHelper? = null
private var mHasFirstRefresh = false
private var mNextPage: Boolean = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (savedInstanceState == null) {
@@ -71,6 +72,7 @@ class GalleryPreviewsScene : BaseToolbarScene() {
private fun onInit() {
val args = arguments ?: return
mGalleryInfo = args.getParcelable(KEY_GALLERY_INFO)
mNextPage = args.getBoolean(KEY_NEXT_PAGE)
}
private fun onRestore(savedInstanceState: Bundle) {
@@ -137,6 +139,12 @@ class GalleryPreviewsScene : BaseToolbarScene() {
if (mGalleryInfo != null) {
if ((mGalleryInfo as GalleryDetail).previewPages > 2) showMenu(R.menu.scene_gallery_previews)
}
runCatching {
mHelper!!.mPages = (mGalleryInfo as GalleryDetail).previewPages
if (mNextPage && mHelper!!.pages > 1) mHelper!!.goTo(1)
}.onFailure {
it.printStackTrace()
}
}
override fun onMenuItemClick(item: MenuItem): Boolean {
@@ -344,6 +352,7 @@ class GalleryPreviewsScene : BaseToolbarScene() {
companion object {
const val KEY_GALLERY_INFO = "gallery_info"
const val KEY_NEXT_PAGE = "next_page"
private const val KEY_HAS_FIRST_REFRESH = "has_first_refresh"
}
}
@@ -227,7 +227,7 @@ public class ContentLayout extends FrameLayout {
/**
* The available page count.
*/
private int mPages;
public int mPages;
private int mNextPage;
private int mCurrentTaskId;
private int mCurrentTaskType;
@@ -35,9 +35,10 @@
app:columnCount="3"
app:itemMargin="8dp" />
<TextView
<Button
style="@style/Widget.Material3.Button.TextButton"
android:id="@+id/preview_text"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />