Avoid starting image loading when activity is destroyed
This commit is contained in:
parent
c6224ad332
commit
f36e9cef13
2 changed files with 11 additions and 8 deletions
|
@ -266,7 +266,7 @@ class TracksAdapter(
|
||||||
.transform(CenterCrop(), RoundedCorners(cornerRadius))
|
.transform(CenterCrop(), RoundedCorners(cornerRadius))
|
||||||
|
|
||||||
context.getTrackCoverArt(track) { coverArt ->
|
context.getTrackCoverArt(track) { coverArt ->
|
||||||
if (!activity.isDestroyed || !activity.isFinishing) {
|
activity.ensureActivityNotDestroyed {
|
||||||
Glide.with(activity)
|
Glide.with(activity)
|
||||||
.load(coverArt)
|
.load(coverArt)
|
||||||
.apply(options)
|
.apply(options)
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package com.simplemobiletools.musicplayer.views
|
package com.simplemobiletools.musicplayer.views
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.drawable.ColorDrawable
|
import android.graphics.drawable.ColorDrawable
|
||||||
import android.os.Handler
|
|
||||||
import android.os.Looper
|
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.widget.RelativeLayout
|
import android.widget.RelativeLayout
|
||||||
|
@ -13,12 +12,14 @@ import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||||
import com.bumptech.glide.request.RequestOptions
|
import com.bumptech.glide.request.RequestOptions
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.musicplayer.R
|
import com.simplemobiletools.musicplayer.R
|
||||||
|
import com.simplemobiletools.musicplayer.extensions.ensureActivityNotDestroyed
|
||||||
import com.simplemobiletools.musicplayer.extensions.getTrackCoverArt
|
import com.simplemobiletools.musicplayer.extensions.getTrackCoverArt
|
||||||
import com.simplemobiletools.musicplayer.extensions.sendIntent
|
import com.simplemobiletools.musicplayer.extensions.sendIntent
|
||||||
import com.simplemobiletools.musicplayer.extensions.updatePlayPauseIcon
|
import com.simplemobiletools.musicplayer.extensions.updatePlayPauseIcon
|
||||||
import com.simplemobiletools.musicplayer.helpers.PLAYPAUSE
|
import com.simplemobiletools.musicplayer.helpers.PLAYPAUSE
|
||||||
import com.simplemobiletools.musicplayer.models.Track
|
import com.simplemobiletools.musicplayer.models.Track
|
||||||
import kotlinx.android.synthetic.main.view_current_track_bar.view.*
|
import kotlinx.android.synthetic.main.view_current_track_bar.view.current_track_label
|
||||||
|
import kotlinx.android.synthetic.main.view_current_track_bar.view.current_track_play_pause
|
||||||
|
|
||||||
class CurrentTrackBar(context: Context, attributeSet: AttributeSet) : RelativeLayout(context, attributeSet) {
|
class CurrentTrackBar(context: Context, attributeSet: AttributeSet) : RelativeLayout(context, attributeSet) {
|
||||||
fun updateColors() {
|
fun updateColors() {
|
||||||
|
@ -51,10 +52,12 @@ class CurrentTrackBar(context: Context, attributeSet: AttributeSet) : RelativeLa
|
||||||
.transform(CenterCrop(), RoundedCorners(cornerRadius))
|
.transform(CenterCrop(), RoundedCorners(cornerRadius))
|
||||||
|
|
||||||
context.getTrackCoverArt(track) { coverArt ->
|
context.getTrackCoverArt(track) { coverArt ->
|
||||||
Glide.with(this)
|
(context as? Activity)?.ensureActivityNotDestroyed {
|
||||||
.load(coverArt)
|
Glide.with(this)
|
||||||
.apply(options)
|
.load(coverArt)
|
||||||
.into(findViewById(R.id.current_track_image))
|
.apply(options)
|
||||||
|
.into(findViewById(R.id.current_track_image))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue