mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-12-23 05:16:58 +00:00
Fix swipe to reply not working. Fixes austinhuang0131/barinsta#1570
This commit is contained in:
parent
65f46e4ca7
commit
49780a61b0
@ -167,6 +167,7 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact
|
||||
private EmojiPickerInsetsAnimationCallback emojiPickerAnimationCallback;
|
||||
private boolean hasKbOpenedOnce;
|
||||
private boolean wasToggled;
|
||||
private SwipeAndRestoreItemTouchHelperCallback touchHelperCallback;
|
||||
|
||||
private final AppExecutors appExecutors = AppExecutors.INSTANCE;
|
||||
private final Animatable2Compat.AnimationCallback micToSendAnimationCallback = new Animatable2Compat.AnimationCallback() {
|
||||
@ -613,20 +614,6 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact
|
||||
}
|
||||
});
|
||||
binding.chats.addItemDecoration(headerItemDecoration);
|
||||
final SwipeAndRestoreItemTouchHelperCallback touchHelperCallback = new SwipeAndRestoreItemTouchHelperCallback(
|
||||
context,
|
||||
(adapterPosition, viewHolder) -> {
|
||||
if (itemsAdapter == null) return;
|
||||
final DirectItemOrHeader directItemOrHeader = itemsAdapter.getList().get(adapterPosition);
|
||||
if (directItemOrHeader.isHeader()) return;
|
||||
viewModel.setReplyToItem(directItemOrHeader.item);
|
||||
}
|
||||
);
|
||||
final Integer inputMode = viewModel.getInputMode().getValue();
|
||||
if (inputMode != null && inputMode != 1) {
|
||||
itemTouchHelper = new ItemTouchHelper(touchHelperCallback);
|
||||
itemTouchHelper.attachToRecyclerView(binding.chats);
|
||||
}
|
||||
}
|
||||
|
||||
private void setObservers() {
|
||||
@ -654,8 +641,11 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact
|
||||
inputModeLiveData = viewModel.getInputMode();
|
||||
inputModeLiveData.observe(getViewLifecycleOwner(), inputMode -> {
|
||||
final Boolean isPending = viewModel.isPending().getValue();
|
||||
if (isPending != null && isPending) return;
|
||||
if (inputMode == null || inputMode == 0) return;
|
||||
if (isPending != null && isPending || inputMode == null) return;
|
||||
if (inputMode != 1) {
|
||||
setupTouchHelper();
|
||||
}
|
||||
if (inputMode == 0) return;
|
||||
if (inputMode == 1) {
|
||||
hideInput();
|
||||
}
|
||||
@ -755,6 +745,22 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact
|
||||
});
|
||||
}
|
||||
|
||||
private void setupTouchHelper() {
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
touchHelperCallback = new SwipeAndRestoreItemTouchHelperCallback(
|
||||
context,
|
||||
(adapterPosition, viewHolder) -> {
|
||||
if (itemsAdapter == null) return;
|
||||
final DirectItemOrHeader directItemOrHeader = itemsAdapter.getList().get(adapterPosition);
|
||||
if (directItemOrHeader.isHeader()) return;
|
||||
viewModel.setReplyToItem(directItemOrHeader.item);
|
||||
}
|
||||
);
|
||||
itemTouchHelper = new ItemTouchHelper(touchHelperCallback);
|
||||
itemTouchHelper.attachToRecyclerView(binding.chats);
|
||||
}
|
||||
|
||||
private void removeObservers() {
|
||||
pendingLiveData.removeObservers(getViewLifecycleOwner());
|
||||
inputModeLiveData.removeObservers(getViewLifecycleOwner());
|
||||
|
Loading…
Reference in New Issue
Block a user