From bbeb9b83a0ba4538107758ab993566aa625749dc Mon Sep 17 00:00:00 2001 From: Koen J Date: Wed, 5 Mar 2025 11:58:09 +0100 Subject: [PATCH] Removed dynamic Polycentric calls. --- .../views/adapters/PlaylistView.kt | 43 ----------- .../views/adapters/SubscriptionViewHolder.kt | 41 ---------- .../adapters/feedtypes/PreviewPostView.kt | 43 ----------- .../adapters/feedtypes/PreviewVideoView.kt | 71 ----------------- .../viewholders/CreatorBarViewHolder.kt | 76 ------------------- .../adapters/viewholders/CreatorViewHolder.kt | 39 ---------- .../viewholders/SubscriptionBarViewHolder.kt | 38 ---------- .../main/res/layout/list_locked_thumbnail.xml | 17 +---- .../main/res/layout/list_playlist_feed.xml | 17 +---- app/src/main/res/layout/list_post_preview.xml | 18 +---- .../main/res/layout/list_post_thumbnail.xml | 19 +---- .../main/res/layout/list_video_thumbnail.xml | 17 +---- .../layout/list_video_thumbnail_nested.xml | 19 +---- 13 files changed, 13 insertions(+), 445 deletions(-) diff --git a/app/src/main/java/com/futo/platformplayer/views/adapters/PlaylistView.kt b/app/src/main/java/com/futo/platformplayer/views/adapters/PlaylistView.kt index b606bf26..c8d86b14 100644 --- a/app/src/main/java/com/futo/platformplayer/views/adapters/PlaylistView.kt +++ b/app/src/main/java/com/futo/platformplayer/views/adapters/PlaylistView.kt @@ -29,21 +29,12 @@ open class PlaylistView : LinearLayout { protected val _imageThumbnail: ImageView protected val _imageChannel: ImageView? protected val _creatorThumbnail: CreatorThumbnail? - protected val _imageNeopassChannel: ImageView?; protected val _platformIndicator: PlatformIndicator; protected val _textPlaylistName: TextView protected val _textVideoCount: TextView protected val _textVideoCountLabel: TextView; protected val _textPlaylistItems: TextView protected val _textChannelName: TextView - protected var _neopassAnimator: ObjectAnimator? = null; - - private val _taskLoadValidClaims = TaskHandler(StateApp.instance.scopeGetter, - { PolycentricCache.instance.getValidClaimsAsync(it).await() }) - .success { it -> updateClaimsLayout(it, animate = true) } - .exception { - Logger.w(TAG, "Failed to load claims.", it); - }; val onPlaylistClicked = Event1(); val onChannelClicked = Event1(); @@ -66,7 +57,6 @@ open class PlaylistView : LinearLayout { _textVideoCountLabel = findViewById(R.id.text_video_count_label); _textChannelName = findViewById(R.id.text_channel_name); _textPlaylistItems = findViewById(R.id.text_playlist_items); - _imageNeopassChannel = findViewById(R.id.image_neopass_channel); setOnClickListener { onOpenClicked() }; _imageChannel?.setOnClickListener { currentPlaylist?.let { onChannelClicked.emit(it.author) } }; @@ -88,20 +78,6 @@ open class PlaylistView : LinearLayout { open fun bind(content: IPlatformContent) { - _taskLoadValidClaims.cancel(); - - if (content.author.id.claimType > 0) { - val cachedClaims = PolycentricCache.instance.getCachedValidClaims(content.author.id); - if (cachedClaims != null) { - updateClaimsLayout(cachedClaims, animate = false); - } else { - updateClaimsLayout(null, animate = false); - _taskLoadValidClaims.run(content.author.id); - } - } else { - updateClaimsLayout(null, animate = false); - } - isClickable = true; _imageChannel?.let { @@ -155,25 +131,6 @@ open class PlaylistView : LinearLayout { } } - private fun updateClaimsLayout(claims: PolycentricCache.CachedOwnedClaims?, animate: Boolean) { - _neopassAnimator?.cancel(); - _neopassAnimator = null; - - val firstClaim = claims?.ownedClaims?.firstOrNull(); - val harborAvailable = firstClaim != null - if (harborAvailable) { - _imageNeopassChannel?.visibility = View.VISIBLE - if (animate) { - _neopassAnimator = ObjectAnimator.ofFloat(_imageNeopassChannel, "alpha", 0.0f, 1.0f).setDuration(500) - _neopassAnimator?.start() - } - } else { - _imageNeopassChannel?.visibility = View.GONE - } - - _creatorThumbnail?.setHarborAvailable(harborAvailable, animate, firstClaim?.system?.toProto()) - } - companion object { private val TAG = "VideoPreviewViewHolder" } diff --git a/app/src/main/java/com/futo/platformplayer/views/adapters/SubscriptionViewHolder.kt b/app/src/main/java/com/futo/platformplayer/views/adapters/SubscriptionViewHolder.kt index 603f79d3..05a3f5e7 100644 --- a/app/src/main/java/com/futo/platformplayer/views/adapters/SubscriptionViewHolder.kt +++ b/app/src/main/java/com/futo/platformplayer/views/adapters/SubscriptionViewHolder.kt @@ -32,14 +32,6 @@ class SubscriptionViewHolder : ViewHolder { private val _platformIndicator : PlatformIndicator; private val _textMeta: TextView; - private val _taskLoadProfile = TaskHandler( - StateApp.instance.scopeGetter, - { PolycentricCache.instance.getProfileAsync(it) }) - .success { it -> onProfileLoaded(null, it, true) } - .exception { - Logger.w(TAG, "Failed to load profile.", it); - }; - var subscription: Subscription? = null private set; @@ -74,45 +66,12 @@ class SubscriptionViewHolder : ViewHolder { } fun bind(sub: Subscription) { - _taskLoadProfile.cancel(); - this.subscription = sub; _creatorThumbnail.setThumbnail(sub.channel.thumbnail, false); _textName.text = sub.channel.name; bindViewMetrics(sub); _platformIndicator.setPlatformFromClientID(sub.channel.id.pluginId); - - val cachedProfile = PolycentricCache.instance.getCachedProfile(sub.channel.url, true); - if (cachedProfile != null) { - onProfileLoaded(sub, cachedProfile, false); - if (cachedProfile.expired) { - _taskLoadProfile.run(sub.channel.id); - } - } else { - _taskLoadProfile.run(sub.channel.id); - } - } - - private fun onProfileLoaded(sub: Subscription?, cachedPolycentricProfile: PolycentricCache.CachedPolycentricProfile?, animate: Boolean) { - val dp_46 = 46.dp(itemView.context.resources); - val profile = cachedPolycentricProfile?.profile; - val avatar = profile?.systemState?.avatar?.selectBestImage(dp_46 * dp_46) - ?.let { it.toURLInfoSystemLinkUrl(profile.system.toProto(), it.process, profile.systemState.servers.toList()) }; - - if (avatar != null) { - _creatorThumbnail.setThumbnail(avatar, animate); - } else { - _creatorThumbnail.setThumbnail(this.subscription?.channel?.thumbnail, animate); - _creatorThumbnail.setHarborAvailable(profile != null, animate, profile?.system?.toProto()); - } - - if (profile != null) { - _textName.text = profile.systemState.username; - } - - if(sub != null) - bindViewMetrics(sub) } fun bindViewMetrics(sub: Subscription?) { diff --git a/app/src/main/java/com/futo/platformplayer/views/adapters/feedtypes/PreviewPostView.kt b/app/src/main/java/com/futo/platformplayer/views/adapters/feedtypes/PreviewPostView.kt index 5a476421..cbf0b8a6 100644 --- a/app/src/main/java/com/futo/platformplayer/views/adapters/feedtypes/PreviewPostView.kt +++ b/app/src/main/java/com/futo/platformplayer/views/adapters/feedtypes/PreviewPostView.kt @@ -44,7 +44,6 @@ class PreviewPostView : LinearLayout { private val _imageAuthorThumbnail: ImageView; private val _textAuthorName: TextView; - private val _imageNeopassChannel: ImageView; private val _textMetadata: TextView; private val _textTitle: TextView; private val _textDescription: TextView; @@ -64,15 +63,6 @@ class PreviewPostView : LinearLayout { private val _layoutComments: LinearLayout?; private val _textComments: TextView?; - private var _neopassAnimator: ObjectAnimator? = null; - - private val _taskLoadValidClaims = TaskHandler(StateApp.instance.scopeGetter, - { PolycentricCache.instance.getValidClaimsAsync(it).await() }) - .success { it -> updateClaimsLayout(it, animate = true) } - .exception { - Logger.w(TAG, "Failed to load claims.", it); - }; - val content: IPlatformContent? get() = _content; val onContentClicked = Event1(); @@ -83,7 +73,6 @@ class PreviewPostView : LinearLayout { _imageAuthorThumbnail = findViewById(R.id.image_author_thumbnail); _textAuthorName = findViewById(R.id.text_author_name); - _imageNeopassChannel = findViewById(R.id.image_neopass_channel); _textMetadata = findViewById(R.id.text_metadata); _textTitle = findViewById(R.id.text_title); _textDescription = findViewById(R.id.text_description); @@ -130,21 +119,8 @@ class PreviewPostView : LinearLayout { } fun bind(content: IPlatformContent) { - _taskLoadValidClaims.cancel(); _content = content; - if (content.author.id.claimType > 0) { - val cachedClaims = PolycentricCache.instance.getCachedValidClaims(content.author.id); - if (cachedClaims != null) { - updateClaimsLayout(cachedClaims, animate = false); - } else { - updateClaimsLayout(null, animate = false); - _taskLoadValidClaims.run(content.author.id); - } - } else { - updateClaimsLayout(null, animate = false); - } - _textAuthorName.text = content.author.name; _textMetadata.text = content.datetime?.toHumanNowDiffString()?.let { "$it ago" } ?: ""; @@ -292,25 +268,6 @@ class PreviewPostView : LinearLayout { }; } - private fun updateClaimsLayout(claims: PolycentricCache.CachedOwnedClaims?, animate: Boolean) { - _neopassAnimator?.cancel(); - _neopassAnimator = null; - - val harborAvailable = claims != null && !claims.ownedClaims.isNullOrEmpty(); - if (harborAvailable) { - _imageNeopassChannel.visibility = View.VISIBLE - if (animate) { - _neopassAnimator = ObjectAnimator.ofFloat(_imageNeopassChannel, "alpha", 0.0f, 1.0f).setDuration(500) - _neopassAnimator?.start() - } - } else { - _imageNeopassChannel.visibility = View.GONE - } - - //TODO: Necessary if we decide to use creator thumbnail with neopass indicator instead - //_creatorThumbnail?.setHarborAvailable(harborAvailable, animate) - } - companion object { val TAG = "PreviewPostView"; } diff --git a/app/src/main/java/com/futo/platformplayer/views/adapters/feedtypes/PreviewVideoView.kt b/app/src/main/java/com/futo/platformplayer/views/adapters/feedtypes/PreviewVideoView.kt index 33066060..f2123832 100644 --- a/app/src/main/java/com/futo/platformplayer/views/adapters/feedtypes/PreviewVideoView.kt +++ b/app/src/main/java/com/futo/platformplayer/views/adapters/feedtypes/PreviewVideoView.kt @@ -47,7 +47,6 @@ open class PreviewVideoView : LinearLayout { protected val _imageVideo: ImageView protected val _imageChannel: ImageView? protected val _creatorThumbnail: CreatorThumbnail? - protected val _imageNeopassChannel: ImageView?; protected val _platformIndicator: PlatformIndicator; protected val _textVideoName: TextView protected val _textChannelName: TextView @@ -57,7 +56,6 @@ open class PreviewVideoView : LinearLayout { protected var _playerVideoThumbnail: FutoThumbnailPlayer? = null; protected val _containerLive: LinearLayout; protected val _playerContainer: FrameLayout; - protected var _neopassAnimator: ObjectAnimator? = null; protected val _layoutDownloaded: FrameLayout; protected val _button_add_to_queue : View; @@ -65,15 +63,6 @@ open class PreviewVideoView : LinearLayout { protected val _button_add_to : View; protected val _exoPlayer: PlayerManager?; - - private val _taskLoadProfile = TaskHandler( - StateApp.instance.scopeGetter, - { PolycentricCache.instance.getProfileAsync(it) }) - .success { it -> onProfileLoaded(it, true) } - .exception { - Logger.w(TAG, "Failed to load profile.", it); - }; - private val _timeBar: ProgressBar?; val onVideoClicked = Event2(); @@ -108,7 +97,6 @@ open class PreviewVideoView : LinearLayout { _button_add_to_queue = findViewById(R.id.button_add_to_queue); _button_add_to_watch_later = findViewById(R.id.button_add_to_watch_later); _button_add_to = findViewById(R.id.button_add_to); - _imageNeopassChannel = findViewById(R.id.image_neopass_channel); _layoutDownloaded = findViewById(R.id.layout_downloaded); _timeBar = findViewById(R.id.time_bar) @@ -160,15 +148,12 @@ open class PreviewVideoView : LinearLayout { open fun bind(content: IPlatformContent) { - _taskLoadProfile.cancel(); - isClickable = true; val isPlanned = (content.datetime?.getNowDiffSeconds() ?: 0) < 0; stopPreview(); - _imageNeopassChannel?.visibility = View.GONE; _creatorThumbnail?.setThumbnail(content.author.thumbnail, false); val thumbnail = content.author.thumbnail @@ -186,16 +171,6 @@ open class PreviewVideoView : LinearLayout { _textChannelName.text = content.author.name - val cachedProfile = PolycentricCache.instance.getCachedProfile(content.author.url, true); - if (cachedProfile != null) { - onProfileLoaded(cachedProfile, false); - if (cachedProfile.expired) { - _taskLoadProfile.run(content.author.id); - } - } else { - _taskLoadProfile.run(content.author.id); - } - _imageChannel?.clipToOutline = true; _textVideoName.text = content.name; @@ -335,52 +310,6 @@ open class PreviewVideoView : LinearLayout { _playerVideoThumbnail?.setMuteChangedListener(callback); } - private fun onProfileLoaded(cachedPolycentricProfile: PolycentricCache.CachedPolycentricProfile?, animate: Boolean) { - _neopassAnimator?.cancel(); - _neopassAnimator = null; - - val profile = cachedPolycentricProfile?.profile; - if (_creatorThumbnail != null) { - val dp_32 = 32.dp(context.resources); - val avatar = profile?.systemState?.avatar?.selectBestImage(dp_32 * dp_32) - ?.let { it.toURLInfoSystemLinkUrl(profile.system.toProto(), it.process, profile.systemState.servers.toList()) }; - - if (avatar != null) { - _creatorThumbnail.setThumbnail(avatar, animate); - } else { - _creatorThumbnail.setThumbnail(content?.author?.thumbnail, animate); - _creatorThumbnail.setHarborAvailable(profile != null, animate, profile?.system?.toProto()); - } - } else if (_imageChannel != null) { - val dp_28 = 28.dp(context.resources); - val avatar = profile?.systemState?.avatar?.selectBestImage(dp_28 * dp_28) - ?.let { it.toURLInfoSystemLinkUrl(profile.system.toProto(), it.process, profile.systemState.servers.toList()) }; - - if (avatar != null) { - _imageChannel.let { - Glide.with(_imageChannel) - .load(avatar) - .placeholder(R.drawable.placeholder_channel_thumbnail) - .into(_imageChannel); - } - - _imageNeopassChannel?.visibility = View.VISIBLE - if (animate) { - _neopassAnimator = ObjectAnimator.ofFloat(_imageNeopassChannel, "alpha", 0.0f, 1.0f).setDuration(500) - _neopassAnimator?.start() - } else { - _imageNeopassChannel?.alpha = 1.0f; - } - } else { - _imageNeopassChannel?.visibility = View.GONE - } - } - - if (profile != null) { - _textChannelName.text = profile.systemState.username - } - } - companion object { private val TAG = "VideoPreviewViewHolder" } diff --git a/app/src/main/java/com/futo/platformplayer/views/adapters/viewholders/CreatorBarViewHolder.kt b/app/src/main/java/com/futo/platformplayer/views/adapters/viewholders/CreatorBarViewHolder.kt index 14322506..897718bf 100644 --- a/app/src/main/java/com/futo/platformplayer/views/adapters/viewholders/CreatorBarViewHolder.kt +++ b/app/src/main/java/com/futo/platformplayer/views/adapters/viewholders/CreatorBarViewHolder.kt @@ -27,14 +27,6 @@ class CreatorBarViewHolder(private val _viewGroup: ViewGroup) : AnyAdapter.AnyVi val onClick = Event1(); - private val _taskLoadProfile = TaskHandler( - StateApp.instance.scopeGetter, - { PolycentricCache.instance.getProfileAsync(it) }) - .success { onProfileLoaded(it, true) } - .exception { - Logger.w(TAG, "Failed to load profile.", it); - }; - init { _creatorThumbnail = _view.findViewById(R.id.creator_thumbnail); _name = _view.findViewById(R.id.text_channel_name); @@ -45,40 +37,10 @@ class CreatorBarViewHolder(private val _viewGroup: ViewGroup) : AnyAdapter.AnyVi } override fun bind(value: IPlatformChannel) { - _taskLoadProfile.cancel(); - _channel = value; _creatorThumbnail.setThumbnail(value.thumbnail, false); _name.text = value.name; - - val cachedProfile = PolycentricCache.instance.getCachedProfile(value.url, true); - if (cachedProfile != null) { - onProfileLoaded(cachedProfile, false); - if (cachedProfile.expired) { - _taskLoadProfile.run(value.id); - } - } else { - _taskLoadProfile.run(value.id); - } - } - - private fun onProfileLoaded(cachedPolycentricProfile: PolycentricCache.CachedPolycentricProfile?, animate: Boolean) { - val dp_55 = 55.dp(itemView.context.resources) - val profile = cachedPolycentricProfile?.profile; - val avatar = profile?.systemState?.avatar?.selectBestImage(dp_55 * dp_55) - ?.let { it.toURLInfoSystemLinkUrl(profile.system.toProto(), it.process, profile.systemState.servers.toList()) }; - - if (avatar != null) { - _creatorThumbnail.setThumbnail(avatar, animate); - } else { - _creatorThumbnail.setThumbnail(_channel?.thumbnail, animate); - _creatorThumbnail.setHarborAvailable(profile != null, animate, profile?.system?.toProto()); - } - - if (profile != null) { - _name.text = profile.systemState.username; - } } companion object { @@ -94,14 +56,6 @@ class SelectableCreatorBarViewHolder(private val _viewGroup: ViewGroup) : AnyAda val onClick = Event1(); - private val _taskLoadProfile = TaskHandler( - StateApp.instance.scopeGetter, - { PolycentricCache.instance.getProfileAsync(it) }) - .success { onProfileLoaded(it, true) } - .exception { - Logger.w(TAG, "Failed to load profile.", it); - }; - init { _creatorThumbnail = _view.findViewById(R.id.creator_thumbnail); _name = _view.findViewById(R.id.text_channel_name); @@ -112,8 +66,6 @@ class SelectableCreatorBarViewHolder(private val _viewGroup: ViewGroup) : AnyAda } override fun bind(value: Selectable) { - _taskLoadProfile.cancel(); - _channel = value; if(value.active) @@ -123,34 +75,6 @@ class SelectableCreatorBarViewHolder(private val _viewGroup: ViewGroup) : AnyAda _creatorThumbnail.setThumbnail(value.channel.thumbnail, false); _name.text = value.channel.name; - - val cachedProfile = PolycentricCache.instance.getCachedProfile(value.channel.url, true); - if (cachedProfile != null) { - onProfileLoaded(cachedProfile, false); - if (cachedProfile.expired) { - _taskLoadProfile.run(value.channel.id); - } - } else { - _taskLoadProfile.run(value.channel.id); - } - } - - private fun onProfileLoaded(cachedPolycentricProfile: PolycentricCache.CachedPolycentricProfile?, animate: Boolean) { - val dp_55 = 55.dp(itemView.context.resources) - val profile = cachedPolycentricProfile?.profile; - val avatar = profile?.systemState?.avatar?.selectBestImage(dp_55 * dp_55) - ?.let { it.toURLInfoSystemLinkUrl(profile.system.toProto(), it.process, profile.systemState.servers.toList()) }; - - if (avatar != null) { - _creatorThumbnail.setThumbnail(avatar, animate); - } else { - _creatorThumbnail.setThumbnail(_channel?.channel?.thumbnail, animate); - _creatorThumbnail.setHarborAvailable(profile != null, animate, profile?.system?.toProto()); - } - - if (profile != null) { - _name.text = profile.systemState.username; - } } companion object { diff --git a/app/src/main/java/com/futo/platformplayer/views/adapters/viewholders/CreatorViewHolder.kt b/app/src/main/java/com/futo/platformplayer/views/adapters/viewholders/CreatorViewHolder.kt index 5c57ffa9..b5784d4c 100644 --- a/app/src/main/java/com/futo/platformplayer/views/adapters/viewholders/CreatorViewHolder.kt +++ b/app/src/main/java/com/futo/platformplayer/views/adapters/viewholders/CreatorViewHolder.kt @@ -34,14 +34,6 @@ class CreatorViewHolder(private val _viewGroup: ViewGroup, private val _tiny: Bo val onClick = Event1(); - private val _taskLoadProfile = TaskHandler( - StateApp.instance.scopeGetter, - { PolycentricCache.instance.getProfileAsync(it) }) - .success { it -> onProfileLoaded(it, true) } - .exception { - Logger.w(TAG, "Failed to load profile.", it); - }; - init { _textName = _view.findViewById(R.id.text_channel_name); _creatorThumbnail = _view.findViewById(R.id.creator_thumbnail); @@ -61,21 +53,9 @@ class CreatorViewHolder(private val _viewGroup: ViewGroup, private val _tiny: Bo } override fun bind(value: PlatformAuthorLink) { - _taskLoadProfile.cancel(); - _creatorThumbnail.setThumbnail(value.thumbnail, false); _textName.text = value.name; - val cachedProfile = PolycentricCache.instance.getCachedProfile(value.url, true); - if (cachedProfile != null) { - onProfileLoaded(cachedProfile, false); - if (cachedProfile.expired) { - _taskLoadProfile.run(value.id); - } - } else { - _taskLoadProfile.run(value.id); - } - if(value.subscribers == null || (value.subscribers ?: 0) <= 0L) _textMetadata.visibility = View.GONE; else { @@ -87,25 +67,6 @@ class CreatorViewHolder(private val _viewGroup: ViewGroup, private val _tiny: Bo _authorLink = value; } - private fun onProfileLoaded(cachedPolycentricProfile: PolycentricCache.CachedPolycentricProfile?, animate: Boolean) { - val dp_61 = 61.dp(itemView.context.resources); - - val profile = cachedPolycentricProfile?.profile; - val avatar = profile?.systemState?.avatar?.selectBestImage(dp_61 * dp_61) - ?.let { it.toURLInfoSystemLinkUrl(profile.system.toProto(), it.process, profile.systemState.servers.toList()) }; - - if (avatar != null) { - _creatorThumbnail.setThumbnail(avatar, animate); - } else { - _creatorThumbnail.setThumbnail(_authorLink?.thumbnail, animate); - _creatorThumbnail.setHarborAvailable(profile != null, animate, profile?.system?.toProto()); - } - - if (profile != null) { - _textName.text = profile.systemState.username; - } - } - companion object { private const val TAG = "CreatorViewHolder"; } diff --git a/app/src/main/java/com/futo/platformplayer/views/adapters/viewholders/SubscriptionBarViewHolder.kt b/app/src/main/java/com/futo/platformplayer/views/adapters/viewholders/SubscriptionBarViewHolder.kt index 2b6350c4..da491cf6 100644 --- a/app/src/main/java/com/futo/platformplayer/views/adapters/viewholders/SubscriptionBarViewHolder.kt +++ b/app/src/main/java/com/futo/platformplayer/views/adapters/viewholders/SubscriptionBarViewHolder.kt @@ -27,14 +27,6 @@ class SubscriptionBarViewHolder(private val _viewGroup: ViewGroup) : AnyAdapter. private var _subscription: Subscription? = null; private var _channel: SerializedChannel? = null; - private val _taskLoadProfile = TaskHandler( - StateApp.instance.scopeGetter, - { PolycentricCache.instance.getProfileAsync(it) }) - .success { onProfileLoaded(it, true) } - .exception { - Logger.w(TAG, "Failed to load profile.", it); - }; - val onClick = Event1(); init { @@ -47,44 +39,14 @@ class SubscriptionBarViewHolder(private val _viewGroup: ViewGroup) : AnyAdapter. } override fun bind(value: Subscription) { - _taskLoadProfile.cancel(); - _channel = value.channel; _creatorThumbnail.setThumbnail(value.channel.thumbnail, false); _name.text = value.channel.name; - val cachedProfile = PolycentricCache.instance.getCachedProfile(value.channel.url, true); - if (cachedProfile != null) { - onProfileLoaded(cachedProfile, false); - if (cachedProfile.expired) { - _taskLoadProfile.run(value.channel.id); - } - } else { - _taskLoadProfile.run(value.channel.id); - } - _subscription = value; } - private fun onProfileLoaded(cachedPolycentricProfile: PolycentricCache.CachedPolycentricProfile?, animate: Boolean) { - val dp_55 = 55.dp(itemView.context.resources) - val profile = cachedPolycentricProfile?.profile; - val avatar = profile?.systemState?.avatar?.selectBestImage(dp_55 * dp_55) - ?.let { it.toURLInfoSystemLinkUrl(profile.system.toProto(), it.process, profile.systemState.servers.toList()) }; - - if (avatar != null) { - _creatorThumbnail.setThumbnail(avatar, animate); - } else { - _creatorThumbnail.setThumbnail(_channel?.thumbnail, animate); - _creatorThumbnail.setHarborAvailable(profile != null, animate, profile?.system?.toProto()); - } - - if (profile != null) { - _name.text = profile.systemState.username; - } - } - companion object { private const val TAG = "SubscriptionBarViewHolder"; } diff --git a/app/src/main/res/layout/list_locked_thumbnail.xml b/app/src/main/res/layout/list_locked_thumbnail.xml index 462d65d4..f00e28f3 100644 --- a/app/src/main/res/layout/list_locked_thumbnail.xml +++ b/app/src/main/res/layout/list_locked_thumbnail.xml @@ -254,7 +254,7 @@ - - - - + app:layout_constraintTop_toBottomOf="@id/text_playlist_name" /> - - - - - - - - - -