project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/RoomlistAdapter.java
changeset 10017 de822cd3df3a
parent 7584 7831c84cc644
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/RoomlistAdapter.java	Tue Jan 21 22:38:13 2014 +0100
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/RoomlistAdapter.java	Tue Jan 21 22:43:06 2014 +0100
@@ -37,77 +37,77 @@
  * Displays the list of all rooms in the lobby
  */
 public class RoomlistAdapter extends ObservableTreeMapAdapter<String, RoomWithId> {
-	private Context context;
-	
-	public RoomlistAdapter(Context context) {
-		this.context = context;
-	}
-	
-	@Override
-	protected Comparator<RoomWithId> getEntryOrder() {
-		return RoomWithId.NEWEST_FIRST_ORDER;
-	}
-	
-	@Override
-	public long getItemId(int position) {
-		return getItem(position).id;
-	}
-	
-	@Override
-	public boolean hasStableIds() {
-		return true;
-	}
-	
-	private static CharSequence formatExtra(Resources res, Room room) {
-		String ownermsg = res.getString(R.string.roomlist_owner, room.owner);
-		String mapmsg = res.getString(R.string.roomlist_map, room.formatMapName(res));
-		String scheme = room.scheme.equals(room.weapons) ? room.scheme : room.scheme + " / " + room.weapons;
-		String schememsg = res.getString(R.string.roomlist_scheme, scheme);
-		return ownermsg + ". " + mapmsg + ", " + schememsg;
-	}
-	
-	public View getView(int position, View convertView, ViewGroup parent) {
-		View v = convertView;
-		if (v == null) {
-			LayoutInflater vi = LayoutInflater.from(context);
-			v = vi.inflate(R.layout.listview_room, null);
-		}
-		
-		Room room = getItem(position).room;
-		int iconRes = room.inProgress ? R.drawable.roomlist_ingame : R.drawable.roomlist_preparing;
-		
-		if(v.findViewById(android.R.id.text1) == null) {
-			// Tabular room list
-			TextView roomnameView = (TextView)v.findViewById(R.id.roomname);
-			TextView playerCountView = (TextView)v.findViewById(R.id.playercount);
-			TextView teamCountView = (TextView)v.findViewById(R.id.teamcount);
-			TextView ownerView = (TextView)v.findViewById(R.id.owner);
-			TextView mapView = (TextView)v.findViewById(R.id.map);
-			TextView schemeView = (TextView)v.findViewById(R.id.scheme);
-			TextView weaponView = (TextView)v.findViewById(R.id.weapons);
-			
-			roomnameView.setCompoundDrawablesWithIntrinsicBounds(iconRes, 0, 0, 0);
-			roomnameView.setText(room.name);
-			if(playerCountView != null) {
-				playerCountView.setText(String.valueOf(room.playerCount));
-			}
-			if(teamCountView != null) {
-				teamCountView.setText(String.valueOf(room.teamCount));
-			}
-			ownerView.setText(room.owner);
-			mapView.setText(room.formatMapName(context.getResources()));
-			schemeView.setText(room.scheme);
-			weaponView.setText(room.weapons);
-		} else {
-			// Small room list
-			TextView v1 = (TextView)v.findViewById(android.R.id.text1);
-			TextView v2 = (TextView)v.findViewById(android.R.id.text2);
-			
-			v1.setCompoundDrawablesWithIntrinsicBounds(iconRes, 0, 0, 0);
-			v1.setText(room.name);
-			v2.setText(formatExtra(context.getResources(), room));
-		}
-		
-		return v;
-	}
+    private Context context;
+
+    public RoomlistAdapter(Context context) {
+        this.context = context;
+    }
+
+    @Override
+    protected Comparator<RoomWithId> getEntryOrder() {
+        return RoomWithId.NEWEST_FIRST_ORDER;
+    }
+
+    @Override
+    public long getItemId(int position) {
+        return getItem(position).id;
+    }
+
+    @Override
+    public boolean hasStableIds() {
+        return true;
+    }
+
+    private static CharSequence formatExtra(Resources res, Room room) {
+        String ownermsg = res.getString(R.string.roomlist_owner, room.owner);
+        String mapmsg = res.getString(R.string.roomlist_map, room.formatMapName(res));
+        String scheme = room.scheme.equals(room.weapons) ? room.scheme : room.scheme + " / " + room.weapons;
+        String schememsg = res.getString(R.string.roomlist_scheme, scheme);
+        return ownermsg + ". " + mapmsg + ", " + schememsg;
+    }
+
+    public View getView(int position, View convertView, ViewGroup parent) {
+        View v = convertView;
+        if (v == null) {
+            LayoutInflater vi = LayoutInflater.from(context);
+            v = vi.inflate(R.layout.listview_room, null);
+        }
+
+        Room room = getItem(position).room;
+        int iconRes = room.inProgress ? R.drawable.roomlist_ingame : R.drawable.roomlist_preparing;
+
+        if(v.findViewById(android.R.id.text1) == null) {
+            // Tabular room list
+            TextView roomnameView = (TextView)v.findViewById(R.id.roomname);
+            TextView playerCountView = (TextView)v.findViewById(R.id.playercount);
+            TextView teamCountView = (TextView)v.findViewById(R.id.teamcount);
+            TextView ownerView = (TextView)v.findViewById(R.id.owner);
+            TextView mapView = (TextView)v.findViewById(R.id.map);
+            TextView schemeView = (TextView)v.findViewById(R.id.scheme);
+            TextView weaponView = (TextView)v.findViewById(R.id.weapons);
+
+            roomnameView.setCompoundDrawablesWithIntrinsicBounds(iconRes, 0, 0, 0);
+            roomnameView.setText(room.name);
+            if(playerCountView != null) {
+                playerCountView.setText(String.valueOf(room.playerCount));
+            }
+            if(teamCountView != null) {
+                teamCountView.setText(String.valueOf(room.teamCount));
+            }
+            ownerView.setText(room.owner);
+            mapView.setText(room.formatMapName(context.getResources()));
+            schemeView.setText(room.scheme);
+            weaponView.setText(room.weapons);
+        } else {
+            // Small room list
+            TextView v1 = (TextView)v.findViewById(android.R.id.text1);
+            TextView v2 = (TextView)v.findViewById(android.R.id.text2);
+
+            v1.setCompoundDrawablesWithIntrinsicBounds(iconRes, 0, 0, 0);
+            v1.setText(room.name);
+            v2.setText(formatExtra(context.getResources(), room));
+        }
+
+        return v;
+    }
 }
\ No newline at end of file