|
|
@ -1,13 +1,18 @@ |
|
|
|
package io.legado.app.ui.association |
|
|
|
package io.legado.app.ui.association |
|
|
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint |
|
|
|
import android.annotation.SuppressLint |
|
|
|
|
|
|
|
import android.graphics.Bitmap |
|
|
|
|
|
|
|
import android.graphics.drawable.Drawable |
|
|
|
import android.os.Bundle |
|
|
|
import android.os.Bundle |
|
|
|
import android.view.MenuItem |
|
|
|
import android.view.MenuItem |
|
|
|
import android.view.View |
|
|
|
import android.view.View |
|
|
|
import android.view.ViewGroup |
|
|
|
import android.view.ViewGroup |
|
|
|
import androidx.appcompat.widget.Toolbar |
|
|
|
import androidx.appcompat.widget.Toolbar |
|
|
|
|
|
|
|
import androidx.core.graphics.drawable.toBitmap |
|
|
|
import com.bumptech.glide.load.engine.DiskCacheStrategy |
|
|
|
import com.bumptech.glide.load.engine.DiskCacheStrategy |
|
|
|
import com.bumptech.glide.request.RequestOptions |
|
|
|
import com.bumptech.glide.request.RequestOptions |
|
|
|
|
|
|
|
import com.bumptech.glide.request.target.CustomTarget |
|
|
|
|
|
|
|
import com.bumptech.glide.request.transition.Transition |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.base.BaseDialogFragment |
|
|
|
import io.legado.app.base.BaseDialogFragment |
|
|
|
import io.legado.app.databinding.DialogVerificationCodeViewBinding |
|
|
|
import io.legado.app.databinding.DialogVerificationCodeViewBinding |
|
|
@ -22,9 +27,6 @@ import io.legado.app.utils.applyTint |
|
|
|
import io.legado.app.utils.setLayout |
|
|
|
import io.legado.app.utils.setLayout |
|
|
|
import io.legado.app.utils.showDialogFragment |
|
|
|
import io.legado.app.utils.showDialogFragment |
|
|
|
import io.legado.app.utils.viewbindingdelegate.viewBinding |
|
|
|
import io.legado.app.utils.viewbindingdelegate.viewBinding |
|
|
|
import kotlinx.coroutines.Dispatchers.IO |
|
|
|
|
|
|
|
import kotlinx.coroutines.launch |
|
|
|
|
|
|
|
import kotlinx.coroutines.withContext |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 图片验证码对话框 |
|
|
|
* 图片验证码对话框 |
|
|
@ -79,9 +81,7 @@ class VerificationCodeDialog() : BaseDialogFragment(R.layout.dialog_verification |
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("CheckResult") |
|
|
|
@SuppressLint("CheckResult") |
|
|
|
private fun loadImage(url: String, sourceUrl: String?) { |
|
|
|
private fun loadImage(url: String, sourceUrl: String?) { |
|
|
|
launch { |
|
|
|
|
|
|
|
ImageProvider.bitmapLruCache.remove(url) |
|
|
|
ImageProvider.bitmapLruCache.remove(url) |
|
|
|
val image = withContext(IO) { |
|
|
|
|
|
|
|
ImageLoader.loadBitmap(requireContext(), url).apply { |
|
|
|
ImageLoader.loadBitmap(requireContext(), url).apply { |
|
|
|
sourceUrl?.let { |
|
|
|
sourceUrl?.let { |
|
|
|
apply( |
|
|
|
apply( |
|
|
@ -91,12 +91,25 @@ class VerificationCodeDialog() : BaseDialogFragment(R.layout.dialog_verification |
|
|
|
}.error(R.drawable.image_loading_error) |
|
|
|
}.error(R.drawable.image_loading_error) |
|
|
|
.diskCacheStrategy(DiskCacheStrategy.NONE) |
|
|
|
.diskCacheStrategy(DiskCacheStrategy.NONE) |
|
|
|
.skipMemoryCache(true) |
|
|
|
.skipMemoryCache(true) |
|
|
|
.submit() |
|
|
|
.into(object : CustomTarget<Bitmap>() { |
|
|
|
.get() |
|
|
|
override fun onLoadFailed(errorDrawable: Drawable?) { |
|
|
|
|
|
|
|
errorDrawable?.toBitmap()?.let { |
|
|
|
|
|
|
|
onResourceReady(it, null) |
|
|
|
} |
|
|
|
} |
|
|
|
ImageProvider.bitmapLruCache.put(url, image) |
|
|
|
|
|
|
|
binding.verificationCodeImageView.setImageBitmap(image) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onResourceReady( |
|
|
|
|
|
|
|
resource: Bitmap, |
|
|
|
|
|
|
|
transition: Transition<in Bitmap>? |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
ImageProvider.bitmapLruCache.put(url, resource) |
|
|
|
|
|
|
|
binding.verificationCodeImageView.setImageBitmap(resource) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onLoadCleared(placeholder: Drawable?) { |
|
|
|
|
|
|
|
// do nothing |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("InflateParams") |
|
|
|
@SuppressLint("InflateParams") |
|
|
|