-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Create ContainerLoadingAdapter - Switch to clients instead of OfflineExtension - Fix some issues with player view
- Loading branch information
1 parent
474b259
commit 647c032
Showing
28 changed files
with
565 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 11 additions & 5 deletions
16
app/src/main/java/dev/brahmkshatriya/echo/data/models/MediaItemsContainer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
package dev.brahmkshatriya.echo.data.models | ||
|
||
data class MediaItemsContainer( | ||
val title: String, | ||
val list: List<MediaItem>, | ||
val subtitle: String? = null | ||
) | ||
sealed class MediaItemsContainer { | ||
data class Category( | ||
val title: String, | ||
val list: List<MediaItem>, | ||
val subtitle: String? = null | ||
) : MediaItemsContainer() | ||
|
||
data class TrackItem( | ||
val track: Track, | ||
) : MediaItemsContainer() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
app/src/main/java/dev/brahmkshatriya/echo/ui/adapters/ContainerLoadingAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package dev.brahmkshatriya.echo.ui.adapters | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.paging.LoadState | ||
import androidx.paging.LoadStateAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import dev.brahmkshatriya.echo.databinding.ItemErrorBinding | ||
import dev.brahmkshatriya.echo.databinding.SkeletonItemContainerBinding | ||
|
||
class ContainerLoadingAdapter(val retry: () -> Unit) : LoadStateAdapter<ContainerLoadingAdapter.ShimmerViewHolder>() { | ||
class ShimmerViewHolder(val container: Container) : | ||
RecyclerView.ViewHolder(container.root) | ||
|
||
sealed class Container(val root: View) { | ||
data class Loading(val binding: SkeletonItemContainerBinding) : Container(binding.root) | ||
data class Error(val binding: ItemErrorBinding) : Container(binding.root) | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, loadState: LoadState): ShimmerViewHolder { | ||
return ShimmerViewHolder( | ||
when (loadState) { | ||
is LoadState.Error, is LoadState.NotLoading -> { | ||
Container.Error( | ||
ItemErrorBinding.inflate( | ||
LayoutInflater.from(parent.context), parent, false | ||
) | ||
) | ||
} | ||
|
||
is LoadState.Loading -> { | ||
Container.Loading( | ||
SkeletonItemContainerBinding.inflate( | ||
LayoutInflater.from(parent.context), parent, false | ||
) | ||
) | ||
} | ||
} | ||
) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ShimmerViewHolder, loadState: LoadState) { | ||
if (loadState !is LoadState.Error) return | ||
|
||
val binding = (holder.container as Container.Error).binding | ||
binding.error.text = loadState.error.localizedMessage | ||
binding.retry.setOnClickListener { | ||
retry() | ||
} | ||
} | ||
} |
Oops, something went wrong.