mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 19:27:25 +01:00
Move queue start/pause to FAB
This commit is contained in:
parent
be09dded20
commit
fc7a040509
@ -15,6 +15,9 @@ import eu.kanade.tachiyomi.source.model.Page
|
|||||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||||
import java.util.HashMap
|
import java.util.HashMap
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
import kotlinx.coroutines.flow.launchIn
|
||||||
|
import kotlinx.coroutines.flow.onEach
|
||||||
|
import reactivecircus.flowbinding.android.view.clicks
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import rx.Subscription
|
import rx.Subscription
|
||||||
import rx.android.schedulers.AndroidSchedulers
|
import rx.android.schedulers.AndroidSchedulers
|
||||||
@ -74,6 +77,21 @@ class DownloadController :
|
|||||||
binding.recycler.layoutManager = LinearLayoutManager(view.context)
|
binding.recycler.layoutManager = LinearLayoutManager(view.context)
|
||||||
binding.recycler.setHasFixedSize(true)
|
binding.recycler.setHasFixedSize(true)
|
||||||
|
|
||||||
|
binding.fab.clicks()
|
||||||
|
.onEach {
|
||||||
|
val context = applicationContext ?: return@onEach
|
||||||
|
|
||||||
|
if (isRunning) {
|
||||||
|
DownloadService.stop(context)
|
||||||
|
presenter.pauseDownloads()
|
||||||
|
} else {
|
||||||
|
DownloadService.start(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
setInformationView()
|
||||||
|
}
|
||||||
|
.launchIn(scope)
|
||||||
|
|
||||||
// Subscribe to changes
|
// Subscribe to changes
|
||||||
DownloadService.runningRelay
|
DownloadService.runningRelay
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
@ -102,8 +120,6 @@ class DownloadController :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onPrepareOptionsMenu(menu: Menu) {
|
override fun onPrepareOptionsMenu(menu: Menu) {
|
||||||
menu.findItem(R.id.start_queue).isVisible = !isRunning && !presenter.downloadQueue.isEmpty()
|
|
||||||
menu.findItem(R.id.pause_queue).isVisible = isRunning
|
|
||||||
menu.findItem(R.id.clear_queue).isVisible = !presenter.downloadQueue.isEmpty()
|
menu.findItem(R.id.clear_queue).isVisible = !presenter.downloadQueue.isEmpty()
|
||||||
menu.findItem(R.id.reorder).isVisible = !presenter.downloadQueue.isEmpty()
|
menu.findItem(R.id.reorder).isVisible = !presenter.downloadQueue.isEmpty()
|
||||||
}
|
}
|
||||||
@ -111,11 +127,6 @@ class DownloadController :
|
|||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
val context = applicationContext ?: return false
|
val context = applicationContext ?: return false
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.start_queue -> DownloadService.start(context)
|
|
||||||
R.id.pause_queue -> {
|
|
||||||
DownloadService.stop(context)
|
|
||||||
presenter.pauseDownloads()
|
|
||||||
}
|
|
||||||
R.id.clear_queue -> {
|
R.id.clear_queue -> {
|
||||||
DownloadService.stop(context)
|
DownloadService.stop(context)
|
||||||
presenter.clearQueue()
|
presenter.clearQueue()
|
||||||
@ -253,8 +264,18 @@ class DownloadController :
|
|||||||
private fun setInformationView() {
|
private fun setInformationView() {
|
||||||
if (presenter.downloadQueue.isEmpty()) {
|
if (presenter.downloadQueue.isEmpty()) {
|
||||||
binding.emptyView.show(R.string.information_no_downloads)
|
binding.emptyView.show(R.string.information_no_downloads)
|
||||||
|
binding.fab.hide()
|
||||||
} else {
|
} else {
|
||||||
binding.emptyView.hide()
|
binding.emptyView.hide()
|
||||||
|
binding.fab.show()
|
||||||
|
|
||||||
|
binding.fab.setImageResource(
|
||||||
|
if (isRunning) {
|
||||||
|
R.drawable.ic_pause_24dp
|
||||||
|
} else {
|
||||||
|
R.drawable.ic_play_arrow_24dp
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/frame_container"
|
android:id="@+id/frame_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -9,8 +10,17 @@
|
|||||||
android:id="@+id/recycler"
|
android:id="@+id/recycler"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:paddingBottom="@dimen/fab_list_padding"
|
||||||
tools:listitem="@layout/download_item" />
|
tools:listitem="@layout/download_item" />
|
||||||
|
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/fab"
|
||||||
|
style="@style/Theme.Widget.FAB"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_anchor="@id/recycler"
|
||||||
|
app:srcCompat="@drawable/ic_pause_24dp" />
|
||||||
|
|
||||||
<eu.kanade.tachiyomi.widget.EmptyView
|
<eu.kanade.tachiyomi.widget.EmptyView
|
||||||
android:id="@+id/empty_view"
|
android:id="@+id/empty_view"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -2,20 +2,6 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/start_queue"
|
|
||||||
android:icon="@drawable/ic_play_arrow_24dp"
|
|
||||||
android:title="@string/action_start"
|
|
||||||
app:iconTint="?attr/colorOnPrimary"
|
|
||||||
app:showAsAction="ifRoom" />
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/pause_queue"
|
|
||||||
android:icon="@drawable/ic_pause_24dp"
|
|
||||||
android:title="@string/action_pause"
|
|
||||||
app:iconTint="?attr/colorOnPrimary"
|
|
||||||
app:showAsAction="ifRoom" />
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/reorder"
|
android:id="@+id/reorder"
|
||||||
android:title="@string/action_reorganize_by"
|
android:title="@string/action_reorganize_by"
|
||||||
|
@ -67,7 +67,6 @@
|
|||||||
<string name="action_show_downloaded">Downloaded</string>
|
<string name="action_show_downloaded">Downloaded</string>
|
||||||
<string name="action_next_unread">Next unread</string>
|
<string name="action_next_unread">Next unread</string>
|
||||||
<string name="action_view_chapters">View chapters</string>
|
<string name="action_view_chapters">View chapters</string>
|
||||||
<string name="action_start">Start</string>
|
|
||||||
<string name="action_stop">Stop</string>
|
<string name="action_stop">Stop</string>
|
||||||
<string name="action_pause">Pause</string>
|
<string name="action_pause">Pause</string>
|
||||||
<string name="action_close">Close</string>
|
<string name="action_close">Close</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user