mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 11:22:12 +00:00
Fix: Manage most missing names of authors
This commit is contained in:
parent
c4a835bf38
commit
070ec76d0c
@ -1231,9 +1231,11 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
|||||||
holder.targetSdk.text = sdk.toString()
|
holder.targetSdk.text = sdk.toString()
|
||||||
holder.version.text = product?.displayRelease?.version
|
holder.version.text = product?.displayRelease?.version
|
||||||
holder.size.text = product?.displayRelease?.size?.formatSize()
|
holder.size.text = product?.displayRelease?.size?.formatSize()
|
||||||
holder.devName.text = product?.author?.name?.replaceFirstChar {
|
val author = product?.author?.name?.replaceFirstChar {
|
||||||
if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString()
|
if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString()
|
||||||
}
|
}
|
||||||
|
val devName = product?.source?.trimAfter('/', 4).trimBefore('/', 3)
|
||||||
|
holder.devName.text = if (author.isNullOrEmpty()) devName else author
|
||||||
when {
|
when {
|
||||||
imageSource.toString()
|
imageSource.toString()
|
||||||
.contains("kde.org") -> holder.devIcon.setImageResource(R.drawable.ic_kde)
|
.contains("kde.org") -> holder.devIcon.setImageResource(R.drawable.ic_kde)
|
||||||
@ -1305,7 +1307,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
|||||||
layoutParams.topMargin = if (position > 0 && items[position - 1] !is Item.LinkItem)
|
layoutParams.topMargin = if (position > 0 && items[position - 1] !is Item.LinkItem)
|
||||||
-context.resources.sizeScaled(8) else 0
|
-context.resources.sizeScaled(8) else 0
|
||||||
holder.itemView.isEnabled = item.uri != null
|
holder.itemView.isEnabled = item.uri != null
|
||||||
holder.icon.setImageDrawable(holder.icon.context.getDrawableCompat(item.iconResId))
|
holder.icon.setImageResource(item.iconResId)
|
||||||
holder.text.text = item.getTitle(context)
|
holder.text.text = item.getTitle(context)
|
||||||
holder.link.visibility = if (item.uri != null) View.VISIBLE else View.GONE
|
holder.link.visibility = if (item.uri != null) View.VISIBLE else View.GONE
|
||||||
holder.link.text = item.displayLink
|
holder.link.text = item.displayLink
|
||||||
|
@ -30,6 +30,17 @@ fun String?.trimAfter(char: Char, repeated: Int): String? {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun String?.trimBefore(char: Char, repeated: Int): String? {
|
||||||
|
var count = 0
|
||||||
|
this?.let {
|
||||||
|
for (i in it.indices) {
|
||||||
|
if (it[i] == char) count++
|
||||||
|
if (repeated == count) return it.substring(i+1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
fun Char.halfByte(): Int {
|
fun Char.halfByte(): Int {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
in '0'..'9' -> this - '0'
|
in '0'..'9' -> this - '0'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user