use of eu.siacs.conversations.ui.util.ScrollState in project Conversations by siacs.
the class ConversationsOverviewFragment method refresh.
@Override
void refresh() {
if (this.binding == null || this.activity == null) {
Log.d(Config.LOGTAG, "ConversationsOverviewFragment.refresh() skipped updated because view binding or activity was null");
return;
}
this.activity.xmppConnectionService.populateWithOrderedConversations(this.conversations);
Conversation removed = this.swipedConversation.peek();
if (removed != null) {
if (removed.isRead()) {
this.conversations.remove(removed);
} else {
pendingActionHelper.execute();
}
}
this.conversationsAdapter.notifyDataSetChanged();
ScrollState scrollState = pendingScrollState.pop();
if (scrollState != null) {
setScrollPosition(scrollState);
}
}
use of eu.siacs.conversations.ui.util.ScrollState in project Conversations by siacs.
the class ConversationsOverviewFragment method onSaveInstanceState.
@Override
public void onSaveInstanceState(Bundle bundle) {
super.onSaveInstanceState(bundle);
ScrollState scrollState = getScrollState();
if (scrollState != null) {
bundle.putParcelable(STATE_SCROLL_POSITION, scrollState);
}
}
use of eu.siacs.conversations.ui.util.ScrollState in project Conversations by siacs.
the class ConversationFragment method onSaveInstanceState.
@Override
public void onSaveInstanceState(@NotNull Bundle outState) {
super.onSaveInstanceState(outState);
if (conversation != null) {
outState.putString(STATE_CONVERSATION_UUID, conversation.getUuid());
outState.putString(STATE_LAST_MESSAGE_UUID, lastMessageUuid);
final Uri uri = pendingTakePhotoUri.peek();
if (uri != null) {
outState.putString(STATE_PHOTO_URI, uri.toString());
}
final ScrollState scrollState = getScrollPosition();
if (scrollState != null) {
outState.putParcelable(STATE_SCROLL_POSITION, scrollState);
}
final ArrayList<Attachment> attachments = mediaPreviewAdapter == null ? new ArrayList<>() : mediaPreviewAdapter.getAttachments();
if (attachments.size() > 0) {
outState.putParcelableArrayList(STATE_MEDIA_PREVIEWS, attachments);
}
}
}
use of eu.siacs.conversations.ui.util.ScrollState in project Conversations by siacs.
the class ConversationFragment method findAndReInitByUuidOrArchive.
private boolean findAndReInitByUuidOrArchive(@NonNull final String uuid) {
Conversation conversation = activity.xmppConnectionService.findConversationByUuid(uuid);
if (conversation == null) {
clearPending();
activity.onConversationArchived(null);
return false;
}
reInit(conversation);
ScrollState scrollState = pendingScrollState.pop();
String lastMessageUuid = pendingLastMessageUuid.pop();
List<Attachment> attachments = pendingMediaPreviews.pop();
if (scrollState != null) {
setScrollPosition(scrollState, lastMessageUuid);
}
if (attachments != null && attachments.size() > 0) {
Log.d(Config.LOGTAG, "had attachments on restore");
mediaPreviewAdapter.addMediaPreviews(attachments);
toggleInputMethod();
}
return true;
}
use of eu.siacs.conversations.ui.util.ScrollState in project Conversations by siacs.
the class ConversationFragment method getScrollPosition.
private ScrollState getScrollPosition() {
final ListView listView = this.binding == null ? null : this.binding.messagesView;
if (listView == null || listView.getCount() == 0 || listView.getLastVisiblePosition() == listView.getCount() - 1) {
return null;
} else {
final int pos = listView.getFirstVisiblePosition();
final View view = listView.getChildAt(0);
if (view == null) {
return null;
} else {
return new ScrollState(pos, view.getTop());
}
}
}
Aggregations