mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 06:09:55 +01:00
[android] Save list position in threaded conversations
This commit is contained in:
@@ -3,6 +3,7 @@ package org.briarproject.briar.android.threaded;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Parcelable;
|
||||||
import android.support.annotation.CallSuper;
|
import android.support.annotation.CallSuper;
|
||||||
import android.support.annotation.StringRes;
|
import android.support.annotation.StringRes;
|
||||||
import android.support.annotation.UiThread;
|
import android.support.annotation.UiThread;
|
||||||
@@ -67,6 +68,8 @@ public abstract class ThreadListActivity<G extends NamedGroup, I extends ThreadI
|
|||||||
protected GroupId groupId;
|
protected GroupId groupId;
|
||||||
private UnreadMessageButton upButton, downButton;
|
private UnreadMessageButton upButton, downButton;
|
||||||
@Nullable
|
@Nullable
|
||||||
|
private Parcelable layoutManagerState;
|
||||||
|
@Nullable
|
||||||
private MessageId replyId;
|
private MessageId replyId;
|
||||||
|
|
||||||
protected abstract ThreadListController<G, I> getController();
|
protected abstract ThreadListController<G, I> getController();
|
||||||
@@ -76,7 +79,6 @@ public abstract class ThreadListActivity<G extends NamedGroup, I extends ThreadI
|
|||||||
|
|
||||||
@CallSuper
|
@CallSuper
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("ConstantConditions")
|
|
||||||
public void onCreate(@Nullable Bundle state) {
|
public void onCreate(@Nullable Bundle state) {
|
||||||
super.onCreate(state);
|
super.onCreate(state);
|
||||||
|
|
||||||
@@ -213,6 +215,11 @@ public abstract class ThreadListActivity<G extends NamedGroup, I extends ThreadI
|
|||||||
adapter.setItemWithIdVisible(messageId);
|
adapter.setItemWithIdVisible(messageId);
|
||||||
updateUnreadCount();
|
updateUnreadCount();
|
||||||
list.showData();
|
list.showData();
|
||||||
|
if (layoutManagerState == null) {
|
||||||
|
list.scrollToPosition(0); // Scroll to the top
|
||||||
|
} else {
|
||||||
|
layoutManager.onRestoreInstanceState(layoutManagerState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadSharingContacts() {
|
protected void loadSharingContacts() {
|
||||||
@@ -253,11 +260,21 @@ public abstract class ThreadListActivity<G extends NamedGroup, I extends ThreadI
|
|||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
|
if (layoutManager != null) {
|
||||||
|
layoutManagerState = layoutManager.onSaveInstanceState();
|
||||||
|
outState.putParcelable("layoutManager", layoutManagerState);
|
||||||
|
}
|
||||||
if (replyId != null) {
|
if (replyId != null) {
|
||||||
outState.putByteArray(KEY_REPLY_ID, replyId.getBytes());
|
outState.putByteArray(KEY_REPLY_ID, replyId.getBytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||||
|
super.onRestoreInstanceState(savedInstanceState);
|
||||||
|
layoutManagerState = savedInstanceState.getParcelable("layoutManager");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user