mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 19:27:25 +01:00
Some bugfixes
This commit is contained in:
parent
deaba48431
commit
17a6ea973e
@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.catalogue
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v7.widget.GridLayoutManager
|
import android.support.v7.widget.GridLayoutManager
|
||||||
import android.support.v7.widget.LinearLayoutManager
|
|
||||||
import android.support.v7.widget.SearchView
|
import android.support.v7.widget.SearchView
|
||||||
import android.support.v7.widget.Toolbar
|
import android.support.v7.widget.Toolbar
|
||||||
import android.view.*
|
import android.view.*
|
||||||
@ -24,6 +23,7 @@ import eu.kanade.tachiyomi.util.snack
|
|||||||
import eu.kanade.tachiyomi.util.toast
|
import eu.kanade.tachiyomi.util.toast
|
||||||
import eu.kanade.tachiyomi.widget.EndlessGridScrollListener
|
import eu.kanade.tachiyomi.widget.EndlessGridScrollListener
|
||||||
import eu.kanade.tachiyomi.widget.EndlessListScrollListener
|
import eu.kanade.tachiyomi.widget.EndlessListScrollListener
|
||||||
|
import eu.kanade.tachiyomi.widget.NpaLinearLayoutManager
|
||||||
import kotlinx.android.synthetic.main.fragment_catalogue.*
|
import kotlinx.android.synthetic.main.fragment_catalogue.*
|
||||||
import kotlinx.android.synthetic.main.toolbar.*
|
import kotlinx.android.synthetic.main.toolbar.*
|
||||||
import nucleus.factory.RequiresPresenter
|
import nucleus.factory.RequiresPresenter
|
||||||
@ -150,7 +150,7 @@ class CatalogueFragment : BaseRxFragment<CataloguePresenter>(), FlexibleViewHold
|
|||||||
catalogue_grid.adapter = adapter
|
catalogue_grid.adapter = adapter
|
||||||
catalogue_grid.addOnScrollListener(gridScrollListener)
|
catalogue_grid.addOnScrollListener(gridScrollListener)
|
||||||
|
|
||||||
val llm = LinearLayoutManager(activity)
|
val llm = NpaLinearLayoutManager(activity)
|
||||||
listScrollListener = EndlessListScrollListener(llm, { requestNextPage() })
|
listScrollListener = EndlessListScrollListener(llm, { requestNextPage() })
|
||||||
catalogue_list.setHasFixedSize(true)
|
catalogue_list.setHasFixedSize(true)
|
||||||
catalogue_list.adapter = adapter
|
catalogue_list.adapter = adapter
|
||||||
|
@ -42,7 +42,7 @@ class CatalogueGridHolder(private val view: View, private val adapter: Catalogue
|
|||||||
* @param manga the manga to bind.
|
* @param manga the manga to bind.
|
||||||
*/
|
*/
|
||||||
fun setImage(manga: Manga) {
|
fun setImage(manga: Manga) {
|
||||||
if (manga.thumbnail_url != null) {
|
if (!manga.thumbnail_url.isNullOrEmpty()) {
|
||||||
val url = manga.thumbnail_url!!
|
val url = manga.thumbnail_url!!
|
||||||
val headers = adapter.fragment.presenter.source.glideHeaders
|
val headers = adapter.fragment.presenter.source.glideHeaders
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v7.view.ActionMode
|
import android.support.v7.view.ActionMode
|
||||||
import android.support.v7.widget.LinearLayoutManager
|
|
||||||
import android.support.v7.widget.RecyclerView
|
import android.support.v7.widget.RecyclerView
|
||||||
import android.support.v7.widget.helper.ItemTouchHelper
|
import android.support.v7.widget.helper.ItemTouchHelper
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
@ -16,6 +15,7 @@ import eu.kanade.tachiyomi.data.database.models.Category
|
|||||||
import eu.kanade.tachiyomi.ui.base.activity.BaseRxActivity
|
import eu.kanade.tachiyomi.ui.base.activity.BaseRxActivity
|
||||||
import eu.kanade.tachiyomi.ui.base.adapter.FlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.adapter.FlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.ui.base.adapter.OnStartDragListener
|
import eu.kanade.tachiyomi.ui.base.adapter.OnStartDragListener
|
||||||
|
import eu.kanade.tachiyomi.widget.NpaLinearLayoutManager
|
||||||
import kotlinx.android.synthetic.main.activity_edit_categories.*
|
import kotlinx.android.synthetic.main.activity_edit_categories.*
|
||||||
import kotlinx.android.synthetic.main.toolbar.*
|
import kotlinx.android.synthetic.main.toolbar.*
|
||||||
import nucleus.factory.RequiresPresenter
|
import nucleus.factory.RequiresPresenter
|
||||||
@ -70,7 +70,7 @@ class CategoryActivity : BaseRxActivity<CategoryPresenter>(), ActionMode.Callbac
|
|||||||
adapter = CategoryAdapter(this)
|
adapter = CategoryAdapter(this)
|
||||||
|
|
||||||
// Create view and inject category items into view
|
// Create view and inject category items into view
|
||||||
recycler.layoutManager = LinearLayoutManager(this)
|
recycler.layoutManager = NpaLinearLayoutManager(this)
|
||||||
recycler.setHasFixedSize(true)
|
recycler.setHasFixedSize(true)
|
||||||
recycler.adapter = adapter
|
recycler.adapter = adapter
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package eu.kanade.tachiyomi.ui.download
|
package eu.kanade.tachiyomi.ui.download
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v7.widget.LinearLayoutManager
|
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadService
|
import eu.kanade.tachiyomi.data.download.DownloadService
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment
|
import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment
|
||||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||||
|
import eu.kanade.tachiyomi.widget.NpaLinearLayoutManager
|
||||||
import kotlinx.android.synthetic.main.fragment_download_queue.*
|
import kotlinx.android.synthetic.main.fragment_download_queue.*
|
||||||
import nucleus.factory.RequiresPresenter
|
import nucleus.factory.RequiresPresenter
|
||||||
import rx.Subscription
|
import rx.Subscription
|
||||||
@ -82,7 +82,7 @@ class DownloadFragment : BaseRxFragment<DownloadPresenter>() {
|
|||||||
recycler.adapter = adapter
|
recycler.adapter = adapter
|
||||||
|
|
||||||
// Set the layout manager for the recycler and fixed size.
|
// Set the layout manager for the recycler and fixed size.
|
||||||
recycler.layoutManager = LinearLayoutManager(activity)
|
recycler.layoutManager = NpaLinearLayoutManager(activity)
|
||||||
recycler.setHasFixedSize(true)
|
recycler.setHasFixedSize(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ import java.util.*
|
|||||||
*
|
*
|
||||||
* @param fragment the fragment containing this adapter.
|
* @param fragment the fragment containing this adapter.
|
||||||
*/
|
*/
|
||||||
class LibraryCategoryAdapter(private val fragment: LibraryCategoryFragment) :
|
class LibraryCategoryAdapter(val fragment: LibraryCategoryFragment) :
|
||||||
FlexibleAdapter<LibraryHolder, Manga>() {
|
FlexibleAdapter<LibraryHolder, Manga>() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,7 @@ import kotlinx.android.synthetic.main.item_catalogue_grid.view.*
|
|||||||
* @param listener a listener to react to single tap and long tap events.
|
* @param listener a listener to react to single tap and long tap events.
|
||||||
* @constructor creates a new library holder.
|
* @constructor creates a new library holder.
|
||||||
*/
|
*/
|
||||||
class LibraryHolder(private val view: View, adapter: LibraryCategoryAdapter, listener: FlexibleViewHolder.OnListItemClickListener) :
|
class LibraryHolder(private val view: View, private val adapter: LibraryCategoryAdapter, listener: FlexibleViewHolder.OnListItemClickListener) :
|
||||||
FlexibleViewHolder(view, adapter, listener) {
|
FlexibleViewHolder(view, adapter, listener) {
|
||||||
|
|
||||||
private var manga: Manga? = null
|
private var manga: Manga? = null
|
||||||
@ -55,9 +55,9 @@ class LibraryHolder(private val view: View, adapter: LibraryCategoryAdapter, lis
|
|||||||
* @param coverCache the cache that stores the cover in the filesystem.
|
* @param coverCache the cache that stores the cover in the filesystem.
|
||||||
*/
|
*/
|
||||||
private fun loadCover(manga: Manga, source: Source, coverCache: CoverCache) {
|
private fun loadCover(manga: Manga, source: Source, coverCache: CoverCache) {
|
||||||
if (manga.thumbnail_url != null) {
|
if (!manga.thumbnail_url.isNullOrEmpty()) {
|
||||||
coverCache.saveOrLoadFromCache(manga.thumbnail_url, source.glideHeaders) {
|
coverCache.saveOrLoadFromCache(manga.thumbnail_url, source.glideHeaders) {
|
||||||
if (this.manga == manga) {
|
if (adapter.fragment.isResumed && this.manga == manga) {
|
||||||
Glide.with(view.context)
|
Glide.with(view.context)
|
||||||
.load(it)
|
.load(it)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESULT)
|
.diskCacheStrategy(DiskCacheStrategy.RESULT)
|
||||||
|
@ -5,7 +5,6 @@ import android.animation.AnimatorListenerAdapter
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v7.view.ActionMode
|
import android.support.v7.view.ActionMode
|
||||||
import android.support.v7.widget.LinearLayoutManager
|
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
@ -22,6 +21,7 @@ import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
|||||||
import eu.kanade.tachiyomi.util.getCoordinates
|
import eu.kanade.tachiyomi.util.getCoordinates
|
||||||
import eu.kanade.tachiyomi.util.getResourceDrawable
|
import eu.kanade.tachiyomi.util.getResourceDrawable
|
||||||
import eu.kanade.tachiyomi.util.toast
|
import eu.kanade.tachiyomi.util.toast
|
||||||
|
import eu.kanade.tachiyomi.widget.NpaLinearLayoutManager
|
||||||
import kotlinx.android.synthetic.main.fragment_manga_chapters.*
|
import kotlinx.android.synthetic.main.fragment_manga_chapters.*
|
||||||
import nucleus.factory.RequiresPresenter
|
import nucleus.factory.RequiresPresenter
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
@ -66,7 +66,7 @@ class ChaptersFragment : BaseRxFragment<ChaptersPresenter>(), ActionMode.Callbac
|
|||||||
adapter = ChaptersAdapter(this)
|
adapter = ChaptersAdapter(this)
|
||||||
|
|
||||||
recycler.adapter = adapter
|
recycler.adapter = adapter
|
||||||
recycler.layoutManager = LinearLayoutManager(activity)
|
recycler.layoutManager = NpaLinearLayoutManager(activity)
|
||||||
recycler.addItemDecoration(DividerItemDecoration(
|
recycler.addItemDecoration(DividerItemDecoration(
|
||||||
context.theme.getResourceDrawable(R.attr.divider_drawable)))
|
context.theme.getResourceDrawable(R.attr.divider_drawable)))
|
||||||
recycler.setHasFixedSize(true)
|
recycler.setHasFixedSize(true)
|
||||||
|
@ -51,8 +51,8 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
|||||||
private var previousChapter: Chapter? = null
|
private var previousChapter: Chapter? = null
|
||||||
private var mangaSyncList: List<MangaSync>? = null
|
private var mangaSyncList: List<MangaSync>? = null
|
||||||
|
|
||||||
private lateinit var retryPageSubject: PublishSubject<Page>
|
private val retryPageSubject by lazy { PublishSubject.create<Page>() }
|
||||||
private lateinit var pageInitializerSubject: PublishSubject<Chapter>
|
private val pageInitializerSubject by lazy { PublishSubject.create<Chapter>() }
|
||||||
|
|
||||||
val isSeamlessMode by lazy { prefs.seamlessMode() }
|
val isSeamlessMode by lazy { prefs.seamlessMode() }
|
||||||
|
|
||||||
@ -120,7 +120,6 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
|||||||
|
|
||||||
private fun initializeSubjects() {
|
private fun initializeSubjects() {
|
||||||
// Listen for pages initialization events
|
// Listen for pages initialization events
|
||||||
pageInitializerSubject = PublishSubject.create<Chapter>()
|
|
||||||
add(pageInitializerSubject.observeOn(Schedulers.io())
|
add(pageInitializerSubject.observeOn(Schedulers.io())
|
||||||
.concatMap { ch ->
|
.concatMap { ch ->
|
||||||
val observable: Observable<Page>
|
val observable: Observable<Page>
|
||||||
@ -141,7 +140,6 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
|||||||
}.subscribe())
|
}.subscribe())
|
||||||
|
|
||||||
// Listen por retry events
|
// Listen por retry events
|
||||||
retryPageSubject = PublishSubject.create<Page>()
|
|
||||||
add(retryPageSubject.observeOn(Schedulers.io())
|
add(retryPageSubject.observeOn(Schedulers.io())
|
||||||
.flatMap { page ->
|
.flatMap { page ->
|
||||||
if (page.imageUrl == null)
|
if (page.imageUrl == null)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package eu.kanade.tachiyomi.ui.recent
|
package eu.kanade.tachiyomi.ui.recent
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v7.widget.LinearLayoutManager
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@ -17,6 +16,7 @@ import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment
|
|||||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||||
import eu.kanade.tachiyomi.util.getResourceDrawable
|
import eu.kanade.tachiyomi.util.getResourceDrawable
|
||||||
|
import eu.kanade.tachiyomi.widget.NpaLinearLayoutManager
|
||||||
import kotlinx.android.synthetic.main.fragment_recent_chapters.*
|
import kotlinx.android.synthetic.main.fragment_recent_chapters.*
|
||||||
import nucleus.factory.RequiresPresenter
|
import nucleus.factory.RequiresPresenter
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
@ -67,7 +67,7 @@ class RecentChaptersFragment : BaseRxFragment<RecentChaptersPresenter>(), Flexib
|
|||||||
*/
|
*/
|
||||||
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
|
||||||
// Init RecyclerView and adapter
|
// Init RecyclerView and adapter
|
||||||
recycler.layoutManager = LinearLayoutManager(activity)
|
recycler.layoutManager = NpaLinearLayoutManager(activity)
|
||||||
recycler.addItemDecoration(DividerItemDecoration(context.theme.getResourceDrawable(R.attr.divider_drawable)))
|
recycler.addItemDecoration(DividerItemDecoration(context.theme.getResourceDrawable(R.attr.divider_drawable)))
|
||||||
recycler.setHasFixedSize(true)
|
recycler.setHasFixedSize(true)
|
||||||
adapter = RecentChaptersAdapter(this)
|
adapter = RecentChaptersAdapter(this)
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package eu.kanade.tachiyomi.widget
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.support.v7.widget.GridLayoutManager
|
||||||
|
import android.util.AttributeSet
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No Predictive Animations GridLayoutManager
|
||||||
|
*/
|
||||||
|
open class NpaGridLayoutManager : GridLayoutManager {
|
||||||
|
|
||||||
|
constructor(context: Context, spanCount: Int) : super(context, spanCount) {}
|
||||||
|
|
||||||
|
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int)
|
||||||
|
: super(context, attrs, defStyleAttr, defStyleRes) {}
|
||||||
|
|
||||||
|
constructor(context: Context, spanCount: Int, orientation: Int, reverseLayout: Boolean)
|
||||||
|
: super(context, spanCount, orientation, reverseLayout) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable predictive animations. There is a bug in RecyclerView which causes views that
|
||||||
|
* are being reloaded to pull invalid ViewHolders from the internal recycler stack if the
|
||||||
|
* adapter size has decreased since the ViewHolder was recycled.
|
||||||
|
*/
|
||||||
|
override fun supportsPredictiveItemAnimations() = false
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package eu.kanade.tachiyomi.widget
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.support.v7.widget.LinearLayoutManager
|
||||||
|
import android.util.AttributeSet
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No Predictive Animations LinearLayoutManager
|
||||||
|
*/
|
||||||
|
open class NpaLinearLayoutManager : LinearLayoutManager {
|
||||||
|
|
||||||
|
constructor(context: Context): super(context) {}
|
||||||
|
|
||||||
|
constructor(context: Context, orientation: Int, reverseLayout: Boolean)
|
||||||
|
: super(context, orientation, reverseLayout) {}
|
||||||
|
|
||||||
|
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int)
|
||||||
|
: super(context, attrs, defStyleAttr, defStyleRes) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable predictive animations. There is a bug in RecyclerView which causes views that
|
||||||
|
* are being reloaded to pull invalid ViewHolders from the internal recycler stack if the
|
||||||
|
* adapter size has decreased since the ViewHolder was recycled.
|
||||||
|
*/
|
||||||
|
override fun supportsPredictiveItemAnimations() = false
|
||||||
|
|
||||||
|
}
|
@ -1,10 +1,9 @@
|
|||||||
package eu.kanade.tachiyomi.widget
|
package eu.kanade.tachiyomi.widget
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.support.v7.widget.LinearLayoutManager
|
|
||||||
import android.support.v7.widget.RecyclerView
|
import android.support.v7.widget.RecyclerView
|
||||||
|
|
||||||
class PreCachingLayoutManager(context: Context) : LinearLayoutManager(context) {
|
class PreCachingLayoutManager(context: Context) : NpaLinearLayoutManager(context) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val DEFAULT_EXTRA_LAYOUT_SPACE = 600
|
const val DEFAULT_EXTRA_LAYOUT_SPACE = 600
|
||||||
@ -19,7 +18,4 @@ class PreCachingLayoutManager(context: Context) : LinearLayoutManager(context) {
|
|||||||
return DEFAULT_EXTRA_LAYOUT_SPACE
|
return DEFAULT_EXTRA_LAYOUT_SPACE
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://stackoverflow.com/questions/30220771/recyclerview-inconsistency-detected-invalid-item-position
|
|
||||||
override fun supportsPredictiveItemAnimations() = false
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user