mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-25 02:21:49 +01:00
Binding for Recents
This commit is contained in:
parent
7b91a8a23b
commit
0a36245177
@ -10,6 +10,7 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadService
|
import eu.kanade.tachiyomi.data.download.DownloadService
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
|
import eu.kanade.tachiyomi.databinding.DownloadBottomSheetBinding
|
||||||
import eu.kanade.tachiyomi.ui.extension.ExtensionDividerItemDecoration
|
import eu.kanade.tachiyomi.ui.extension.ExtensionDividerItemDecoration
|
||||||
import eu.kanade.tachiyomi.ui.recents.RecentsController
|
import eu.kanade.tachiyomi.ui.recents.RecentsController
|
||||||
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
import eu.kanade.tachiyomi.util.view.RecyclerWindowInsetsListener
|
||||||
@ -21,7 +22,6 @@ import eu.kanade.tachiyomi.util.view.isCollapsed
|
|||||||
import eu.kanade.tachiyomi.util.view.isExpanded
|
import eu.kanade.tachiyomi.util.view.isExpanded
|
||||||
import eu.kanade.tachiyomi.util.view.isHidden
|
import eu.kanade.tachiyomi.util.view.isHidden
|
||||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||||
import kotlinx.android.synthetic.main.download_bottom_sheet.view.*
|
|
||||||
|
|
||||||
class DownloadBottomSheet @JvmOverloads constructor(
|
class DownloadBottomSheet @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
@ -45,20 +45,26 @@ class DownloadBottomSheet @JvmOverloads constructor(
|
|||||||
private var isRunning: Boolean = false
|
private var isRunning: Boolean = false
|
||||||
private var activity: Activity? = null
|
private var activity: Activity? = null
|
||||||
|
|
||||||
|
lateinit var binding: DownloadBottomSheetBinding
|
||||||
|
override fun onFinishInflate() {
|
||||||
|
super.onFinishInflate()
|
||||||
|
binding = DownloadBottomSheetBinding.bind(this)
|
||||||
|
}
|
||||||
|
|
||||||
fun onCreate(controller: RecentsController) {
|
fun onCreate(controller: RecentsController) {
|
||||||
// Initialize adapter, scroll listener and recycler views
|
// Initialize adapter, scroll listener and recycler views
|
||||||
adapter = DownloadAdapter(this)
|
adapter = DownloadAdapter(this)
|
||||||
sheetBehavior = BottomSheetBehavior.from(this)
|
sheetBehavior = BottomSheetBehavior.from(this)
|
||||||
activity = controller.activity
|
activity = controller.activity
|
||||||
// Create recycler and set adapter.
|
// Create recycler and set adapter.
|
||||||
dl_recycler.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(context)
|
binding.dlRecycler.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(context)
|
||||||
dl_recycler.adapter = adapter
|
binding.dlRecycler.adapter = adapter
|
||||||
adapter?.isHandleDragEnabled = true
|
adapter?.isHandleDragEnabled = true
|
||||||
adapter?.isSwipeEnabled = true
|
adapter?.isSwipeEnabled = true
|
||||||
adapter?.fastScroller = fast_scroller
|
adapter?.fastScroller = binding.fastScroller
|
||||||
dl_recycler.setHasFixedSize(true)
|
binding.dlRecycler.setHasFixedSize(true)
|
||||||
dl_recycler.addItemDecoration(ExtensionDividerItemDecoration(context))
|
binding.dlRecycler.addItemDecoration(ExtensionDividerItemDecoration(context))
|
||||||
dl_recycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
|
binding.dlRecycler.setOnApplyWindowInsetsListener(RecyclerWindowInsetsListener)
|
||||||
this.controller = controller
|
this.controller = controller
|
||||||
updateDLTitle()
|
updateDLTitle()
|
||||||
|
|
||||||
@ -66,12 +72,12 @@ class DownloadBottomSheet @JvmOverloads constructor(
|
|||||||
val array = context.obtainStyledAttributes(attrsArray)
|
val array = context.obtainStyledAttributes(attrsArray)
|
||||||
val headerHeight = array.getDimensionPixelSize(0, 0)
|
val headerHeight = array.getDimensionPixelSize(0, 0)
|
||||||
array.recycle()
|
array.recycle()
|
||||||
recycler_layout.doOnApplyWindowInsets { v, windowInsets, _ ->
|
binding.recyclerLayout.doOnApplyWindowInsets { v, windowInsets, _ ->
|
||||||
v.updateLayoutParams<MarginLayoutParams> {
|
v.updateLayoutParams<MarginLayoutParams> {
|
||||||
topMargin = windowInsets.systemWindowInsetTop + headerHeight - sheet_layout.height
|
topMargin = windowInsets.systemWindowInsetTop + headerHeight - binding.sheetLayout.height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sheet_layout.setOnClickListener {
|
binding.sheetLayout.setOnClickListener {
|
||||||
if (!sheetBehavior.isExpanded()) {
|
if (!sheetBehavior.isExpanded()) {
|
||||||
sheetBehavior?.expand()
|
sheetBehavior?.expand()
|
||||||
} else {
|
} else {
|
||||||
@ -93,7 +99,7 @@ class DownloadBottomSheet @JvmOverloads constructor(
|
|||||||
|
|
||||||
private fun updateDLTitle() {
|
private fun updateDLTitle() {
|
||||||
val extCount = presenter.downloadQueue.firstOrNull()
|
val extCount = presenter.downloadQueue.firstOrNull()
|
||||||
title_text.text = if (extCount != null) resources.getString(
|
binding.titleText.text = if (extCount != null) resources.getString(
|
||||||
R.string.downloading_,
|
R.string.downloading_,
|
||||||
extCount.chapter.name
|
extCount.chapter.name
|
||||||
)
|
)
|
||||||
@ -153,7 +159,7 @@ class DownloadBottomSheet @JvmOverloads constructor(
|
|||||||
* @return the holder of the download or null if it's not bound.
|
* @return the holder of the download or null if it's not bound.
|
||||||
*/
|
*/
|
||||||
private fun getHolder(download: Download): DownloadHolder? {
|
private fun getHolder(download: Download): DownloadHolder? {
|
||||||
return dl_recycler?.findViewHolderForItemId(download.chapter.id!!) as? DownloadHolder
|
return binding.dlRecycler?.findViewHolderForItemId(download.chapter.id!!) as? DownloadHolder
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -163,12 +169,12 @@ class DownloadBottomSheet @JvmOverloads constructor(
|
|||||||
updateDLTitle()
|
updateDLTitle()
|
||||||
setBottomSheet()
|
setBottomSheet()
|
||||||
if (presenter.downloadQueue.isEmpty()) {
|
if (presenter.downloadQueue.isEmpty()) {
|
||||||
empty_view?.show(
|
binding.emptyView.show(
|
||||||
R.drawable.ic_download_off_24dp,
|
R.drawable.ic_download_off_24dp,
|
||||||
R.string.nothing_is_downloading
|
R.string.nothing_is_downloading
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
empty_view?.hide()
|
binding.emptyView.hide()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,10 +8,10 @@ import android.widget.FrameLayout
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
|
import eu.kanade.tachiyomi.databinding.DownloadButtonBinding
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.view.gone
|
import eu.kanade.tachiyomi.util.view.gone
|
||||||
import eu.kanade.tachiyomi.util.view.visible
|
import eu.kanade.tachiyomi.util.view.visible
|
||||||
import kotlinx.android.synthetic.main.download_button.view.*
|
|
||||||
|
|
||||||
class DownloadButton @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
class DownloadButton @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||||
FrameLayout(context, attrs) {
|
FrameLayout(context, attrs) {
|
||||||
@ -52,53 +52,60 @@ class DownloadButton @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
private var isAnimating = false
|
private var isAnimating = false
|
||||||
private var iconAnimation: ObjectAnimator? = null
|
private var iconAnimation: ObjectAnimator? = null
|
||||||
|
|
||||||
|
lateinit var binding: DownloadButtonBinding
|
||||||
|
|
||||||
|
override fun onFinishInflate() {
|
||||||
|
super.onFinishInflate()
|
||||||
|
binding = DownloadButtonBinding.bind(this)
|
||||||
|
}
|
||||||
|
|
||||||
fun setDownloadStatus(state: Int, progress: Int = 0) {
|
fun setDownloadStatus(state: Int, progress: Int = 0) {
|
||||||
if (state != Download.DOWNLOADING) {
|
if (state != Download.DOWNLOADING) {
|
||||||
iconAnimation?.cancel()
|
iconAnimation?.cancel()
|
||||||
download_icon.alpha = 1f
|
binding.downloadIcon.alpha = 1f
|
||||||
isAnimating = false
|
isAnimating = false
|
||||||
}
|
}
|
||||||
download_icon.setImageDrawable(
|
binding.downloadIcon.setImageDrawable(
|
||||||
if (state == Download.CHECKED) {
|
if (state == Download.CHECKED) {
|
||||||
checkDrawable
|
checkDrawable
|
||||||
} else downloadDrawable
|
} else downloadDrawable
|
||||||
)
|
)
|
||||||
when (state) {
|
when (state) {
|
||||||
Download.CHECKED -> {
|
Download.CHECKED -> {
|
||||||
download_progress.gone()
|
binding.downloadProgress.gone()
|
||||||
download_border.visible()
|
binding.downloadBorder.visible()
|
||||||
download_progress_indeterminate.gone()
|
binding.downloadProgressIndeterminate.gone()
|
||||||
download_border.setImageDrawable(filledCircle)
|
binding.downloadBorder.setImageDrawable(filledCircle)
|
||||||
download_border.drawable.setTint(activeColor)
|
binding.downloadBorder.drawable.setTint(activeColor)
|
||||||
download_icon.drawable.setTint(Color.WHITE)
|
binding.downloadIcon.drawable.setTint(Color.WHITE)
|
||||||
}
|
}
|
||||||
Download.NOT_DOWNLOADED -> {
|
Download.NOT_DOWNLOADED -> {
|
||||||
download_border.visible()
|
binding.downloadBorder.visible()
|
||||||
download_progress.gone()
|
binding.downloadProgress.gone()
|
||||||
download_progress_indeterminate.gone()
|
binding.downloadProgressIndeterminate.gone()
|
||||||
download_border.setImageDrawable(borderCircle)
|
binding.downloadBorder.setImageDrawable(borderCircle)
|
||||||
download_border.drawable.setTint(activeColor)
|
binding.downloadBorder.drawable.setTint(activeColor)
|
||||||
download_icon.drawable.setTint(activeColor)
|
binding.downloadIcon.drawable.setTint(activeColor)
|
||||||
}
|
}
|
||||||
Download.QUEUE -> {
|
Download.QUEUE -> {
|
||||||
download_border.gone()
|
binding.downloadBorder.gone()
|
||||||
download_progress.gone()
|
binding.downloadProgress.gone()
|
||||||
download_progress_indeterminate.visible()
|
binding.downloadProgressIndeterminate.visible()
|
||||||
download_progress.isIndeterminate = true
|
binding.downloadProgress.isIndeterminate = true
|
||||||
download_icon.drawable.setTint(disabledColor)
|
binding.downloadIcon.drawable.setTint(disabledColor)
|
||||||
}
|
}
|
||||||
Download.DOWNLOADING -> {
|
Download.DOWNLOADING -> {
|
||||||
download_border.visible()
|
binding.downloadBorder.visible()
|
||||||
download_progress.visible()
|
binding.downloadProgress.visible()
|
||||||
download_progress_indeterminate.gone()
|
binding.downloadProgressIndeterminate.gone()
|
||||||
download_border.setImageDrawable(borderCircle)
|
binding.downloadBorder.setImageDrawable(borderCircle)
|
||||||
download_progress.isIndeterminate = false
|
binding.downloadProgress.isIndeterminate = false
|
||||||
download_progress.progress = progress
|
binding.downloadProgress.progress = progress
|
||||||
download_border.drawable.setTint(progressBGColor)
|
binding.downloadBorder.drawable.setTint(progressBGColor)
|
||||||
download_progress.progressDrawable?.setTint(downloadedColor)
|
binding.downloadProgress.progressDrawable?.setTint(downloadedColor)
|
||||||
download_icon.drawable.setTint(disabledColor)
|
binding.downloadIcon.drawable.setTint(disabledColor)
|
||||||
if (!isAnimating) {
|
if (!isAnimating) {
|
||||||
iconAnimation = ObjectAnimator.ofFloat(download_icon, "alpha", 1f, 0f).apply {
|
iconAnimation = ObjectAnimator.ofFloat(binding.downloadIcon, "alpha", 1f, 0f).apply {
|
||||||
duration = 1000
|
duration = 1000
|
||||||
repeatCount = ObjectAnimator.INFINITE
|
repeatCount = ObjectAnimator.INFINITE
|
||||||
repeatMode = ObjectAnimator.REVERSE
|
repeatMode = ObjectAnimator.REVERSE
|
||||||
@ -108,20 +115,20 @@ class DownloadButton @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Download.DOWNLOADED -> {
|
Download.DOWNLOADED -> {
|
||||||
download_progress.gone()
|
binding.downloadProgress.gone()
|
||||||
download_border.visible()
|
binding.downloadBorder.visible()
|
||||||
download_progress_indeterminate.gone()
|
binding.downloadProgressIndeterminate.gone()
|
||||||
download_border.setImageDrawable(filledCircle)
|
binding.downloadBorder.setImageDrawable(filledCircle)
|
||||||
download_border.drawable.setTint(downloadedColor)
|
binding.downloadBorder.drawable.setTint(downloadedColor)
|
||||||
download_icon.drawable.setTint(Color.WHITE)
|
binding.downloadIcon.drawable.setTint(Color.WHITE)
|
||||||
}
|
}
|
||||||
Download.ERROR -> {
|
Download.ERROR -> {
|
||||||
download_progress.gone()
|
binding.downloadProgress.gone()
|
||||||
download_border.visible()
|
binding.downloadBorder.visible()
|
||||||
download_progress_indeterminate.gone()
|
binding.downloadProgressIndeterminate.gone()
|
||||||
download_border.setImageDrawable(borderCircle)
|
binding.downloadBorder.setImageDrawable(borderCircle)
|
||||||
download_border.drawable.setTint(errorColor)
|
binding.downloadBorder.drawable.setTint(errorColor)
|
||||||
download_icon.drawable.setTint(errorColor)
|
binding.downloadIcon.drawable.setTint(errorColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,65 +5,66 @@ import android.view.View
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.image.coil.loadLibraryManga
|
import eu.kanade.tachiyomi.data.image.coil.loadLibraryManga
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
|
import eu.kanade.tachiyomi.databinding.RecentMangaItemBinding
|
||||||
import eu.kanade.tachiyomi.source.LocalSource
|
import eu.kanade.tachiyomi.source.LocalSource
|
||||||
import eu.kanade.tachiyomi.ui.manga.chapter.BaseChapterHolder
|
import eu.kanade.tachiyomi.ui.manga.chapter.BaseChapterHolder
|
||||||
import eu.kanade.tachiyomi.util.chapter.ChapterUtil
|
import eu.kanade.tachiyomi.util.chapter.ChapterUtil
|
||||||
import eu.kanade.tachiyomi.util.system.timeSpanFromNow
|
import eu.kanade.tachiyomi.util.system.timeSpanFromNow
|
||||||
import eu.kanade.tachiyomi.util.view.visibleIf
|
import eu.kanade.tachiyomi.util.view.visibleIf
|
||||||
import kotlinx.android.synthetic.main.download_button.*
|
|
||||||
import kotlinx.android.synthetic.main.recent_manga_item.*
|
|
||||||
|
|
||||||
class RecentMangaHolder(
|
class RecentMangaHolder(
|
||||||
view: View,
|
view: View,
|
||||||
val adapter: RecentMangaAdapter
|
val adapter: RecentMangaAdapter
|
||||||
) : BaseChapterHolder(view, adapter) {
|
) : BaseChapterHolder(view, adapter) {
|
||||||
|
|
||||||
|
private val binding = RecentMangaItemBinding.bind(view)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
card_layout?.setOnClickListener { adapter.delegate.onCoverClick(flexibleAdapterPosition) }
|
binding.cardLayout.setOnClickListener { adapter.delegate.onCoverClick(flexibleAdapterPosition) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bind(recentsType: Int) {
|
fun bind(recentsType: Int) {
|
||||||
when (recentsType) {
|
when (recentsType) {
|
||||||
RecentMangaHeaderItem.CONTINUE_READING -> {
|
RecentMangaHeaderItem.CONTINUE_READING -> {
|
||||||
title.setText(R.string.view_history)
|
binding.title.setText(R.string.view_history)
|
||||||
}
|
}
|
||||||
RecentMangaHeaderItem.NEW_CHAPTERS -> {
|
RecentMangaHeaderItem.NEW_CHAPTERS -> {
|
||||||
title.setText(R.string.view_all_updates)
|
binding.title.setText(R.string.view_all_updates)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bind(item: RecentMangaItem) {
|
fun bind(item: RecentMangaItem) {
|
||||||
download_button.visibleIf(item.mch.manga.source != LocalSource.ID)
|
binding.downloadButton.downloadButton.visibleIf(item.mch.manga.source != LocalSource.ID)
|
||||||
|
|
||||||
title.apply {
|
binding.title.apply {
|
||||||
text = item.chapter.name
|
text = item.chapter.name
|
||||||
ChapterUtil.setTextViewForChapter(this, item)
|
ChapterUtil.setTextViewForChapter(this, item)
|
||||||
}
|
}
|
||||||
subtitle.apply {
|
binding.subtitle.apply {
|
||||||
text = item.mch.manga.title
|
text = item.mch.manga.title
|
||||||
setTextColor(ChapterUtil.readColor(context, item))
|
setTextColor(ChapterUtil.readColor(context, item))
|
||||||
}
|
}
|
||||||
val notValidNum = item.mch.chapter.chapter_number <= 0
|
val notValidNum = item.mch.chapter.chapter_number <= 0
|
||||||
body.text = when {
|
binding.body.text = when {
|
||||||
item.mch.chapter.id == null -> body.context.getString(
|
item.mch.chapter.id == null -> binding.body.context.getString(
|
||||||
R.string.added_,
|
R.string.added_,
|
||||||
item.mch.manga.date_added.timeSpanFromNow
|
item.mch.manga.date_added.timeSpanFromNow
|
||||||
)
|
)
|
||||||
item.mch.history.id == null -> body.context.getString(
|
item.mch.history.id == null -> binding.body.context.getString(
|
||||||
R.string.updated_,
|
R.string.updated_,
|
||||||
item.chapter.date_upload.timeSpanFromNow
|
item.chapter.date_upload.timeSpanFromNow
|
||||||
)
|
)
|
||||||
item.chapter.id != item.mch.chapter.id ->
|
item.chapter.id != item.mch.chapter.id ->
|
||||||
body.context.getString(
|
binding.body.context.getString(
|
||||||
R.string.read_,
|
R.string.read_,
|
||||||
item.mch.history.last_read.timeSpanFromNow
|
item.mch.history.last_read.timeSpanFromNow
|
||||||
) + "\n" + body.context.getString(
|
) + "\n" + binding.body.context.getString(
|
||||||
if (notValidNum) R.string.last_read_ else R.string.last_read_chapter_,
|
if (notValidNum) R.string.last_read_ else R.string.last_read_chapter_,
|
||||||
if (notValidNum) item.mch.chapter.name else adapter.decimalFormat.format(item.mch.chapter.chapter_number)
|
if (notValidNum) item.mch.chapter.name else adapter.decimalFormat.format(item.mch.chapter.chapter_number)
|
||||||
)
|
)
|
||||||
item.chapter.pages_left > 0 && !item.chapter.read ->
|
item.chapter.pages_left > 0 && !item.chapter.read ->
|
||||||
body.context.getString(
|
binding.body.context.getString(
|
||||||
R.string.read_,
|
R.string.read_,
|
||||||
item.mch.history.last_read.timeSpanFromNow
|
item.mch.history.last_read.timeSpanFromNow
|
||||||
) + "\n" + itemView.resources.getQuantityString(
|
) + "\n" + itemView.resources.getQuantityString(
|
||||||
@ -71,13 +72,13 @@ class RecentMangaHolder(
|
|||||||
item.chapter.pages_left,
|
item.chapter.pages_left,
|
||||||
item.chapter.pages_left
|
item.chapter.pages_left
|
||||||
)
|
)
|
||||||
else -> body.context.getString(
|
else -> binding.body.context.getString(
|
||||||
R.string.read_,
|
R.string.read_,
|
||||||
item.mch.history.last_read.timeSpanFromNow
|
item.mch.history.last_read.timeSpanFromNow
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if ((itemView.context as? Activity)?.isDestroyed != true) {
|
if ((itemView.context as? Activity)?.isDestroyed != true) {
|
||||||
cover_thumbnail.loadLibraryManga(item.mch.manga)
|
binding.coverThumbnail.loadLibraryManga(item.mch.manga)
|
||||||
}
|
}
|
||||||
notifyStatus(
|
notifyStatus(
|
||||||
if (adapter.isSelected(flexibleAdapterPosition)) Download.CHECKED else item.status,
|
if (adapter.isSelected(flexibleAdapterPosition)) Download.CHECKED else item.status,
|
||||||
@ -87,7 +88,7 @@ class RecentMangaHolder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun resetFrontView() {
|
private fun resetFrontView() {
|
||||||
if (front_view.translationX != 0f) itemView.post { adapter.notifyItemChanged(flexibleAdapterPosition) }
|
if (binding.frontView.translationX != 0f) itemView.post { adapter.notifyItemChanged(flexibleAdapterPosition) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLongClick(view: View?): Boolean {
|
override fun onLongClick(view: View?): Boolean {
|
||||||
@ -97,13 +98,13 @@ class RecentMangaHolder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun notifyStatus(status: Int, progress: Int) =
|
fun notifyStatus(status: Int, progress: Int) =
|
||||||
download_button.setDownloadStatus(status, progress)
|
binding.downloadButton.downloadButton.setDownloadStatus(status, progress)
|
||||||
|
|
||||||
override fun getFrontView(): View {
|
override fun getFrontView(): View {
|
||||||
return front_view
|
return binding.frontView
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getRearRightView(): View {
|
override fun getRearRightView(): View {
|
||||||
return right_view
|
return binding.rightView
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,16 +51,6 @@ import eu.kanade.tachiyomi.util.view.snack
|
|||||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||||
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
||||||
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
||||||
import kotlinx.android.synthetic.main.download_bottom_sheet.*
|
|
||||||
import kotlinx.android.synthetic.main.download_bottom_sheet.sheet_layout
|
|
||||||
import kotlinx.android.synthetic.main.download_bottom_sheet.view.*
|
|
||||||
import kotlinx.android.synthetic.main.extensions_bottom_sheet.*
|
|
||||||
import kotlinx.android.synthetic.main.main_activity.*
|
|
||||||
import kotlinx.android.synthetic.main.recents_controller.*
|
|
||||||
import kotlinx.android.synthetic.main.recents_controller.recycler
|
|
||||||
import kotlinx.android.synthetic.main.recents_controller.shadow
|
|
||||||
import kotlinx.android.synthetic.main.recents_controller.shadow2
|
|
||||||
import kotlinx.android.synthetic.main.source_controller.*
|
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
|
|
||||||
@ -102,7 +92,8 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||||
return inflater.inflate(R.layout.recents_controller, container, false)
|
binding = RecentsControllerBinding.inflate(inflater)
|
||||||
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,11 +105,11 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
super.onViewCreated(view)
|
super.onViewCreated(view)
|
||||||
// Initialize adapter
|
// Initialize adapter
|
||||||
adapter = RecentMangaAdapter(this)
|
adapter = RecentMangaAdapter(this)
|
||||||
recycler.adapter = adapter
|
binding.recycler.adapter = adapter
|
||||||
recycler.layoutManager = LinearLayoutManager(view.context)
|
binding.recycler.layoutManager = LinearLayoutManager(view.context)
|
||||||
recycler.setHasFixedSize(true)
|
binding.recycler.setHasFixedSize(true)
|
||||||
recycler.recycledViewPool.setMaxRecycledViews(0, 0)
|
binding.recycler.recycledViewPool.setMaxRecycledViews(0, 0)
|
||||||
recycler.addItemDecoration(
|
binding.recycler.addItemDecoration(
|
||||||
RecentMangaDivider(view.context)
|
RecentMangaDivider(view.context)
|
||||||
)
|
)
|
||||||
adapter.isSwipeEnabled = true
|
adapter.isSwipeEnabled = true
|
||||||
@ -129,13 +120,13 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
val array = view.context.obtainStyledAttributes(attrsArray)
|
val array = view.context.obtainStyledAttributes(attrsArray)
|
||||||
val appBarHeight = array.getDimensionPixelSize(0, 0)
|
val appBarHeight = array.getDimensionPixelSize(0, 0)
|
||||||
array.recycle()
|
array.recycle()
|
||||||
swipe_refresh.setStyle()
|
binding.swipeRefresh.setStyle()
|
||||||
scrollViewWith(
|
scrollViewWith(
|
||||||
recycler,
|
binding.recycler,
|
||||||
swipeRefreshLayout = swipe_refresh,
|
swipeRefreshLayout = binding.swipeRefresh,
|
||||||
afterInsets = {
|
afterInsets = {
|
||||||
headerHeight = it.systemWindowInsetTop + appBarHeight
|
headerHeight = it.systemWindowInsetTop + appBarHeight
|
||||||
recycler.updatePaddingRelative(bottom = activity!!.bottom_nav.height)
|
binding.recycler.updatePaddingRelative(bottom = activityBinding?.bottomNav?.height ?: 0)
|
||||||
},
|
},
|
||||||
onBottomNavUpdate = {
|
onBottomNavUpdate = {
|
||||||
setBottomPadding()
|
setBottomPadding()
|
||||||
@ -150,25 +141,24 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dl_bottom_sheet.onCreate(this)
|
binding.downloadBottomSheet.dlBottomSheet.onCreate(this)
|
||||||
|
|
||||||
shadow2.alpha =
|
binding.shadow2.alpha =
|
||||||
if (dl_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_COLLAPSED) 0.25f else 0f
|
if (binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.state == BottomSheetBehavior.STATE_COLLAPSED) 0.25f else 0f
|
||||||
shadow.alpha =
|
binding.shadow.alpha =
|
||||||
if (dl_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_COLLAPSED) 0.5f else 0f
|
if (binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.state == BottomSheetBehavior.STATE_COLLAPSED) 0.5f else 0f
|
||||||
|
|
||||||
dl_bottom_sheet.sheetBehavior?.addBottomSheetCallback(
|
binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.addBottomSheetCallback(
|
||||||
object :
|
object :
|
||||||
BottomSheetBehavior.BottomSheetCallback() {
|
BottomSheetBehavior.BottomSheetCallback() {
|
||||||
override fun onSlide(bottomSheet: View, progress: Float) {
|
override fun onSlide(bottomSheet: View, progress: Float) {
|
||||||
val shadow2 = shadow2 ?: return
|
binding.shadow2.alpha = (1 - abs(progress)) * 0.25f
|
||||||
shadow2.alpha = (1 - abs(progress)) * 0.25f
|
binding.shadow.alpha = (1 - abs(progress)) * 0.5f
|
||||||
shadow.alpha = (1 - abs(progress)) * 0.5f
|
|
||||||
if (progress >= 0) activityBinding?.appBar?.elevation = max(
|
if (progress >= 0) activityBinding?.appBar?.elevation = max(
|
||||||
progress * 15f,
|
progress * 15f,
|
||||||
if (recycler.canScrollVertically(-1)) 15f else 0f
|
if (binding.recycler.canScrollVertically(-1)) 15f else 0f
|
||||||
)
|
)
|
||||||
sheet_layout.alpha = 1 - progress
|
binding.downloadBottomSheet.sheetLayout.alpha = 1 - progress
|
||||||
activityBinding?.appBar?.y = max(activityBinding!!.appBar.y, -headerHeight * (1 - progress))
|
activityBinding?.appBar?.y = max(activityBinding!!.appBar.y, -headerHeight * (1 - progress))
|
||||||
val oldShow = showingDownloads
|
val oldShow = showingDownloads
|
||||||
showingDownloads = progress > 0.92f
|
showingDownloads = progress > 0.92f
|
||||||
@ -182,7 +172,7 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
if (this@RecentsController.view == null) return
|
if (this@RecentsController.view == null) return
|
||||||
if (state == BottomSheetBehavior.STATE_EXPANDED) activityBinding?.appBar?.y = 0f
|
if (state == BottomSheetBehavior.STATE_EXPANDED) activityBinding?.appBar?.y = 0f
|
||||||
if (state == BottomSheetBehavior.STATE_EXPANDED || state == BottomSheetBehavior.STATE_COLLAPSED) {
|
if (state == BottomSheetBehavior.STATE_EXPANDED || state == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
sheet_layout.alpha =
|
binding.downloadBottomSheet.sheetLayout.alpha =
|
||||||
if (state == BottomSheetBehavior.STATE_COLLAPSED) 1f else 0f
|
if (state == BottomSheetBehavior.STATE_COLLAPSED) 1f else 0f
|
||||||
showingDownloads = state == BottomSheetBehavior.STATE_EXPANDED
|
showingDownloads = state == BottomSheetBehavior.STATE_EXPANDED
|
||||||
setTitle()
|
setTitle()
|
||||||
@ -191,64 +181,63 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
|
|
||||||
if (state == BottomSheetBehavior.STATE_COLLAPSED) {
|
if (state == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
if (hasQueue()) {
|
if (hasQueue()) {
|
||||||
dl_bottom_sheet.sheetBehavior?.isHideable = false
|
binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.isHideable = false
|
||||||
} else {
|
} else {
|
||||||
dl_bottom_sheet.sheetBehavior?.isHideable = true
|
binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.isHideable = true
|
||||||
dl_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
|
binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
|
||||||
}
|
}
|
||||||
} else if (state == BottomSheetBehavior.STATE_HIDDEN) {
|
} else if (state == BottomSheetBehavior.STATE_HIDDEN) {
|
||||||
if (!hasQueue()) {
|
if (!hasQueue()) {
|
||||||
dl_bottom_sheet.sheetBehavior?.skipCollapsed = true
|
binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.skipCollapsed = true
|
||||||
} else {
|
} else {
|
||||||
dl_bottom_sheet.sheetBehavior?.skipCollapsed = false
|
binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.skipCollapsed = false
|
||||||
dl_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == BottomSheetBehavior.STATE_HIDDEN || state == BottomSheetBehavior.STATE_COLLAPSED) {
|
if (state == BottomSheetBehavior.STATE_HIDDEN || state == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
shadow2.alpha = if (state == BottomSheetBehavior.STATE_COLLAPSED) 0.25f else 0f
|
binding.shadow2.alpha = if (state == BottomSheetBehavior.STATE_COLLAPSED) 0.25f else 0f
|
||||||
shadow.alpha = if (state == BottomSheetBehavior.STATE_COLLAPSED) 0.5f else 0f
|
binding.shadow.alpha = if (state == BottomSheetBehavior.STATE_COLLAPSED) 0.5f else 0f
|
||||||
}
|
}
|
||||||
|
|
||||||
sheet_layout?.isClickable = state == BottomSheetBehavior.STATE_COLLAPSED
|
binding.downloadBottomSheet.sheetLayout.isClickable = state == BottomSheetBehavior.STATE_COLLAPSED
|
||||||
sheet_layout?.isFocusable = state == BottomSheetBehavior.STATE_COLLAPSED
|
binding.downloadBottomSheet.sheetLayout.isFocusable = state == BottomSheetBehavior.STATE_COLLAPSED
|
||||||
setPadding(dl_bottom_sheet.sheetBehavior?.isHideable == true)
|
setPadding(binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.isHideable == true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
swipe_refresh.isRefreshing = LibraryUpdateService.isRunning()
|
binding.swipeRefresh.isRefreshing = LibraryUpdateService.isRunning()
|
||||||
swipe_refresh.setOnRefreshListener {
|
binding.swipeRefresh.setOnRefreshListener {
|
||||||
if (!LibraryUpdateService.isRunning()) {
|
if (!LibraryUpdateService.isRunning()) {
|
||||||
LibraryUpdateService.start(view.context)
|
LibraryUpdateService.start(view.context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showingDownloads) {
|
if (showingDownloads) {
|
||||||
dl_bottom_sheet.sheetBehavior?.expand()
|
binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.expand()
|
||||||
}
|
}
|
||||||
setPadding(dl_bottom_sheet.sheetBehavior?.isHideable == true)
|
setPadding(binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.isHideable == true)
|
||||||
requestPermissionsSafe(arrayOf(WRITE_EXTERNAL_STORAGE), 301)
|
requestPermissionsSafe(arrayOf(WRITE_EXTERNAL_STORAGE), 301)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setBottomPadding() {
|
fun setBottomPadding() {
|
||||||
val bottomBar = activity?.bottom_nav ?: return
|
val bottomBar = activityBinding?.bottomNav ?: return
|
||||||
dl_bottom_sheet ?: return
|
|
||||||
val pad = bottomBar.translationY - bottomBar.height
|
val pad = bottomBar.translationY - bottomBar.height
|
||||||
val padding = max(
|
val padding = max(
|
||||||
(-pad).toInt(),
|
(-pad).toInt(),
|
||||||
if (dl_bottom_sheet.sheetBehavior.isExpanded()) 0 else {
|
if (binding.downloadBottomSheet.dlBottomSheet.sheetBehavior.isExpanded()) 0 else {
|
||||||
view?.rootWindowInsets?.systemWindowInsetBottom ?: 0
|
view?.rootWindowInsets?.systemWindowInsetBottom ?: 0
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
shadow2.translationY = pad
|
binding.shadow2.translationY = pad
|
||||||
dl_bottom_sheet.sheetBehavior?.peekHeight = 48.spToPx + padding
|
binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.peekHeight = 48.spToPx + padding
|
||||||
dl_bottom_sheet.fast_scroller.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
binding.downloadBottomSheet.fastScroller.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
bottomMargin = -pad.toInt()
|
bottomMargin = -pad.toInt()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setRefreshing(refresh: Boolean) {
|
fun setRefreshing(refresh: Boolean) {
|
||||||
swipe_refresh?.isRefreshing = refresh
|
binding.swipeRefresh.isRefreshing = refresh
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemMove(fromPosition: Int, toPosition: Int) { }
|
override fun onItemMove(fromPosition: Int, toPosition: Int) { }
|
||||||
@ -256,21 +245,21 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
override fun shouldMoveItem(fromPosition: Int, toPosition: Int) = true
|
override fun shouldMoveItem(fromPosition: Int, toPosition: Int) = true
|
||||||
|
|
||||||
override fun onActionStateChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) {
|
override fun onActionStateChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) {
|
||||||
swipe_refresh.isEnabled = actionState != ItemTouchHelper.ACTION_STATE_SWIPE ||
|
binding.swipeRefresh.isEnabled = actionState != ItemTouchHelper.ACTION_STATE_SWIPE ||
|
||||||
swipe_refresh.isRefreshing
|
binding.swipeRefresh.isRefreshing
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handleSheetBack(): Boolean {
|
override fun handleSheetBack(): Boolean {
|
||||||
if (dl_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) {
|
if (binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) {
|
||||||
dl_bottom_sheet.dismiss()
|
binding.downloadBottomSheet.dlBottomSheet.dismiss()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setPadding(sheetIsHidden: Boolean) {
|
fun setPadding(sheetIsHidden: Boolean) {
|
||||||
recycler?.updatePaddingRelative(bottom = if (sheetIsHidden) 0 else 20.dpToPx)
|
binding.recycler.updatePaddingRelative(bottom = if (sheetIsHidden) 0 else 20.dpToPx)
|
||||||
recycler?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
binding.recycler.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
bottomMargin = if (sheetIsHidden) 0 else 30.dpToPx
|
bottomMargin = if (sheetIsHidden) 0 else 30.dpToPx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -279,7 +268,7 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
super.onActivityResumed(activity)
|
super.onActivityResumed(activity)
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
refresh()
|
refresh()
|
||||||
dl_bottom_sheet?.update()
|
binding.downloadBottomSheet.dlBottomSheet.update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,7 +283,7 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
|
|
||||||
fun showLists(recents: List<RecentMangaItem>) {
|
fun showLists(recents: List<RecentMangaItem>) {
|
||||||
if (view == null) return
|
if (view == null) return
|
||||||
swipe_refresh.isRefreshing = LibraryUpdateService.isRunning()
|
binding.swipeRefresh.isRefreshing = LibraryUpdateService.isRunning()
|
||||||
adapter.updateItems(recents)
|
adapter.updateItems(recents)
|
||||||
adapter.removeAllScrollableHeaders()
|
adapter.removeAllScrollableHeaders()
|
||||||
if (presenter.viewType > 0) {
|
if (presenter.viewType > 0) {
|
||||||
@ -308,11 +297,11 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
|
|
||||||
fun updateChapterDownload(download: Download) {
|
fun updateChapterDownload(download: Download) {
|
||||||
if (view == null) return
|
if (view == null) return
|
||||||
dl_bottom_sheet.update()
|
binding.downloadBottomSheet.dlBottomSheet.update()
|
||||||
dl_bottom_sheet.onUpdateProgress(download)
|
binding.downloadBottomSheet.dlBottomSheet.onUpdateProgress(download)
|
||||||
dl_bottom_sheet.onUpdateDownloadedPages(download)
|
binding.downloadBottomSheet.dlBottomSheet.onUpdateDownloadedPages(download)
|
||||||
val id = download.chapter.id ?: return
|
val id = download.chapter.id ?: return
|
||||||
val holder = recycler.findViewHolderForItemId(id) as? RecentMangaHolder ?: return
|
val holder = binding.recycler.findViewHolderForItemId(id) as? RecentMangaHolder ?: return
|
||||||
holder.notifyStatus(download.status, download.progress)
|
holder.notifyStatus(download.status, download.progress)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,7 +388,7 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
lastChapterId = chapter.id
|
lastChapterId = chapter.id
|
||||||
presenter.markChapterRead(chapter, true)
|
presenter.markChapterRead(chapter, true)
|
||||||
snack = view?.snack(R.string.marked_as_read, Snackbar.LENGTH_INDEFINITE) {
|
snack = view?.snack(R.string.marked_as_read, Snackbar.LENGTH_INDEFINITE) {
|
||||||
anchorView = activity?.bottom_nav
|
anchorView = activityBinding?.bottomNav
|
||||||
var undoing = false
|
var undoing = false
|
||||||
setAction(R.string.undo) {
|
setAction(R.string.undo) {
|
||||||
presenter.markChapterRead(chapter, false, lastRead, pagesLeft)
|
presenter.markChapterRead(chapter, false, lastRead, pagesLeft)
|
||||||
@ -457,14 +446,14 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
|
|
||||||
override fun onPrepareOptionsMenu(menu: Menu) {
|
override fun onPrepareOptionsMenu(menu: Menu) {
|
||||||
super.onPrepareOptionsMenu(menu)
|
super.onPrepareOptionsMenu(menu)
|
||||||
if (showingDownloads) dl_bottom_sheet.prepareMenu(menu)
|
if (showingDownloads) binding.downloadBottomSheet.dlBottomSheet.prepareMenu(menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||||
super.onChangeStarted(handler, type)
|
super.onChangeStarted(handler, type)
|
||||||
if (type.isEnter) {
|
if (type.isEnter) {
|
||||||
if (type == ControllerChangeType.POP_ENTER) presenter.onCreate()
|
if (type == ControllerChangeType.POP_ENTER) presenter.onCreate()
|
||||||
dl_bottom_sheet.dismiss()
|
binding.downloadBottomSheet.dlBottomSheet.dismiss()
|
||||||
} else {
|
} else {
|
||||||
if (type == ControllerChangeType.POP_EXIT) presenter.onDestroy()
|
if (type == ControllerChangeType.POP_EXIT) presenter.onDestroy()
|
||||||
snack?.dismiss()
|
snack?.dismiss()
|
||||||
@ -480,29 +469,29 @@ class RecentsController(bundle: Bundle? = null) :
|
|||||||
fun hasQueue() = presenter.downloadManager.hasQueue()
|
fun hasQueue() = presenter.downloadManager.hasQueue()
|
||||||
|
|
||||||
override fun showSheet() {
|
override fun showSheet() {
|
||||||
if (dl_bottom_sheet.sheetBehavior?.isHideable == false || hasQueue()) {
|
if (binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.isHideable == false || hasQueue()) {
|
||||||
dl_bottom_sheet.sheetBehavior?.expand()
|
binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.expand()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toggleSheet() {
|
override fun toggleSheet() {
|
||||||
if (showingDownloads) dl_bottom_sheet.dismiss()
|
if (showingDownloads) binding.downloadBottomSheet.dlBottomSheet.dismiss()
|
||||||
else dl_bottom_sheet.sheetBehavior?.expand()
|
else binding.downloadBottomSheet.dlBottomSheet.sheetBehavior?.expand()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun sheetIsExpanded(): Boolean = dl_bottom_sheet.sheetBehavior.isExpanded()
|
override fun sheetIsExpanded(): Boolean = binding.downloadBottomSheet.dlBottomSheet.sheetBehavior.isExpanded()
|
||||||
|
|
||||||
override fun expandSearch() {
|
override fun expandSearch() {
|
||||||
if (showingDownloads) {
|
if (showingDownloads) {
|
||||||
dl_bottom_sheet.dismiss()
|
binding.downloadBottomSheet.dlBottomSheet.dismiss()
|
||||||
} else {
|
} else {
|
||||||
activity?.toolbar?.menu?.findItem(R.id.action_search)?.expandActionView()
|
activityBinding?.toolbar?.menu?.findItem(R.id.action_search)?.expandActionView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
if (showingDownloads) {
|
if (showingDownloads) {
|
||||||
return dl_bottom_sheet.onOptionsItemSelected(item)
|
return binding.downloadBottomSheet.dlBottomSheet.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.action_group_all, R.id.action_ungroup_all, R.id.action_only_history,
|
R.id.action_group_all, R.id.action_ungroup_all, R.id.action_only_history,
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
android:layout_gravity="end|center"
|
android:layout_gravity="end|center"
|
||||||
android:layout_marginEnd="21dp"
|
android:layout_marginEnd="21dp"
|
||||||
android:src="@drawable/ic_eye_24dp"
|
android:src="@drawable/ic_eye_24dp"
|
||||||
android:tint="@color/md_white_1000" />
|
app:tint="@color/md_white_1000" />
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
@ -151,6 +151,7 @@
|
|||||||
|
|
||||||
<include
|
<include
|
||||||
layout="@layout/download_button"
|
layout="@layout/download_button"
|
||||||
|
android:id="@+id/download_button"
|
||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
|
@ -35,10 +35,11 @@
|
|||||||
android:alpha="0.5"
|
android:alpha="0.5"
|
||||||
android:background="@drawable/shape_gradient_top_shadow"
|
android:background="@drawable/shape_gradient_top_shadow"
|
||||||
android:paddingBottom="10dp"
|
android:paddingBottom="10dp"
|
||||||
app:layout_anchor="@id/dl_bottom_sheet"
|
app:layout_anchor="@id/download_bottom_sheet"
|
||||||
app:layout_anchorGravity="top" />
|
app:layout_anchorGravity="top" />
|
||||||
<!-- Adding bottom sheet after main content -->
|
<!-- Adding bottom sheet after main content -->
|
||||||
<include layout="@layout/download_bottom_sheet" />
|
<include layout="@layout/download_bottom_sheet"
|
||||||
|
android:id="@+id/download_bottom_sheet"/>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/shadow2"
|
android:id="@+id/shadow2"
|
||||||
|
Loading…
Reference in New Issue
Block a user