mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2026-05-16 04:52:39 +02:00
Fixed artwork not updating when in audio only.
This commit is contained in:
+32
-13
@@ -216,6 +216,7 @@ class VideoDetailView : ConstraintLayout {
|
|||||||
private val _playerProgress: PlayerControlView;
|
private val _playerProgress: PlayerControlView;
|
||||||
private val _timeBar: TimeBar;
|
private val _timeBar: TimeBar;
|
||||||
private var _upNext: UpNextView;
|
private var _upNext: UpNextView;
|
||||||
|
private var _artworkTarget: CustomTarget<Bitmap>? = null
|
||||||
|
|
||||||
private val rootView: ConstraintLayout;
|
private val rootView: ConstraintLayout;
|
||||||
|
|
||||||
@@ -882,6 +883,9 @@ class VideoDetailView : ConstraintLayout {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onClose.subscribe {
|
onClose.subscribe {
|
||||||
|
_artworkTarget?.let { Glide.with(context).clear(it) }
|
||||||
|
_artworkTarget = null
|
||||||
|
_player.setArtwork(null)
|
||||||
checkAndRemoveWatchLater();
|
checkAndRemoveWatchLater();
|
||||||
_lastVideoSource = null;
|
_lastVideoSource = null;
|
||||||
_lastAudioSource = null;
|
_lastAudioSource = null;
|
||||||
@@ -1264,6 +1268,9 @@ class VideoDetailView : ConstraintLayout {
|
|||||||
fun onDestroy() {
|
fun onDestroy() {
|
||||||
Logger.i(TAG, "onDestroy");
|
Logger.i(TAG, "onDestroy");
|
||||||
_destroyed = true;
|
_destroyed = true;
|
||||||
|
_artworkTarget?.let { Glide.with(context).clear(it) }
|
||||||
|
_artworkTarget = null
|
||||||
|
_player.setArtwork(null)
|
||||||
_taskLoadVideo.cancel();
|
_taskLoadVideo.cancel();
|
||||||
_commentsList.cancel();
|
_commentsList.cancel();
|
||||||
_player.clear();
|
_player.clear();
|
||||||
@@ -2053,19 +2060,31 @@ class VideoDetailView : ConstraintLayout {
|
|||||||
_player.switchToVideoMode()
|
_player.switchToVideoMode()
|
||||||
isAudioOnlyUserAction = false;
|
isAudioOnlyUserAction = false;
|
||||||
} else {
|
} else {
|
||||||
val thumbnail = video.thumbnails.getHQThumbnail();
|
_artworkTarget?.let { Glide.with(context).clear(it) }
|
||||||
if ((videoSource == null) && !thumbnail.isNullOrBlank()) // || _player.isAudioMode
|
_artworkTarget = null
|
||||||
Glide.with(context).asBitmap().load(thumbnail).withMaxSizePx()
|
|
||||||
.into(object: CustomTarget<Bitmap>() {
|
val thumbnail = video.thumbnails.getHQThumbnail()
|
||||||
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
|
val showArtwork = _player.isAudioMode || isAudioOnlyUserAction || (videoSource == null)
|
||||||
_player.setArtwork(BitmapDrawable(resources, resource));
|
|
||||||
}
|
if (showArtwork && !thumbnail.isNullOrBlank()) {
|
||||||
override fun onLoadCleared(placeholder: Drawable?) {
|
val target = object : CustomTarget<Bitmap>() {
|
||||||
_player.setArtwork(null);
|
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
|
||||||
}
|
_player.setArtwork(BitmapDrawable(resources, resource))
|
||||||
});
|
}
|
||||||
else
|
override fun onLoadCleared(placeholder: Drawable?) {
|
||||||
_player.setArtwork(null);
|
_player.setArtwork(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_artworkTarget = target
|
||||||
|
|
||||||
|
Glide.with(context)
|
||||||
|
.asBitmap()
|
||||||
|
.load(thumbnail)
|
||||||
|
.withMaxSizePx()
|
||||||
|
.into(target)
|
||||||
|
} else {
|
||||||
|
_player.setArtwork(null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment.lifecycleScope.launch(Dispatchers.Main) {
|
fragment.lifecycleScope.launch(Dispatchers.Main) {
|
||||||
|
|||||||
@@ -542,7 +542,7 @@
|
|||||||
<string name="restart_playback_when_gaining_connectivity_after_a_loss">Restart playback when gaining connectivity after a loss</string>
|
<string name="restart_playback_when_gaining_connectivity_after_a_loss">Restart playback when gaining connectivity after a loss</string>
|
||||||
<string name="chapter_update_fps_title">Chapter Update FPS</string>
|
<string name="chapter_update_fps_title">Chapter Update FPS</string>
|
||||||
<string name="chapter_update_fps_description">Change accuracy of chapter updating, higher might cost more performance</string>
|
<string name="chapter_update_fps_description">Change accuracy of chapter updating, higher might cost more performance</string>
|
||||||
<string name="set_automatic_backup">Set Automatic Backup</string>
|
<string name="set_automatic_backup">Configure Automatic Backup</string>
|
||||||
<string name="shortly_after_opening_the_app_start_fetching_subscriptions">Shortly after opening the app, start fetching subscriptions</string>
|
<string name="shortly_after_opening_the_app_start_fetching_subscriptions">Shortly after opening the app, start fetching subscriptions</string>
|
||||||
<string name="show_faq">Show FAQ</string>
|
<string name="show_faq">Show FAQ</string>
|
||||||
<string name="show_issues">Show Issues</string>
|
<string name="show_issues">Show Issues</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user