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