This repository was archived by the owner on Feb 9, 2026. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
retrofit/src/main/java/com/crazylegend/retrofit/viewstate Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package com.crazylegend.retrofit.viewstate
22
33import androidx.lifecycle.SavedStateHandle
44import com.crazylegend.retrofit.apiresult.*
5+ import com.crazylegend.retrofit.throwables.isNoConnectionException
56import okhttp3.ResponseBody
67
78/* *
@@ -52,7 +53,8 @@ fun SavedStateHandle.handleApiErrorFromSavedState(errorBody: ResponseBody?): Str
5253 return get<String >(errorStateKey)
5354}
5455
55- fun handleApiError (savedStateHandle : SavedStateHandle , errorBody : ResponseBody ? ): String? = savedStateHandle.handleApiErrorFromSavedState(errorBody)
56+ fun handleApiError (savedStateHandle : SavedStateHandle , errorBody : ResponseBody ? ): String? =
57+ savedStateHandle.handleApiErrorFromSavedState(errorBody)
5658
5759
5860val <T > ViewStateContract <T >.showEmptyDataOnErrorsOrSuccess: Boolean
@@ -86,3 +88,11 @@ val <T> ViewStateContract<T>.showEmptyDataOnSuccess: Boolean
8688 return isDataNotLoaded && retrofitResult.isSuccess
8789 }
8890
91+ val <T > ViewStateContract <T >.shouldShowEmptyDataOnNoConnection: Boolean
92+ get() {
93+ val retrofitResult = data.value
94+ return isDataNotLoaded &&
95+ retrofitResult.isError &&
96+ retrofitResult.asError().throwable.isNoConnectionException
97+ }
98+
You can’t perform that action at this time.
0 commit comments