2016-05-13 09:45:36 -04:00
|
|
|
package eu.kanade.tachiyomi.widget
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import android.util.AttributeSet
|
|
|
|
import android.view.View
|
|
|
|
import android.widget.RelativeLayout
|
|
|
|
import eu.kanade.tachiyomi.R
|
2020-02-02 22:22:54 -05:00
|
|
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
|
|
|
import eu.kanade.tachiyomi.util.view.setVectorCompat
|
2020-01-28 22:47:57 -05:00
|
|
|
import kotlinx.android.synthetic.main.common_view_empty.view.image_view
|
|
|
|
import kotlinx.android.synthetic.main.common_view_empty.view.text_label
|
2016-05-13 09:45:36 -04:00
|
|
|
|
|
|
|
class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
2020-02-17 17:23:37 -05:00
|
|
|
RelativeLayout(context, attrs) {
|
2016-05-13 09:45:36 -04:00
|
|
|
|
|
|
|
init {
|
2017-05-25 06:16:58 -04:00
|
|
|
inflate(context, R.layout.common_view_empty, this)
|
2016-05-13 09:45:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hide the information view
|
|
|
|
*/
|
|
|
|
fun hide() {
|
|
|
|
this.visibility = View.GONE
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the information view
|
|
|
|
* @param drawable icon of information view
|
|
|
|
* @param textResource text of information view
|
|
|
|
*/
|
|
|
|
fun show(drawable: Int, textResource: Int) {
|
2017-01-08 12:50:51 -05:00
|
|
|
image_view.setVectorCompat(drawable, context.getResourceColor(android.R.attr.textColorHint))
|
2016-05-13 09:45:36 -04:00
|
|
|
text_label.text = context.getString(textResource)
|
|
|
|
this.visibility = View.VISIBLE
|
|
|
|
}
|
|
|
|
}
|