Skip to content
Browse files

Sorting the RoomList so it's actually useful

  • Loading branch information...
1 parent 4731579 commit 0e907effee54324265a05bbc17581e5c64d0ffda @qrush committed
Showing with 9 additions and 3 deletions.
  1. +4 −2 src/campyre/android/RoomList.java
  2. +5 −1 src/campyre/java/Room.java
View
6 src/campyre/android/RoomList.java
@@ -1,6 +1,7 @@
package campyre.android;
import java.util.ArrayList;
+import java.util.Collections;
import android.app.Dialog;
import android.app.ListActivity;
@@ -101,9 +102,10 @@ public Object onRetainNonConfigurationInstance() {
}
public void onLoadRooms(ArrayList<Room> rooms, CampfireException exception) {
- if (exception == null && rooms != null)
+ if (exception == null && rooms != null) {
this.rooms = rooms;
- else {
+ Collections.sort(this.rooms);
+ } else {
this.rooms = new ArrayList<Room>();
this.error = true;
Utils.alert(this, exception);
View
6 src/campyre/java/Room.java
@@ -10,7 +10,7 @@
import org.json.JSONException;
import org.json.JSONObject;
-public class Room {
+public class Room implements Comparable<Room> {
public String id, name;
public boolean full = false;
public Campfire campfire;
@@ -109,4 +109,8 @@ public void uploadImage(InputStream stream, String filename, String mimeType) th
public String toString() {
return name;
}
+
+ public int compareTo(Room room) {
+ return (this.name.compareTo(room.name));
+ }
}

0 comments on commit 0e907ef

Please sign in to comment.
Something went wrong with that request. Please try again.