mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 01:59:19 +01:00
Fix #577. Fix language not applied in reader activity.
This commit is contained in:
parent
97e3b5d2ab
commit
816cc17ed3
@ -3,10 +3,15 @@ package eu.kanade.tachiyomi.ui.base.activity
|
||||
import android.os.Bundle
|
||||
import eu.kanade.tachiyomi.App
|
||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||
import eu.kanade.tachiyomi.util.LocaleHelper
|
||||
import nucleus.view.NucleusAppCompatActivity
|
||||
|
||||
abstract class BaseRxActivity<P : BasePresenter<*>> : NucleusAppCompatActivity<P>(), ActivityMixin {
|
||||
|
||||
init {
|
||||
LocaleHelper.updateCfg(this)
|
||||
}
|
||||
|
||||
override fun onCreate(savedState: Bundle?) {
|
||||
val superFactory = presenterFactory
|
||||
setPresenterFactory {
|
||||
|
@ -227,7 +227,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
toast(error.message)
|
||||
}
|
||||
|
||||
fun onLongPress(page: Page) {
|
||||
fun onLongClick(page: Page) {
|
||||
MaterialDialog.Builder(this)
|
||||
.title(getString(R.string.options))
|
||||
.items(R.array.reader_image_options)
|
||||
|
@ -212,6 +212,16 @@ abstract class BaseReader : BaseFragment() {
|
||||
moveLeft()
|
||||
}
|
||||
|
||||
/**
|
||||
* Method the implementations can call to show a menu with options for the given page.
|
||||
*/
|
||||
fun onLongClick(page: Page?): Boolean {
|
||||
if (isAdded && page != null) {
|
||||
readerActivity.onLongClick(page)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the active decoder class.
|
||||
*
|
||||
|
@ -71,6 +71,7 @@ class PageView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
|
||||
setBitmapDecoderClass(reader.bitmapDecoderClass)
|
||||
setVerticalScrollingParent(reader is VerticalReader)
|
||||
setOnTouchListener { v, motionEvent -> reader.gestureDetector.onTouchEvent(motionEvent) }
|
||||
setOnLongClickListener { reader.onLongClick(page) }
|
||||
setOnImageEventListener(object : SubsamplingScaleImageView.DefaultOnImageEventListener() {
|
||||
override fun onReady() {
|
||||
onImageDecoded(reader)
|
||||
|
@ -66,7 +66,7 @@ abstract class PagerReader : BaseReader() {
|
||||
/**
|
||||
* Gesture detector for touch events.
|
||||
*/
|
||||
val gestureDetector by lazy { createGestureDetector() }
|
||||
val gestureDetector by lazy { GestureDetector(context, ImageGestureListener()) }
|
||||
|
||||
/**
|
||||
* Subscriptions for reader settings.
|
||||
@ -166,12 +166,10 @@ abstract class PagerReader : BaseReader() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the gesture detector for the pager.
|
||||
*
|
||||
* @return a gesture detector.
|
||||
* Gesture detector for Subsampling Scale Image View.
|
||||
*/
|
||||
protected fun createGestureDetector(): GestureDetector {
|
||||
return GestureDetector(activity, object : GestureDetector.SimpleOnGestureListener() {
|
||||
inner class ImageGestureListener : GestureDetector.SimpleOnGestureListener() {
|
||||
|
||||
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
|
||||
if (isAdded) {
|
||||
val positionX = e.x
|
||||
@ -186,17 +184,6 @@ abstract class PagerReader : BaseReader() {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onLongPress(e: MotionEvent?) {
|
||||
if (isAdded) {
|
||||
val page = adapter.pages.getOrNull(pager.currentItem)
|
||||
if (page != null)
|
||||
readerActivity.onLongPress(page)
|
||||
else
|
||||
context.toast(getString(R.string.unknown_error))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,12 +22,7 @@ class WebtoonAdapter(val fragment: WebtoonReader) : RecyclerView.Adapter<Webtoon
|
||||
/**
|
||||
* Touch listener for images in holders.
|
||||
*/
|
||||
val imageTouchListener = View.OnTouchListener { v, ev -> fragment.imageGestureDetector.onTouchEvent(ev) }
|
||||
|
||||
/**
|
||||
* Touch listener for the other views.
|
||||
*/
|
||||
val viewTouchListener = View.OnTouchListener { v, ev -> fragment.viewGestureDetector.onTouchEvent(ev) }
|
||||
val touchListener = View.OnTouchListener { v, ev -> fragment.imageGestureDetector.onTouchEvent(ev) }
|
||||
|
||||
/**
|
||||
* Returns the number of pages.
|
||||
|
@ -63,7 +63,8 @@ class WebtoonHolder(private val view: View, private val adapter: WebtoonAdapter)
|
||||
setRegionDecoderClass(webtoonReader.regionDecoderClass)
|
||||
setBitmapDecoderClass(webtoonReader.bitmapDecoderClass)
|
||||
setVerticalScrollingParent(true)
|
||||
setOnTouchListener(adapter.imageTouchListener)
|
||||
setOnTouchListener(adapter.touchListener)
|
||||
setOnLongClickListener { webtoonReader.onLongClick(page) }
|
||||
setOnImageEventListener(object : SubsamplingScaleImageView.DefaultOnImageEventListener() {
|
||||
override fun onReady() {
|
||||
onImageDecoded()
|
||||
@ -77,7 +78,7 @@ class WebtoonHolder(private val view: View, private val adapter: WebtoonAdapter)
|
||||
|
||||
view.progress_container.minimumHeight = view.resources.displayMetrics.heightPixels * 2
|
||||
|
||||
view.setOnTouchListener(adapter.viewTouchListener)
|
||||
view.setOnTouchListener(adapter.touchListener)
|
||||
view.retry_button.setOnTouchListener { v, event ->
|
||||
if (event.action == MotionEvent.ACTION_UP) {
|
||||
readerActivity.presenter.retryPage(page)
|
||||
|
@ -3,14 +3,11 @@ package eu.kanade.tachiyomi.ui.reader.viewer.webtoon
|
||||
import android.os.Bundle
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.*
|
||||
import android.view.GestureDetector.SimpleOnGestureListener
|
||||
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
||||
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.source.model.Page
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderChapter
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.base.BaseReader
|
||||
import eu.kanade.tachiyomi.util.toast
|
||||
import eu.kanade.tachiyomi.widget.PreCachingLayoutManager
|
||||
import rx.subscriptions.CompositeSubscription
|
||||
|
||||
@ -59,11 +56,6 @@ class WebtoonReader : BaseReader() {
|
||||
*/
|
||||
val imageGestureDetector by lazy { GestureDetector(context, ImageGestureListener()) }
|
||||
|
||||
/**
|
||||
* Gesture detector for other views touch events.
|
||||
*/
|
||||
val viewGestureDetector by lazy { GestureDetector(context, ViewGestureListener()) }
|
||||
|
||||
/**
|
||||
* Subscriptions used while the view exists.
|
||||
*/
|
||||
@ -127,14 +119,9 @@ class WebtoonReader : BaseReader() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gesture detector for Subsampling Scale Image View. [onDown] needs to be false or else
|
||||
* double tap to zoom doesn't work.
|
||||
* Gesture detector for Subsampling Scale Image View.
|
||||
*/
|
||||
inner open class ImageGestureListener : SimpleOnGestureListener() {
|
||||
|
||||
override fun onDown(e: MotionEvent): Boolean {
|
||||
return false
|
||||
}
|
||||
inner class ImageGestureListener : GestureDetector.SimpleOnGestureListener() {
|
||||
|
||||
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
|
||||
if (isAdded) {
|
||||
@ -150,29 +137,6 @@ class WebtoonReader : BaseReader() {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onLongPress(e: MotionEvent) {
|
||||
if (isAdded) {
|
||||
val child = recycler.findChildViewUnder(e.rawX, e.rawY)
|
||||
val position = recycler.getChildAdapterPosition(child)
|
||||
val page = adapter.pages?.getOrNull(position)
|
||||
if (page != null)
|
||||
readerActivity.onLongPress(page)
|
||||
else
|
||||
context.toast(getString(R.string.unknown_error))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gesture detector for other views. [onDown] needs to be true here or it will incorrectly
|
||||
* detect events.
|
||||
*/
|
||||
inner class ViewGestureListener : ImageGestureListener() {
|
||||
|
||||
override fun onDown(e: MotionEvent): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user