image: fix error on api 21
Fix an API 21-specific bug that could result in covers not loading when quality covers was enabled. This stemmed from a use of `use` on MediaMetadataRetriever, which relied on an interface not present on the class on API 21.
This commit is contained in:
parent
9b13b4c94e
commit
ad87c72cd6
5 changed files with 8 additions and 12 deletions
|
@ -39,8 +39,8 @@ import org.oxycblt.auxio.util.logD
|
||||||
/**
|
/**
|
||||||
* The single [AppCompatActivity] for Auxio.
|
* The single [AppCompatActivity] for Auxio.
|
||||||
*
|
*
|
||||||
* TODO: Add crash reporting and error screens. This likely has to be an external activity, so it is
|
* TODO: Add error screens. This likely has to be an external activity, so it is blocked by
|
||||||
* blocked by eliminating exitProcess from the app.
|
* eliminating exitProcess from the app.
|
||||||
*
|
*
|
||||||
* TODO: Custom language support
|
* TODO: Custom language support
|
||||||
*
|
*
|
||||||
|
|
|
@ -114,18 +114,15 @@ abstract class BaseFetcher : Fetcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fetchAospMetadataCovers(context: Context, album: Album): InputStream? {
|
private fun fetchAospMetadataCovers(context: Context, album: Album): InputStream? {
|
||||||
// FIXME: Do not use use here, as Lollipop devices apparently do not have
|
MediaMetadataRetriever().apply {
|
||||||
// MediaMetadataRetriever implemented as AutoClosable.
|
|
||||||
|
|
||||||
MediaMetadataRetriever().use { ext ->
|
|
||||||
// This call is time-consuming but it also doesn't seem to hold up the main thread,
|
// This call is time-consuming but it also doesn't seem to hold up the main thread,
|
||||||
// so it's probably fine not to wrap it.
|
// so it's probably fine not to wrap it.
|
||||||
ext.setDataSource(context, album.songs[0].uri)
|
setDataSource(context, album.songs[0].uri)
|
||||||
|
|
||||||
// Get the embedded picture from MediaMetadataRetriever, which will return a full
|
// Get the embedded picture from MediaMetadataRetriever, which will return a full
|
||||||
// ByteArray of the cover without any compression artifacts.
|
// ByteArray of the cover without any compression artifacts.
|
||||||
// If its null [i.e there is no embedded cover], than just ignore it and move on
|
// If its null [i.e there is no embedded cover], than just ignore it and move on
|
||||||
return ext.embeddedPicture?.let { coverBytes -> ByteArrayInputStream(coverBytes) }
|
return embeddedPicture?.let { ByteArrayInputStream(it) }.also { release() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,6 @@ import org.oxycblt.auxio.util.newMainPendingIntent
|
||||||
* Loading music is actually somewhat time-consuming, to the point where it's likely better suited
|
* Loading music is actually somewhat time-consuming, to the point where it's likely better suited
|
||||||
* to a service that is less likely to be
|
* to a service that is less likely to be
|
||||||
*
|
*
|
||||||
* TODO: Rename all instances of loading in-app with indexing
|
|
||||||
*
|
|
||||||
* @author OxygenCobalt
|
* @author OxygenCobalt
|
||||||
*/
|
*/
|
||||||
class IndexerService : Service(), Indexer.Callback {
|
class IndexerService : Service(), Indexer.Callback {
|
||||||
|
|
|
@ -40,7 +40,6 @@ import org.oxycblt.auxio.music.queryCursor
|
||||||
import org.oxycblt.auxio.music.useQuery
|
import org.oxycblt.auxio.music.useQuery
|
||||||
import org.oxycblt.auxio.settings.SettingsManager
|
import org.oxycblt.auxio.settings.SettingsManager
|
||||||
import org.oxycblt.auxio.util.contentResolverSafe
|
import org.oxycblt.auxio.util.contentResolverSafe
|
||||||
import org.oxycblt.auxio.util.logW
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file acts as the base for most the black magic required to get a remotely sensible music
|
* This file acts as the base for most the black magic required to get a remotely sensible music
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
<resources>
|
<resources>
|
||||||
<integer name="detail_app_bar_title_anim_duration">150</integer>
|
<integer name="detail_app_bar_title_anim_duration">150</integer>
|
||||||
|
|
||||||
<!-- FIXME: Unify this with the integer table object by simply defining a class for each setting. -->
|
<!--
|
||||||
|
FIXME: Unify SettingsManager into this by making it context-dependent again (requires a bunch
|
||||||
|
of technical reworks) -->
|
||||||
<!-- Preference values -->
|
<!-- Preference values -->
|
||||||
<string-array name="entries_theme">
|
<string-array name="entries_theme">
|
||||||
<item>@string/set_theme_auto</item>
|
<item>@string/set_theme_auto</item>
|
||||||
|
|
Loading…
Reference in a new issue