mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-09 10:38:56 +01:00
Random kaomoji for empty view
This commit is contained in:
@@ -2,12 +2,13 @@ package eu.kanade.tachiyomi.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.annotation.StringRes
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.view.setVectorCompat
|
||||
import kotlinx.android.synthetic.main.common_view_empty.view.image_view
|
||||
import eu.kanade.tachiyomi.util.view.gone
|
||||
import eu.kanade.tachiyomi.util.view.visible
|
||||
import kotlin.random.Random
|
||||
import kotlinx.android.synthetic.main.common_view_empty.view.text_face
|
||||
import kotlinx.android.synthetic.main.common_view_empty.view.text_label
|
||||
|
||||
class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
@@ -21,17 +22,31 @@ class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
|
||||
* Hide the information view
|
||||
*/
|
||||
fun hide() {
|
||||
this.visibility = View.GONE
|
||||
this.gone()
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the information view
|
||||
* @param drawable icon of information view
|
||||
* @param textResource text of information view
|
||||
*/
|
||||
fun show(drawable: Int, textResource: Int) {
|
||||
image_view.setVectorCompat(drawable, context.getResourceColor(android.R.attr.textColorHint))
|
||||
fun show(@StringRes textResource: Int) {
|
||||
text_face.text = getRandomErrorFace()
|
||||
text_label.text = context.getString(textResource)
|
||||
this.visibility = View.VISIBLE
|
||||
this.visible()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val ERROR_FACES = listOf(
|
||||
"(・o・;)",
|
||||
"Σ(ಠ_ಠ)",
|
||||
"ಥ_ಥ",
|
||||
"(˘・_・˘)",
|
||||
"(; ̄Д ̄)",
|
||||
"(・Д・。"
|
||||
)
|
||||
|
||||
fun getRandomErrorFace(): String {
|
||||
return ERROR_FACES[Random.nextInt(ERROR_FACES.size)]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user