Substitute some deprecated functions (#386)
* Deprecated color filter * Various deprecated functions
This commit is contained in:
parent
69aaa323e2
commit
1bb975c584
@ -52,19 +52,19 @@ class AddSourceActivity : AppCompatActivity() {
|
||||
scoop.bindStatusBar(this, Toppings.PRIMARY_DARK.value)
|
||||
|
||||
val drawable = binding.nameInput.background
|
||||
drawable.setColorFilter(appColors.colorAccent, PorterDuff.Mode.SRC_ATOP)
|
||||
drawable.setTint(appColors.colorAccent)
|
||||
|
||||
|
||||
// TODO: clean
|
||||
binding.nameInput.background = drawable
|
||||
|
||||
val drawable1 = binding.sourceUri.background
|
||||
drawable1.setColorFilter(appColors.colorAccent, PorterDuff.Mode.SRC_ATOP)
|
||||
drawable1.setTint(appColors.colorAccent)
|
||||
|
||||
binding.sourceUri.background = drawable1
|
||||
|
||||
val drawable2 = binding.tags.background
|
||||
drawable2.setColorFilter(appColors.colorAccent, PorterDuff.Mode.SRC_ATOP)
|
||||
drawable2.setTint(appColors.colorAccent)
|
||||
|
||||
binding.tags.background = drawable2
|
||||
|
||||
|
@ -61,14 +61,14 @@ class MyApp : MultiDexApplication() {
|
||||
private fun initDrawerImageLoader() {
|
||||
DrawerImageLoader.init(object : AbstractDrawerImageLoader() {
|
||||
override fun set(imageView: ImageView, uri: Uri, placeholder: Drawable, tag: String?) {
|
||||
Glide.with(imageView?.context)
|
||||
Glide.with(imageView.context)
|
||||
.loadMaybeBasicAuth(config, uri.toString())
|
||||
.apply(RequestOptions.fitCenterTransform().placeholder(placeholder))
|
||||
.into(imageView)
|
||||
}
|
||||
|
||||
override fun cancel(imageView: ImageView) {
|
||||
Glide.with(imageView?.context).clear(imageView)
|
||||
Glide.with(imageView.context).clear(imageView)
|
||||
}
|
||||
|
||||
override fun placeholder(ctx: Context, tag: String?): Drawable {
|
||||
|
@ -127,7 +127,7 @@ class ReaderActivity : AppCompatActivity() {
|
||||
notifyAdapter()
|
||||
|
||||
binding.pager.setPageTransformer(true, DepthPageTransformer())
|
||||
(binding.indicator as CircleIndicator).setViewPager(binding.pager)
|
||||
binding.indicator.setViewPager(binding.pager)
|
||||
|
||||
binding.pager.addOnPageChangeListener(
|
||||
object : ViewPager.SimpleOnPageChangeListener() {
|
||||
|
@ -14,6 +14,8 @@ import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
private fun constructUrl(config: Config?, path: String, file: String?): String {
|
||||
return if (file.isEmptyOrNullOrNullString()) {
|
||||
@ -155,14 +157,14 @@ data class Item(
|
||||
}
|
||||
|
||||
fun getImages() : ArrayList<String> {
|
||||
var allImages = ArrayList<String>()
|
||||
val allImages = ArrayList<String>()
|
||||
|
||||
for ( image in Jsoup.parse(content).getElementsByTag("img")) {
|
||||
val url = image.attr("src")
|
||||
if (url.toLowerCase().contains(".jpg") ||
|
||||
url.toLowerCase().contains(".jpeg") ||
|
||||
url.toLowerCase().contains(".png") ||
|
||||
url.toLowerCase().contains(".webp"))
|
||||
if (url.lowercase(Locale.US).contains(".jpg") ||
|
||||
url.lowercase(Locale.US).contains(".jpeg") ||
|
||||
url.lowercase(Locale.US).contains(".png") ||
|
||||
url.lowercase(Locale.US).contains(".webp"))
|
||||
{
|
||||
allImages.add(url)
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ import retrofit2.Callback
|
||||
import retrofit2.Response
|
||||
import java.net.MalformedURLException
|
||||
import java.net.URL
|
||||
import java.util.*
|
||||
import java.util.concurrent.ExecutionException
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
@ -430,19 +431,19 @@ class ArticleFragment : Fragment() {
|
||||
|
||||
override fun shouldInterceptRequest(view: WebView?, url: String): WebResourceResponse? {
|
||||
val glideOptions = RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.ALL)
|
||||
if (url.toLowerCase().contains(".jpg") || url.toLowerCase().contains(".jpeg")) {
|
||||
if (url.lowercase(Locale.US).contains(".jpg") || url.lowercase(Locale.US).contains(".jpeg")) {
|
||||
try {
|
||||
val image = Glide.with(view).asBitmap().apply(glideOptions).load(url).submit().get()
|
||||
return WebResourceResponse("image/jpg", "UTF-8", getBitmapInputStream(image, Bitmap.CompressFormat.JPEG))
|
||||
}catch ( e : ExecutionException) {}
|
||||
}
|
||||
else if (url.toLowerCase().contains(".png")) {
|
||||
else if (url.lowercase(Locale.US).contains(".png")) {
|
||||
try {
|
||||
val image = Glide.with(view).asBitmap().apply(glideOptions).load(url).submit().get()
|
||||
return WebResourceResponse("image/jpg", "UTF-8", getBitmapInputStream(image, Bitmap.CompressFormat.PNG))
|
||||
}catch ( e : ExecutionException) {}
|
||||
}
|
||||
else if (url.toLowerCase().contains(".webp")) {
|
||||
else if (url.lowercase(Locale.US).contains(".webp")) {
|
||||
try {
|
||||
val image = Glide.with(view).asBitmap().apply(glideOptions).load(url).submit().get()
|
||||
return WebResourceResponse("image/jpg", "UTF-8", getBitmapInputStream(image, Bitmap.CompressFormat.WEBP))
|
||||
|
@ -13,7 +13,7 @@ fun String.longHash(): Long {
|
||||
val chars = this.toCharArray()
|
||||
|
||||
for (i in 0 until l) {
|
||||
h = 31 * h + chars[i].toLong()
|
||||
h = 31 * h + chars[i].code.toLong()
|
||||
}
|
||||
return h
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user