mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Fix warnings in MangaDetailsController
This commit is contained in:
parent
818bf2f1da
commit
ab8f019460
1 changed files with 22 additions and 16 deletions
|
@ -1,6 +1,7 @@
|
|||
package eu.kanade.tachiyomi.ui.manga
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
|
@ -99,6 +100,7 @@ import eu.kanade.tachiyomi.util.system.isPromptChecked
|
|||
import eu.kanade.tachiyomi.util.system.isTablet
|
||||
import eu.kanade.tachiyomi.util.system.launchUI
|
||||
import eu.kanade.tachiyomi.util.system.materialAlertDialog
|
||||
import eu.kanade.tachiyomi.util.system.rootWindowInsetsCompat
|
||||
import eu.kanade.tachiyomi.util.system.setCustomTitleAndMessage
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.view.activityBinding
|
||||
|
@ -164,12 +166,12 @@ class MangaDetailsController :
|
|||
|
||||
private var manga: Manga? = null
|
||||
private var source: Source? = null
|
||||
var colorAnimator: ValueAnimator? = null
|
||||
private var colorAnimator: ValueAnimator? = null
|
||||
val presenter: MangaDetailsPresenter
|
||||
var coverColor: Int? = null
|
||||
var accentColor: Int? = null
|
||||
var headerColor: Int? = null
|
||||
var toolbarIsColored = false
|
||||
private var coverColor: Int? = null
|
||||
private var accentColor: Int? = null
|
||||
private var headerColor: Int? = null
|
||||
private var toolbarIsColored = false
|
||||
private var snack: Snackbar? = null
|
||||
val fromCatalogue = args.getBoolean(FROM_CATALOGUE_EXTRA, false)
|
||||
private var trackingBottomSheet: TrackingBottomSheet? = null
|
||||
|
@ -177,7 +179,7 @@ class MangaDetailsController :
|
|||
private var rangeMode: RangeMode? = null
|
||||
private var editMangaDialog: EditMangaDialog? = null
|
||||
var refreshTracker: Int? = null
|
||||
var chapterPopupMenu: Pair<Int, PopupMenu>? = null
|
||||
private var chapterPopupMenu: Pair<Int, PopupMenu>? = null
|
||||
|
||||
// Tablet Layout
|
||||
var isTablet = false
|
||||
|
@ -188,8 +190,8 @@ class MangaDetailsController :
|
|||
|
||||
private var actionMode: ActionMode? = null
|
||||
|
||||
var headerHeight = 0
|
||||
var fullCoverActive = false
|
||||
private var headerHeight = 0
|
||||
private var fullCoverActive = false
|
||||
|
||||
override fun getTitle(): String? {
|
||||
return manga?.title
|
||||
|
@ -332,7 +334,8 @@ class MangaDetailsController :
|
|||
|
||||
if (isTablet) {
|
||||
val tHeight = toolbarHeight.takeIf { it ?: 0 > 0 } ?: appbarHeight
|
||||
headerHeight = tHeight + (activityBinding?.root?.rootWindowInsets?.systemWindowInsetTop ?: 0)
|
||||
headerHeight = tHeight +
|
||||
(view.rootWindowInsetsCompat?.getInsets(systemBars())?.top ?: 0)
|
||||
binding.recycler.updatePaddingRelative(top = headerHeight + 4.dpToPx)
|
||||
binding.recycler.doOnApplyWindowInsetsCompat { _, insets, _ ->
|
||||
setInsets(insets, appbarHeight, offset)
|
||||
|
@ -411,10 +414,11 @@ class MangaDetailsController :
|
|||
val scrollingStatusColor = ColorUtils.setAlphaComponent(scrollingColor, (0.87f * 255).roundToInt())
|
||||
colorAnimator?.cancel()
|
||||
if (animate) {
|
||||
colorAnimator = ValueAnimator.ofFloat(
|
||||
val cA = ValueAnimator.ofFloat(
|
||||
if (toolbarIsColored) 0f else 1f,
|
||||
if (toolbarIsColored) 1f else 0f
|
||||
)
|
||||
colorAnimator = cA
|
||||
colorAnimator?.duration = 250 // milliseconds
|
||||
colorAnimator?.addUpdateListener { animator ->
|
||||
activityBinding?.appBar?.setBackgroundColor(
|
||||
|
@ -434,7 +438,7 @@ class MangaDetailsController :
|
|||
Color.TRANSPARENT
|
||||
}
|
||||
}
|
||||
colorAnimator?.start()
|
||||
cA.start()
|
||||
} else {
|
||||
activityBinding?.appBar?.setBackgroundColor(if (toolbarIsColored) scrollingColor else topColor)
|
||||
activity.window?.statusBarColor = if (toolbarIsColored) scrollingStatusColor else topColor
|
||||
|
@ -696,6 +700,7 @@ class MangaDetailsController :
|
|||
else binding.recycler.findViewHolderForAdapterPosition(0) as? MangaHeaderHolder
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
fun updateHeader() {
|
||||
binding.swipeRefresh.isRefreshing = presenter.isLoading
|
||||
adapter?.setChapters(presenter.chapters)
|
||||
|
@ -704,6 +709,7 @@ class MangaDetailsController :
|
|||
activity?.invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
fun updateChapters(chapters: List<ChapterItem>) {
|
||||
view ?: return
|
||||
binding.swipeRefresh.isRefreshing = presenter.isLoading
|
||||
|
@ -730,6 +736,7 @@ class MangaDetailsController :
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
fun refreshAdapter() = adapter?.notifyDataSetChanged()
|
||||
|
||||
override fun onItemClick(view: View?, position: Int): Boolean {
|
||||
|
@ -1210,8 +1217,7 @@ class MangaDetailsController :
|
|||
presenter.downloadChapters(chapters)
|
||||
val text = view.context.getString(
|
||||
R.string.add_x_to_library,
|
||||
presenter.manga.seriesType
|
||||
(view.context).toLowerCase(Locale.ROOT)
|
||||
presenter.manga.seriesType(view.context).lowercase(Locale.ROOT)
|
||||
)
|
||||
if (!presenter.manga.favorite && (
|
||||
snack == null ||
|
||||
|
@ -1335,7 +1341,7 @@ class MangaDetailsController :
|
|||
toggleMangaFavorite()
|
||||
} else {
|
||||
val favButton = getHeader()?.binding?.favoriteButton ?: return
|
||||
val popup = makeFavPopup(favButton, manga, categories)
|
||||
val popup = makeFavPopup(favButton, categories)
|
||||
popup?.show()
|
||||
}
|
||||
}
|
||||
|
@ -1349,11 +1355,11 @@ class MangaDetailsController :
|
|||
popupView.setOnTouchListener(null)
|
||||
return
|
||||
}
|
||||
val popup = makeFavPopup(popupView, manga, presenter.getCategories())
|
||||
val popup = makeFavPopup(popupView, presenter.getCategories())
|
||||
popupView.setOnTouchListener(popup?.dragToOpenListener)
|
||||
}
|
||||
|
||||
private fun makeFavPopup(popupView: View, manga: Manga, categories: List<Category>): PopupMenu? {
|
||||
private fun makeFavPopup(popupView: View, categories: List<Category>): PopupMenu? {
|
||||
val view = view ?: return null
|
||||
val popup = PopupMenu(view.context, popupView)
|
||||
popup.menu.add(0, 1, 0, R.string.remove_from_library)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue