diff --git a/app/src/main/java/com/futo/platformplayer/views/segments/CommentsList.kt b/app/src/main/java/com/futo/platformplayer/views/segments/CommentsList.kt index e377d81d..e02205b7 100644 --- a/app/src/main/java/com/futo/platformplayer/views/segments/CommentsList.kt +++ b/app/src/main/java/com/futo/platformplayer/views/segments/CommentsList.kt @@ -1,10 +1,14 @@ package com.futo.platformplayer.views.segments import android.content.Context +import android.graphics.Color import android.util.AttributeSet +import android.view.Gravity +import android.view.KeyCharacterMap.UnavailableException import android.view.LayoutInflater import android.view.View import android.widget.FrameLayout +import android.widget.TextView import androidx.constraintlayout.widget.ConstraintLayout import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -19,6 +23,7 @@ import com.futo.platformplayer.api.media.structures.IAsyncPager import com.futo.platformplayer.api.media.structures.IPager import com.futo.platformplayer.constructs.Event1 import com.futo.platformplayer.constructs.TaskHandler +import com.futo.platformplayer.engine.exceptions.ScriptUnavailableException import com.futo.platformplayer.fullyBackfillServersAnnounceExceptions import com.futo.platformplayer.states.StatePolycentric import com.futo.platformplayer.views.adapters.CommentViewHolder @@ -29,15 +34,22 @@ import java.net.UnknownHostException class CommentsList : ConstraintLayout { private val _llmReplies: LinearLayoutManager; + private val _textMessage: TextView; private val _taskLoadComments = if(!isInEditMode) TaskHandler IPager, IPager>(StateApp.instance.scopeGetter, { it(); }) .success { pager -> onCommentsLoaded(pager); } .exception { - UIDialogs.toast("Failed to load comments"); + setMessage("UnknownHostException: " + it.message); + Logger.e(TAG, "Failed to load comments.", it); + setLoading(false); + } + .exception { + setMessage(it.message); + Logger.e(TAG, "Failed to load comments.", it); setLoading(false); } .exception { + setMessage("Throwable: " + it.message); Logger.e(TAG, "Failed to load comments.", it); - UIDialogs.toast(context, context.getString(R.string.failed_to_load_comments) + "\n" + (it.message ?: "")); //UIDialogs.showGeneralRetryErrorDialog(context, context.getString(R.string.failed_to_load_comments) + (it.message ?: ""), it, ::fetchComments); setLoading(false); } else TaskHandler(IPlatformVideoDetails::class.java, StateApp.instance.scopeGetter); @@ -75,15 +87,26 @@ class CommentsList : ConstraintLayout { var onRepliesClick = Event1(); var onCommentsLoaded = Event1(); + + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { LayoutInflater.from(context).inflate(R.layout.view_comments_list, this, true); _recyclerComments = findViewById(R.id.recycler_comments); + _textMessage = TextView(context).apply { + layoutParams = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT).apply { + setMargins(0, 30, 0, 0) + } + textSize = 12.0f + setTextColor(Color.WHITE) + typeface = resources.getFont(R.font.inter_regular) + gravity = Gravity.CENTER_HORIZONTAL + } _prependedView = FrameLayout(context); _prependedView.layoutParams = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); - _adapterComments = InsertedViewAdapterWithLoader(context, arrayListOf(_prependedView), arrayListOf(), + _adapterComments = InsertedViewAdapterWithLoader(context, arrayListOf(_prependedView, _textMessage), arrayListOf(), childCountGetter = { _comments.size }, childViewHolderBinder = { viewHolder, position -> viewHolder.bind(_comments[position], _readonly); }, childViewHolderFactory = { viewGroup, _ -> @@ -100,6 +123,16 @@ class CommentsList : ConstraintLayout { _recyclerComments.addOnScrollListener(_scrollListener); } + private fun setMessage(message: String?) { + Logger.i(TAG, "setMessage " + message) + if (message != null) { + _textMessage.visibility = View.VISIBLE + _textMessage.text = message + } else { + _textMessage.visibility = View.GONE + } + } + fun addComment(comment: IPlatformComment) { _comments.add(0, comment); _adapterComments.notifyItemRangeInserted(_adapterComments.childToParentPosition(0), 1); @@ -183,6 +216,7 @@ class CommentsList : ConstraintLayout { fun load(readonly: Boolean, loader: suspend () -> IPager) { cancel(); + setMessage(null); _readonly = readonly; setLoading(true); @@ -213,6 +247,7 @@ class CommentsList : ConstraintLayout { _comments.clear(); _commentsPager = null; _adapterComments.notifyDataSetChanged(); + setMessage(null); } fun cancel() { diff --git a/app/src/main/res/layout/view_comments_list.xml b/app/src/main/res/layout/view_comments_list.xml index f285cae0..48318415 100644 --- a/app/src/main/res/layout/view_comments_list.xml +++ b/app/src/main/res/layout/view_comments_list.xml @@ -1,13 +1,11 @@ - + android:layout_height="match_parent"> - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/stable/assets/sources/rumble b/app/src/stable/assets/sources/rumble index 60a7ee2d..b0e35a9b 160000 --- a/app/src/stable/assets/sources/rumble +++ b/app/src/stable/assets/sources/rumble @@ -1 +1 @@ -Subproject commit 60a7ee2ddf71b936d9c289a3343020cc20edfe56 +Subproject commit b0e35a9b6631fb3279fb38619ecc3eba812e5ed6 diff --git a/app/src/unstable/assets/sources/rumble b/app/src/unstable/assets/sources/rumble index 60a7ee2d..b0e35a9b 160000 --- a/app/src/unstable/assets/sources/rumble +++ b/app/src/unstable/assets/sources/rumble @@ -1 +1 @@ -Subproject commit 60a7ee2ddf71b936d9c289a3343020cc20edfe56 +Subproject commit b0e35a9b6631fb3279fb38619ecc3eba812e5ed6