Skip to content

Commit 7ec6376

Browse files
Refactor: Use common lesson description layout in RoomActivity
This commit refactors `activity_room.xml` to use the reusable `lesson_description_section.xml` layout, replacing the previous `MaterialTextView`. The `RoomActivity.java` file is updated to call the new `LessonUiUtils.setupDescriptionSection` method to populate the description text. An additional section header for "Layout Preview" has also been added to the XML layout.
1 parent 1fc90f3 commit 7ec6376

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

app/src/main/java/com/d4rk/androidtutorials/java/ui/screens/android/lessons/data/room/RoomActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.d4rk.androidtutorials.java.ui.screens.android.lessons.common.LessonCodeTabsActivity;
1818
import com.d4rk.androidtutorials.java.ui.screens.android.lessons.data.room.tabs.RoomTabCodeFragment;
1919
import com.d4rk.androidtutorials.java.ui.screens.android.lessons.data.room.tabs.RoomTabLayoutFragment;
20+
import com.d4rk.androidtutorials.java.ui.utils.LessonUiUtils;
2021
import com.d4rk.androidtutorials.java.utils.EdgeToEdgeHelper;
2122

2223
import java.util.Arrays;
@@ -40,6 +41,10 @@ protected void onCreate(Bundle savedInstanceState) {
4041
setContentView(binding.getRoot());
4142
EdgeToEdgeHelper.applyEdgeToEdge(getWindow(), binding.getRoot());
4243

44+
LessonUiUtils.setupDescriptionSection(binding.descriptionSection,
45+
R.string.summary_room_database,
46+
true);
47+
4348
db = AppDatabase.getInstance(this);
4449

4550
binding.recyclerView.setLayoutManager(new LinearLayoutManager(this));

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,31 @@
66
android:layout_width="match_parent"
77
android:layout_height="match_parent">
88

9-
<com.google.android.material.textview.MaterialTextView
10-
android:id="@+id/textViewSummary"
9+
<include
10+
android:id="@+id/description_section"
11+
layout="@layout/lesson_description_section"
1112
android:layout_width="0dp"
1213
android:layout_height="wrap_content"
13-
android:padding="16dp"
14-
android:text="@string/summary_room_database"
14+
android:layout_marginStart="16dp"
15+
android:layout_marginTop="16dp"
16+
android:layout_marginEnd="16dp"
1517
app:layout_constraintEnd_toEndOf="parent"
1618
app:layout_constraintStart_toStartOf="parent"
1719
app:layout_constraintTop_toTopOf="parent" />
1820

21+
<include
22+
android:id="@+id/layout_preview_header"
23+
layout="@layout/lesson_section_header"
24+
android:layout_width="0dp"
25+
android:layout_height="wrap_content"
26+
android:layout_marginStart="16dp"
27+
android:layout_marginTop="24dp"
28+
android:layout_marginEnd="16dp"
29+
app:layout_constraintEnd_toEndOf="parent"
30+
app:layout_constraintStart_toStartOf="parent"
31+
app:layout_constraintTop_toBottomOf="@id/description_section"
32+
tools:text="@string/layout_preview" />
33+
1934
<com.google.android.material.textfield.TextInputLayout
2035
android:id="@+id/textInputLayout"
2136
android:layout_width="0dp"
@@ -24,7 +39,7 @@
2439
android:layout_marginHorizontal="16dp"
2540
app:layout_constraintEnd_toEndOf="parent"
2641
app:layout_constraintStart_toStartOf="parent"
27-
app:layout_constraintTop_toBottomOf="@id/textViewSummary">
42+
app:layout_constraintTop_toBottomOf="@id/layout_preview_header">
2843

2944
<com.google.android.material.textfield.TextInputEditText
3045
android:id="@+id/editTextNote"

0 commit comments

Comments
 (0)