decrease delay when scrolling to position

This commit is contained in:
Daniel Gultsch 2018-03-08 16:37:45 +01:00
parent 5e32b4ab17
commit 4227c63e5d
1 changed files with 30 additions and 29 deletions

View File

@ -134,15 +134,14 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
private final PendingItem<Bundle> pendingExtras = new PendingItem<>();
private final PendingItem<Uri> pendingTakePhotoUri = new PendingItem<>();
private final PendingItem<ScrollState> pendingScrollState = new PendingItem<>();
private final PendingItem<Message> pendingMessage = new PendingItem<>();
public Uri mPendingEditorContent = null;
protected MessageAdapter messageListAdapter;
private Conversation conversation;
private FragmentConversationBinding binding;
private Toast messageLoaderToast;
private ConversationsActivity activity;
private boolean reInitRequiredOnStart = true;
private OnClickListener clickToMuc = new OnClickListener() {
@Override
@ -258,7 +257,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}
}
};
private EditMessage.OnCommitContentListener mEditorContentListener = new EditMessage.OnCommitContentListener() {
@Override
public boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts, String[] contentMimeTypes) {
@ -328,7 +326,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}
}
};
protected OnClickListener clickToDecryptListener = new OnClickListener() {
@Override
@ -407,8 +404,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
private int lastCompletionCursor;
private boolean firstWord = false;
private Message mPendingDownloadableMessage;
private final PendingItem<Message> pendingMessage = new PendingItem<>();
private static ConversationFragment findConversationFragment(Activity activity) {
Fragment fragment = activity.getFragmentManager().findFragmentById(R.id.main_fragment);
@ -474,6 +469,24 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
return getConversation(activity, R.id.main_fragment);
}
private static boolean allGranted(int[] grantResults) {
for (int grantResult : grantResults) {
if (grantResult != PackageManager.PERMISSION_GRANTED) {
return false;
}
}
return true;
}
private static String getFirstDenied(int[] grantResults, String[] permissions) {
for (int i = 0; i < grantResults.length; ++i) {
if (grantResults[i] == PackageManager.PERMISSION_DENIED) {
return permissions[i];
}
}
return null;
}
private int getIndexOf(String uuid, List<Message> messages) {
if (uuid == null) {
return messages.size() - 1;
@ -1290,24 +1303,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}
}
private static boolean allGranted(int[] grantResults) {
for(int grantResult : grantResults) {
if (grantResult != PackageManager.PERMISSION_GRANTED) {
return false;
}
}
return true;
}
private static String getFirstDenied(int[] grantResults, String[] permissions) {
for(int i = 0; i < grantResults.length; ++i) {
if (grantResults[i] == PackageManager.PERMISSION_DENIED) {
return permissions[i];
}
}
return null;
}
public void startDownloadable(Message message) {
if (!Config.ONLY_INTERNAL_STORAGE && !hasStoragePermission(REQUEST_START_DOWNLOAD)) {
this.mPendingDownloadableMessage = message;
@ -1587,7 +1582,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
new Handler().post(() -> {
int size = messageList.size();
this.binding.messagesView.setSelection(size - 1);
}); }
});
}
private void copyUrl(Message message) {
final String url;
@ -1819,7 +1815,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
int i = getIndexOf(first.getUuid(), this.messageList);
pos = i < 0 ? bottom : i;
}
this.binding.messagesView.post(() -> this.binding.messagesView.setSelection(pos));
setSelection(pos);
}
}
@ -1829,6 +1825,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
return true;
}
private void setSelection(int pos) {
this.binding.messagesView.setSelection(pos);
this.binding.messagesView.post(() -> this.binding.messagesView.setSelection(pos));
}
private boolean scrolledToBottom() {
if (this.binding == null) {
return false;