diff --git a/app/src/main/java/com/readrops/app/utils/EmptyListView.kt b/app/src/main/java/com/readrops/app/utils/EmptyListView.kt index e237b915..dadd5c20 100644 --- a/app/src/main/java/com/readrops/app/utils/EmptyListView.kt +++ b/app/src/main/java/com/readrops/app/utils/EmptyListView.kt @@ -2,26 +2,22 @@ package com.readrops.app.utils import android.content.Context import android.util.AttributeSet -import android.view.View -import android.widget.ImageView +import android.view.LayoutInflater import android.widget.LinearLayout -import android.widget.TextView import com.readrops.app.R +import com.readrops.app.databinding.EmptyListViewBinding /** * A simple custom view to display a empty list message */ class EmptyListView(context: Context, attrs: AttributeSet) : LinearLayout(context, attrs) { - init { - // no binding here, it makes the view rendering fail - View.inflate(context, R.layout.empty_list_view, this) - val imageView: ImageView = findViewById(R.id.empty_list_image) - val textView: TextView = findViewById(R.id.empty_list_text_v) + val binding: EmptyListViewBinding = EmptyListViewBinding.inflate(LayoutInflater.from(context), this, true) + init { val attributes = context.obtainStyledAttributes(attrs, R.styleable.EmptyListView) - imageView.setImageDrawable(attributes.getDrawable(R.styleable.EmptyListView_image)) - textView.text = attributes.getString(R.styleable.EmptyListView_text) + binding.emptyListImage.setImageDrawable(attributes.getDrawable(R.styleable.EmptyListView_image)) + binding.emptyListText.text = attributes.getString(R.styleable.EmptyListView_text) attributes.recycle() } diff --git a/app/src/main/res/layout/empty_list_view.xml b/app/src/main/res/layout/empty_list_view.xml index 2e00bf5b..2529b8f3 100644 --- a/app/src/main/res/layout/empty_list_view.xml +++ b/app/src/main/res/layout/empty_list_view.xml @@ -15,7 +15,7 @@ tools:src="@drawable/ic_rss_feed_grey" />