Run linter
This commit is contained in:
@@ -15,8 +15,8 @@ import eu.kanade.tachiyomi.widget.OutlineSpan
|
||||
* Page indicator found at the bottom of the reader
|
||||
*/
|
||||
class PageIndicatorTextView(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null
|
||||
) : AppCompatTextView(context, attrs) {
|
||||
|
||||
init {
|
||||
|
||||
@@ -41,6 +41,9 @@ import eu.kanade.tachiyomi.util.view.gone
|
||||
import eu.kanade.tachiyomi.util.view.visible
|
||||
import eu.kanade.tachiyomi.widget.SimpleAnimationListener
|
||||
import eu.kanade.tachiyomi.widget.SimpleSeekBarListener
|
||||
import java.io.File
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.math.abs
|
||||
import kotlinx.android.synthetic.main.reader_activity.*
|
||||
import me.zhanghai.android.systemuihelper.SystemUiHelper
|
||||
import nucleus.factory.RequiresPresenter
|
||||
@@ -50,9 +53,6 @@ import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.subscriptions.CompositeSubscription
|
||||
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
|
||||
@@ -747,7 +747,5 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
color_overlay.visibility = View.VISIBLE
|
||||
color_overlay.setFilterColor(value, preferences.colorFilterMode().getOrDefault())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.util.lang.plusAssign
|
||||
import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener
|
||||
import eu.kanade.tachiyomi.widget.SimpleSeekBarListener
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.math.abs
|
||||
import kotlinx.android.synthetic.main.reader_color_filter.*
|
||||
import kotlinx.android.synthetic.main.reader_color_filter_sheet.brightness_overlay
|
||||
import kotlinx.android.synthetic.main.reader_color_filter_sheet.color_overlay
|
||||
@@ -20,8 +22,6 @@ 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.
|
||||
@@ -181,7 +181,7 @@ class ReaderColorFilterSheet(activity: ReaderActivity) : BottomSheetDialog(activ
|
||||
val green = getGreenFromColor(color)
|
||||
val blue = getBlueFromColor(color)
|
||||
|
||||
//Initialize values
|
||||
// Initialize values
|
||||
with(view) {
|
||||
txt_color_filter_alpha_value.text = alpha.toString()
|
||||
|
||||
@@ -324,5 +324,4 @@ class ReaderColorFilterSheet(activity: ReaderActivity) : BottomSheetDialog(activ
|
||||
/** Integer mask of blue value **/
|
||||
const val BLUE_MASK: Long = 0x000000FF
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ import android.util.AttributeSet
|
||||
import android.view.View
|
||||
|
||||
class ReaderColorFilterView(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null
|
||||
) : View(context, attrs) {
|
||||
|
||||
private val colorFilterPaint: Paint = Paint()
|
||||
|
||||
@@ -15,8 +15,8 @@ import kotlinx.android.synthetic.main.reader_page_sheet.share_layout
|
||||
* Sheet to show when a page is long clicked.
|
||||
*/
|
||||
class ReaderPageSheet(
|
||||
private val activity: ReaderActivity,
|
||||
private val page: ReaderPage
|
||||
private val activity: ReaderActivity,
|
||||
private val page: ReaderPage
|
||||
) : BottomSheetDialog(activity) {
|
||||
|
||||
/**
|
||||
@@ -72,5 +72,4 @@ class ReaderPageSheet(
|
||||
activity.saveImage(page)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,9 @@ import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
||||
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
||||
import eu.kanade.tachiyomi.util.system.ImageUtil
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
import java.util.concurrent.TimeUnit
|
||||
import rx.Completable
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
@@ -31,19 +34,16 @@ import rx.schedulers.Schedulers
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* Presenter used by the activity to perform background operations.
|
||||
*/
|
||||
class ReaderPresenter(
|
||||
private val db: DatabaseHelper = Injekt.get(),
|
||||
private val sourceManager: SourceManager = Injekt.get(),
|
||||
private val downloadManager: DownloadManager = Injekt.get(),
|
||||
private val coverCache: CoverCache = Injekt.get(),
|
||||
private val preferences: PreferencesHelper = Injekt.get()
|
||||
private val db: DatabaseHelper = Injekt.get(),
|
||||
private val sourceManager: SourceManager = Injekt.get(),
|
||||
private val downloadManager: DownloadManager = Injekt.get(),
|
||||
private val coverCache: CoverCache = Injekt.get(),
|
||||
private val preferences: PreferencesHelper = Injekt.get()
|
||||
) : BasePresenter<ReaderActivity>() {
|
||||
|
||||
/**
|
||||
@@ -237,8 +237,8 @@ class ReaderPresenter(
|
||||
* Callers must also handle the onError event.
|
||||
*/
|
||||
private fun getLoadObservable(
|
||||
loader: ChapterLoader,
|
||||
chapter: ReaderChapter
|
||||
loader: ChapterLoader,
|
||||
chapter: ReaderChapter
|
||||
): Observable<ViewerChapters> {
|
||||
return loader.loadChapter(chapter)
|
||||
.andThen(Observable.fromCallable {
|
||||
@@ -638,5 +638,4 @@ class ReaderPresenter(
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import androidx.appcompat.widget.AppCompatSeekBar
|
||||
* Seekbar to show current chapter progress.
|
||||
*/
|
||||
class ReaderSeekBar @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null
|
||||
) : AppCompatSeekBar(context, attrs) {
|
||||
|
||||
/**
|
||||
@@ -41,5 +41,4 @@ class ReaderSeekBar @JvmOverloads constructor(
|
||||
}
|
||||
return super.onTouchEvent(event)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -109,5 +109,4 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
|
||||
}
|
||||
setSelection(pref.getOrDefault() - offset, false)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -103,5 +103,4 @@ class SaveImageNotifier(private val context: Context) {
|
||||
}
|
||||
updateNotification()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ import timber.log.Timber
|
||||
* Loader used to retrieve the [PageLoader] for a given chapter.
|
||||
*/
|
||||
class ChapterLoader(
|
||||
private val downloadManager: DownloadManager,
|
||||
private val manga: Manga,
|
||||
private val source: Source
|
||||
private val downloadManager: DownloadManager,
|
||||
private val manga: Manga,
|
||||
private val source: Source
|
||||
) {
|
||||
|
||||
/**
|
||||
@@ -80,5 +80,4 @@ class ChapterLoader(
|
||||
else -> error("Loader not implemented")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder
|
||||
import eu.kanade.tachiyomi.util.system.ImageUtil
|
||||
import rx.Observable
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import rx.Observable
|
||||
|
||||
/**
|
||||
* Loader used to load a chapter from a directory given on [file].
|
||||
@@ -37,5 +37,4 @@ class DirectoryPageLoader(val file: File) : PageLoader() {
|
||||
override fun getPage(page: ReaderPage): Observable<Int> {
|
||||
return Observable.just(Page.READY)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@ import uy.kohesive.injekt.injectLazy
|
||||
* Loader used to load a chapter from the downloaded chapters.
|
||||
*/
|
||||
class DownloadPageLoader(
|
||||
private val chapter: ReaderChapter,
|
||||
private val manga: Manga,
|
||||
private val source: Source,
|
||||
private val downloadManager: DownloadManager
|
||||
private val chapter: ReaderChapter,
|
||||
private val manga: Manga,
|
||||
private val source: Source,
|
||||
private val downloadManager: DownloadManager
|
||||
) : PageLoader() {
|
||||
|
||||
/**
|
||||
@@ -45,5 +45,4 @@ class DownloadPageLoader(
|
||||
override fun getPage(page: ReaderPage): Observable<Int> {
|
||||
return Observable.just(Page.READY) // TODO maybe check if file still exists?
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package eu.kanade.tachiyomi.ui.reader.loader
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import eu.kanade.tachiyomi.util.storage.EpubFile
|
||||
import rx.Observable
|
||||
import java.io.File
|
||||
import rx.Observable
|
||||
|
||||
/**
|
||||
* Loader used to load a chapter from a .epub file.
|
||||
@@ -50,5 +50,4 @@ class EpubPageLoader(file: File) : PageLoader() {
|
||||
Page.READY
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import eu.kanade.tachiyomi.util.lang.plusAssign
|
||||
import java.util.concurrent.PriorityBlockingQueue
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import kotlin.math.min
|
||||
import rx.Completable
|
||||
import rx.Observable
|
||||
import rx.schedulers.Schedulers
|
||||
@@ -15,17 +18,14 @@ import rx.subscriptions.CompositeSubscription
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.util.concurrent.PriorityBlockingQueue
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import kotlin.math.min
|
||||
|
||||
/**
|
||||
* Loader used to load chapters from an online source.
|
||||
*/
|
||||
class HttpPageLoader(
|
||||
private val chapter: ReaderChapter,
|
||||
private val source: HttpSource,
|
||||
private val chapterCache: ChapterCache = Injekt.get()
|
||||
private val chapter: ReaderChapter,
|
||||
private val source: HttpSource,
|
||||
private val chapterCache: ChapterCache = Injekt.get()
|
||||
) : PageLoader() {
|
||||
|
||||
/**
|
||||
@@ -165,8 +165,8 @@ class HttpPageLoader(
|
||||
* Data class used to keep ordering of pages in order to maintain priority.
|
||||
*/
|
||||
private class PriorityPage(
|
||||
val page: ReaderPage,
|
||||
val priority: Int
|
||||
val page: ReaderPage,
|
||||
val priority: Int
|
||||
) : Comparable<PriorityPage> {
|
||||
|
||||
companion object {
|
||||
@@ -179,7 +179,6 @@ class HttpPageLoader(
|
||||
val p = other.priority.compareTo(priority)
|
||||
return if (p != 0) p else identifier.compareTo(other.identifier)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,5 +42,4 @@ abstract class PageLoader {
|
||||
* online source is used.
|
||||
*/
|
||||
open fun retryPage(page: ReaderPage) {}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,14 +4,14 @@ import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder
|
||||
import eu.kanade.tachiyomi.util.system.ImageUtil
|
||||
import junrar.Archive
|
||||
import junrar.rarfile.FileHeader
|
||||
import rx.Observable
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
import java.io.PipedInputStream
|
||||
import java.io.PipedOutputStream
|
||||
import java.util.concurrent.Executors
|
||||
import junrar.Archive
|
||||
import junrar.rarfile.FileHeader
|
||||
import rx.Observable
|
||||
|
||||
/**
|
||||
* Loader used to load a chapter from a .rar or .cbr file.
|
||||
@@ -83,5 +83,4 @@ class RarPageLoader(file: File) : PageLoader() {
|
||||
}
|
||||
return pipeIn
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder
|
||||
import eu.kanade.tachiyomi.util.system.ImageUtil
|
||||
import rx.Observable
|
||||
import java.io.File
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipFile
|
||||
import rx.Observable
|
||||
|
||||
/**
|
||||
* Loader used to load a chapter from a .zip or .cbz file.
|
||||
|
||||
@@ -6,11 +6,13 @@ sealed class ChapterTransition {
|
||||
abstract val to: ReaderChapter?
|
||||
|
||||
class Prev(
|
||||
override val from: ReaderChapter, override val to: ReaderChapter?
|
||||
override val from: ReaderChapter,
|
||||
override val to: ReaderChapter?
|
||||
) : ChapterTransition()
|
||||
|
||||
class Next(
|
||||
override val from: ReaderChapter, override val to: ReaderChapter?
|
||||
override val from: ReaderChapter,
|
||||
override val to: ReaderChapter?
|
||||
) : ChapterTransition()
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
@@ -30,5 +32,4 @@ sealed class ChapterTransition {
|
||||
override fun toString(): String {
|
||||
return "${javaClass.simpleName}(from=${from.chapter.url}, to=${to?.chapter?.url})"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,12 +4,11 @@ import eu.kanade.tachiyomi.source.model.Page
|
||||
import java.io.InputStream
|
||||
|
||||
class ReaderPage(
|
||||
index: Int,
|
||||
url: String = "",
|
||||
imageUrl: String? = null,
|
||||
var stream: (() -> InputStream)? = null
|
||||
index: Int,
|
||||
url: String = "",
|
||||
imageUrl: String? = null,
|
||||
var stream: (() -> InputStream)? = null
|
||||
) : Page(index, url, imageUrl, null) {
|
||||
|
||||
lateinit var chapter: ReaderChapter
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package eu.kanade.tachiyomi.ui.reader.model
|
||||
|
||||
data class ViewerChapters(
|
||||
val currChapter: ReaderChapter,
|
||||
val prevChapter: ReaderChapter?,
|
||||
val nextChapter: ReaderChapter?
|
||||
val currChapter: ReaderChapter,
|
||||
val prevChapter: ReaderChapter?,
|
||||
val nextChapter: ReaderChapter?
|
||||
) {
|
||||
|
||||
fun ref() {
|
||||
@@ -17,5 +17,4 @@ data class ViewerChapters(
|
||||
prevChapter?.unref()
|
||||
nextChapter?.unref()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,5 +42,4 @@ interface BaseViewer {
|
||||
* return true if the event was handled, false otherwise.
|
||||
*/
|
||||
fun handleGenericMotionEvent(event: MotionEvent): Boolean
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -12,8 +12,8 @@ import kotlin.math.abs
|
||||
* one conflicts with the quick scale feature.
|
||||
*/
|
||||
open class GestureDetectorWithLongTap(
|
||||
context: Context,
|
||||
listener: Listener
|
||||
context: Context,
|
||||
listener: Listener
|
||||
) : GestureDetector(context, listener) {
|
||||
|
||||
private val handler = Handler()
|
||||
@@ -71,5 +71,4 @@ open class GestureDetectorWithLongTap(
|
||||
open fun onLongTapConfirmed(ev: MotionEvent) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ import kotlin.math.min
|
||||
* user also approximately knows how much the operation will take.
|
||||
*/
|
||||
class ReaderProgressBar @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : View(context, attrs, defStyleAttr) {
|
||||
|
||||
/**
|
||||
@@ -209,5 +209,4 @@ class ReaderProgressBar @JvmOverloads constructor(
|
||||
start()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ import eu.kanade.tachiyomi.ui.reader.viewer.GestureDetectorWithLongTap
|
||||
* pager can also be declared to be vertical by creating it with [isHorizontal] to false.
|
||||
*/
|
||||
open class Pager(
|
||||
context: Context,
|
||||
isHorizontal: Boolean = true
|
||||
context: Context,
|
||||
isHorizontal: Boolean = true
|
||||
) : DirectionalViewPager(context, isHorizontal) {
|
||||
|
||||
/**
|
||||
@@ -104,5 +104,4 @@ open class Pager(
|
||||
fun setGestureDetectorEnabled(enabled: Boolean) {
|
||||
isGestureDetectorEnabled = enabled
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,5 +21,4 @@ class PagerButton(context: Context, viewer: PagerViewer) : AppCompatButton(conte
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -77,8 +77,8 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe
|
||||
}
|
||||
|
||||
private fun <T> Preference<T>.register(
|
||||
valueAssignment: (T) -> Unit,
|
||||
onChanged: (T) -> Unit = {}
|
||||
valueAssignment: (T) -> Unit,
|
||||
onChanged: (T) -> Unit = {}
|
||||
) {
|
||||
asObservable()
|
||||
.doOnNext(valueAssignment)
|
||||
@@ -109,5 +109,4 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe
|
||||
enum class ZoomType {
|
||||
Left, Center, Right
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,20 +37,20 @@ import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.view.gone
|
||||
import eu.kanade.tachiyomi.util.view.visible
|
||||
import eu.kanade.tachiyomi.widget.ViewPagerAdapter
|
||||
import java.io.InputStream
|
||||
import java.util.concurrent.TimeUnit
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.schedulers.Schedulers
|
||||
import java.io.InputStream
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* View of the ViewPager that contains a page of a chapter.
|
||||
*/
|
||||
@SuppressLint("ViewConstructor")
|
||||
class PagerPageHolder(
|
||||
val viewer: PagerViewer,
|
||||
val page: ReaderPage
|
||||
val viewer: PagerViewer,
|
||||
val page: ReaderPage
|
||||
) : FrameLayout(viewer.activity), ViewPagerAdapter.PositionableView {
|
||||
|
||||
/**
|
||||
@@ -442,21 +442,21 @@ class PagerPageHolder(
|
||||
.transition(DrawableTransitionOptions.with(NoTransition.getFactory()))
|
||||
.listener(object : RequestListener<Drawable> {
|
||||
override fun onLoadFailed(
|
||||
e: GlideException?,
|
||||
model: Any?,
|
||||
target: Target<Drawable>?,
|
||||
isFirstResource: Boolean
|
||||
e: GlideException?,
|
||||
model: Any?,
|
||||
target: Target<Drawable>?,
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
onImageDecodeError()
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onResourceReady(
|
||||
resource: Drawable?,
|
||||
model: Any?,
|
||||
target: Target<Drawable>?,
|
||||
dataSource: DataSource?,
|
||||
isFirstResource: Boolean
|
||||
resource: Drawable?,
|
||||
model: Any?,
|
||||
target: Target<Drawable>?,
|
||||
dataSource: DataSource?,
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
if (resource is GifDrawable) {
|
||||
resource.setLoopCount(GifDrawable.LOOP_INTRINSIC)
|
||||
@@ -467,5 +467,4 @@ class PagerPageHolder(
|
||||
})
|
||||
.into(this)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -27,8 +27,8 @@ import rx.android.schedulers.AndroidSchedulers
|
||||
*/
|
||||
@SuppressLint("ViewConstructor")
|
||||
class PagerTransitionHolder(
|
||||
val viewer: PagerViewer,
|
||||
val transition: ChapterTransition
|
||||
val viewer: PagerViewer,
|
||||
val transition: ChapterTransition
|
||||
) : LinearLayout(viewer.activity), ViewPagerAdapter.PositionableView {
|
||||
|
||||
/**
|
||||
@@ -205,5 +205,4 @@ class PagerTransitionHolder(
|
||||
private fun View.wrapContent() {
|
||||
layoutParams = ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -323,5 +323,4 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -101,5 +101,4 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() {
|
||||
}
|
||||
return PagerAdapter.POSITION_NONE
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -121,8 +121,8 @@ class WebtoonAdapter(val viewer: WebtoonViewer) : RecyclerView.Adapter<RecyclerV
|
||||
* Diff util callback used to dispatch delta updates instead of full dataset changes.
|
||||
*/
|
||||
private class Callback(
|
||||
private val oldItems: List<Any>,
|
||||
private val newItems: List<Any>
|
||||
private val oldItems: List<Any>,
|
||||
private val newItems: List<Any>
|
||||
) : DiffUtil.Callback() {
|
||||
|
||||
/**
|
||||
@@ -168,5 +168,4 @@ class WebtoonAdapter(val viewer: WebtoonViewer) : RecyclerView.Adapter<RecyclerV
|
||||
*/
|
||||
const val TRANSITION_VIEW = 1
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import eu.kanade.tachiyomi.ui.base.holder.BaseViewHolder
|
||||
import rx.Subscription
|
||||
|
||||
abstract class WebtoonBaseHolder(
|
||||
view: View,
|
||||
protected val viewer: WebtoonViewer
|
||||
view: View,
|
||||
protected val viewer: WebtoonViewer
|
||||
) : BaseViewHolder(view) {
|
||||
|
||||
/**
|
||||
@@ -42,5 +42,4 @@ abstract class WebtoonBaseHolder(
|
||||
protected fun View.wrapContent() {
|
||||
layoutParams = LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) {
|
||||
}
|
||||
|
||||
private fun <T> Preference<T>.register(
|
||||
valueAssignment: (T) -> Unit,
|
||||
onChanged: (T) -> Unit = {}
|
||||
valueAssignment: (T) -> Unit,
|
||||
onChanged: (T) -> Unit = {}
|
||||
) {
|
||||
asObservable()
|
||||
.doOnNext(valueAssignment)
|
||||
@@ -76,5 +76,4 @@ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) {
|
||||
.subscribe()
|
||||
.addTo(subscriptions)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -68,13 +68,12 @@ class WebtoonFrame(context: Context) : FrameLayout(context) {
|
||||
}
|
||||
|
||||
override fun onFling(
|
||||
e1: MotionEvent?,
|
||||
e2: MotionEvent?,
|
||||
velocityX: Float,
|
||||
velocityY: Float
|
||||
e1: MotionEvent?,
|
||||
e2: MotionEvent?,
|
||||
velocityX: Float,
|
||||
velocityY: Float
|
||||
): Boolean {
|
||||
return recycler?.zoomFling(velocityX.toInt(), velocityY.toInt()) ?: false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,5 +51,4 @@ class WebtoonLayoutManager(activity: ReaderActivity) : LinearLayoutManager(activ
|
||||
|
||||
return if (child == null) NO_POSITION else getPosition(child)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+13
-16
@@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.reader.viewer.webtoon
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import android.view.Gravity
|
||||
@@ -32,15 +31,14 @@ import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressBar
|
||||
import eu.kanade.tachiyomi.util.system.ImageUtil
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.system.pxToDp
|
||||
import eu.kanade.tachiyomi.util.view.gone
|
||||
import eu.kanade.tachiyomi.util.view.visible
|
||||
import java.io.InputStream
|
||||
import java.util.concurrent.TimeUnit
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.schedulers.Schedulers
|
||||
import java.io.InputStream
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* Holder of the webtoon reader for a single page of a chapter.
|
||||
@@ -50,8 +48,8 @@ import java.util.concurrent.TimeUnit
|
||||
* @constructor creates a new webtoon holder.
|
||||
*/
|
||||
class WebtoonPageHolder(
|
||||
private val frame: FrameLayout,
|
||||
viewer: WebtoonViewer
|
||||
private val frame: FrameLayout,
|
||||
viewer: WebtoonViewer
|
||||
) : WebtoonBaseHolder(frame, viewer) {
|
||||
|
||||
/**
|
||||
@@ -493,21 +491,21 @@ class WebtoonPageHolder(
|
||||
.transition(DrawableTransitionOptions.with(NoTransition.getFactory()))
|
||||
.listener(object : RequestListener<Drawable> {
|
||||
override fun onLoadFailed(
|
||||
e: GlideException?,
|
||||
model: Any?,
|
||||
target: Target<Drawable>?,
|
||||
isFirstResource: Boolean
|
||||
e: GlideException?,
|
||||
model: Any?,
|
||||
target: Target<Drawable>?,
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
onImageDecodeError()
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onResourceReady(
|
||||
resource: Drawable?,
|
||||
model: Any?,
|
||||
target: Target<Drawable>?,
|
||||
dataSource: DataSource?,
|
||||
isFirstResource: Boolean
|
||||
resource: Drawable?,
|
||||
model: Any?,
|
||||
target: Target<Drawable>?,
|
||||
dataSource: DataSource?,
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
if (resource is GifDrawable) {
|
||||
resource.setLoopCount(GifDrawable.LOOP_INTRINSIC)
|
||||
@@ -518,5 +516,4 @@ class WebtoonPageHolder(
|
||||
})
|
||||
.into(this)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-15
@@ -18,9 +18,9 @@ import kotlin.math.abs
|
||||
* Implementation of a [RecyclerView] used by the webtoon reader.
|
||||
*/
|
||||
open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyle: Int = 0
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyle: Int = 0
|
||||
) : RecyclerView(context, attrs, defStyle) {
|
||||
|
||||
private var isZooming = false
|
||||
@@ -77,12 +77,12 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun zoom(
|
||||
fromRate: Float,
|
||||
toRate: Float,
|
||||
fromX: Float,
|
||||
toX: Float,
|
||||
fromY: Float,
|
||||
toY: Float
|
||||
fromRate: Float,
|
||||
toRate: Float,
|
||||
fromX: Float,
|
||||
toX: Float,
|
||||
fromY: Float,
|
||||
toY: Float
|
||||
) {
|
||||
isZooming = true
|
||||
val animatorSet = AnimatorSet()
|
||||
@@ -102,7 +102,6 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
animatorSet.start()
|
||||
animatorSet.addListener(object : Animator.AnimatorListener {
|
||||
override fun onAnimationStart(animation: Animator) {
|
||||
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
@@ -111,11 +110,9 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
override fun onAnimationCancel(animation: Animator) {
|
||||
|
||||
}
|
||||
|
||||
override fun onAnimationRepeat(animation: Animator) {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -222,7 +219,6 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inner class Detector : GestureDetectorWithLongTap(context, listener) {
|
||||
@@ -310,7 +306,6 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
}
|
||||
return super.onTouchEvent(ev)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private companion object {
|
||||
@@ -318,5 +313,4 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
const val DEFAULT_RATE = 1f
|
||||
const val MAX_SCALE_RATE = 3f
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -10,12 +10,11 @@ import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||
* webtoon viewer handles all the gestures.
|
||||
*/
|
||||
class WebtoonSubsamplingImageView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null
|
||||
) : SubsamplingScaleImageView(context, attrs) {
|
||||
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -24,8 +24,8 @@ import rx.android.schedulers.AndroidSchedulers
|
||||
* Holder of the webtoon viewer that contains a chapter transition.
|
||||
*/
|
||||
class WebtoonTransitionHolder(
|
||||
val layout: LinearLayout,
|
||||
viewer: WebtoonViewer
|
||||
val layout: LinearLayout,
|
||||
viewer: WebtoonViewer
|
||||
) : WebtoonBaseHolder(layout, viewer) {
|
||||
|
||||
/**
|
||||
@@ -212,5 +212,4 @@ class WebtoonTransitionHolder(
|
||||
pagesContainer.addView(textView)
|
||||
pagesContainer.addView(retryBtn)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer
|
||||
import rx.subscriptions.CompositeSubscription
|
||||
import timber.log.Timber
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import rx.subscriptions.CompositeSubscription
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* Implementation of a [BaseViewer] to display pages with a [RecyclerView].
|
||||
@@ -264,5 +264,4 @@ class WebtoonViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
val position = layoutManager.findLastEndVisibleItemPosition()
|
||||
adapter.notifyItemRangeChanged(max(0, position - 1), min(2, adapter.itemCount - position))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user