From c51eba966ea31e0ead85d98b3e92dbffa071a528 Mon Sep 17 00:00:00 2001 From: LooKeR Date: Fri, 20 Oct 2023 11:28:20 +0530 Subject: [PATCH] Replace text view with button --- .../ui/app_detail/AppDetailAdapter.kt | 31 +++---------------- .../main/res/layout/expand_view_button.xml | 10 ++++++ 2 files changed, 14 insertions(+), 27 deletions(-) create mode 100644 app/src/main/res/layout/expand_view_button.xml diff --git a/app/src/main/kotlin/com/looker/droidify/ui/app_detail/AppDetailAdapter.kt b/app/src/main/kotlin/com/looker/droidify/ui/app_detail/AppDetailAdapter.kt index e13b421b7..377cfd0ed 100644 --- a/app/src/main/kotlin/com/looker/droidify/ui/app_detail/AppDetailAdapter.kt +++ b/app/src/main/kotlin/com/looker/droidify/ui/app_detail/AppDetailAdapter.kt @@ -408,31 +408,8 @@ class AppDetailAdapter(private val callbacks: Callbacks) : val icon = itemView.findViewById(R.id.icon)!! } - private class ExpandViewHolder(context: Context) : - RecyclerView.ViewHolder(TextView(context)) { - val text: TextView - get() = itemView as TextView - - init { - with(itemView as TextView) { - typeface = TypefaceExtra.medium - isFocusable = true - setTextSizeScaled(14) - background = context.corneredBackground - backgroundTintList = - context.getColorFromAttr(MaterialR.attr.colorSurface) - gravity = Gravity.CENTER - isAllCaps = true - layoutParams = RecyclerView.LayoutParams( - RecyclerView.LayoutParams.MATCH_PARENT, - 48.dp - ).apply { - topMargin = 16.dp - leftMargin = 30.dp - rightMargin = 30.dp - } - } - } + private class ExpandViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + val button = itemView.findViewById(R.id.expand_view_button)!! } private class TextViewHolder(context: Context) : @@ -1069,7 +1046,7 @@ class AppDetailAdapter(private val callbacks: Callbacks) : } } - ViewType.EXPAND -> ExpandViewHolder(parent.context).apply { + ViewType.EXPAND -> ExpandViewHolder(parent.inflate(R.layout.expand_view_button)).apply { itemView.setOnClickListener { val position = absoluteAdapterPosition val expandItem = items[position] as Item.ExpandItem @@ -1366,7 +1343,7 @@ class AppDetailAdapter(private val callbacks: Callbacks) : ViewType.EXPAND -> { holder as ExpandViewHolder item as Item.ExpandItem - holder.text.text = if (item.expandType !in expanded) { + holder.button.text = if (item.expandType !in expanded) { when (item.expandType) { ExpandType.VERSIONS -> context.getString(stringRes.show_older_versions) else -> context.getString(stringRes.show_more) diff --git a/app/src/main/res/layout/expand_view_button.xml b/app/src/main/res/layout/expand_view_button.xml new file mode 100644 index 000000000..3902db0c3 --- /dev/null +++ b/app/src/main/res/layout/expand_view_button.xml @@ -0,0 +1,10 @@ + + \ No newline at end of file