This commit is contained in:
reduplicated 2022-08-19 20:28:03 +02:00
parent 1f60c877de
commit db3e23621a
6 changed files with 38 additions and 26 deletions

View File

@ -12,9 +12,11 @@ import androidx.recyclerview.widget.RecyclerView
import com.lagradost.cloudstream3.PROVIDER_STATUS_DOWN
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.plugins.PluginManager
import com.lagradost.cloudstream3.ui.result.setText
import com.lagradost.cloudstream3.ui.result.txt
import com.lagradost.cloudstream3.utils.AppUtils.html
import com.lagradost.cloudstream3.utils.GlideApp
import com.lagradost.cloudstream3.utils.SubtitleHelper.getFlagFromIso
import com.lagradost.cloudstream3.utils.SubtitleHelper.fromTwoLettersToLanguage
import com.lagradost.cloudstream3.utils.UIHelper.setImage
import com.lagradost.cloudstream3.utils.UIHelper.toPx
import kotlinx.android.synthetic.main.repository_item.view.*
@ -93,8 +95,9 @@ class PluginAdapter(
Assert.assertEquals(512, findClosestBase2(700))
}
val iconSize by lazy {
findClosestBase2(32.toPx, 16, 512)
private val iconSizeExact = 32.toPx
private val iconSize by lazy {
findClosestBase2(iconSizeExact, 16, 512)
}
}
@ -105,7 +108,8 @@ class PluginAdapter(
data: PluginViewData,
) {
val metadata = data.plugin.second
val alpha = if (metadata.status == PROVIDER_STATUS_DOWN) 0.6f else 1f
val disabled = metadata.status == PROVIDER_STATUS_DOWN
val alpha = if (disabled) 0.6f else 1f
itemView.main_text?.alpha = alpha
itemView.sub_text?.alpha = alpha
@ -157,6 +161,9 @@ class PluginAdapter(
metadata.iconUrl?.replace(
"%size%",
"$iconSize"
)?.replace(
"%exact_size%",
"$iconSizeExact"
),
null,
errorImageDrawable = R.drawable.ic_baseline_extension_24
@ -170,7 +177,8 @@ class PluginAdapter(
if (metadata.language != null) {
itemView.lang_icon?.isVisible = true
itemView.lang_icon.text = getFlagFromIso(metadata.language)
//itemView.lang_icon.text = getFlagFromIso(metadata.language)
itemView.lang_icon.text = fromTwoLettersToLanguage(metadata.language)
} else {
itemView.lang_icon?.isVisible = false
}
@ -182,8 +190,7 @@ class PluginAdapter(
} else {
itemView.ext_filesize?.isVisible = false
}
itemView.main_text?.text = metadata.name
itemView.main_text.setText(if(disabled) txt(R.string.single_plugin_disabled, metadata.name) else txt(metadata.name))
itemView.sub_text?.isGone = metadata.description.isNullOrBlank()
itemView.sub_text?.text = metadata.description.html()
}

View File

@ -75,7 +75,7 @@ object AppUtils {
val layoutManager =
this.layoutManager as? LinearLayoutManager?
val adapter = adapter
return if (layoutManager == null || adapter == null) false else layoutManager.findLastCompletelyVisibleItemPosition() < adapter.itemCount - 2
return if (layoutManager == null || adapter == null) false else layoutManager.findLastCompletelyVisibleItemPosition() < adapter.itemCount - 7 // bit more than 1 to make it more seamless
}
//fun Context.deleteFavorite(data: SearchResponse) {

View File

@ -138,14 +138,14 @@ object SubtitleHelper {
private fun getFlagFromIsoShort(flagAscii: String?): String? {
if (flagAscii.isNullOrBlank() || flagAscii.length < 2) return null
try {
return try {
val firstChar: Int = Character.codePointAt(flagAscii, 0) + offset
val secondChar: Int = Character.codePointAt(flagAscii, 1) + offset
return (String(Character.toChars(firstChar)) + String(Character.toChars(secondChar)))
(String(Character.toChars(firstChar)) + String(Character.toChars(secondChar)))
} catch (e: Exception) {
logError(e)
return null
null
}
}

View File

@ -30,6 +30,7 @@
android:id="@+id/main_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/textColor"
android:textSize="16sp"
tools:text="Test repository" />
@ -42,9 +43,10 @@
<TextView
android:id="@+id/lang_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_height="match_parent"
android:text="🇷🇼"
android:textColor="?attr/grayTextColor"
android:visibility="gone"
tools:visibility="visible" />
@ -53,17 +55,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="5dp"
android:text="v1"
android:visibility="gone"
tools:visibility="visible" />
<TextView
android:id="@+id/nsfw_marker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="@string/is_adult"
android:textColor="@color/adultColor"
android:textColor="?attr/grayTextColor"
android:visibility="gone"
tools:visibility="visible" />
@ -72,9 +66,19 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:layout_marginStart="5dp"
android:text="100MB"
android:textColor="?attr/grayTextColor"
android:visibility="gone"
tools:visibility="visible" />
<TextView
android:id="@+id/nsfw_marker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:text="@string/is_adult"
android:textColor="@color/adultColor"
android:visibility="gone"
tools:visibility="visible" />

View File

@ -31,7 +31,7 @@
<color name="typeColor">#3BF585</color>
<color name="typeColorBg">?attr/colorPrimaryDark</color>
<color name="adultColor">#F54A3B</color> <!-- same as sub color -->
<color name="adultColor">#FF6F63</color> <!-- same as sub color -->
<color name="video_ripple">#80FFFFFF</color>
<color name="video_button_ripple">#32FFFFFF</color>

View File

@ -602,4 +602,5 @@
<string name="uppercase_all_subtitles">Uppercase all subtitles</string>
<string name="download_all_plugins_from_repo">Download all plugins from this repository?</string>
<string name="single_plugin_disabled" formatted="true">%s (Disabled)</string>
</resources>