Skip to content

Commit 71282fa

Browse files
committed
update ui
1 parent f9705f0 commit 71282fa

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

app/src/main/java/com/hoc081098/firestore_coroutinesflow/ui/main/CategoryAdapter.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.view.ViewGroup
55
import androidx.recyclerview.widget.DiffUtil
66
import androidx.recyclerview.widget.ListAdapter
77
import androidx.recyclerview.widget.RecyclerView
8+
import com.bumptech.glide.load.engine.DiskCacheStrategy
89
import com.hoc081098.firestore_coroutinesflow.GlideRequests
910
import com.hoc081098.firestore_coroutinesflow.databinding.CategoryItemBinding
1011
import com.hoc081098.firestore_coroutinesflow.domain.entity.Category
@@ -37,8 +38,10 @@ class CategoryAdapter(
3738
fun bind(item: Category) {
3839
glide
3940
.load(item.imageUrl)
41+
.diskCacheStrategy(DiskCacheStrategy.ALL)
4042
.centerCrop()
4143
.into(binding.imageView)
44+
binding.textView.text = item.name
4245
}
4346
}
4447
}

app/src/main/java/com/hoc081098/firestore_coroutinesflow/ui/main/MainFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.hoc081098.firestore_coroutinesflow.ui.main
22

33
import android.os.Bundle
4+
import android.util.Log
45
import android.view.View
56
import androidx.core.view.isGone
67
import androidx.core.view.isVisible

app/src/main/res/layout/category_item.xml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
45
android:layout_width="match_parent"
56
android:layout_height="wrap_content"
67
app:cardCornerRadius="4dp"
78
app:cardElevation="3dp"
89
app:cardPreventCornerOverlap="true"
9-
app:cardUseCompatPadding="true">
10+
app:cardUseCompatPadding="true"
11+
tools:layout_width="200dp">
1012

1113
<androidx.constraintlayout.widget.ConstraintLayout
1214
android:layout_width="match_parent"
@@ -17,7 +19,23 @@
1719
android:layout_width="match_parent"
1820
android:layout_height="0dp"
1921
app:layout_constraintBottom_toBottomOf="parent"
20-
app:layout_constraintDimensionRatio="1:1"
22+
app:layout_constraintDimensionRatio="1"
23+
app:layout_constraintEnd_toEndOf="parent"
24+
app:layout_constraintHorizontal_bias="0.5"
25+
app:layout_constraintStart_toStartOf="parent"
26+
app:layout_constraintTop_toTopOf="parent"
27+
tools:srcCompat="@tools:sample/backgrounds/scenic" />
28+
29+
<androidx.appcompat.widget.AppCompatTextView
30+
android:id="@+id/textView"
31+
android:layout_width="0dp"
32+
android:layout_height="wrap_content"
33+
android:background="#9A000000"
34+
android:gravity="center"
35+
android:maxLines="1"
36+
android:padding="12dp"
37+
android:textColor="@android:color/white"
38+
app:layout_constraintBottom_toBottomOf="parent"
2139
app:layout_constraintEnd_toEndOf="parent"
2240
app:layout_constraintHorizontal_bias="0.5"
2341
app:layout_constraintStart_toStartOf="parent"

0 commit comments

Comments
 (0)