Binding Empty View + Remove DialogCheckboxView

This commit is contained in:
Jays2Kings 2021-03-29 23:07:36 -04:00
parent 89f4ad393b
commit ef737dd40b
2 changed files with 8 additions and 37 deletions

View File

@ -1,29 +0,0 @@
package eu.kanade.tachiyomi.widget
import android.content.Context
import android.util.AttributeSet
import android.widget.LinearLayout
import androidx.annotation.StringRes
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.view.inflate
import kotlinx.android.synthetic.main.common_dialog_with_checkbox.view.*
class DialogCheckboxView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
LinearLayout(context, attrs) {
init {
addView(inflate(R.layout.common_dialog_with_checkbox))
}
fun setDescription(@StringRes id: Int) {
description.text = context.getString(id)
}
fun setOptionDescription(@StringRes id: Int) {
checkbox_option.text = context.getString(id)
}
fun isChecked(): Boolean {
return checkbox_option.isChecked
}
}

View File

@ -2,23 +2,23 @@ package eu.kanade.tachiyomi.widget
import android.content.Context import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.RelativeLayout import android.widget.RelativeLayout
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import androidx.annotation.StringRes import androidx.annotation.StringRes
import com.google.android.material.button.MaterialButton import com.google.android.material.button.MaterialButton
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.CommonViewEmptyBinding
import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.setVectorCompat import eu.kanade.tachiyomi.util.view.setVectorCompat
import eu.kanade.tachiyomi.util.view.visible import eu.kanade.tachiyomi.util.view.visible
import kotlinx.android.synthetic.main.common_view_empty.view.*
class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
RelativeLayout(context, attrs) { RelativeLayout(context, attrs) {
init { private val binding: CommonViewEmptyBinding =
inflate(context, R.layout.common_view_empty, this) CommonViewEmptyBinding.inflate(LayoutInflater.from(context), this, true)
}
/** /**
* Hide the information view * Hide the information view
@ -41,10 +41,10 @@ class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
* @param textResource text of information view * @param textResource text of information view
*/ */
fun show(@DrawableRes drawable: Int, message: String, actions: List<Action>? = null) { fun show(@DrawableRes drawable: Int, message: String, actions: List<Action>? = null) {
image_view.setVectorCompat(drawable, context.getResourceColor(android.R.attr.textColorHint)) binding.imageView.setVectorCompat(drawable, context.getResourceColor(android.R.attr.textColorHint))
text_label.text = message binding.textLabel.text = message
actions_container.removeAllViews() binding.actionsContainer.removeAllViews()
if (!actions.isNullOrEmpty()) { if (!actions.isNullOrEmpty()) {
actions.forEach { actions.forEach {
val button = ( val button = (
@ -58,7 +58,7 @@ class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
setOnClickListener(it.listener) setOnClickListener(it.listener)
} }
actions_container.addView(button) binding.actionsContainer.addView(button)
} }
} }