mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
fixed icon size
This commit is contained in:
parent
6149d48443
commit
fc5f80c112
1 changed files with 32 additions and 3 deletions
|
@ -1,6 +1,8 @@
|
||||||
package com.lagradost.cloudstream3.ui.settings.extensions
|
package com.lagradost.cloudstream3.ui.settings.extensions
|
||||||
|
|
||||||
|
import android.content.res.Resources
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.util.TypedValue
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
@ -15,7 +17,10 @@ import com.lagradost.cloudstream3.utils.AppUtils.html
|
||||||
import com.lagradost.cloudstream3.utils.GlideApp
|
import com.lagradost.cloudstream3.utils.GlideApp
|
||||||
import com.lagradost.cloudstream3.utils.SubtitleHelper.getFlagFromIso
|
import com.lagradost.cloudstream3.utils.SubtitleHelper.getFlagFromIso
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.setImage
|
import com.lagradost.cloudstream3.utils.UIHelper.setImage
|
||||||
|
import com.lagradost.cloudstream3.utils.UIHelper.toPx
|
||||||
import kotlinx.android.synthetic.main.repository_item.view.*
|
import kotlinx.android.synthetic.main.repository_item.view.*
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
|
||||||
data class PluginViewData(
|
data class PluginViewData(
|
||||||
|
@ -73,6 +78,27 @@ class PluginAdapter(
|
||||||
super.onViewRecycled(holder)
|
super.onViewRecycled(holder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private tailrec fun findClosestBase2(target: Int, current: Int = 16, max: Int = 512): Int {
|
||||||
|
if (current >= max) return max
|
||||||
|
if (current >= target) return current
|
||||||
|
return findClosestBase2(target, current * 2, max)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testFindClosestBase2() {
|
||||||
|
Assert.assertEquals(16, findClosestBase2(0))
|
||||||
|
Assert.assertEquals(256, findClosestBase2(170))
|
||||||
|
Assert.assertEquals(256, findClosestBase2(256))
|
||||||
|
Assert.assertEquals(512, findClosestBase2(257))
|
||||||
|
Assert.assertEquals(512, findClosestBase2(700))
|
||||||
|
}
|
||||||
|
|
||||||
|
val iconSize by lazy {
|
||||||
|
findClosestBase2(24.toPx, 16, 512)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inner class PluginViewHolder(itemView: View) :
|
inner class PluginViewHolder(itemView: View) :
|
||||||
RecyclerView.ViewHolder(itemView) {
|
RecyclerView.ViewHolder(itemView) {
|
||||||
|
|
||||||
|
@ -94,7 +120,7 @@ class PluginAdapter(
|
||||||
itemView.action_button?.setOnClickListener {
|
itemView.action_button?.setOnClickListener {
|
||||||
iconClickCallback.invoke(data.plugin)
|
iconClickCallback.invoke(data.plugin)
|
||||||
}
|
}
|
||||||
|
testFindClosestBase2()
|
||||||
//if (itemView.context?.isTrueTvSettings() == false) {
|
//if (itemView.context?.isTrueTvSettings() == false) {
|
||||||
// val siteUrl = metadata.repositoryUrl
|
// val siteUrl = metadata.repositoryUrl
|
||||||
// if (siteUrl != null && siteUrl.isNotBlank() && siteUrl != "NONE") {
|
// if (siteUrl != null && siteUrl.isNotBlank() && siteUrl != "NONE") {
|
||||||
|
@ -128,8 +154,11 @@ class PluginAdapter(
|
||||||
itemView.action_settings?.isVisible = false
|
itemView.action_settings?.isVisible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemView.entry_icon?.setImage(
|
if (itemView.entry_icon?.setImage(//itemView.entry_icon?.height ?:
|
||||||
metadata.iconUrl?.replace("&sz=24", "&sz=128"), // lazy fix for better resolution
|
metadata.iconUrl?.replace(
|
||||||
|
"&sz=24",
|
||||||
|
"&sz=$iconSize"
|
||||||
|
), // lazy fix for better resolution
|
||||||
null,
|
null,
|
||||||
errorImageDrawable = R.drawable.ic_baseline_extension_24
|
errorImageDrawable = R.drawable.ic_baseline_extension_24
|
||||||
) != true
|
) != true
|
||||||
|
|
Loading…
Reference in a new issue