loading: improve new ui
Improve the loading UI somewhat, reverting the progress bar and applying some padding to the icon so that it looks a bit better on Android 12.
This commit is contained in:
@@ -54,10 +54,7 @@ class LibraryFragment : Fragment() {
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
val binding = FragmentLibraryBinding.inflate(inflater)
|
||||
|
||||
val libraryAdapter = LibraryAdapter(::navToDetail) { view, data ->
|
||||
newMenu(view, data)
|
||||
}
|
||||
val libraryAdapter = LibraryAdapter(::navToDetail, ::newMenu)
|
||||
|
||||
// --- UI SETUP ---
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.oxycblt.auxio.R
|
||||
import org.oxycblt.auxio.databinding.FragmentLoadingBinding
|
||||
import org.oxycblt.auxio.logD
|
||||
import org.oxycblt.auxio.music.MusicStore
|
||||
import org.oxycblt.auxio.ui.isLandscape
|
||||
|
||||
/**
|
||||
* Fragment that handles what to display during the loading process.
|
||||
@@ -58,6 +59,10 @@ class LoadingFragment : Fragment() {
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.loadingModel = loadingModel
|
||||
|
||||
// The loading panel shouldn't fit the system window on landscape as that will cause it
|
||||
// to be mis-aligned with the Auxio icon.
|
||||
binding.loadingPanel.fitsSystemWindows = !isLandscape(resources)
|
||||
|
||||
// --- VIEWMODEL SETUP ---
|
||||
|
||||
loadingModel.doGrant.observe(viewLifecycleOwner) { doGrant ->
|
||||
@@ -141,7 +146,6 @@ class LoadingFragment : Fragment() {
|
||||
*/
|
||||
private fun showLoading(binding: FragmentLoadingBinding) {
|
||||
binding.apply {
|
||||
loadingErrorIcon.visibility = View.INVISIBLE
|
||||
loadingErrorText.visibility = View.INVISIBLE
|
||||
loadingActionButton.visibility = View.INVISIBLE
|
||||
loadingCircle.visibility = View.VISIBLE
|
||||
@@ -155,7 +159,6 @@ class LoadingFragment : Fragment() {
|
||||
*/
|
||||
private fun showError(binding: FragmentLoadingBinding, error: MusicStore.Response) {
|
||||
binding.loadingCircle.visibility = View.GONE
|
||||
binding.loadingErrorIcon.visibility = View.VISIBLE
|
||||
binding.loadingErrorText.visibility = View.VISIBLE
|
||||
binding.loadingActionButton.visibility = View.VISIBLE
|
||||
|
||||
|
||||
@@ -32,16 +32,34 @@ sealed class BaseModel {
|
||||
abstract val name: String
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a versatile static hash for a music item that will not change when
|
||||
* MediaStore changes.
|
||||
*
|
||||
* The reason why this is used is down a couple of reasons:
|
||||
* - MediaStore will refresh the unique ID of a piece of media whenever the library
|
||||
* changes, which creates bad UX
|
||||
* - Using song names makes collisions too common to be reliable
|
||||
* - Hashing into an integer makes databases both smaller and more efficent
|
||||
*
|
||||
* This does lock me into a "Load everything at once, lol" architecture for Auxio, but I
|
||||
* think its worth it.
|
||||
*
|
||||
* @property hash A unique-ish hash for this media item
|
||||
*
|
||||
* TODO: Make this hash stronger
|
||||
*/
|
||||
sealed interface Hashable {
|
||||
val hash: Int
|
||||
}
|
||||
|
||||
/**
|
||||
* [BaseModel] variant that denotes that this object is a parent of other data objects, such
|
||||
* as an [Album] or [Artist]
|
||||
* @property hash A versatile, unique(ish) hash used for databases
|
||||
* @property displayName Name that handles the usage of [Genre.resolvedName]
|
||||
* and the normal [BaseModel.name]
|
||||
*/
|
||||
sealed class Parent : BaseModel() {
|
||||
abstract val hash: Int
|
||||
|
||||
sealed class Parent : BaseModel(), Hashable {
|
||||
val displayName: String get() = if (this is Genre) {
|
||||
resolvedName
|
||||
} else {
|
||||
@@ -61,7 +79,6 @@ sealed class Parent : BaseModel() {
|
||||
* These are not ensured to be linked due to possible quirks in the genre loading system.
|
||||
* @property seconds The Song's duration in seconds
|
||||
* @property formattedDuration The Song's duration as a duration string.
|
||||
* @property hash A versatile, unique(ish) hash used for databases
|
||||
*/
|
||||
data class Song(
|
||||
override val id: Long,
|
||||
@@ -70,7 +87,7 @@ data class Song(
|
||||
val albumId: Long,
|
||||
val track: Int,
|
||||
val duration: Long
|
||||
) : BaseModel() {
|
||||
) : BaseModel(), Hashable {
|
||||
private var mAlbum: Album? = null
|
||||
private var mGenre: Genre? = null
|
||||
|
||||
@@ -80,7 +97,12 @@ data class Song(
|
||||
val seconds = duration / 1000
|
||||
val formattedDuration = seconds.toDuration()
|
||||
|
||||
val hash = songHash()
|
||||
override val hash: Int get() {
|
||||
var result = name.hashCode()
|
||||
result = 31 * result + track
|
||||
result = 31 * result + duration.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
fun linkAlbum(album: Album) {
|
||||
if (mAlbum == null) {
|
||||
@@ -93,13 +115,6 @@ data class Song(
|
||||
mGenre = genre
|
||||
}
|
||||
}
|
||||
|
||||
private fun songHash(): Int {
|
||||
var result = name.hashCode()
|
||||
result = 31 * result + track
|
||||
result = 31 * result + duration.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +142,12 @@ data class Album(
|
||||
val totalDuration: String get() =
|
||||
songs.sumOf { it.seconds }.toDuration()
|
||||
|
||||
override val hash = albumHash()
|
||||
override val hash: Int get() {
|
||||
var result = name.hashCode()
|
||||
result = 31 * result + artistName.hashCode()
|
||||
result = 31 * result + year
|
||||
return result
|
||||
}
|
||||
|
||||
fun linkArtist(artist: Artist) {
|
||||
mArtist = artist
|
||||
@@ -139,13 +159,6 @@ data class Album(
|
||||
mSongs.add(song)
|
||||
}
|
||||
}
|
||||
|
||||
private fun albumHash(): Int {
|
||||
var result = name.hashCode()
|
||||
result = 31 * result + artistName.hashCode()
|
||||
result = 31 * result + year
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,9 +60,7 @@ class SearchFragment : Fragment() {
|
||||
): View {
|
||||
val binding = FragmentSearchBinding.inflate(inflater)
|
||||
|
||||
val searchAdapter = SearchAdapter(::onItemSelection) { view, data ->
|
||||
newMenu(view, data)
|
||||
}
|
||||
val searchAdapter = SearchAdapter(::onItemSelection, ::newMenu)
|
||||
|
||||
val toolbarParams = binding.searchToolbar.layoutParams as AppBarLayout.LayoutParams
|
||||
val defaultParams = toolbarParams.scrollFlags
|
||||
|
||||
@@ -49,9 +49,7 @@ class SongsFragment : Fragment() {
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
val binding = FragmentSongsBinding.inflate(inflater)
|
||||
val songAdapter = SongsAdapter(musicStore.songs, playbackModel::playSong) { view, data ->
|
||||
newMenu(view, data)
|
||||
}
|
||||
val songAdapter = SongsAdapter(musicStore.songs, playbackModel::playSong, ::newMenu)
|
||||
|
||||
// --- UI SETUP ---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user