Fix user profile images
parent
f0b73eeb29
commit
598364b8e0
|
@ -32,6 +32,7 @@ import code.name.monkey.retromusic.util.NavigationUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import kotlinx.android.synthetic.main.abs_playlists.*
|
import kotlinx.android.synthetic.main.abs_playlists.*
|
||||||
import kotlinx.android.synthetic.main.fragment_banner_home.*
|
import kotlinx.android.synthetic.main.fragment_banner_home.*
|
||||||
import kotlinx.android.synthetic.main.home_content.*
|
import kotlinx.android.synthetic.main.home_content.*
|
||||||
|
@ -59,6 +60,8 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
||||||
Glide.with(requireContext())
|
Glide.with(requireContext())
|
||||||
.load(File(PreferenceUtil.getInstance(requireContext()).profileImage, Constants.USER_PROFILE))
|
.load(File(PreferenceUtil.getInstance(requireContext()).profileImage, Constants.USER_PROFILE))
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
|
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||||
|
.skipMemoryCache(true)
|
||||||
.placeholder(R.drawable.ic_person_flat)
|
.placeholder(R.drawable.ic_person_flat)
|
||||||
.error(R.drawable.ic_person_flat)
|
.error(R.drawable.ic_person_flat)
|
||||||
.into(userImage)
|
.into(userImage)
|
||||||
|
@ -198,12 +201,16 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
||||||
val request = Glide.with(requireContext())
|
val request = Glide.with(requireContext())
|
||||||
if (PreferenceUtil.getInstance(requireContext()).bannerImage.isEmpty()) {
|
if (PreferenceUtil.getInstance(requireContext()).bannerImage.isEmpty()) {
|
||||||
request.load(day)
|
request.load(day)
|
||||||
|
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||||
|
.skipMemoryCache(true)
|
||||||
.placeholder(R.drawable.material_design_default)
|
.placeholder(R.drawable.material_design_default)
|
||||||
.error(R.drawable.material_design_default)
|
.error(R.drawable.material_design_default)
|
||||||
.into(it)
|
.into(it)
|
||||||
} else {
|
} else {
|
||||||
request.load(File(PreferenceUtil.getInstance(requireContext()).bannerImage, USER_BANNER))
|
request.load(File(PreferenceUtil.getInstance(requireContext()).bannerImage, USER_BANNER))
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
|
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||||
|
.skipMemoryCache(true)
|
||||||
.placeholder(R.drawable.material_design_default)
|
.placeholder(R.drawable.material_design_default)
|
||||||
.error(R.drawable.material_design_default)
|
.error(R.drawable.material_design_default)
|
||||||
.into(it)
|
.into(it)
|
||||||
|
|
|
@ -24,10 +24,12 @@ import code.name.monkey.retromusic.model.lyrics.AbsSynchronizedLyrics
|
||||||
import code.name.monkey.retromusic.model.lyrics.Lyrics
|
import code.name.monkey.retromusic.model.lyrics.Lyrics
|
||||||
import code.name.monkey.retromusic.util.NavigationUtil
|
import code.name.monkey.retromusic.util.NavigationUtil
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
|
||||||
import kotlinx.android.synthetic.main.fragment_full.*
|
import kotlinx.android.synthetic.main.fragment_full.*
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback {
|
class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback {
|
||||||
private lateinit var lyricsLayout: FrameLayout
|
private lateinit var lyricsLayout: FrameLayout
|
||||||
|
@ -213,18 +215,19 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
|
||||||
private val compositeDisposable = CompositeDisposable()
|
private val compositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
private fun updateArtistImage() {
|
private fun updateArtistImage() {
|
||||||
compositeDisposable.addAll(ArtistLoader.getArtistFlowable(context!!, MusicPlayerRemote.currentSong.artistId)
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
.subscribeOn(Schedulers.io())
|
val artist = ArtistLoader.getArtist(requireContext(), MusicPlayerRemote.currentSong.artistId)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
withContext(Dispatchers.Main) {
|
||||||
.subscribe {
|
ArtistGlideRequest.Builder.from(Glide.with(requireContext()), artist)
|
||||||
ArtistGlideRequest.Builder.from(Glide.with(requireContext()), it)
|
|
||||||
.generatePalette(requireContext())
|
.generatePalette(requireContext())
|
||||||
.build().into(object : RetroMusicColoredTarget(artistImage) {
|
.build()
|
||||||
|
.into(object : RetroMusicColoredTarget(artistImage) {
|
||||||
override fun onColorReady(color: Int) {
|
override fun onColorReady(color: Int) {
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onQueueChanged() {
|
override fun onQueueChanged() {
|
||||||
|
|
|
@ -30,20 +30,6 @@ object ArtistLoader {
|
||||||
PreferenceUtil.getInstance(context).artistDetailSongSortOrder
|
PreferenceUtil.getInstance(context).artistDetailSongSortOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAllArtistsFlowable(
|
|
||||||
context: Context
|
|
||||||
): Observable<ArrayList<Artist>> {
|
|
||||||
return Observable.create { e ->
|
|
||||||
SongLoader.getSongsFlowable(SongLoader.makeSongCursor(
|
|
||||||
context, null, null,
|
|
||||||
getSongLoaderSortOrder(context))
|
|
||||||
).subscribe { songs ->
|
|
||||||
e.onNext(splitIntoArtists(AlbumLoader.splitIntoAlbums(songs)))
|
|
||||||
e.onComplete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getAllArtists(context: Context): ArrayList<Artist> {
|
fun getAllArtists(context: Context): ArrayList<Artist> {
|
||||||
val songs = SongLoader.getSongs(SongLoader.makeSongCursor(
|
val songs = SongLoader.getSongs(SongLoader.makeSongCursor(
|
||||||
context,
|
context,
|
||||||
|
@ -53,20 +39,6 @@ object ArtistLoader {
|
||||||
return splitIntoArtists(AlbumLoader.splitIntoAlbums(songs))
|
return splitIntoArtists(AlbumLoader.splitIntoAlbums(songs))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getArtistsFlowable(context: Context, query: String): Observable<ArrayList<Artist>> {
|
|
||||||
return Observable.create { e ->
|
|
||||||
SongLoader.getSongsFlowable(SongLoader.makeSongCursor(
|
|
||||||
context,
|
|
||||||
AudioColumns.ARTIST + " LIKE ?",
|
|
||||||
arrayOf("%$query%"),
|
|
||||||
getSongLoaderSortOrder(context))
|
|
||||||
).subscribe { songs ->
|
|
||||||
e.onNext(splitIntoArtists(AlbumLoader.splitIntoAlbums(songs)))
|
|
||||||
e.onComplete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getArtists(context: Context, query: String): ArrayList<Artist> {
|
fun getArtists(context: Context, query: String): ArrayList<Artist> {
|
||||||
val songs = SongLoader.getSongs(SongLoader.makeSongCursor(
|
val songs = SongLoader.getSongs(SongLoader.makeSongCursor(
|
||||||
context,
|
context,
|
||||||
|
|
|
@ -80,7 +80,7 @@ class CustomArtistImageUtil private constructor(context: Context) {
|
||||||
if (succesful) {
|
if (succesful) {
|
||||||
mPreferences.edit().putBoolean(getFileName(artist), true).commit()
|
mPreferences.edit().putBoolean(getFileName(artist), true).commit()
|
||||||
ArtistSignatureUtil.getInstance(App.getContext()).updateArtistSignature(artist.name)
|
ArtistSignatureUtil.getInstance(App.getContext()).updateArtistSignature(artist.name)
|
||||||
App.getContext().getContentResolver().notifyChange(Uri.parse("content://media"), null) // trigger media store changed to force artist image reload
|
App.getContext().contentResolver.notifyChange(Uri.parse("content://media"), null) // trigger media store changed to force artist image reload
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue