mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 13:49:53 +01:00
Scroll to the first unread message, or the end of the list if all read.
This commit is contained in:
@@ -50,6 +50,7 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
|
|||||||
@Inject @DatabaseExecutor private Executor dbExecutor;
|
@Inject @DatabaseExecutor private Executor dbExecutor;
|
||||||
|
|
||||||
private ConversationAdapter adapter = null;
|
private ConversationAdapter adapter = null;
|
||||||
|
private ListView list = null;
|
||||||
private String contactName = null;
|
private String contactName = null;
|
||||||
private volatile ContactId contactId = null;
|
private volatile ContactId contactId = null;
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
|
|||||||
layout.setGravity(CENTER_HORIZONTAL);
|
layout.setGravity(CENTER_HORIZONTAL);
|
||||||
|
|
||||||
adapter = new ConversationAdapter(this);
|
adapter = new ConversationAdapter(this);
|
||||||
ListView list = new ListView(this);
|
list = new ListView(this);
|
||||||
// Give me all the width and all the unused height
|
// Give me all the width and all the unused height
|
||||||
list.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT, 1f));
|
list.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT, 1f));
|
||||||
list.setAdapter(adapter);
|
list.setAdapter(adapter);
|
||||||
@@ -149,9 +150,16 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
|
|||||||
final Collection<PrivateMessageHeader> headers) {
|
final Collection<PrivateMessageHeader> headers) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
int firstUnread = -1;
|
||||||
adapter.clear();
|
adapter.clear();
|
||||||
for(PrivateMessageHeader h : headers) adapter.add(h);
|
for(PrivateMessageHeader h : headers) {
|
||||||
|
if(firstUnread == -1 && !h.isRead())
|
||||||
|
firstUnread = adapter.getCount();
|
||||||
|
adapter.add(h);
|
||||||
|
}
|
||||||
adapter.sort(AscendingHeaderComparator.INSTANCE);
|
adapter.sort(AscendingHeaderComparator.INSTANCE);
|
||||||
|
if(firstUnread == -1) list.setSelection(adapter.getCount() - 1);
|
||||||
|
else list.setSelection(firstUnread);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user