info: update ARCHITECTURE

Update the ARCHITECTURE document to reflect the architectural changes
made in 2.5.0.
This commit is contained in:
OxygenCobalt
2022-07-13 09:27:11 -06:00
parent ce7dd48f02
commit 08423d5e93
7 changed files with 240 additions and 183 deletions
@@ -75,12 +75,12 @@ class HomeFragment : ViewBindingFragment<FragmentHomeBinding>(), Toolbar.OnMenuI
private val playbackModel: PlaybackViewModel by androidActivityViewModels()
private val navModel: NavigationViewModel by activityViewModels()
private val homeModel: HomeViewModel by androidActivityViewModels()
private val indexerModel: MusicViewModel by activityViewModels()
private val musicModel: MusicViewModel by activityViewModels()
// lifecycleObject builds this in the creation step, so doing this is okay.
private val storagePermissionLauncher: ActivityResultLauncher<String> by lifecycleObject {
registerForActivityResult(ActivityResultContracts.RequestPermission()) {
indexerModel.reindex()
musicModel.reindex()
}
}
@@ -142,8 +142,8 @@ class HomeFragment : ViewBindingFragment<FragmentHomeBinding>(), Toolbar.OnMenuI
collect(homeModel.recreateTabs, ::handleRecreateTabs)
collectImmediately(homeModel.currentTab, ::updateCurrentTab)
collectImmediately(indexerModel.libraryExists, homeModel.isFastScrolling, ::updateFab)
collectImmediately(indexerModel.indexerState, ::handleIndexerState)
collectImmediately(musicModel.libraryExists, homeModel.isFastScrolling, ::updateFab)
collectImmediately(musicModel.indexerState, ::handleIndexerState)
collect(navModel.exploreNavigationItem, ::handleNavigation)
}
@@ -283,7 +283,7 @@ class HomeFragment : ViewBindingFragment<FragmentHomeBinding>(), Toolbar.OnMenuI
binding.homeIndexingAction.apply {
visibility = View.VISIBLE
text = getString(R.string.lbl_retry)
setOnClickListener { indexerModel.reindex() }
setOnClickListener { musicModel.reindex() }
}
}
is Indexer.Response.NoMusic -> {
@@ -292,7 +292,7 @@ class HomeFragment : ViewBindingFragment<FragmentHomeBinding>(), Toolbar.OnMenuI
binding.homeIndexingAction.apply {
visibility = View.VISIBLE
text = getString(R.string.lbl_retry)
setOnClickListener { indexerModel.reindex() }
setOnClickListener { musicModel.reindex() }
}
}
is Indexer.Response.NoPerms -> {
@@ -46,6 +46,8 @@ import org.oxycblt.auxio.util.logD
* You could probably do the same using WorkManager and the GooberQueue library or whatever, but the
* boilerplate you skip is not worth the insanity of androidx.
*
* TODO: Add a wake-lock to the music loading process
*
* @author OxygenCobalt
*/
class IndexerService : Service(), Indexer.Controller, Settings.Callback {
@@ -29,13 +29,12 @@ enum class RepeatMode {
TRACK;
/** Increment the mode, e.g from [NONE] to [ALL] */
fun increment(): RepeatMode {
return when (this) {
fun increment() =
when (this) {
NONE -> ALL
ALL -> TRACK
TRACK -> NONE
}
}
/** The integer code representing this particular mode. */
val intCode: Int
@@ -48,13 +47,12 @@ enum class RepeatMode {
companion object {
/** Convert an int [code] into an instance, or null if it isn't valid. */
fun fromIntCode(code: Int): RepeatMode? {
return when (code) {
fun fromIntCode(code: Int) =
when (code) {
IntegerTable.REPEAT_MODE_NONE -> NONE
IntegerTable.REPEAT_MODE_ALL -> ALL
IntegerTable.REPEAT_MODE_TRACK -> TRACK
else -> null
}
}
}
}
@@ -55,7 +55,7 @@ import org.oxycblt.auxio.util.systemBarInsetsCompat
@Suppress("UNUSED")
class SettingsListFragment : PreferenceFragmentCompat() {
private val playbackModel: PlaybackViewModel by androidActivityViewModels()
private val indexerModel: MusicViewModel by activityViewModels()
private val musicModel: MusicViewModel by activityViewModels()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@@ -129,7 +129,7 @@ class SettingsListFragment : PreferenceFragmentCompat() {
}
}
getString(R.string.set_key_reindex) -> {
indexerModel.reindex()
musicModel.reindex()
}
else -> return super.onPreferenceTreeClick(preference)
}