mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 04:49:17 +01:00
Remove some progress dialogs
This commit is contained in:
parent
3d10dad780
commit
d6e49be268
@ -24,7 +24,6 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
|||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
import eu.kanade.tachiyomi.databinding.ChaptersControllerBinding
|
import eu.kanade.tachiyomi.databinding.ChaptersControllerBinding
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.popControllerWithTag
|
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||||
import eu.kanade.tachiyomi.util.lang.launchInUI
|
import eu.kanade.tachiyomi.util.lang.launchInUI
|
||||||
@ -504,12 +503,10 @@ class ChaptersController : NucleusController<ChaptersControllerBinding, Chapters
|
|||||||
fun deleteChapters(chapters: List<ChapterItem>) {
|
fun deleteChapters(chapters: List<ChapterItem>) {
|
||||||
if (chapters.isEmpty()) return
|
if (chapters.isEmpty()) return
|
||||||
|
|
||||||
DeletingChaptersDialog().showDialog(router)
|
|
||||||
presenter.deleteChapters(chapters)
|
presenter.deleteChapters(chapters)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onChaptersDeleted(chapters: List<ChapterItem>) {
|
fun onChaptersDeleted(chapters: List<ChapterItem>) {
|
||||||
dismissDeletingDialog()
|
|
||||||
// this is needed so the downloaded text gets removed from the item
|
// this is needed so the downloaded text gets removed from the item
|
||||||
chapters.forEach {
|
chapters.forEach {
|
||||||
adapter?.updateItem(it)
|
adapter?.updateItem(it)
|
||||||
@ -518,14 +515,9 @@ class ChaptersController : NucleusController<ChaptersControllerBinding, Chapters
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun onChaptersDeletedError(error: Throwable) {
|
fun onChaptersDeletedError(error: Throwable) {
|
||||||
dismissDeletingDialog()
|
|
||||||
Timber.e(error)
|
Timber.e(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dismissDeletingDialog() {
|
|
||||||
router.popControllerWithTag(DeletingChaptersDialog.TAG)
|
|
||||||
}
|
|
||||||
|
|
||||||
// OVERFLOW MENU DIALOGS
|
// OVERFLOW MENU DIALOGS
|
||||||
|
|
||||||
private fun setDisplayMode(id: Int) {
|
private fun setDisplayMode(id: Int) {
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
package eu.kanade.tachiyomi.ui.manga.chapter
|
|
||||||
|
|
||||||
import android.app.Dialog
|
|
||||||
import android.os.Bundle
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
|
||||||
import com.bluelinelabs.conductor.Router
|
|
||||||
import eu.kanade.tachiyomi.R
|
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
|
||||||
|
|
||||||
class DeletingChaptersDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val TAG = "deleting_dialog"
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
|
||||||
return MaterialDialog.Builder(activity!!)
|
|
||||||
.progress(true, 0)
|
|
||||||
.content(R.string.deleting)
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun showDialog(router: Router) {
|
|
||||||
showDialog(router, TAG)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
package eu.kanade.tachiyomi.ui.recent.updates
|
|
||||||
|
|
||||||
import android.app.Dialog
|
|
||||||
import android.os.Bundle
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
|
||||||
import com.bluelinelabs.conductor.Router
|
|
||||||
import eu.kanade.tachiyomi.R
|
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
|
||||||
|
|
||||||
class DeletingChaptersDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val TAG = "deleting_dialog"
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
|
||||||
return MaterialDialog.Builder(activity!!)
|
|
||||||
.progress(true, 0)
|
|
||||||
.content(R.string.deleting)
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun showDialog(router: Router) {
|
|
||||||
showDialog(router, TAG)
|
|
||||||
}
|
|
||||||
}
|
|
@ -21,7 +21,6 @@ import eu.kanade.tachiyomi.databinding.UpdatesControllerBinding
|
|||||||
import eu.kanade.tachiyomi.ui.base.controller.NoToolbarElevationController
|
import eu.kanade.tachiyomi.ui.base.controller.NoToolbarElevationController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.RootController
|
import eu.kanade.tachiyomi.ui.base.controller.RootController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.popControllerWithTag
|
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||||
@ -262,7 +261,6 @@ class UpdatesController : NucleusController<UpdatesControllerBinding, UpdatesPre
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun deleteChapters(chaptersToDelete: List<UpdatesItem>) {
|
override fun deleteChapters(chaptersToDelete: List<UpdatesItem>) {
|
||||||
DeletingChaptersDialog().showDialog(router)
|
|
||||||
presenter.deleteChapters(chaptersToDelete)
|
presenter.deleteChapters(chaptersToDelete)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +284,6 @@ class UpdatesController : NucleusController<UpdatesControllerBinding, UpdatesPre
|
|||||||
* Called when chapters are deleted
|
* Called when chapters are deleted
|
||||||
*/
|
*/
|
||||||
fun onChaptersDeleted() {
|
fun onChaptersDeleted() {
|
||||||
dismissDeletingDialog()
|
|
||||||
adapter?.notifyDataSetChanged()
|
adapter?.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,17 +292,9 @@ class UpdatesController : NucleusController<UpdatesControllerBinding, UpdatesPre
|
|||||||
* @param error error message
|
* @param error error message
|
||||||
*/
|
*/
|
||||||
fun onChaptersDeletedError(error: Throwable) {
|
fun onChaptersDeletedError(error: Throwable) {
|
||||||
dismissDeletingDialog()
|
|
||||||
Timber.e(error)
|
Timber.e(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called to dismiss deleting dialog
|
|
||||||
*/
|
|
||||||
private fun dismissDeletingDialog() {
|
|
||||||
router.popControllerWithTag(DeletingChaptersDialog.TAG)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when ActionMode created.
|
* Called when ActionMode created.
|
||||||
* @param mode the ActionMode object
|
* @param mode the ActionMode object
|
||||||
|
@ -9,7 +9,6 @@ import android.os.Build
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import android.view.View
|
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.bluelinelabs.conductor.RouterTransaction
|
import com.bluelinelabs.conductor.RouterTransaction
|
||||||
@ -117,10 +116,6 @@ class SettingsAdvancedController : SettingsController() {
|
|||||||
|
|
||||||
var deletedFiles = 0
|
var deletedFiles = 0
|
||||||
|
|
||||||
val ctrl = DeletingFilesDialogController()
|
|
||||||
ctrl.total = files.size
|
|
||||||
ctrl.showDialog(router)
|
|
||||||
|
|
||||||
Observable.defer { Observable.from(files) }
|
Observable.defer { Observable.from(files) }
|
||||||
.doOnNext { file ->
|
.doOnNext { file ->
|
||||||
if (chapterCache.removeFileFromCache(file.name)) {
|
if (chapterCache.removeFileFromCache(file.name)) {
|
||||||
@ -129,50 +124,15 @@ class SettingsAdvancedController : SettingsController() {
|
|||||||
}
|
}
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe({
|
.doOnError {
|
||||||
ctrl.setProgress(deletedFiles)
|
|
||||||
}, {
|
|
||||||
activity?.toast(R.string.cache_delete_error)
|
activity?.toast(R.string.cache_delete_error)
|
||||||
}, {
|
}
|
||||||
ctrl.finish()
|
.doOnCompleted {
|
||||||
activity?.toast(resources?.getString(R.string.cache_deleted, deletedFiles))
|
activity?.toast(resources?.getString(R.string.cache_deleted, deletedFiles))
|
||||||
findPreference(CLEAR_CACHE_KEY)?.summary =
|
findPreference(CLEAR_CACHE_KEY)?.summary =
|
||||||
resources?.getString(R.string.used_cache, chapterCache.readableSize)
|
resources?.getString(R.string.used_cache, chapterCache.readableSize)
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
class DeletingFilesDialogController : DialogController() {
|
|
||||||
|
|
||||||
var total = 0
|
|
||||||
|
|
||||||
private var materialDialog: MaterialDialog? = null
|
|
||||||
|
|
||||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
|
||||||
return MaterialDialog.Builder(activity!!)
|
|
||||||
.title(R.string.deleting)
|
|
||||||
.progress(false, total, true)
|
|
||||||
.cancelable(false)
|
|
||||||
.build()
|
|
||||||
.also { materialDialog = it }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroyView(view: View) {
|
|
||||||
super.onDestroyView(view)
|
|
||||||
materialDialog = null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
|
||||||
super.onRestoreInstanceState(savedInstanceState)
|
|
||||||
finish()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setProgress(deletedFiles: Int) {
|
|
||||||
materialDialog?.setProgress(deletedFiles)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun finish() {
|
|
||||||
router.popController(this)
|
|
||||||
}
|
}
|
||||||
|
.subscribe()
|
||||||
}
|
}
|
||||||
|
|
||||||
class ClearDatabaseDialogController : DialogController() {
|
class ClearDatabaseDialogController : DialogController() {
|
||||||
|
@ -112,7 +112,6 @@
|
|||||||
<string name="action_webview_refresh">Refresh</string>
|
<string name="action_webview_refresh">Refresh</string>
|
||||||
|
|
||||||
<!-- Operations -->
|
<!-- Operations -->
|
||||||
<string name="deleting">Deleting…</string>
|
|
||||||
<string name="loading">Loading…</string>
|
<string name="loading">Loading…</string>
|
||||||
|
|
||||||
<!-- Shortcuts-->
|
<!-- Shortcuts-->
|
||||||
|
Loading…
Reference in New Issue
Block a user