Refresh webtoon adapter on image property changed
This commit is contained in:
parent
1afcf34829
commit
b323b9c843
@ -14,6 +14,8 @@ import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
|||||||
import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer
|
import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer
|
||||||
import rx.subscriptions.CompositeSubscription
|
import rx.subscriptions.CompositeSubscription
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
import kotlin.math.max
|
||||||
|
import kotlin.math.min
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of a [BaseViewer] to display pages with a [RecyclerView].
|
* Implementation of a [BaseViewer] to display pages with a [RecyclerView].
|
||||||
@ -110,6 +112,10 @@ class WebtoonViewer(val activity: ReaderActivity) : BaseViewer {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.imagePropertyChangedListener = {
|
||||||
|
refreshAdapter()
|
||||||
|
}
|
||||||
|
|
||||||
frame.layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)
|
frame.layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)
|
||||||
frame.addView(recycler)
|
frame.addView(recycler)
|
||||||
}
|
}
|
||||||
@ -250,4 +256,13 @@ class WebtoonViewer(val activity: ReaderActivity) : BaseViewer {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies adapter of changes around the current page to trigger a relayout in the recycler.
|
||||||
|
* Used when a image configuration is changed.
|
||||||
|
*/
|
||||||
|
private fun refreshAdapter() {
|
||||||
|
val position = layoutManager.findLastEndVisibleItemPosition()
|
||||||
|
adapter.notifyItemRangeChanged(max(0, position - 1), min(2, adapter.itemCount - position))
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user