Skip to content

Commit

Permalink
Replace text view with button
Browse files Browse the repository at this point in the history
  • Loading branch information
Iamlooker committed Oct 20, 2023
1 parent aa102b4 commit c51eba9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -408,31 +408,8 @@ class AppDetailAdapter(private val callbacks: Callbacks) :
val icon = itemView.findViewById<ShapeableImageView>(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<MaterialButton>(R.id.expand_view_button)!!
}

private class TextViewHolder(context: Context) :
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/layout/expand_view_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.button.MaterialButton xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/expand_view_button"
style="@style/Widget.Material3.Button.ElevatedButton"
android:elevation="4dp"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginHorizontal="48dp"
android:layout_marginTop="16dp"
android:textAllCaps="true" />

0 comments on commit c51eba9

Please sign in to comment.