mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 22:09:16 +01:00
Minor changes for Kotlin 1.1
This commit is contained in:
parent
c00eaae62b
commit
5c67161dce
@ -176,8 +176,7 @@ class YamlHttpSource(mappings: Map<*, *>) : HttpSource() {
|
|||||||
|
|
||||||
val pages = mutableListOf<Page>()
|
val pages = mutableListOf<Page>()
|
||||||
|
|
||||||
// TODO lazy initialization in Kotlin 1.1
|
val document by lazy { Jsoup.parse(body, url) }
|
||||||
val document = Jsoup.parse(body, url)
|
|
||||||
|
|
||||||
with(map.pages) {
|
with(map.pages) {
|
||||||
// Capture a list of values where page urls will be resolved.
|
// Capture a list of values where page urls will be resolved.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package eu.kanade.tachiyomi.ui.base.fragment
|
package eu.kanade.tachiyomi.ui.base.fragment
|
||||||
|
|
||||||
import android.support.v7.app.AppCompatActivity
|
import android.support.v4.app.FragmentActivity
|
||||||
import eu.kanade.tachiyomi.ui.base.activity.ActivityMixin
|
import eu.kanade.tachiyomi.ui.base.activity.ActivityMixin
|
||||||
|
|
||||||
interface FragmentMixin {
|
interface FragmentMixin {
|
||||||
@ -13,7 +13,7 @@ interface FragmentMixin {
|
|||||||
(getActivity() as ActivityMixin).setToolbarTitle(getString(resourceId))
|
(getActivity() as ActivityMixin).setToolbarTitle(getString(resourceId))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getActivity(): AppCompatActivity
|
fun getActivity(): FragmentActivity
|
||||||
|
|
||||||
fun getString(resource: Int): String
|
fun getString(resource: Int): String
|
||||||
}
|
}
|
@ -4,6 +4,7 @@ import android.content.res.Configuration
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.design.widget.Snackbar
|
import android.support.design.widget.Snackbar
|
||||||
import android.support.v4.widget.DrawerLayout
|
import android.support.v4.widget.DrawerLayout
|
||||||
|
import android.support.v7.app.AppCompatActivity
|
||||||
import android.support.v7.widget.*
|
import android.support.v7.widget.*
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
@ -155,7 +156,7 @@ open class CatalogueFragment : BaseRxFragment<CataloguePresenter>(),
|
|||||||
setupRecycler()
|
setupRecycler()
|
||||||
|
|
||||||
// Create toolbar spinner
|
// Create toolbar spinner
|
||||||
val themedContext = activity.supportActionBar?.themedContext ?: activity
|
val themedContext = (activity as AppCompatActivity).supportActionBar?.themedContext ?: activity
|
||||||
|
|
||||||
val spinnerAdapter = ArrayAdapter(themedContext,
|
val spinnerAdapter = ArrayAdapter(themedContext,
|
||||||
android.R.layout.simple_spinner_item, presenter.sources)
|
android.R.layout.simple_spinner_item, presenter.sources)
|
||||||
|
@ -9,6 +9,7 @@ import android.support.design.widget.TabLayout
|
|||||||
import android.support.v4.graphics.drawable.DrawableCompat
|
import android.support.v4.graphics.drawable.DrawableCompat
|
||||||
import android.support.v4.view.ViewPager
|
import android.support.v4.view.ViewPager
|
||||||
import android.support.v4.widget.DrawerLayout
|
import android.support.v4.widget.DrawerLayout
|
||||||
|
import android.support.v7.app.AppCompatActivity
|
||||||
import android.support.v7.view.ActionMode
|
import android.support.v7.view.ActionMode
|
||||||
import android.support.v7.widget.SearchView
|
import android.support.v7.widget.SearchView
|
||||||
import android.view.*
|
import android.view.*
|
||||||
@ -356,7 +357,7 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
|
|||||||
*/
|
*/
|
||||||
fun createActionModeIfNeeded() {
|
fun createActionModeIfNeeded() {
|
||||||
if (actionMode == null) {
|
if (actionMode == null) {
|
||||||
actionMode = activity.startSupportActionMode(this)
|
actionMode = (activity as AppCompatActivity).startSupportActionMode(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,12 +177,9 @@ class LibraryPresenter : BasePresenter<LibraryFragment>() {
|
|||||||
private fun applySort(map: Map<Int, List<Manga>>): Map<Int, List<Manga>> {
|
private fun applySort(map: Map<Int, List<Manga>>): Map<Int, List<Manga>> {
|
||||||
val sortingMode = preferences.librarySortingMode().getOrDefault()
|
val sortingMode = preferences.librarySortingMode().getOrDefault()
|
||||||
|
|
||||||
// TODO lazy initialization in kotlin 1.1
|
val lastReadManga by lazy {
|
||||||
var lastReadManga: Map<Long, Int>? = null
|
|
||||||
if (sortingMode == LibrarySort.LAST_READ) {
|
|
||||||
var counter = 0
|
var counter = 0
|
||||||
lastReadManga = db.getLastReadManga().executeAsBlocking()
|
db.getLastReadManga().executeAsBlocking().associate { it.id!! to counter++ }
|
||||||
.associate { it.id!! to counter++ }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val sortFn: (Manga, Manga) -> Int = { manga1, manga2 ->
|
val sortFn: (Manga, Manga) -> Int = { manga1, manga2 ->
|
||||||
@ -190,8 +187,8 @@ class LibraryPresenter : BasePresenter<LibraryFragment>() {
|
|||||||
LibrarySort.ALPHA -> manga1.title.compareTo(manga2.title)
|
LibrarySort.ALPHA -> manga1.title.compareTo(manga2.title)
|
||||||
LibrarySort.LAST_READ -> {
|
LibrarySort.LAST_READ -> {
|
||||||
// Get index of manga, set equal to list if size unknown.
|
// Get index of manga, set equal to list if size unknown.
|
||||||
val manga1LastRead = lastReadManga!![manga1.id!!] ?: lastReadManga!!.size
|
val manga1LastRead = lastReadManga[manga1.id!!] ?: lastReadManga.size
|
||||||
val manga2LastRead = lastReadManga!![manga2.id!!] ?: lastReadManga!!.size
|
val manga2LastRead = lastReadManga[manga2.id!!] ?: lastReadManga.size
|
||||||
manga1LastRead.compareTo(manga2LastRead)
|
manga1LastRead.compareTo(manga2LastRead)
|
||||||
}
|
}
|
||||||
LibrarySort.LAST_UPDATED -> manga2.last_update.compareTo(manga1.last_update)
|
LibrarySort.LAST_UPDATED -> manga2.last_update.compareTo(manga1.last_update)
|
||||||
|
@ -6,6 +6,7 @@ import android.content.Intent
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.design.widget.Snackbar
|
import android.support.design.widget.Snackbar
|
||||||
import android.support.v4.app.DialogFragment
|
import android.support.v4.app.DialogFragment
|
||||||
|
import android.support.v7.app.AppCompatActivity
|
||||||
import android.support.v7.view.ActionMode
|
import android.support.v7.view.ActionMode
|
||||||
import android.support.v7.widget.DividerItemDecoration
|
import android.support.v7.widget.DividerItemDecoration
|
||||||
import android.support.v7.widget.LinearLayoutManager
|
import android.support.v7.widget.LinearLayoutManager
|
||||||
@ -420,7 +421,7 @@ class ChaptersFragment : BaseRxFragment<ChaptersPresenter>(), ActionMode.Callbac
|
|||||||
|
|
||||||
override fun onListItemLongClick(position: Int) {
|
override fun onListItemLongClick(position: Int) {
|
||||||
if (actionMode == null)
|
if (actionMode == null)
|
||||||
actionMode = activity.startSupportActionMode(this)
|
actionMode = (activity as AppCompatActivity).startSupportActionMode(this)
|
||||||
|
|
||||||
toggleSelection(position)
|
toggleSelection(position)
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.recent_updates
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v4.app.DialogFragment
|
import android.support.v4.app.DialogFragment
|
||||||
|
import android.support.v7.app.AppCompatActivity
|
||||||
import android.support.v7.view.ActionMode
|
import android.support.v7.view.ActionMode
|
||||||
import android.support.v7.widget.DividerItemDecoration
|
import android.support.v7.widget.DividerItemDecoration
|
||||||
import android.support.v7.widget.LinearLayoutManager
|
import android.support.v7.widget.LinearLayoutManager
|
||||||
@ -142,7 +143,7 @@ class RecentChaptersFragment:
|
|||||||
*/
|
*/
|
||||||
override fun onItemLongClick(position: Int) {
|
override fun onItemLongClick(position: Int) {
|
||||||
if (actionMode == null)
|
if (actionMode == null)
|
||||||
actionMode = activity.startSupportActionMode(this)
|
actionMode = (activity as AppCompatActivity).startSupportActionMode(this)
|
||||||
|
|
||||||
toggleSelection(position)
|
toggleSelection(position)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user