mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-17 14:37:29 +01:00
Minor code cleanup
This commit is contained in:
@@ -363,7 +363,7 @@ open class BrowseCataloguePresenter(
|
||||
* @param selectedCategories selected categories
|
||||
*/
|
||||
fun updateMangaCategories(manga: Manga, selectedCategories: List<Category>) {
|
||||
if (!selectedCategories.isEmpty()) {
|
||||
if (selectedCategories.isNotEmpty()) {
|
||||
if (!manga.favorite)
|
||||
changeMangaFavorite(manga)
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ abstract class Pager(var currentPage: Int = 1) {
|
||||
fun onPageReceived(mangasPage: MangasPage) {
|
||||
val page = currentPage
|
||||
currentPage++
|
||||
hasNextPage = mangasPage.hasNextPage && !mangasPage.mangas.isEmpty()
|
||||
hasNextPage = mangasPage.hasNextPage && mangasPage.mangas.isNotEmpty()
|
||||
results.call(Pair(page, mangasPage.mangas))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +205,6 @@ open class CatalogueSearchPresenter(
|
||||
.map { Pair(source as CatalogueSource, it) }
|
||||
|
||||
}
|
||||
|
||||
.onBackpressureBuffer()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ (source, manga) ->
|
||||
|
||||
@@ -207,11 +207,11 @@ class CategoryController : NucleusController<CategoryPresenter>(),
|
||||
*/
|
||||
override fun onItemClick(view: View, position: Int): Boolean {
|
||||
// Check if action mode is initialized and selected item exist.
|
||||
if (actionMode != null && position != RecyclerView.NO_POSITION) {
|
||||
return if (actionMode != null && position != RecyclerView.NO_POSITION) {
|
||||
toggleSelection(position)
|
||||
return true
|
||||
true
|
||||
} else {
|
||||
return false
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,9 +33,9 @@ class CategoryCreateDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
|
||||
.title(R.string.action_add_category)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.alwaysCallInputCallback()
|
||||
.input(resources?.getString(R.string.name), currentName, false, { _, input ->
|
||||
.input(resources?.getString(R.string.name), currentName, false) { _, input ->
|
||||
currentName = input.toString()
|
||||
})
|
||||
}
|
||||
.onPositive { _, _ -> (targetController as? Listener)?.createCategory(currentName) }
|
||||
.build()
|
||||
}
|
||||
@@ -44,4 +44,4 @@ class CategoryCreateDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
|
||||
fun createCategory(name: String)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,9 +38,9 @@ class CategoryRenameDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
|
||||
.title(R.string.action_rename_category)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.alwaysCallInputCallback()
|
||||
.input(resources!!.getString(R.string.name), currentName, false, { _, input ->
|
||||
.input(resources!!.getString(R.string.name), currentName, false) { _, input ->
|
||||
currentName = input.toString()
|
||||
})
|
||||
}
|
||||
.onPositive { _, _ -> onPositive() }
|
||||
.build()
|
||||
}
|
||||
@@ -83,4 +83,4 @@ class CategoryRenameDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
|
||||
const val CATEGORY_KEY = "CategoryRenameDialog.category"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ class DownloadPresenter : BasePresenter<DownloadController>() {
|
||||
downloadQueue.getUpdatedObservable()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.map { ArrayList(it) }
|
||||
.subscribeLatestCache(DownloadController::onNextDownloads, { _, error ->
|
||||
.subscribeLatestCache(DownloadController::onNextDownloads) { _, error ->
|
||||
Timber.e(error)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fun getDownloadStatusObservable(): Observable<Download> {
|
||||
@@ -62,4 +62,4 @@ class DownloadPresenter : BasePresenter<DownloadController>() {
|
||||
downloadManager.clearQueue()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ open class ExtensionController : NucleusController<ExtensionPresenter>(),
|
||||
val searchView = searchItem.actionView as SearchView
|
||||
searchView.maxWidth = Int.MAX_VALUE
|
||||
|
||||
if (!query.isEmpty()) {
|
||||
if (query.isNotEmpty()) {
|
||||
searchItem.expandActionView()
|
||||
searchView.setQuery(query, true)
|
||||
searchView.clearFocus()
|
||||
|
||||
@@ -178,7 +178,7 @@ class LibraryController(
|
||||
override fun createSecondaryDrawer(drawer: DrawerLayout): ViewGroup {
|
||||
val view = drawer.inflate(R.layout.library_drawer) as LibraryNavigationView
|
||||
navView = view
|
||||
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.END)
|
||||
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, GravityCompat.END)
|
||||
|
||||
navView?.onGroupClicked = { group ->
|
||||
when (group) {
|
||||
|
||||
@@ -209,9 +209,9 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
|
||||
item.group.items.forEach { (it as Item.Radio).checked = false }
|
||||
item.checked = true
|
||||
|
||||
preferences.libraryAsList().set(if (item == list) true else false)
|
||||
preferences.libraryAsList().set(item == list)
|
||||
|
||||
item.group.items.forEach { adapter.notifyItemChanged(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,12 +89,15 @@ class LibraryPresenter(
|
||||
fun subscribeLibrary() {
|
||||
if (librarySubscription.isNullOrUnsubscribed()) {
|
||||
librarySubscription = getLibraryObservable()
|
||||
.combineLatest(downloadTriggerRelay.observeOn(Schedulers.io()),
|
||||
{ lib, _ -> lib.apply { setDownloadCount(mangaMap) } })
|
||||
.combineLatest(filterTriggerRelay.observeOn(Schedulers.io()),
|
||||
{ lib, _ -> lib.copy(mangaMap = applyFilters(lib.mangaMap)) })
|
||||
.combineLatest(sortTriggerRelay.observeOn(Schedulers.io()),
|
||||
{ lib, _ -> lib.copy(mangaMap = applySort(lib.mangaMap)) })
|
||||
.combineLatest(downloadTriggerRelay.observeOn(Schedulers.io())) {
|
||||
lib, _ -> lib.apply { setDownloadCount(mangaMap) }
|
||||
}
|
||||
.combineLatest(filterTriggerRelay.observeOn(Schedulers.io())) {
|
||||
lib, _ -> lib.copy(mangaMap = applyFilters(lib.mangaMap))
|
||||
}
|
||||
.combineLatest(sortTriggerRelay.observeOn(Schedulers.io())) {
|
||||
lib, _ -> lib.copy(mangaMap = applySort(lib.mangaMap))
|
||||
}
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeLatestCache({ view, (categories, mangaMap) ->
|
||||
view.onNextLibraryUpdate(categories, mangaMap)
|
||||
@@ -222,16 +225,16 @@ class LibraryPresenter(
|
||||
* @return an observable of the categories and its manga.
|
||||
*/
|
||||
private fun getLibraryObservable(): Observable<Library> {
|
||||
return Observable.combineLatest(getCategoriesObservable(), getLibraryMangasObservable(),
|
||||
{ dbCategories, libraryManga ->
|
||||
val categories = if (libraryManga.containsKey(0))
|
||||
arrayListOf(Category.createDefault()) + dbCategories
|
||||
else
|
||||
dbCategories
|
||||
return Observable.combineLatest(getCategoriesObservable(), getLibraryMangasObservable()) {
|
||||
dbCategories, libraryManga ->
|
||||
val categories = if (libraryManga.containsKey(0))
|
||||
arrayListOf(Category.createDefault()) + dbCategories
|
||||
else
|
||||
dbCategories
|
||||
|
||||
this.categories = categories
|
||||
Library(categories, libraryManga)
|
||||
})
|
||||
this.categories = categories
|
||||
Library(categories, libraryManga)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,7 @@ import it.gmariotti.changelibs.library.view.ChangeLogRecyclerView
|
||||
|
||||
class ChangelogDialogController : DialogController() {
|
||||
|
||||
override fun onCreateDialog(savedState: Bundle?): Dialog {
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
val activity = activity!!
|
||||
val view = WhatsNewRecyclerView(activity)
|
||||
return MaterialDialog.Builder(activity)
|
||||
@@ -29,4 +29,4 @@ class ChangelogDialogController : DialogController() {
|
||||
mChangeLogFileResourceId = if (BuildConfig.DEBUG) R.raw.changelog_debug else R.raw.changelog_release
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ class MainActivity : BaseActivity() {
|
||||
|
||||
//Get the search query provided in extras, and if not null, perform a global search with it.
|
||||
val query = intent.getStringExtra(SearchManager.QUERY)
|
||||
if (query != null && !query.isEmpty()) {
|
||||
if (query != null && query.isNotEmpty()) {
|
||||
if (router.backstackSize > 1) {
|
||||
router.popToRoot()
|
||||
}
|
||||
@@ -180,7 +180,7 @@ class MainActivity : BaseActivity() {
|
||||
INTENT_SEARCH -> {
|
||||
val query = intent.getStringExtra(INTENT_SEARCH_QUERY)
|
||||
val filter = intent.getStringExtra(INTENT_SEARCH_FILTER)
|
||||
if (query != null && !query.isEmpty()) {
|
||||
if (query != null && query.isNotEmpty()) {
|
||||
if (router.backstackSize > 1) {
|
||||
router.popToRoot()
|
||||
}
|
||||
|
||||
@@ -109,8 +109,9 @@ class ChaptersPresenter(
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.filter { download -> download.manga.id == manga.id }
|
||||
.doOnNext { onDownloadStatusChange(it) }
|
||||
.subscribeLatestCache(ChaptersController::onChapterStatusChange,
|
||||
{ _, error -> Timber.e(error) })
|
||||
.subscribeLatestCache(ChaptersController::onChapterStatusChange) {
|
||||
_, error -> Timber.e(error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,7 +13,7 @@ class DeletingChaptersDialog(bundle: Bundle? = null) : DialogController(bundle)
|
||||
const val TAG = "deleting_dialog"
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedState: Bundle?): Dialog {
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
return MaterialDialog.Builder(activity!!)
|
||||
.progress(true, 0)
|
||||
.content(R.string.deleting)
|
||||
@@ -24,4 +24,4 @@ class DeletingChaptersDialog(bundle: Bundle? = null) : DialogController(bundle)
|
||||
showDialog(router, TAG)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,11 +195,7 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
}
|
||||
|
||||
// If manga source is known update source TextView.
|
||||
manga_source.text = if (source == null) {
|
||||
view.context.getString(R.string.unknown)
|
||||
} else {
|
||||
source.toString()
|
||||
}
|
||||
manga_source.text = source?.toString() ?: view.context.getString(R.string.unknown)
|
||||
|
||||
// Update genres list
|
||||
if (manga.genre.isNullOrBlank().not()) {
|
||||
|
||||
@@ -32,7 +32,7 @@ class SetTrackStatusDialog<T> : DialogController
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
val item = item
|
||||
val statusList = item.service.getStatusList().orEmpty()
|
||||
val statusList = item.service.getStatusList()
|
||||
val statusString = statusList.mapNotNull { item.service.getStatus(it) }
|
||||
val selectedIndex = statusList.indexOf(item.track?.status)
|
||||
|
||||
@@ -40,10 +40,10 @@ class SetTrackStatusDialog<T> : DialogController
|
||||
.title(R.string.status)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.items(statusString)
|
||||
.itemsCallbackSingleChoice(selectedIndex, { _, _, i, _ ->
|
||||
.itemsCallbackSingleChoice(selectedIndex) { _, _, i, _ ->
|
||||
(targetController as? Listener)?.setStatus(item, i)
|
||||
true
|
||||
})
|
||||
}
|
||||
.build()
|
||||
}
|
||||
|
||||
@@ -55,4 +55,4 @@ class SetTrackStatusDialog<T> : DialogController
|
||||
const val KEY_ITEM_TRACK = "SetTrackStatusDialog.item.track"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class TrackHolder(view: View, adapter: TrackAdapter) : BaseViewHolder(view) {
|
||||
logo_container.setBackgroundColor(item.service.getLogoColor())
|
||||
if (track != null) {
|
||||
track_title.setTextAppearance(itemView.context, R.style.TextAppearance_Regular_Body1_Secondary)
|
||||
track_title.setAllCaps(false)
|
||||
track_title.isAllCaps = false
|
||||
track_title.text = track.title
|
||||
track_chapters.text = "${track.last_chapter_read}/" +
|
||||
if (track.total_chapters > 0) track.total_chapters else "-"
|
||||
|
||||
@@ -50,7 +50,7 @@ class TrackSearchDialog : DialogController {
|
||||
service = Injekt.get<TrackManager>().getService(bundle.getInt(KEY_SERVICE))!!
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedState: Bundle?): Dialog {
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
val dialog = MaterialDialog.Builder(activity!!)
|
||||
.customView(R.layout.track_search_dialog, false)
|
||||
.positiveText(android.R.string.ok)
|
||||
@@ -63,7 +63,7 @@ class TrackSearchDialog : DialogController {
|
||||
}
|
||||
|
||||
dialogView = dialog.view
|
||||
onViewCreated(dialog.view, savedState)
|
||||
onViewCreated(dialog.view, savedViewState)
|
||||
|
||||
return dialog
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ class MigrationPresenter(
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnNext { state = state.copy(sourcesWithManga = findSourcesWithManga(it)) }
|
||||
.combineLatest(stateRelay.map { it.selectedSource }
|
||||
.distinctUntilChanged(),
|
||||
{ library, source -> library to source })
|
||||
.distinctUntilChanged()
|
||||
) { library, source -> library to source }
|
||||
.filter { (_, source) -> source != null }
|
||||
.observeOn(Schedulers.io())
|
||||
.map { (library, source) -> libraryToMigrationItem(library, source!!.id) }
|
||||
|
||||
@@ -77,13 +77,13 @@ class SearchController(
|
||||
.content(R.string.migration_dialog_what_to_include)
|
||||
.items(MigrationFlags.titles.map { resources?.getString(it) })
|
||||
.alwaysCallMultiChoiceCallback()
|
||||
.itemsCallbackMultiChoice(preselected.toTypedArray(), { _, positions, _ ->
|
||||
.itemsCallbackMultiChoice(preselected.toTypedArray()) { _, positions, _ ->
|
||||
// Save current settings for the next time
|
||||
val newValue = MigrationFlags.getFlagsFromPositions(positions)
|
||||
preferences.migrateFlags().set(newValue)
|
||||
|
||||
true
|
||||
})
|
||||
}
|
||||
.positiveText(R.string.migrate)
|
||||
.negativeText(R.string.copy)
|
||||
.neutralText(android.R.string.cancel)
|
||||
@@ -98,4 +98,4 @@ class SearchController(
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import timber.log.Timber
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.io.File
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.math.abs
|
||||
|
||||
/**
|
||||
* Activity containing the reader of Tachiyomi. This activity is mostly a container of the
|
||||
@@ -692,18 +693,22 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
*/
|
||||
private fun setCustomBrightnessValue(value: Int) {
|
||||
// Calculate and set reader brightness.
|
||||
val readerBrightness = if (value > 0) {
|
||||
value / 100f
|
||||
} else if (value < 0) {
|
||||
0.01f
|
||||
} else WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
|
||||
val readerBrightness = when {
|
||||
value > 0 -> {
|
||||
value / 100f
|
||||
}
|
||||
value < 0 -> {
|
||||
0.01f
|
||||
}
|
||||
else -> WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
|
||||
}
|
||||
|
||||
window.attributes = window.attributes.apply { screenBrightness = readerBrightness }
|
||||
|
||||
// Set black overlay visibility.
|
||||
if (value < 0) {
|
||||
brightness_overlay.visibility = View.VISIBLE
|
||||
val alpha = (Math.abs(value) * 2.56).toInt()
|
||||
val alpha = (abs(value) * 2.56).toInt()
|
||||
brightness_overlay.setBackgroundColor(Color.argb(alpha, 0, 0, 0))
|
||||
} else {
|
||||
brightness_overlay.visibility = View.GONE
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package eu.kanade.tachiyomi.ui.reader
|
||||
|
||||
import android.graphics.Color
|
||||
import androidx.annotation.ColorInt
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.SeekBar
|
||||
import androidx.annotation.ColorInt
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
@@ -14,12 +14,14 @@ import eu.kanade.tachiyomi.util.plusAssign
|
||||
import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener
|
||||
import eu.kanade.tachiyomi.widget.SimpleSeekBarListener
|
||||
import kotlinx.android.synthetic.main.reader_color_filter.*
|
||||
import kotlinx.android.synthetic.main.reader_color_filter_sheet.*
|
||||
import kotlinx.android.synthetic.main.reader_color_filter_sheet.brightness_overlay
|
||||
import kotlinx.android.synthetic.main.reader_color_filter_sheet.color_overlay
|
||||
import rx.Subscription
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.subscriptions.CompositeSubscription
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.math.abs
|
||||
|
||||
/**
|
||||
* Color filter sheet to toggle custom filter and brightness overlay.
|
||||
@@ -221,7 +223,7 @@ class ReaderColorFilterSheet(activity: ReaderActivity) : BottomSheetDialog(activ
|
||||
// Set black overlay visibility.
|
||||
if (value < 0) {
|
||||
brightness_overlay.visibility = View.VISIBLE
|
||||
val alpha = (Math.abs(value) * 2.56).toInt()
|
||||
val alpha = (abs(value) * 2.56).toInt()
|
||||
brightness_overlay.setBackgroundColor(Color.argb(alpha, 0, 0, 0))
|
||||
} else {
|
||||
brightness_overlay.visibility = View.GONE
|
||||
|
||||
@@ -13,7 +13,7 @@ class ReaderColorFilterView(
|
||||
private val colorFilterPaint: Paint = Paint()
|
||||
|
||||
fun setFilterColor(color: Int, filterMode: Int) {
|
||||
colorFilterPaint.setColor(color)
|
||||
colorFilterPaint.color = color
|
||||
colorFilterPaint.xfermode = PorterDuffXfermode(when (filterMode) {
|
||||
1 -> PorterDuff.Mode.MULTIPLY
|
||||
2 -> PorterDuff.Mode.SCREEN
|
||||
|
||||
@@ -90,7 +90,7 @@ class ReaderPresenter(
|
||||
|
||||
val chaptersForReader =
|
||||
if (preferences.skipRead()) {
|
||||
var list = dbChapters.filter { it -> !it.read }.toMutableList()
|
||||
val list = dbChapters.filter { !it.read }.toMutableList()
|
||||
val find = list.find { it.id == chapterId }
|
||||
if (find == null) {
|
||||
list.add(selectedChapter)
|
||||
|
||||
@@ -57,8 +57,9 @@ class SaveImageNotifier(private val context: Context) {
|
||||
setStyle(NotificationCompat.BigPictureStyle().bigPicture(image))
|
||||
setLargeIcon(image)
|
||||
setAutoCancel(true)
|
||||
|
||||
// Clear old actions if they exist
|
||||
if (!mActions.isEmpty())
|
||||
if (mActions.isNotEmpty())
|
||||
mActions.clear()
|
||||
|
||||
setContentIntent(NotificationHandler.openImagePendingActivity(context, file))
|
||||
@@ -70,8 +71,8 @@ class SaveImageNotifier(private val context: Context) {
|
||||
addAction(R.drawable.ic_delete_grey_24dp,
|
||||
context.getString(R.string.action_delete),
|
||||
NotificationReceiver.deleteImagePendingBroadcast(context, file.absolutePath, notificationId))
|
||||
updateNotification()
|
||||
|
||||
updateNotification()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +88,6 @@ class SaveImageNotifier(private val context: Context) {
|
||||
context.notificationManager.notify(notificationId, notificationBuilder.build())
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called on error while downloading image.
|
||||
* @param error string containing error information.
|
||||
|
||||
@@ -12,20 +12,6 @@ sealed class ChapterTransition {
|
||||
override val from: ReaderChapter, override val to: ReaderChapter?
|
||||
) : ChapterTransition()
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is ChapterTransition) return false
|
||||
if (from == other.from && to == other.to) return true
|
||||
if (from == other.to && to == other.from) return true
|
||||
return false
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = from.hashCode()
|
||||
result = 31 * result + (to?.hashCode() ?: 0)
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "${javaClass.simpleName}(from=${from.chapter.url}, to=${to?.chapter?.url})"
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.os.Handler
|
||||
import android.view.GestureDetector
|
||||
import android.view.MotionEvent
|
||||
import android.view.ViewConfiguration
|
||||
import kotlin.math.abs
|
||||
|
||||
/**
|
||||
* A custom gesture detector that also implements an on long tap confirmed, because the built-in
|
||||
@@ -45,7 +46,7 @@ open class GestureDetectorWithLongTap(
|
||||
}
|
||||
}
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
if (Math.abs(ev.rawX - downX) > slop || Math.abs(ev.rawY - downY) > slop) {
|
||||
if (abs(ev.rawX - downX) > slop || abs(ev.rawY - downY) > slop) {
|
||||
handler.removeCallbacks(longTapFn)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import android.view.animation.LinearInterpolator
|
||||
import android.view.animation.RotateAnimation
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.getResourceColor
|
||||
import kotlin.math.min
|
||||
|
||||
/**
|
||||
* A custom progress bar that always rotates while being determinate. By always rotating we give
|
||||
@@ -75,7 +76,7 @@ class ReaderProgressBar @JvmOverloads constructor(
|
||||
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
|
||||
super.onLayout(changed, left, top, right, bottom)
|
||||
|
||||
val diameter = Math.min(width, height)
|
||||
val diameter = min(width, height)
|
||||
val thickness = diameter / 10f
|
||||
val pad = thickness / 2f
|
||||
ovalRect.set(pad, pad, diameter - pad, diameter - pad)
|
||||
|
||||
@@ -12,6 +12,7 @@ import android.view.animation.DecelerateInterpolator
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.GestureDetectorWithLongTap
|
||||
import kotlin.math.abs
|
||||
|
||||
/**
|
||||
* Implementation of a [RecyclerView] used by the webtoon reader.
|
||||
@@ -267,7 +268,7 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
if (!isZoomDragging && currentScale > 1f) {
|
||||
var startScroll = false
|
||||
|
||||
if (Math.abs(dx) > touchSlop) {
|
||||
if (abs(dx) > touchSlop) {
|
||||
if (dx < 0) {
|
||||
dx += touchSlop
|
||||
} else {
|
||||
@@ -275,7 +276,7 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
}
|
||||
startScroll = true
|
||||
}
|
||||
if (Math.abs(dy) > touchSlop) {
|
||||
if (abs(dy) > touchSlop) {
|
||||
if (dy < 0) {
|
||||
dy += touchSlop
|
||||
} else {
|
||||
|
||||
@@ -13,7 +13,7 @@ class DeletingChaptersDialog(bundle: Bundle? = null) : DialogController(bundle)
|
||||
const val TAG = "deleting_dialog"
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedState: Bundle?): Dialog {
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
return MaterialDialog.Builder(activity!!)
|
||||
.progress(true, 0)
|
||||
.content(R.string.deleting)
|
||||
@@ -24,4 +24,4 @@ class DeletingChaptersDialog(bundle: Bundle? = null) : DialogController(bundle)
|
||||
showDialog(router, TAG)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,9 @@ class RecentChaptersPresenter(
|
||||
.subscribeLatestCache(RecentChaptersController::onNextRecentChapters)
|
||||
|
||||
getChapterStatusObservable()
|
||||
.subscribeLatestCache(RecentChaptersController::onChapterStatusChange,
|
||||
{ _, error -> Timber.e(error) })
|
||||
.subscribeLatestCache(RecentChaptersController::onChapterStatusChange) {
|
||||
_, error -> Timber.e(error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,7 @@ class AnilistLoginActivity : AppCompatActivity() {
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
returnToSettings()
|
||||
}, { _ ->
|
||||
}, {
|
||||
returnToSettings()
|
||||
})
|
||||
} else {
|
||||
|
||||
@@ -61,14 +61,16 @@ inline fun <P : Preference> PreferenceGroup.initThenAdd(p: P, block: P.() -> Uni
|
||||
return p.apply {
|
||||
block()
|
||||
this.isIconSpaceReserved = false
|
||||
addPreference(this) }
|
||||
addPreference(this)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <P : Preference> PreferenceGroup.addThenInit(p: P, block: P.() -> Unit): P {
|
||||
return p.apply {
|
||||
this.isIconSpaceReserved = false
|
||||
addPreference(this)
|
||||
block() }
|
||||
block()
|
||||
}
|
||||
}
|
||||
|
||||
inline fun Preference.onClick(crossinline block: () -> Unit) {
|
||||
|
||||
@@ -206,7 +206,7 @@ class SettingsBackupController : SettingsController() {
|
||||
.content(R.string.backup_choice)
|
||||
.items(options)
|
||||
.itemsDisabledIndices(0)
|
||||
.itemsCallbackMultiChoice(arrayOf(0, 1, 2, 3, 4), { _, positions, _ ->
|
||||
.itemsCallbackMultiChoice(arrayOf(0, 1, 2, 3, 4)) { _, positions, _ ->
|
||||
var flags = 0
|
||||
for (i in 1 until positions.size) {
|
||||
when (positions[i]) {
|
||||
@@ -219,7 +219,7 @@ class SettingsBackupController : SettingsController() {
|
||||
|
||||
(targetController as? SettingsBackupController)?.createBackup(flags)
|
||||
true
|
||||
})
|
||||
}
|
||||
.positiveText(R.string.action_create)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.build()
|
||||
|
||||
@@ -147,7 +147,7 @@ class SettingsDownloadController : SettingsController() {
|
||||
|
||||
return MaterialDialog.Builder(activity)
|
||||
.items(externalDirs)
|
||||
.itemsCallbackSingleChoice(selectedIndex, { _, _, which, text ->
|
||||
.itemsCallbackSingleChoice(selectedIndex) { _, _, which, text ->
|
||||
val target = targetController as? SettingsDownloadController
|
||||
if (which == externalDirs.lastIndex) {
|
||||
target?.customDirectorySelected(currentDir)
|
||||
@@ -155,7 +155,7 @@ class SettingsDownloadController : SettingsController() {
|
||||
target?.predefinedDirectorySelected(text.toString())
|
||||
}
|
||||
true
|
||||
})
|
||||
}
|
||||
.build()
|
||||
}
|
||||
|
||||
|
||||
@@ -79,8 +79,8 @@ class SettingsGeneralController : SettingsController() {
|
||||
|
||||
Observable.combineLatest(
|
||||
preferences.portraitColumns().asObservable(),
|
||||
preferences.landscapeColumns().asObservable(),
|
||||
{ portraitCols, landscapeCols -> Pair(portraitCols, landscapeCols) })
|
||||
preferences.landscapeColumns().asObservable()
|
||||
) { portraitCols, landscapeCols -> Pair(portraitCols, landscapeCols) }
|
||||
.subscribeUntilDestroy { (portraitCols, landscapeCols) ->
|
||||
val portrait = getColumnValue(portraitCols)
|
||||
val landscape = getColumnValue(landscapeCols)
|
||||
|
||||
Reference in New Issue
Block a user