mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-19 19:14:51 +00:00
Mostly implemented recommendations.
This commit is contained in:
parent
fdd1af3287
commit
3d25d94a77
8 changed files with 267 additions and 141 deletions
|
@ -371,8 +371,8 @@ class MenuBottomBarFragment : MainActivityFragment() {
|
|||
ButtonDefinition(0, R.drawable.ic_home, R.drawable.ic_home_filled, R.string.home, canToggle = true, { it.currentMain is HomeFragment }, {
|
||||
val currentMain = it.currentMain
|
||||
if (currentMain is HomeFragment) {
|
||||
currentMain.scrollToTop(false)
|
||||
currentMain.reloadFeed()
|
||||
currentMain.scrollToTop()
|
||||
} else {
|
||||
it.navigate<HomeFragment>()
|
||||
}
|
||||
|
|
|
@ -50,8 +50,8 @@ class HomeFragment : MainFragment() {
|
|||
_view?.reloadFeed()
|
||||
}
|
||||
|
||||
fun scrollToTop() {
|
||||
_view?.scrollToTop()
|
||||
fun scrollToTop(smooth: Boolean) {
|
||||
_view?.scrollToTop(smooth)
|
||||
}
|
||||
|
||||
override fun onShownWithView(parameter: Any?, isBack: Boolean) {
|
||||
|
@ -159,8 +159,12 @@ class HomeFragment : MainFragment() {
|
|||
finishRefreshLayoutLoader();
|
||||
}
|
||||
|
||||
fun scrollToTop() {
|
||||
_recyclerResults.smoothScrollToPosition(0)
|
||||
fun scrollToTop(smooth: Boolean) {
|
||||
if (smooth) {
|
||||
_recyclerResults.smoothScrollToPosition(0)
|
||||
} else {
|
||||
_recyclerResults.scrollToPosition(0)
|
||||
}
|
||||
}
|
||||
|
||||
fun reloadFeed() {
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewPropertyAnimator
|
||||
import android.widget.Button
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageButton
|
||||
import android.widget.ImageView
|
||||
|
@ -19,6 +20,7 @@ import androidx.core.view.children
|
|||
import androidx.lifecycle.lifecycleScope
|
||||
import com.bumptech.glide.Glide
|
||||
import com.futo.platformplayer.R
|
||||
import com.futo.platformplayer.Settings
|
||||
import com.futo.platformplayer.UIDialogs
|
||||
import com.futo.platformplayer.api.media.PlatformID
|
||||
import com.futo.platformplayer.api.media.models.Thumbnails
|
||||
|
@ -135,10 +137,7 @@ class PostDetailFragment : MainFragment {
|
|||
private val _imageDislikeIcon: ImageView;
|
||||
private val _textDislikes: TextView;
|
||||
|
||||
private val _textComments: TextView;
|
||||
private val _textCommentType: TextView;
|
||||
private val _addCommentView: AddCommentView;
|
||||
private val _toggleCommentType: Toggle;
|
||||
|
||||
private val _rating: PillRatingLikesDislikes;
|
||||
|
||||
|
@ -152,6 +151,10 @@ class PostDetailFragment : MainFragment {
|
|||
|
||||
private val _commentsList: CommentsList;
|
||||
|
||||
private var _commentType: Boolean? = null;
|
||||
private val _buttonPolycentric: Button
|
||||
private val _buttonPlatform: Button
|
||||
|
||||
private val _taskLoadPost = if(!isInEditMode) TaskHandler<String, IPlatformPostDetails>(
|
||||
StateApp.instance.scopeGetter,
|
||||
{
|
||||
|
@ -198,9 +201,6 @@ class PostDetailFragment : MainFragment {
|
|||
_textDislikes = findViewById(R.id.text_dislikes);
|
||||
|
||||
_commentsList = findViewById(R.id.comments_list);
|
||||
_textCommentType = findViewById(R.id.text_comment_type);
|
||||
_toggleCommentType = findViewById(R.id.toggle_comment_type);
|
||||
_textComments = findViewById(R.id.text_comments);
|
||||
_addCommentView = findViewById(R.id.add_comment_view);
|
||||
|
||||
_rating = findViewById(R.id.rating);
|
||||
|
@ -213,6 +213,9 @@ class PostDetailFragment : MainFragment {
|
|||
|
||||
_repliesOverlay = findViewById(R.id.replies_overlay);
|
||||
|
||||
_buttonPolycentric = findViewById(R.id.button_polycentric)
|
||||
_buttonPlatform = findViewById(R.id.button_platform)
|
||||
|
||||
_textContent.setPlatformPlayerLinkMovementMethod(context);
|
||||
|
||||
_buttonSubscribe.onSubscribed.subscribe {
|
||||
|
@ -224,9 +227,10 @@ class PostDetailFragment : MainFragment {
|
|||
root.removeView(layoutTop);
|
||||
_commentsList.setPrependedView(layoutTop);
|
||||
|
||||
/*TODO: Why is this here?
|
||||
_commentsList.onCommentsLoaded.subscribe {
|
||||
updateCommentType(false);
|
||||
};
|
||||
};*/
|
||||
|
||||
_commentsList.onRepliesClick.subscribe { c ->
|
||||
val replyCount = c.replyCount ?: 0;
|
||||
|
@ -237,7 +241,7 @@ class PostDetailFragment : MainFragment {
|
|||
|
||||
if (c is PolycentricPlatformComment) {
|
||||
var parentComment: PolycentricPlatformComment = c;
|
||||
_repliesOverlay.load(_toggleCommentType.value, metadata, c.contextUrl, c.reference, c,
|
||||
_repliesOverlay.load(_commentType!!, metadata, c.contextUrl, c.reference, c,
|
||||
{ StatePolycentric.instance.getCommentPager(c.contextUrl, c.reference) },
|
||||
{
|
||||
val newComment = parentComment.cloneWithUpdatedReplyCount((parentComment.replyCount ?: 0) + 1);
|
||||
|
@ -245,22 +249,23 @@ class PostDetailFragment : MainFragment {
|
|||
parentComment = newComment;
|
||||
});
|
||||
} else {
|
||||
_repliesOverlay.load(_toggleCommentType.value, metadata, null, null, c, { StatePlatform.instance.getSubComments(c) });
|
||||
_repliesOverlay.load(_commentType!!, metadata, null, null, c, { StatePlatform.instance.getSubComments(c) });
|
||||
}
|
||||
|
||||
setRepliesOverlayVisible(isVisible = true, animate = true);
|
||||
};
|
||||
|
||||
if (StatePolycentric.instance.enabled) {
|
||||
_buttonPolycentric.setOnClickListener {
|
||||
updateCommentType(false)
|
||||
}
|
||||
} else {
|
||||
_buttonPolycentric.visibility = View.GONE
|
||||
}
|
||||
|
||||
_toggleCommentType.onValueChanged.subscribe {
|
||||
updateCommentType(true);
|
||||
};
|
||||
|
||||
_textCommentType.setOnClickListener {
|
||||
_toggleCommentType.setValue(!_toggleCommentType.value, true);
|
||||
updateCommentType(true);
|
||||
};
|
||||
|
||||
_buttonPlatform.setOnClickListener {
|
||||
updateCommentType(true)
|
||||
}
|
||||
_layoutMonetization.visibility = View.GONE;
|
||||
|
||||
_buttonSupport.setOnClickListener {
|
||||
|
@ -432,7 +437,7 @@ class PostDetailFragment : MainFragment {
|
|||
_taskLoadPolycentricProfile.cancel();
|
||||
_version++;
|
||||
|
||||
_toggleCommentType.setValue(false, false);
|
||||
updateCommentType(null)
|
||||
_url = null;
|
||||
_post = null;
|
||||
_postOverview = null;
|
||||
|
@ -476,7 +481,8 @@ class PostDetailFragment : MainFragment {
|
|||
_addCommentView.setContext(value.url, Models.referenceFromBuffer(value.url.toByteArray()));
|
||||
}
|
||||
|
||||
updateCommentType(true);
|
||||
val commentType = !Settings.instance.other.polycentricEnabled || Settings.instance.comments.defaultCommentSection == 1
|
||||
updateCommentType(commentType, true);
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
|
@ -679,20 +685,29 @@ class PostDetailFragment : MainFragment {
|
|||
_commentsList.load(false) { StatePolycentric.instance.getCommentPager(post!!.url, ref, listOfNotNull(extraBytesRef)); };
|
||||
}
|
||||
|
||||
private fun updateCommentType(reloadComments: Boolean) {
|
||||
if (_toggleCommentType.value) {
|
||||
_textCommentType.text = "Platform";
|
||||
_addCommentView.visibility = View.GONE;
|
||||
private fun updateCommentType(commentType: Boolean?, forceReload: Boolean = false) {
|
||||
val changed = commentType != _commentType
|
||||
_commentType = commentType
|
||||
|
||||
if (reloadComments) {
|
||||
fetchComments();
|
||||
}
|
||||
if (commentType == null) {
|
||||
_buttonPlatform.setTextColor(resources.getColor(R.color.gray_ac))
|
||||
_buttonPolycentric.setTextColor(resources.getColor(R.color.gray_ac))
|
||||
} else {
|
||||
_textCommentType.text = "Polycentric";
|
||||
_addCommentView.visibility = View.VISIBLE;
|
||||
_buttonPlatform.setTextColor(resources.getColor(if (commentType) R.color.white else R.color.gray_ac))
|
||||
_buttonPolycentric.setTextColor(resources.getColor(if (!commentType) R.color.white else R.color.gray_ac))
|
||||
|
||||
if (reloadComments) {
|
||||
fetchPolycentricComments()
|
||||
if (commentType) {
|
||||
_addCommentView.visibility = View.GONE;
|
||||
|
||||
if (forceReload || changed) {
|
||||
fetchComments();
|
||||
}
|
||||
} else {
|
||||
_addCommentView.visibility = View.VISIBLE;
|
||||
|
||||
if (forceReload || changed) {
|
||||
fetchPolycentricComments()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.view.View
|
|||
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
||||
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
import android.view.WindowManager
|
||||
import android.widget.Button
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageButton
|
||||
import android.widget.ImageView
|
||||
|
@ -52,6 +53,7 @@ import com.futo.platformplayer.api.media.models.PlatformAuthorMembershipLink
|
|||
import com.futo.platformplayer.api.media.models.chapters.ChapterType
|
||||
import com.futo.platformplayer.api.media.models.chapters.IChapter
|
||||
import com.futo.platformplayer.api.media.models.comments.PolycentricPlatformComment
|
||||
import com.futo.platformplayer.api.media.models.contents.IPlatformContent
|
||||
import com.futo.platformplayer.api.media.models.live.ILiveChatWindowDescriptor
|
||||
import com.futo.platformplayer.api.media.models.live.IPlatformLiveEvent
|
||||
import com.futo.platformplayer.api.media.models.playback.IPlaybackTracker
|
||||
|
@ -72,7 +74,6 @@ import com.futo.platformplayer.api.media.models.video.IPlatformVideoDetails
|
|||
import com.futo.platformplayer.api.media.models.video.SerializedPlatformVideo
|
||||
import com.futo.platformplayer.api.media.platforms.js.SourcePluginConfig
|
||||
import com.futo.platformplayer.api.media.platforms.js.models.JSVideoDetails
|
||||
import com.futo.platformplayer.api.media.platforms.js.models.sources.JSSource
|
||||
import com.futo.platformplayer.api.media.structures.IPager
|
||||
import com.futo.platformplayer.casting.CastConnectionState
|
||||
import com.futo.platformplayer.casting.StateCasting
|
||||
|
@ -117,12 +118,14 @@ import com.futo.platformplayer.toHumanBytesSize
|
|||
import com.futo.platformplayer.toHumanNowDiffString
|
||||
import com.futo.platformplayer.toHumanNumber
|
||||
import com.futo.platformplayer.toHumanTime
|
||||
import com.futo.platformplayer.views.FeedStyle
|
||||
import com.futo.platformplayer.views.LoaderView
|
||||
import com.futo.platformplayer.views.MonetizationView
|
||||
import com.futo.platformplayer.views.adapters.feedtypes.PreviewVideoView
|
||||
import com.futo.platformplayer.views.behavior.TouchInterceptFrameLayout
|
||||
import com.futo.platformplayer.views.casting.CastView
|
||||
import com.futo.platformplayer.views.comments.AddCommentView
|
||||
import com.futo.platformplayer.views.others.CreatorThumbnail
|
||||
import com.futo.platformplayer.views.others.Toggle
|
||||
import com.futo.platformplayer.views.overlays.DescriptionOverlay
|
||||
import com.futo.platformplayer.views.overlays.LiveChatOverlay
|
||||
import com.futo.platformplayer.views.overlays.QueueEditorOverlay
|
||||
|
@ -156,6 +159,8 @@ import kotlinx.coroutines.launch
|
|||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import kotlinx.coroutines.withContext
|
||||
import okhttp3.Dispatcher
|
||||
import org.w3c.dom.Text
|
||||
import userpackage.Protocol
|
||||
import java.time.OffsetDateTime
|
||||
import kotlin.math.abs
|
||||
|
@ -226,10 +231,8 @@ class VideoDetailView : ConstraintLayout {
|
|||
|
||||
var preventPictureInPicture: Boolean = false;
|
||||
|
||||
private val _textComments: TextView;
|
||||
private val _textCommentType: TextView;
|
||||
private val _addCommentView: AddCommentView;
|
||||
private val _toggleCommentType: Toggle;
|
||||
private var _tabIndex: Int? = null;
|
||||
|
||||
private val _layoutSkip: LinearLayout;
|
||||
private val _textSkip: TextView;
|
||||
|
@ -237,6 +240,7 @@ class VideoDetailView : ConstraintLayout {
|
|||
private val _layoutResume: LinearLayout;
|
||||
private var _jobHideResume: Job? = null;
|
||||
private val _layoutPlayerContainer: TouchInterceptFrameLayout;
|
||||
private val _layoutChangeBottomSection: LinearLayout;
|
||||
|
||||
//Overlays
|
||||
private val _overlayContainer: FrameLayout;
|
||||
|
@ -260,12 +264,16 @@ class VideoDetailView : ConstraintLayout {
|
|||
private val _layoutRating: LinearLayout;
|
||||
private val _imageDislikeIcon: ImageView;
|
||||
private val _imageLikeIcon: ImageView;
|
||||
private val _layoutToggleCommentSection: LinearLayout;
|
||||
|
||||
private val _monetization: MonetizationView;
|
||||
|
||||
private val _buttonMore: RoundButton;
|
||||
|
||||
private val _buttonPolycentric: Button
|
||||
private val _buttonPlatform: Button
|
||||
private val _buttonRecommended: Button
|
||||
private val _layoutRecommended: LinearLayout
|
||||
|
||||
private var _didStop: Boolean = false;
|
||||
private var _onPauseCalled = false;
|
||||
private var _lastVideoSource: IVideoSource? = null;
|
||||
|
@ -335,9 +343,8 @@ class VideoDetailView : ConstraintLayout {
|
|||
_overlay_loading_spinner = findViewById(R.id.videodetail_loader);
|
||||
_rating = findViewById(R.id.videodetail_rating);
|
||||
_upNext = findViewById(R.id.up_next);
|
||||
_textCommentType = findViewById(R.id.text_comment_type);
|
||||
_toggleCommentType = findViewById(R.id.toggle_comment_type);
|
||||
_layoutToggleCommentSection = findViewById(R.id.layout_toggle_comment_section);
|
||||
_layoutChangeBottomSection = findViewById(R.id.layout_change_bottom_section);
|
||||
_layoutRecommended = findViewById(R.id.layout_recommended)
|
||||
|
||||
_overlayContainer = findViewById(R.id.overlay_container);
|
||||
_overlay_quality_container = findViewById(R.id.videodetail_quality_overview);
|
||||
|
@ -359,7 +366,6 @@ class VideoDetailView : ConstraintLayout {
|
|||
_container_content_support = findViewById(R.id.videodetail_container_support);
|
||||
_container_content_browser = findViewById(R.id.videodetail_container_webview)
|
||||
|
||||
_textComments = findViewById(R.id.text_comments);
|
||||
_addCommentView = findViewById(R.id.add_comment_view);
|
||||
_commentsList = findViewById(R.id.comments_list);
|
||||
|
||||
|
@ -376,6 +382,10 @@ class VideoDetailView : ConstraintLayout {
|
|||
_imageLikeIcon = findViewById(R.id.image_like_icon);
|
||||
_imageDislikeIcon = findViewById(R.id.image_dislike_icon);
|
||||
|
||||
_buttonPolycentric = findViewById(R.id.button_polycentric)
|
||||
_buttonPlatform = findViewById(R.id.button_platform)
|
||||
_buttonRecommended = findViewById(R.id.button_recommended)
|
||||
|
||||
_monetization = findViewById(R.id.monetization);
|
||||
_player.attachPlayer();
|
||||
|
||||
|
@ -429,17 +439,24 @@ class VideoDetailView : ConstraintLayout {
|
|||
|
||||
_commentsList.onCommentsLoaded.subscribe { count ->
|
||||
_commentsCount = count;
|
||||
updateCommentType(false);
|
||||
//TODO: Why is this here ? updateTabs(false);
|
||||
};
|
||||
|
||||
_toggleCommentType.onValueChanged.subscribe {
|
||||
updateCommentType(true);
|
||||
};
|
||||
if (StatePolycentric.instance.enabled) {
|
||||
_buttonPolycentric.setOnClickListener {
|
||||
setTabIndex(0)
|
||||
}
|
||||
} else {
|
||||
_buttonPolycentric.visibility = View.GONE
|
||||
}
|
||||
|
||||
_textCommentType.setOnClickListener {
|
||||
_toggleCommentType.setValue(!_toggleCommentType.value, true);
|
||||
updateCommentType(true);
|
||||
};
|
||||
_buttonRecommended.setOnClickListener {
|
||||
setTabIndex(2)
|
||||
}
|
||||
|
||||
_buttonPlatform.setOnClickListener {
|
||||
setTabIndex(1)
|
||||
}
|
||||
|
||||
val layoutTop: LinearLayout = findViewById(R.id.layout_top);
|
||||
_container_content_main.removeView(layoutTop);
|
||||
|
@ -676,7 +693,7 @@ class VideoDetailView : ConstraintLayout {
|
|||
|
||||
if (c is PolycentricPlatformComment) {
|
||||
var parentComment: PolycentricPlatformComment = c;
|
||||
_container_content_replies.load(_toggleCommentType.value, metadata, c.contextUrl, c.reference, c,
|
||||
_container_content_replies.load(if (_tabIndex!! == 0) false else true, metadata, c.contextUrl, c.reference, c,
|
||||
{ StatePolycentric.instance.getCommentPager(c.contextUrl, c.reference) },
|
||||
{
|
||||
val newComment = parentComment.cloneWithUpdatedReplyCount((parentComment.replyCount ?: 0) + 1);
|
||||
|
@ -684,7 +701,7 @@ class VideoDetailView : ConstraintLayout {
|
|||
parentComment = newComment;
|
||||
});
|
||||
} else {
|
||||
_container_content_replies.load(_toggleCommentType.value, metadata, null, null, c, { StatePlatform.instance.getSubComments(c) });
|
||||
_container_content_replies.load(if (_tabIndex!! == 0) false else true, metadata, null, null, c, { StatePlatform.instance.getSubComments(c) });
|
||||
}
|
||||
switchContentView(_container_content_replies);
|
||||
};
|
||||
|
@ -1023,7 +1040,6 @@ class VideoDetailView : ConstraintLayout {
|
|||
setDescription("".fixHtmlWhitespace());
|
||||
_descriptionContainer.visibility = View.GONE;
|
||||
_player.clear();
|
||||
_textComments.visibility = View.INVISIBLE;
|
||||
_commentsList.clear();
|
||||
|
||||
_lastVideoSource = null;
|
||||
|
@ -1047,7 +1063,7 @@ class VideoDetailView : ConstraintLayout {
|
|||
setLastPositionMilliseconds(_videoResumePositionMilliseconds, false);
|
||||
_addCommentView.setContext(null, null);
|
||||
|
||||
_toggleCommentType.setValue(false, false);
|
||||
setTabIndex(0)
|
||||
_commentsList.clear();
|
||||
|
||||
setEmpty();
|
||||
|
@ -1087,12 +1103,11 @@ class VideoDetailView : ConstraintLayout {
|
|||
setLastPositionMilliseconds(_videoResumePositionMilliseconds, false);
|
||||
_addCommentView.setContext(null, null);
|
||||
|
||||
_toggleCommentType.setValue(false, false);
|
||||
setTabIndex(null)
|
||||
|
||||
_title.text = video.name;
|
||||
_rating.visibility = View.GONE;
|
||||
_layoutRating.visibility = View.GONE;
|
||||
_textComments.visibility = View.VISIBLE;
|
||||
|
||||
_minimize_title.text = video.name;
|
||||
_minimize_meta.text = video.author.name;
|
||||
|
@ -1277,13 +1292,12 @@ class VideoDetailView : ConstraintLayout {
|
|||
_player.setMetadata(video.name, video.author.name);
|
||||
|
||||
if (video is TutorialFragment.TutorialVideo) {
|
||||
_toggleCommentType.setValue(false, false);
|
||||
setTabIndex(0, true)
|
||||
} else {
|
||||
_toggleCommentType.setValue(!Settings.instance.other.polycentricEnabled || Settings.instance.comments.defaultCommentSection == 1, false);
|
||||
val commentType = !Settings.instance.other.polycentricEnabled || Settings.instance.comments.defaultCommentSection == 1
|
||||
setTabIndex(if (commentType) 1 else 0, true)
|
||||
}
|
||||
|
||||
updateCommentType(true);
|
||||
|
||||
//UI
|
||||
_title.text = video.name;
|
||||
_channelName.text = video.author.name;
|
||||
|
@ -1477,13 +1491,13 @@ class VideoDetailView : ConstraintLayout {
|
|||
_buttonMore.visibility = View.GONE
|
||||
_buttonPins.visibility = View.GONE
|
||||
_layoutRating.visibility = View.GONE
|
||||
_layoutToggleCommentSection.visibility = View.GONE
|
||||
_layoutChangeBottomSection.visibility = View.GONE
|
||||
} else {
|
||||
_buttonSubscribe.visibility = View.VISIBLE
|
||||
_buttonMore.visibility = View.VISIBLE
|
||||
_buttonPins.visibility = View.VISIBLE
|
||||
_layoutRating.visibility = View.VISIBLE
|
||||
_layoutToggleCommentSection.visibility = View.VISIBLE
|
||||
_layoutChangeBottomSection.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
fun loadLiveChat(video: IPlatformVideoDetails) {
|
||||
|
@ -2271,24 +2285,93 @@ class VideoDetailView : ConstraintLayout {
|
|||
};
|
||||
}
|
||||
|
||||
private fun updateCommentType(reloadComments: Boolean) {
|
||||
if (_toggleCommentType.value) {
|
||||
_textCommentType.text = "Platform";
|
||||
_addCommentView.visibility = View.GONE;
|
||||
private fun setTabIndex(index: Int?, forceReload: Boolean = false) {
|
||||
Logger.i(TAG, "setTabIndex (index: ${index}, forceReload: ${forceReload})")
|
||||
val changed = _tabIndex != index || forceReload
|
||||
if (!changed) {
|
||||
return
|
||||
}
|
||||
|
||||
if (reloadComments) {
|
||||
fetchComments();
|
||||
}
|
||||
} else {
|
||||
_textCommentType.text = "Polycentric";
|
||||
_addCommentView.visibility = View.VISIBLE;
|
||||
_taskLoadRecommendations.cancel()
|
||||
_tabIndex = index
|
||||
_buttonRecommended.setTextColor(resources.getColor(if (index == 2) R.color.white else R.color.gray_ac))
|
||||
_buttonPlatform.setTextColor(resources.getColor(if (index == 1) R.color.white else R.color.gray_ac))
|
||||
_buttonPolycentric.setTextColor(resources.getColor(if (index == 0) R.color.white else R.color.gray_ac))
|
||||
_layoutRecommended.removeAllViews()
|
||||
|
||||
if (reloadComments) {
|
||||
fetchPolycentricComments()
|
||||
if (index == null) {
|
||||
_addCommentView.visibility = View.GONE
|
||||
_commentsList.clear()
|
||||
_layoutRecommended.visibility = View.GONE
|
||||
} else if (index == 0) {
|
||||
_addCommentView.visibility = View.VISIBLE
|
||||
_layoutRecommended.visibility = View.GONE
|
||||
fetchPolycentricComments()
|
||||
} else if (index == 1) {
|
||||
_addCommentView.visibility = View.VISIBLE
|
||||
_layoutRecommended.visibility = View.GONE
|
||||
fetchComments()
|
||||
} else if (index == 2) {
|
||||
_addCommentView.visibility = View.GONE
|
||||
_layoutRecommended.visibility = View.VISIBLE
|
||||
_commentsList.clear()
|
||||
|
||||
val url = _url
|
||||
if (url != null) {
|
||||
_layoutRecommended.addView(LoaderView(context).apply {
|
||||
layoutParams = LinearLayout.LayoutParams(60.dp(resources), 60.dp(resources))
|
||||
start()
|
||||
})
|
||||
_taskLoadRecommendations.run(url)
|
||||
} else {
|
||||
_layoutRecommended.addView(TextView(context).apply {
|
||||
layoutParams = LinearLayout.LayoutParams(60.dp(resources), 60.dp(resources))
|
||||
textSize = 12.0f
|
||||
text = "No recommendations found"
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setRecommendations(pager: IPager<IPlatformContent>?, message: String? = null) {
|
||||
_layoutRecommended.removeAllViews()
|
||||
if (pager == null) {
|
||||
_layoutRecommended.addView(TextView(context).apply {
|
||||
layoutParams = LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT).apply {
|
||||
setMargins(20.dp(resources), 20.dp(resources), 20.dp(resources), 20.dp(resources))
|
||||
}
|
||||
textAlignment = TEXT_ALIGNMENT_CENTER
|
||||
textSize = 14.0f
|
||||
text = message
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
val results = pager.getResults().filter { it is IPlatformVideo }
|
||||
for (result in results) {
|
||||
_layoutRecommended.addView(PreviewVideoView(context, FeedStyle.THUMBNAIL, null, false).apply {
|
||||
layoutParams = LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT)
|
||||
bind(result)
|
||||
|
||||
hideAddTo()
|
||||
|
||||
onVideoClicked.subscribe { video, _ ->
|
||||
fragment.navigate<VideoDetailFragment>(video).maximizeVideoDetail()
|
||||
}
|
||||
|
||||
onChannelClicked.subscribe {
|
||||
fragment.navigate<ChannelFragment>(it)
|
||||
}
|
||||
|
||||
onAddToWatchLaterClicked.subscribe(this) {
|
||||
if(it is IPlatformVideo) {
|
||||
StatePlaylists.instance.addToWatchLater(SerializedPlatformVideo.fromVideo(it));
|
||||
UIDialogs.toast("Added to watch later\n[${it.name}]");
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
//Picture2Picture
|
||||
fun startPictureInPicture() {
|
||||
|
@ -2634,6 +2717,13 @@ class VideoDetailView : ConstraintLayout {
|
|||
}
|
||||
} else TaskHandler(IPlatformVideoDetails::class.java, {fragment.lifecycleScope});
|
||||
|
||||
private val _taskLoadRecommendations = TaskHandler<String, IPager<IPlatformContent>?>(StateApp.instance.scopeGetter, { video?.getContentRecommendations(StatePlatform.instance.getContentClient(it)) })
|
||||
.success { setRecommendations(it, "No recommendations found") }
|
||||
.exception<Throwable> {
|
||||
setRecommendations(null, it.message)
|
||||
Logger.w(TAG, "Failed to load recommendations.", it);
|
||||
};
|
||||
|
||||
private val _taskLoadPolycentricProfile = TaskHandler<PlatformID, PolycentricCache.CachedPolycentricProfile?>(StateApp.instance.scopeGetter, { PolycentricCache.instance.getProfileAsync(it) })
|
||||
.success { it -> setPolycentricProfile(it, animate = true) }
|
||||
.exception<Throwable> {
|
||||
|
|
|
@ -130,6 +130,11 @@ open class PreviewVideoView : LinearLayout {
|
|||
_button_add_to_watch_later.setOnClickListener { currentVideo?.let { onAddToWatchLaterClicked.emit(it); } }
|
||||
}
|
||||
|
||||
fun hideAddTo() {
|
||||
_button_add_to.visibility = View.GONE
|
||||
_button_add_to_queue.visibility = View.GONE
|
||||
}
|
||||
|
||||
protected open fun inflate(feedStyle: FeedStyle) {
|
||||
inflate(context, when(feedStyle) {
|
||||
FeedStyle.PREVIEW -> R.layout.list_video_preview
|
||||
|
|
|
@ -254,6 +254,7 @@ class CommentsList : ConstraintLayout {
|
|||
|
||||
fun clear() {
|
||||
cancel();
|
||||
setLoading(false);
|
||||
_comments.clear();
|
||||
_commentsPager = null;
|
||||
_adapterComments.notifyDataSetChanged();
|
||||
|
|
|
@ -299,43 +299,41 @@
|
|||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_change_bottom_section"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginTop="8dp">
|
||||
android:background="@drawable/background_videodetail_description"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginLeft="14dp"
|
||||
android:layout_marginRight="14dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_comments"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="14dp"
|
||||
android:fontFamily="@font/inter_medium"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="17dp"
|
||||
android:text="@string/comments" />
|
||||
|
||||
<Space
|
||||
<Button
|
||||
android:id="@+id/button_polycentric"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="match_parent" />
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:text="Polycentric"
|
||||
android:textColor="#fff"
|
||||
android:textSize="10dp"
|
||||
android:lines="1"
|
||||
android:ellipsize="marquee"
|
||||
android:padding="10dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_comment_type"
|
||||
android:layout_width="wrap_content"
|
||||
<Button
|
||||
android:id="@+id/button_platform"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter_extra_light"
|
||||
android:textSize="14dp"
|
||||
android:textColor="@color/white"
|
||||
android:text="@string/polycentric"
|
||||
android:layout_marginEnd="8dp" />
|
||||
|
||||
<com.futo.platformplayer.views.others.Toggle
|
||||
android:id="@+id/toggle_comment_type"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:toggleEnabled="false"
|
||||
android:layout_marginEnd="14dp" />
|
||||
android:layout_weight="1"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:text="Platform"
|
||||
android:textColor="#fff"
|
||||
android:textSize="10dp"
|
||||
android:lines="1"
|
||||
android:ellipsize="marquee"
|
||||
android:padding="10dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.futo.platformplayer.views.comments.AddCommentView
|
||||
|
|
|
@ -467,49 +467,62 @@
|
|||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_change_bottom_section"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginTop="10dp">
|
||||
android:background="@drawable/background_videodetail_description"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginLeft="14dp"
|
||||
android:layout_marginRight="14dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_comments"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="14dp"
|
||||
android:fontFamily="@font/inter_medium"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="17dp"
|
||||
android:text="@string/comments" />
|
||||
|
||||
<Space
|
||||
<Button
|
||||
android:id="@+id/button_polycentric"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="match_parent" />
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:text="Polycentric"
|
||||
android:textColor="#fff"
|
||||
android:textSize="10dp"
|
||||
android:lines="1"
|
||||
android:ellipsize="marquee"
|
||||
android:padding="10dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_toggle_comment_section"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
<Button
|
||||
android:id="@+id/button_platform"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:text="Platform"
|
||||
android:textColor="#fff"
|
||||
android:textSize="10dp"
|
||||
android:lines="1"
|
||||
android:ellipsize="marquee"
|
||||
android:padding="10dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_comment_type"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter_extra_light"
|
||||
android:textSize="14dp"
|
||||
android:textColor="@color/white"
|
||||
android:text="@string/polycentric"
|
||||
android:layout_marginEnd="8dp" />
|
||||
<Button
|
||||
android:id="@+id/button_recommended"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:text="Recommended"
|
||||
android:textColor="#fff"
|
||||
android:textSize="10dp"
|
||||
android:lines="1"
|
||||
android:ellipsize="marquee"
|
||||
android:padding="10dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.futo.platformplayer.views.others.Toggle
|
||||
android:id="@+id/toggle_comment_type"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:toggleEnabled="false"
|
||||
android:layout_marginEnd="14dp" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_recommended"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal">
|
||||
</LinearLayout>
|
||||
|
||||
<com.futo.platformplayer.views.comments.AddCommentView
|
||||
|
|
Loading…
Add table
Reference in a new issue