mirror of
https://github.com/yuliskov/SmartTube.git
synced 2026-05-01 02:21:23 -05:00
comments: focus fix
This commit is contained in:
@@ -9,6 +9,7 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.LayoutRes;
|
||||
@@ -744,6 +745,8 @@ public class MessageHolders {
|
||||
|
||||
protected ViewGroup bubble;
|
||||
protected TextView text;
|
||||
// See: item_incoming_text_message.xml
|
||||
protected RelativeLayout wrapper;
|
||||
|
||||
@Deprecated
|
||||
public IncomingTextMessageViewHolder(View itemView) {
|
||||
@@ -789,6 +792,10 @@ public class MessageHolders {
|
||||
// Link configurator makes textView focusable.
|
||||
if (style.isMessageFocusable()) {
|
||||
configureLinksBehavior(text);
|
||||
wrapper.setFocusable(true);
|
||||
wrapper.setFocusableInTouchMode(true);
|
||||
wrapper.setClickable(true);
|
||||
wrapper.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -796,6 +803,7 @@ public class MessageHolders {
|
||||
private void init(View itemView) {
|
||||
bubble = itemView.findViewById(R.id.bubble);
|
||||
text = itemView.findViewById(R.id.messageText);
|
||||
wrapper = (RelativeLayout) itemView;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -807,6 +815,8 @@ public class MessageHolders {
|
||||
|
||||
protected ViewGroup bubble;
|
||||
protected TextView text;
|
||||
// See: item_outcoming_text_message.xml
|
||||
protected RelativeLayout wrapper;
|
||||
|
||||
@Deprecated
|
||||
public OutcomingTextMessageViewHolder(View itemView) {
|
||||
@@ -852,6 +862,10 @@ public class MessageHolders {
|
||||
// Link configurator makes textView focusable.
|
||||
if (style.isMessageFocusable()) {
|
||||
configureLinksBehavior(text);
|
||||
wrapper.setFocusable(true);
|
||||
wrapper.setFocusableInTouchMode(true);
|
||||
wrapper.setClickable(true);
|
||||
wrapper.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -859,6 +873,7 @@ public class MessageHolders {
|
||||
private void init(View itemView) {
|
||||
bubble = itemView.findViewById(R.id.bubble);
|
||||
text = itemView.findViewById(R.id.messageText);
|
||||
wrapper = (RelativeLayout) itemView;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ class RecyclerScrollMoreListener
|
||||
private OnLoadMoreListener loadMoreListener;
|
||||
private int currentPage = 0;
|
||||
private int previousTotalItemCount = 0;
|
||||
private int currentScrollPos = 0;
|
||||
private int maxScrollPos = 0;
|
||||
private boolean loading = true;
|
||||
|
||||
private RecyclerView.LayoutManager mLayoutManager;
|
||||
@@ -51,6 +53,13 @@ class RecyclerScrollMoreListener
|
||||
@Override
|
||||
public void onScrolled(RecyclerView view, int dx, int dy) {
|
||||
if (loadMoreListener != null) {
|
||||
// MODIFIED: throttle calls
|
||||
currentScrollPos += dy;
|
||||
if (currentScrollPos <= maxScrollPos) {
|
||||
return;
|
||||
}
|
||||
maxScrollPos += dy;
|
||||
|
||||
int lastVisibleItemPosition = 0;
|
||||
int totalItemCount = mLayoutManager.getItemCount();
|
||||
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ public class CommentsPreferenceDialogFragment extends LeanbackPreferenceDialogFr
|
||||
.circleCrop() // resize image
|
||||
.into(imageView));
|
||||
adapter.setLoadMoreListener((page, totalItemsCount) -> mCommentsReceiver.onLoadMore(mNextCommentsKey));
|
||||
adapter.setOnMessageLongClickListener(message -> mCommentsReceiver.onCommentClicked(message.getNestedCommentsKey()));
|
||||
adapter.setOnMessageClickListener(message -> mCommentsReceiver.onCommentClicked(message.getNestedCommentsKey()));
|
||||
messagesList.setAdapter(adapter);
|
||||
|
||||
if (mCommentsReceiver != null) {
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ public class ChatItemMessage implements IMessage {
|
||||
ChatItemMessage message = new ChatItemMessage();
|
||||
message.mId = chatItem.getId();
|
||||
if (chatItem.getMessage() != null && !chatItem.getMessage().trim().isEmpty()) {
|
||||
message.mText = String.format("%s: %s", chatItem.getAuthorName(), chatItem.getMessage());
|
||||
message.mText = TextUtils.concat(Utils.bold(chatItem.getAuthorName()), ": ", chatItem.getMessage());
|
||||
}
|
||||
message.mAuthor = ChatItemAuthor.from(chatItem);
|
||||
message.mCreatedAt = new Date();
|
||||
|
||||
Reference in New Issue
Block a user