From ef737dd40b1bd14c6fe9e38225ab8ee61ce3bfa7 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Mon, 29 Mar 2021 23:07:36 -0400 Subject: [PATCH] Binding Empty View + Remove DialogCheckboxView --- .../tachiyomi/widget/DialogCheckboxView.kt | 29 ------------------- .../eu/kanade/tachiyomi/widget/EmptyView.kt | 16 +++++----- 2 files changed, 8 insertions(+), 37 deletions(-) delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/widget/DialogCheckboxView.kt diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/DialogCheckboxView.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/DialogCheckboxView.kt deleted file mode 100644 index dd99d9bc5b..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/DialogCheckboxView.kt +++ /dev/null @@ -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 - } -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/EmptyView.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/EmptyView.kt index d4a01a489c..90f8a3a3b2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/EmptyView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/EmptyView.kt @@ -2,23 +2,23 @@ package eu.kanade.tachiyomi.widget import android.content.Context import android.util.AttributeSet +import android.view.LayoutInflater import android.widget.RelativeLayout import androidx.annotation.DrawableRes import androidx.annotation.StringRes import com.google.android.material.button.MaterialButton import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.databinding.CommonViewEmptyBinding import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.setVectorCompat 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) : RelativeLayout(context, attrs) { - init { - inflate(context, R.layout.common_view_empty, this) - } + private val binding: CommonViewEmptyBinding = + CommonViewEmptyBinding.inflate(LayoutInflater.from(context), this, true) /** * Hide the information view @@ -41,10 +41,10 @@ class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet? * @param textResource text of information view */ fun show(@DrawableRes drawable: Int, message: String, actions: List? = null) { - image_view.setVectorCompat(drawable, context.getResourceColor(android.R.attr.textColorHint)) - text_label.text = message + binding.imageView.setVectorCompat(drawable, context.getResourceColor(android.R.attr.textColorHint)) + binding.textLabel.text = message - actions_container.removeAllViews() + binding.actionsContainer.removeAllViews() if (!actions.isNullOrEmpty()) { actions.forEach { val button = ( @@ -58,7 +58,7 @@ class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet? setOnClickListener(it.listener) } - actions_container.addView(button) + binding.actionsContainer.addView(button) } }