Minor refactor

This commit is contained in:
tarsin committed 2023-01-14 12:11:27 +08:00
1 parent 94a8b78d1a
commit ca3fc370c3
4 files changed
+15 -15

No files matched your search

@@ -61,6 +61,7 @@ import com.hippo.ehviewer.download.DownloadService
import com.hippo.ehviewer.ui.scene.BaseScene
import com.hippo.ehviewer.ui.scene.GalleryDetailScene
import com.hippo.ehviewer.ui.scene.GalleryListScene
import com.hippo.ehviewer.ui.scene.GalleryListScene.Companion.toStartArgs
import com.hippo.ehviewer.ui.scene.ProgressScene
import com.hippo.io.UniFileInputStreamPipe
import com.hippo.unifile.UniFile
@@ -185,7 +186,7 @@ class MainActivity : EhActivity() {
builder.keyword = intent.getStringExtra(Intent.EXTRA_TEXT)
navController.navigate(
R.id.galleryListScene,
GalleryListScene.getStartArgs(builder)
builder.toStartArgs()
)
return true
} else if (type != null && type.startsWith("image/")) {
@@ -200,7 +201,7 @@ class MainActivity : EhActivity() {
builder.isUseSimilarityScan = true
navController.navigate(
R.id.galleryListScene,
GalleryListScene.getStartArgs(builder)
builder.toStartArgs()
)
return true
}
@@ -66,7 +66,7 @@ import com.hippo.ehviewer.client.data.ListUrlBuilder
import com.hippo.ehviewer.client.parser.VoteCommentParser
import com.hippo.ehviewer.dao.Filter
import com.hippo.ehviewer.ui.MainActivity
import com.hippo.ehviewer.ui.scene.GalleryListScene.Companion.getStartArgs
import com.hippo.ehviewer.ui.scene.GalleryListScene.Companion.toStartArgs
import com.hippo.text.URLImageGetter
import com.hippo.util.ExceptionUtils
import com.hippo.util.ReadableTime
@@ -834,7 +834,7 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh
val lub = ListUrlBuilder()
lub.mode = ListUrlBuilder.MODE_UPLOADER
lub.keyword = value.user
navigate(R.id.galleryListScene, getStartArgs(lub), true)
navigate(R.id.galleryListScene, lub.toStartArgs(), true)
}
time.text = ReadableTime.getTimeAgo(value.time)
comment.text = generateComment(comment.context, comment, value)
@@ -91,7 +91,7 @@ import com.hippo.ehviewer.spider.SpiderDen
import com.hippo.ehviewer.ui.CommonOperations
import com.hippo.ehviewer.ui.GalleryInfoBottomSheet
import com.hippo.ehviewer.ui.MainActivity
import com.hippo.ehviewer.ui.scene.GalleryListScene.Companion.getStartArgs
import com.hippo.ehviewer.ui.scene.GalleryListScene.Companion.toStartArgs
import com.hippo.ehviewer.widget.GalleryRatingBar
import com.hippo.ehviewer.widget.GalleryRatingBar.OnUserRateListener
import com.hippo.text.URLImageGetter
@@ -736,7 +736,7 @@ class GalleryDetailScene : CollapsingToolbarScene(), View.OnClickListener, Downl
val lub = ListUrlBuilder()
lub.mode = ListUrlBuilder.MODE_NORMAL
lub.keyword = "\"" + keyword + "\""
navigate(R.id.galleryListScene, getStartArgs(lub), true)
navigate(R.id.galleryListScene, lub.toStartArgs(), true)
return
}
val artist = getArtist(gd.tags)
@@ -744,14 +744,14 @@ class GalleryDetailScene : CollapsingToolbarScene(), View.OnClickListener, Downl
val lub = ListUrlBuilder()
lub.mode = ListUrlBuilder.MODE_TAG
lub.keyword = "artist:$artist"
navigate(R.id.galleryListScene, getStartArgs(lub), true)
navigate(R.id.galleryListScene, lub.toStartArgs(), true)
return
}
if (null != gd.uploader) {
val lub = ListUrlBuilder()
lub.mode = ListUrlBuilder.MODE_UPLOADER
lub.keyword = gd.uploader
navigate(R.id.galleryListScene, getStartArgs(lub), true)
navigate(R.id.galleryListScene, lub.toStartArgs(), true)
}
}
@@ -768,7 +768,7 @@ class GalleryDetailScene : CollapsingToolbarScene(), View.OnClickListener, Downl
lub.mode = ListUrlBuilder.MODE_IMAGE_SEARCH
lub.imagePath = path.toString()
lub.isUseSimilarityScan = true
navigate(R.id.galleryListScene, getStartArgs(lub), true)
navigate(R.id.galleryListScene, lub.toStartArgs(), true)
} catch (e: Throwable) {
e.printStackTrace()
}
@@ -792,7 +792,7 @@ class GalleryDetailScene : CollapsingToolbarScene(), View.OnClickListener, Downl
val lub = ListUrlBuilder()
lub.mode = ListUrlBuilder.MODE_UPLOADER
lub.keyword = uploader
navigate(R.id.galleryListScene, getStartArgs(lub), true)
navigate(R.id.galleryListScene, lub.toStartArgs(), true)
} else if (binding.content.header.category === v) {
val category = this.category
if (category == EhUtils.NONE || category == EhUtils.PRIVATE || category == EhUtils.UNKNOWN) {
@@ -800,7 +800,7 @@ class GalleryDetailScene : CollapsingToolbarScene(), View.OnClickListener, Downl
}
val lub = ListUrlBuilder()
lub.category = category
navigate(R.id.galleryListScene, getStartArgs(lub), true)
navigate(R.id.galleryListScene, lub.toStartArgs(), true)
} else if (binding.content.header.download === v) {
val galleryInfo = galleryInfo
if (galleryInfo != null) {
@@ -973,7 +973,7 @@ class GalleryDetailScene : CollapsingToolbarScene(), View.OnClickListener, Downl
val lub = ListUrlBuilder()
lub.mode = ListUrlBuilder.MODE_TAG
lub.keyword = o
navigate(R.id.galleryListScene, getStartArgs(lub), true)
navigate(R.id.galleryListScene, lub.toStartArgs(), true)
return
}
val galleryInfo = galleryInfo
@@ -1475,11 +1475,10 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
}
}
@JvmStatic
fun getStartArgs(lub: ListUrlBuilder): Bundle {
fun ListUrlBuilder.toStartArgs(): Bundle {
val args = Bundle()
args.putString(KEY_ACTION, ACTION_LIST_URL_BUILDER)
args.putParcelable(KEY_LIST_URL_BUILDER, lub)
args.putParcelable(KEY_LIST_URL_BUILDER, this)
return args
}
}