info: update architecture

Update architecture to reflect the new changes made in 2.3.0.
This commit is contained in:
OxygenCobalt
2022-05-26 10:03:41 -06:00
parent 1a02aaad4b
commit b59ef1a746
8 changed files with 107 additions and 102 deletions
@@ -21,9 +21,9 @@ import android.app.Application
import coil.ImageLoader
import coil.ImageLoaderFactory
import coil.request.CachePolicy
import org.oxycblt.auxio.image.AlbumArtFetcher
import org.oxycblt.auxio.image.AlbumCoverFetcher
import org.oxycblt.auxio.image.ArtistImageFetcher
import org.oxycblt.auxio.image.CrossfadeFactory
import org.oxycblt.auxio.image.CrossfadeTransitionFactory
import org.oxycblt.auxio.image.GenreImageFetcher
import org.oxycblt.auxio.image.MusicKeyer
import org.oxycblt.auxio.settings.SettingsManager
@@ -41,13 +41,13 @@ class AuxioApp : Application(), ImageLoaderFactory {
override fun newImageLoader(): ImageLoader {
return ImageLoader.Builder(applicationContext)
.components {
add(AlbumArtFetcher.SongFactory())
add(AlbumArtFetcher.AlbumFactory())
add(AlbumCoverFetcher.SongFactory())
add(AlbumCoverFetcher.AlbumFactory())
add(ArtistImageFetcher.Factory())
add(GenreImageFetcher.Factory())
add(MusicKeyer())
}
.transitionFactory(CrossfadeFactory())
.transitionFactory(CrossfadeTransitionFactory())
.diskCachePolicy(CachePolicy.DISABLED) // Not downloading anything, so no disk-caching
.build()
}
@@ -50,10 +50,10 @@ class MusicKeyer : Keyer<Music> {
}
/**
* Fetcher that returns the album art for a given [Album] or [Song], depending on the factory used.
* Fetcher that returns the album cover for a given [Album] or [Song], depending on the factory used.
* @author OxygenCobalt
*/
class AlbumArtFetcher private constructor(private val context: Context, private val album: Album) :
class AlbumCoverFetcher private constructor(private val context: Context, private val album: Album) :
BaseFetcher() {
override suspend fun fetch(): FetchResult? {
return fetchArt(context, album)?.let { stream ->
@@ -66,13 +66,13 @@ class AlbumArtFetcher private constructor(private val context: Context, private
class SongFactory : Fetcher.Factory<Song> {
override fun create(data: Song, options: Options, imageLoader: ImageLoader): Fetcher {
return AlbumArtFetcher(options.context, data.album)
return AlbumCoverFetcher(options.context, data.album)
}
}
class AlbumFactory : Fetcher.Factory<Album> {
override fun create(data: Album, options: Options, imageLoader: ImageLoader) =
AlbumArtFetcher(options.context, data)
AlbumCoverFetcher(options.context, data)
}
}
@@ -133,11 +133,11 @@ private inline fun <T : Any, R : Any> Collection<T>.mapAtMost(
val out = mutableListOf<R>()
for (item in this) {
if (out.size >= until) {
if (out.size < until) {
transform(item)?.let(out::add)
} else {
break
}
transform(item)?.let(out::add)
}
return out
@@ -30,7 +30,7 @@ import coil.transition.TransitionTarget
* Like they used to.
* @author Coil Team
*/
class CrossfadeFactory : Transition.Factory {
class CrossfadeTransitionFactory : Transition.Factory {
override fun create(target: TransitionTarget, result: ImageResult): Transition {
// Don't animate if the request was fulfilled by the memory cache.
if (result is SuccessResult && result.dataSource == DataSource.MEMORY_CACHE) {
@@ -29,7 +29,7 @@ enum class RepeatMode {
ALL,
TRACK;
/** Increment the LoopMode, e.g from [NONE] to [ALL] */
/** Increment the mode, e.g from [NONE] to [ALL] */
fun increment(): RepeatMode {
return when (this) {
NONE -> ALL
@@ -47,8 +47,7 @@ enum class RepeatMode {
}
/**
* Convert the LoopMode to an int constant that is saved in PlaybackStateDatabase
* @return The int constant for this mode
* The integer code representing this particular mode.
*/
val intCode: Int
get() =
@@ -27,9 +27,7 @@ import org.oxycblt.auxio.BuildConfig
* Shortcut method for logging a non-string [obj] to debug. Should only be used for debug
* preferably.
*/
fun Any.logD(obj: Any) {
logD(obj.toString())
}
fun Any.logD(obj: Any?) = logD("$obj")
/**
* Shortcut method for logging [msg] to the debug console. Handles debug builds and anonymous
@@ -38,19 +36,15 @@ fun Any.logD(obj: Any) {
fun Any.logD(msg: String) {
if (BuildConfig.DEBUG) {
basedCopyleftNotice()
Log.d(name, msg)
Log.d(autoTag, msg)
}
}
/** Shortcut method for logging [msg] as a warning to the console. Handles anonymous objects */
fun Any.logW(msg: String) {
Log.w(name, msg)
}
fun Any.logW(msg: String) = Log.w(autoTag, msg)
/** Shortcut method for logging [msg] as an error to the console. Handles anonymous objects */
fun Any.logE(msg: String) {
Log.e(name, msg)
}
fun Any.logE(msg: String) = Log.e(autoTag, msg)
/**
* Logs an error in production while still throwing it in debug mode. This is useful for
@@ -65,10 +59,9 @@ fun Throwable.logTraceOrThrow() {
}
/**
* Get a non-nullable name, used so that logs will always show up by Auxio
* @return The name of the object, otherwise "Anonymous Object"
* Automatically creates a tag that identifies the object currently logging.
*/
private val Any.name: String
private val Any.autoTag: String
get() = "Auxio.${this::class.simpleName ?: "Anonymous Object"}"
/**