|
|
@ -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,
|
|
|
|