Update NDK, more KTX usage (#4792)

* Update NDK

* Utilize more KTX extensions
This commit is contained in:
Taco 2021-04-08 17:56:01 -04:00 committed by GitHub
parent b2d697131c
commit b3471234ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 34 deletions

View File

@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.browse.source.filter
import android.view.View import android.view.View
import android.widget.EditText import android.widget.EditText
import androidx.core.widget.doOnTextChanged
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.textfield.TextInputLayout import com.google.android.material.textfield.TextInputLayout
import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.FlexibleAdapter
@ -10,7 +11,6 @@ import eu.davidea.flexibleadapter.items.IFlexible
import eu.davidea.viewholders.FlexibleViewHolder import eu.davidea.viewholders.FlexibleViewHolder
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.source.model.Filter import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.widget.SimpleTextWatcher
open class TextItem(val filter: Filter.Text) : AbstractFlexibleItem<TextItem.Holder>() { open class TextItem(val filter: Filter.Text) : AbstractFlexibleItem<TextItem.Holder>() {
@ -25,11 +25,9 @@ open class TextItem(val filter: Filter.Text) : AbstractFlexibleItem<TextItem.Hol
override fun bindViewHolder(adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>, holder: Holder, position: Int, payloads: List<Any?>?) { override fun bindViewHolder(adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>, holder: Holder, position: Int, payloads: List<Any?>?) {
holder.wrapper.hint = filter.name holder.wrapper.hint = filter.name
holder.edit.setText(filter.state) holder.edit.setText(filter.state)
holder.edit.addTextChangedListener(object : SimpleTextWatcher() { holder.edit.doOnTextChanged { text, _, _, _ ->
override fun onTextChanged(text: CharSequence, start: Int, before: Int, count: Int) {
filter.state = text.toString() filter.state = text.toString()
} }
})
} }
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {

View File

@ -820,7 +820,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
* Sets the visibility of the bottom page indicator according to [visible]. * Sets the visibility of the bottom page indicator according to [visible].
*/ */
fun setPageNumberVisibility(visible: Boolean) { fun setPageNumberVisibility(visible: Boolean) {
binding.pageNumber.visibility = if (visible) View.VISIBLE else View.INVISIBLE binding.pageNumber.isVisible = visible
} }
/** /**

View File

@ -4,6 +4,7 @@ import android.graphics.Bitmap
import android.graphics.BitmapFactory import android.graphics.BitmapFactory
import android.graphics.Canvas import android.graphics.Canvas
import android.graphics.Rect import android.graphics.Rect
import androidx.core.graphics.createBitmap
import java.io.ByteArrayInputStream import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.io.InputStream import java.io.InputStream
@ -99,7 +100,7 @@ object ImageUtil {
val singlePage = Rect(0, 0, width / 2, height) val singlePage = Rect(0, 0, width / 2, height)
val half = Bitmap.createBitmap(width / 2, height, Bitmap.Config.ARGB_8888) val half = createBitmap(width / 2, height)
val part = when (side) { val part = when (side) {
Side.RIGHT -> Rect(width - width / 2, 0, width, height) Side.RIGHT -> Rect(width - width / 2, 0, width, height)
Side.LEFT -> Rect(0, 0, width / 2, height) Side.LEFT -> Rect(0, 0, width / 2, height)
@ -122,7 +123,7 @@ object ImageUtil {
val height = imageBitmap.height val height = imageBitmap.height
val width = imageBitmap.width val width = imageBitmap.width
val result = Bitmap.createBitmap(width / 2, height * 2, Bitmap.Config.ARGB_8888) val result = createBitmap(width / 2, height * 2)
val canvas = Canvas(result) val canvas = Canvas(result)
// right -> upper // right -> upper
val rightPart = when (upperSide) { val rightPart = when (upperSide) {

View File

@ -6,6 +6,7 @@ import android.util.AttributeSet
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.core.widget.doOnTextChanged
import eu.kanade.tachiyomi.databinding.DownloadCustomAmountBinding import eu.kanade.tachiyomi.databinding.DownloadCustomAmountBinding
import timber.log.Timber import timber.log.Timber
@ -65,8 +66,7 @@ class DialogCustomDownloadView @JvmOverloads constructor(context: Context, attrs
} }
// When user inputs custom number set amount equal to input. // When user inputs custom number set amount equal to input.
binding.myNumber.addTextChangedListener(object : SimpleTextWatcher() { binding.myNumber.doOnTextChanged { text, _, _, _ ->
override fun onTextChanged(text: CharSequence, start: Int, before: Int, count: Int) {
try { try {
amount = getAmount(text.toString().toInt()) amount = getAmount(text.toString().toInt())
} catch (error: NumberFormatException) { } catch (error: NumberFormatException) {
@ -74,7 +74,6 @@ class DialogCustomDownloadView @JvmOverloads constructor(context: Context, attrs
Timber.e(error) Timber.e(error)
} }
} }
})
} }
/** /**

View File

@ -1,15 +0,0 @@
package eu.kanade.tachiyomi.widget
import android.text.Editable
import android.text.TextWatcher
open class SimpleTextWatcher : TextWatcher {
override fun beforeTextChanged(text: CharSequence, start: Int, count: Int, after: Int) {
}
override fun onTextChanged(text: CharSequence, start: Int, before: Int, count: Int) {
}
override fun afterTextChanged(text: Editable) {
}
}

View File

@ -3,5 +3,5 @@ object AndroidConfig {
const val minSdk = 21 const val minSdk = 21
const val targetSdk = 29 const val targetSdk = 29
const val buildTools = "30.0.3" const val buildTools = "30.0.3"
const val ndk = "22.0.7026061" const val ndk = "22.1.7171670"
} }