File tree Expand file tree Collapse file tree 11 files changed +20
-17
lines changed
java/com/google/firebase/example/dataconnect Expand file tree Collapse file tree 11 files changed +20
-17
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import com.google.firebase.dataconnect.movies.GetMovieByIdQuery
7
7
sealed class ActorDetailUIState {
8
8
data object Loading : ActorDetailUIState ()
9
9
10
- data class Error (val errorMessage : String ): ActorDetailUIState()
10
+ data class Error (val errorMessage : String? ): ActorDetailUIState()
11
11
12
12
data class Success (
13
13
// Actor is null if it can't be found on the DB
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ class ActorDetailViewModel(
57
57
)
58
58
}
59
59
} catch (e: Exception ) {
60
- _uiState .value = ActorDetailUIState .Error (e.message ? : " " )
60
+ _uiState .value = ActorDetailUIState .Error (e.message)
61
61
}
62
62
}
63
63
}
@@ -76,7 +76,7 @@ class ActorDetailViewModel(
76
76
// Re-run the query to fetch the actor details
77
77
fetchActor()
78
78
} catch (e: Exception ) {
79
- _uiState .value = ActorDetailUIState .Error (e.message ? : " " )
79
+ _uiState .value = ActorDetailUIState .Error (e.message)
80
80
}
81
81
}
82
82
}
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ sealed class GenreDetailUIState {
6
6
7
7
data object Loading : GenreDetailUIState ()
8
8
9
- data class Error (val errorMessage : String ): GenreDetailUIState()
9
+ data class Error (val errorMessage : String? ): GenreDetailUIState()
10
10
11
11
data class Success (
12
12
val genreName : String ,
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class GenreDetailViewModel(
37
37
mostRecent = mostRecent
38
38
)
39
39
} catch (e: Exception ) {
40
- _uiState .value = GenreDetailUIState .Error (e.message ? : " " )
40
+ _uiState .value = GenreDetailUIState .Error (e.message)
41
41
}
42
42
}
43
43
}
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import com.google.firebase.dataconnect.movies.GetMovieByIdQuery
6
6
sealed class MovieDetailUIState {
7
7
data object Loading : MovieDetailUIState ()
8
8
9
- data class Error (val errorMessage : String ): MovieDetailUIState()
9
+ data class Error (val errorMessage : String? ): MovieDetailUIState()
10
10
11
11
data class Success (
12
12
// Movie is null if it can't be found on the DB
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ class MovieDetailViewModel(
63
63
)
64
64
}
65
65
} catch (e: Exception ) {
66
- _uiState .value = MovieDetailUIState .Error (e.message ? : " " )
66
+ _uiState .value = MovieDetailUIState .Error (e.message)
67
67
}
68
68
}
69
69
}
@@ -84,7 +84,7 @@ class MovieDetailViewModel(
84
84
// Re-run the query to fetch movie
85
85
fetchMovie()
86
86
} catch (e: Exception ) {
87
- _uiState .value = MovieDetailUIState .Error (e.message ? : " " )
87
+ _uiState .value = MovieDetailUIState .Error (e.message)
88
88
}
89
89
}
90
90
}
@@ -105,7 +105,7 @@ class MovieDetailViewModel(
105
105
// Re-run the query to fetch movie
106
106
fetchMovie()
107
107
} catch (e: Exception ) {
108
- _uiState .value = MovieDetailUIState .Error (e.message ? : " " )
108
+ _uiState .value = MovieDetailUIState .Error (e.message)
109
109
}
110
110
}
111
111
}
@@ -124,7 +124,7 @@ class MovieDetailViewModel(
124
124
// Re-run the query to fetch movie
125
125
fetchMovie()
126
126
} catch (e: Exception ) {
127
- _uiState .value = MovieDetailUIState .Error (e.message ? : " " )
127
+ _uiState .value = MovieDetailUIState .Error (e.message)
128
128
}
129
129
}
130
130
}
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ sealed class MoviesUIState {
7
7
8
8
data object Loading : MoviesUIState ()
9
9
10
- data class Error (val errorMessage : String ): MoviesUIState()
10
+ data class Error (val errorMessage : String? ): MoviesUIState()
11
11
12
12
data class Success (
13
13
val top10movies : List <MoviesTop10Query .Data .MoviesItem >,
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import com.google.firebase.dataconnect.movies.GetUserByIdQuery
5
5
sealed class ProfileUIState {
6
6
data object Loading : ProfileUIState ()
7
7
8
- data class Error (val errorMessage : String ): ProfileUIState()
8
+ data class Error (val errorMessage : String? ): ProfileUIState()
9
9
10
10
data object AuthState : ProfileUIState ()
11
11
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ class ProfileViewModel(
54
54
)?.await()
55
55
moviesConnector.upsertUser.execute(username = displayName)
56
56
} catch (e: Exception ) {
57
- _uiState .value = ProfileUIState .Error (e.message ? : " " )
57
+ _uiState .value = ProfileUIState .Error (e.message)
58
58
e.printStackTrace()
59
59
}
60
60
}
@@ -65,7 +65,7 @@ class ProfileViewModel(
65
65
try {
66
66
auth.signInWithEmailAndPassword(email, password).await()
67
67
} catch (e: Exception ) {
68
- _uiState .value = ProfileUIState .Error (e.message ? : " " )
68
+ _uiState .value = ProfileUIState .Error (e.message)
69
69
}
70
70
}
71
71
}
@@ -89,7 +89,7 @@ class ProfileViewModel(
89
89
)
90
90
Log .d(" DisplayUser" , " $user " )
91
91
} catch (e: Exception ) {
92
- _uiState .value = ProfileUIState .Error (e.message ? : " " )
92
+ _uiState .value = ProfileUIState .Error (e.message)
93
93
}
94
94
}
95
95
}
Original file line number Diff line number Diff line change @@ -8,20 +8,22 @@ import androidx.compose.material3.MaterialTheme
8
8
import androidx.compose.material3.Text
9
9
import androidx.compose.runtime.Composable
10
10
import androidx.compose.ui.Modifier
11
+ import androidx.compose.ui.res.stringResource
11
12
import androidx.compose.ui.tooling.preview.Preview
12
13
import androidx.compose.ui.unit.dp
14
+ import com.google.firebase.example.dataconnect.R
13
15
14
16
@Composable
15
17
fun ErrorCard (
16
- errorMessage : String
18
+ errorMessage : String?
17
19
) {
18
20
Card (
19
21
colors = CardDefaults .cardColors(containerColor = MaterialTheme .colorScheme.errorContainer),
20
22
modifier = Modifier .padding(16 .dp)
21
23
.fillMaxWidth()
22
24
) {
23
25
Text (
24
- text = errorMessage,
26
+ text = errorMessage ? : stringResource( R .string.unknown_error) ,
25
27
modifier = Modifier .padding(16 .dp)
26
28
.fillMaxWidth()
27
29
)
Original file line number Diff line number Diff line change 1
1
<resources >
2
2
<string name =" app_name" >Firebase Data Connect</string >
3
+ <string name =" unknown_error" >An unknown error occurred</string >
3
4
4
5
<!-- NavBar labels -->
5
6
<string name =" label_movies" >Movies</string >
You can’t perform that action at this time.
0 commit comments