aboutsummaryrefslogtreecommitdiffstats
path: root/src/de/gultsch/chat/ConversationList.java
blob: b043f61a7c55e33bfdd646354fe8b32cb3bc9862 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package de.gultsch.chat;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class ConversationList extends ArrayList<Conversation> {
	
	private static final long serialVersionUID = 3661496589984289968L;
	
	private int selectedConversationPosition = -1;
	
	private ConversationCursor cursor = new ConversationCursor(this);

	public ConversationCursor getCursor() {
		return this.cursor;
	}

	public Conversation getSelectedConversation() {
		return this.get(this.selectedConversationPosition);
	}

	public void setSelectedConversationPosition(int selectedConversation) {
		this.selectedConversationPosition = selectedConversation;
	}
	
	public void sort() {
		Conversation selectedConversation = this.get(selectedConversationPosition);
		//sort this
		Collections.sort(this, new Comparator<Conversation>() {

			@Override
			public int compare(Conversation lhs, Conversation rhs) {
				// TODO Auto-generated method stub
				return 0;
			}
		});
		
		this.selectedConversationPosition = this.indexOf(selectedConversation);
	}
}