Fix user profile images
This commit is contained in:
parent
f0b73eeb29
commit
598364b8e0
4 changed files with 24 additions and 42 deletions
|
@ -32,6 +32,7 @@ import code.name.monkey.retromusic.util.NavigationUtil
|
|||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import kotlinx.android.synthetic.main.abs_playlists.*
|
||||
import kotlinx.android.synthetic.main.fragment_banner_home.*
|
||||
import kotlinx.android.synthetic.main.home_content.*
|
||||
|
@ -59,6 +60,8 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
|||
Glide.with(requireContext())
|
||||
.load(File(PreferenceUtil.getInstance(requireContext()).profileImage, Constants.USER_PROFILE))
|
||||
.asBitmap()
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.skipMemoryCache(true)
|
||||
.placeholder(R.drawable.ic_person_flat)
|
||||
.error(R.drawable.ic_person_flat)
|
||||
.into(userImage)
|
||||
|
@ -198,12 +201,16 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
|||
val request = Glide.with(requireContext())
|
||||
if (PreferenceUtil.getInstance(requireContext()).bannerImage.isEmpty()) {
|
||||
request.load(day)
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.skipMemoryCache(true)
|
||||
.placeholder(R.drawable.material_design_default)
|
||||
.error(R.drawable.material_design_default)
|
||||
.into(it)
|
||||
} else {
|
||||
request.load(File(PreferenceUtil.getInstance(requireContext()).bannerImage, USER_BANNER))
|
||||
.asBitmap()
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.skipMemoryCache(true)
|
||||
.placeholder(R.drawable.material_design_default)
|
||||
.error(R.drawable.material_design_default)
|
||||
.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.util.NavigationUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
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 {
|
||||
private lateinit var lyricsLayout: FrameLayout
|
||||
|
@ -213,18 +215,19 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
|
|||
private val compositeDisposable = CompositeDisposable()
|
||||
|
||||
private fun updateArtistImage() {
|
||||
compositeDisposable.addAll(ArtistLoader.getArtistFlowable(context!!, MusicPlayerRemote.currentSong.artistId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
ArtistGlideRequest.Builder.from(Glide.with(requireContext()), it)
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val artist = ArtistLoader.getArtist(requireContext(), MusicPlayerRemote.currentSong.artistId)
|
||||
withContext(Dispatchers.Main) {
|
||||
ArtistGlideRequest.Builder.from(Glide.with(requireContext()), artist)
|
||||
.generatePalette(requireContext())
|
||||
.build().into(object : RetroMusicColoredTarget(artistImage) {
|
||||
.build()
|
||||
.into(object : RetroMusicColoredTarget(artistImage) {
|
||||
override fun onColorReady(color: Int) {
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onQueueChanged() {
|
||||
|
|
|
@ -30,20 +30,6 @@ object ArtistLoader {
|
|||
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> {
|
||||
val songs = SongLoader.getSongs(SongLoader.makeSongCursor(
|
||||
context,
|
||||
|
@ -53,20 +39,6 @@ object ArtistLoader {
|
|||
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> {
|
||||
val songs = SongLoader.getSongs(SongLoader.makeSongCursor(
|
||||
context,
|
||||
|
|
|
@ -80,7 +80,7 @@ class CustomArtistImageUtil private constructor(context: Context) {
|
|||
if (succesful) {
|
||||
mPreferences.edit().putBoolean(getFileName(artist), true).commit()
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue