Skip to content
Snippets Groups Projects
Commit 7cfdacb0 authored by akwizgran's avatar akwizgran
Browse files

Scroll to the first unread message, or the end of the list if all read.

parent 706ca5d5
No related branches found
No related tags found
No related merge requests found
...@@ -50,6 +50,7 @@ implements DatabaseListener, OnClickListener, OnItemClickListener { ...@@ -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 { ...@@ -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 { ...@@ -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);
} }
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment