Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fe84d1c

Browse files
Set RecyclerView visibility based on success status
1 parent e213fa2 commit fe84d1c

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

‎Tutorial2-1FlowBasics/src/main/java/com/smarttoolfactory/tutorial2_1flowbasics/data/model/ViewState.kt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ class ViewState<T>(
66
val data: T? = null,
77
val error: Throwable? = null
88
) {
9+
10+
fun isSuccess() = status == Status.SUCCESS
11+
912
fun isLoading() = status == Status.LOADING
1013

1114
fun getErrorMessage() = error?.message

‎Tutorial2-1FlowBasics/src/main/res/layout/fragment_post_list.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
android:layout_width="match_parent"
2727
android:layout_height="match_parent"
2828
android:paddingTop="16dp"
29-
visibilityBasedOn="@{!viewModel.postViewState.loading}"
29+
visibilityBasedOn="@{viewModel.postViewState.success}"
3030
app:items="@{viewModel.postViewState.data}"
3131
app:layout_constraintBottom_toBottomOf="parent"
3232
app:layout_constraintEnd_toEndOf="parent"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /