Skip to content

Commit

Permalink
fix(video): Resolved the issue where the videoScreen did not display …
Browse files Browse the repository at this point in the history
…a retry option when loading failed.
  • Loading branch information
azrael8576 committed Dec 6, 2023
1 parent 7e81fb7 commit 0d19777
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 13 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,32 @@
- Kotlin Flow

#### Network
- [_Retrofit2 & OkHttp3_](https://github.com/square/retrofit): Construct the REST APIs and paging network data.
- [_Paging3_](https://developer.android.com/topic/libraries/architecture/paging/v3-overview?hl=en): The Android Paging library efficiently handles large datasets by loading and displaying data in manageable pages, enhancing performance and resource use.
- **Retrofit2 & OkHttp3**: [Retrofit2](https://github.com/square/retrofit) is widely used for constructing REST APIs in Android, working alongside OkHttp3 for efficient HTTP networking.
- **Paging3**: The [Paging3](https://developer.android.com/topic/libraries/architecture/paging/v3-overview?hl=en) library from Android's Jetpack suite is designed for efficient loading and displaying of paged data, which is essential for handling large datasets smoothly.

#### DI
- [_Hilt_](https://developer.android.com/training/dependency-injection/hilt-android?hl=en): for dependency injection.
#### Dependency Injection (DI)
- **Hilt**: [Hilt](https://developer.android.com/training/dependency-injection/hilt-android?hl=en) simplifies dependency injection in Android, making it more manageable and concise.

#### Navigation
- [_Navigation Compose_](https://developer.android.com/jetpack/compose/navigation?hl=en): The [_Navigation component_](https://developer.android.com/guide/navigation?hl=en) provides support for [_Jetpack Compose_](https://developer.android.com/jetpack/compose?hl=en) applications.
- **Navigation Compose**: [Navigation Compose](https://developer.android.com/jetpack/compose/navigation?hl=en) integrates with the [Navigation component](https://developer.android.com/guide/navigation?hl=en) to support navigation in Jetpack Compose applications.

#### Data Storage
- [_Proto DataStore_](https://developer.android.com/topic/libraries/architecture/datastore?hl=en): A Jetpack solution for storing key-value pairs or typed objects using [_protocol buffers_](https://developers.google.com/protocol-buffers?hl=en). It leverages Kotlin coroutines and Flow for asynchronous and transactional data storage.
- **Proto DataStore**: [Proto DataStore](https://developer.android.com/topic/libraries/architecture/datastore?hl=en) is a data storage solution that uses protocol buffers, offering asynchronous and transactional data management.

#### Image Loading
- [_Coil_](https://coil-kt.github.io/coil/): An image loading library for Android backed by Kotlin Coroutines.
- **Coil**: [Coil](https://coil-kt.github.io/coil/) is a Kotlin-centric image loading library, leveraging the power of Kotlin Coroutines for efficient image handling.

#### Jetpack Media3
- [_ExoPlayer_](https://developer.android.com/guide/topics/media/media3?hl=en): Jetpack Media3 is the new home for media libraries that enables Android apps to display rich audio and visual experiences.
- **ExoPlayer**: [ExoPlayer](https://developer.android.com/guide/topics/media/media3?hl=en) is a key part of Jetpack Media3, offering advanced media playback capabilities.

#### Testing
- [_Turbine_](https://github.com/cashapp/turbine): A small testing library for kotlinx.coroutines Flow.
- [_Google Truth_](https://github.com/google/truth): Fluent assertions for Java and Android.
- [_Roborazzi_](https://github.com/takahirom/roborazzi): A screenshot testing library for JVM.
- [_Robolectric_](https://github.com/robolectric/robolectric): Robolectric is the industry-standard unit testing framework for Android.
- **Turbine**: [Turbine](https://github.com/cashapp/turbine) is a specialized library for testing Kotlin's coroutines Flow.
- **Google Truth**: [Google Truth](https://github.com/google/truth) provides fluent assertion capabilities, enhancing testing in Java and Android.
- **Roborazzi**: [Roborazzi](https://github.com/takahirom/roborazzi) is a JVM-based screenshot testing tool.
- **Robolectric**: [Robolectric](https://github.com/robolectric/robolectric) remains the standard in Android unit testing, offering robust testing capabilities without the need for an emulator.

#### Backend
- [_Pixabay API_](https://pixabay.com/api/docs/)
- **Pixabay API**: The [Pixabay API](https://pixabay.com/api/docs/) allows access to a vast library of images and videos, useful for various applications requiring multimedia content.

## Require

Expand Down
Binary file modified docs/demo/demo-light-landscape.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -244,6 +245,10 @@ fun VideoPlayer(uri: Uri, previewUrl: String) {
@Composable
fun PagingStateHandling(lazyPagingItems: LazyPagingItems<VideoDetail>) {
lazyPagingItems.apply {
when {
loadState.refresh is LoadState.Loading -> PageLoader()
loadState.refresh is LoadState.Error -> PageLoaderError { retry() }
}
if (itemCount == 0 &&
loadState.append is LoadState.NotLoading &&
loadState.append.endOfPaginationReached
Expand Down Expand Up @@ -278,6 +283,28 @@ fun NoDataMessage() {
}
}

@Composable
fun PageLoaderError(onClickRetry: () -> Unit) {
Box(
contentAlignment = Alignment.Center,
modifier = Modifier.fillMaxSize(),
) {
OutlinedButton(onClick = onClickRetry) {
Text(text = stringResource(R.string.retry))
}
}
}

@Composable
fun PageLoader() {
Box(
contentAlignment = Alignment.Center,
modifier = Modifier.fillMaxSize(),
) {
CircularProgressIndicator()
}
}

@Composable
private fun LoadingView(previewUrl: String) {
Box(
Expand Down

0 comments on commit 0d19777

Please sign in to comment.