summaryrefslogtreecommitdiff
path: root/Source/Android/app/src/main/java
diff options
context:
space:
mode:
authorsigmabeta <bastos.eder@gmail.com>2015-07-20 20:15:26 -0400
committersigmabeta <sigmabeta@users.noreply.github.com>2015-07-25 12:26:31 -0400
commit0b1212b77db43376012756c4219156708316810e (patch)
tree1ba78ceac8b310d3f12b33220af071bfc20f9831 /Source/Android/app/src/main/java
parent7c14996e3e24b0a4a1064ece1c656bcbe6c923c7 (diff)
Android TV: Add row listing all games
Diffstat (limited to 'Source/Android/app/src/main/java')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/TvMainActivity.java123
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/Game.java1
2 files changed, 83 insertions, 41 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/TvMainActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/TvMainActivity.java
index 2c191bdaf0..0e716d6503 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/TvMainActivity.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/TvMainActivity.java
@@ -78,64 +78,105 @@ public final class TvMainActivity extends Activity
{
mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
- // For each row
- for (int platformIndex = 0; platformIndex <= Game.PLATFORM_WII_WARE; ++platformIndex)
+ // For each platform
+ for (int platformIndex = 0; platformIndex <= Game.PLATFORM_ALL; ++platformIndex)
{
- // Create an adapter for this row.
- CursorObjectAdapter row = new CursorObjectAdapter(new GamePresenter(platformIndex));
+ ListRow row = buildGamesRow(platformIndex);
- // Add items to the adapter.
- Cursor games = getContentResolver().query(
+ // Add row to the adapter only if it is not empty.
+ if (row != null)
+ {
+ mRowsAdapter.add(row);
+ }
+ }
+
+ mBrowseFragment.setAdapter(mRowsAdapter);
+ }
+
+ private ListRow buildGamesRow(int platform)
+ {
+ // Create an adapter for this row.
+ CursorObjectAdapter row = new CursorObjectAdapter(new GamePresenter(platform));
+
+ Cursor games;
+ if (platform == Game.PLATFORM_ALL)
+ {
+ // Get all games.
+ games = getContentResolver().query(
+ GameProvider.URI_GAME, // URI of table to query
+ null, // Return all columns
+ null, // Return all games
+ null, // Return all games
+ GameDatabase.KEY_GAME_TITLE + " asc" // Sort by game name, ascending order
+ );
+ }
+ else
+ {
+ // Get games for this particular platform.
+ games = getContentResolver().query(
GameProvider.URI_GAME, // URI of table to query
null, // Return all columns
GameDatabase.KEY_GAME_PLATFORM + " = ?", // Select by platform
- new String[]{Integer.toString(platformIndex)}, // Platform id
+ new String[]{Integer.toString(platform)}, // Platform id
GameDatabase.KEY_GAME_TITLE + " asc" // Sort by game name, ascending order
);
+ }
- row.swapCursor(games);
- row.setMapper(new CursorMapper()
- {
- @Override
- protected void bindColumns(Cursor cursor)
- {
- // No-op? Not sure what this does.
- }
+ // If cursor is empty, don't return a Row.
+ if (!games.moveToFirst())
+ {
+ return null;
+ }
- @Override
- protected Object bind(Cursor cursor)
- {
- return Game.fromCursor(cursor);
- }
- });
+ row.changeCursor(games);
+ row.setMapper(new CursorMapper()
+ {
+ @Override
+ protected void bindColumns(Cursor cursor)
+ {
+ // No-op? Not sure what this does.
+ }
- String headerName;
- switch (platformIndex)
+ @Override
+ protected Object bind(Cursor cursor)
{
- case Game.PLATFORM_GC:
- headerName = "GameCube Games";
- break;
+ return Game.fromCursor(cursor);
+ }
+ });
- case Game.PLATFORM_WII:
- headerName = "Wii Games";
- break;
+ String headerName;
+ switch (platform)
+ {
+ case Game.PLATFORM_GC:
+ headerName = "GameCube Games";
+ break;
- case Game.PLATFORM_WII_WARE:
- headerName = "WiiWare";
- break;
+ case Game.PLATFORM_WII:
+ headerName = "Wii Games";
+ break;
- default:
- headerName = "Error";
- break;
- }
+ case Game.PLATFORM_WII_WARE:
+ headerName = "WiiWare";
+ break;
- // Create a header for this row.
- HeaderItem header = new HeaderItem(platformIndex, headerName);
+ case Game.PLATFORM_ALL:
+ headerName = "All Games";
+ break;
- // Create the row, passing it the filled adapter and the header, and give it to the master adapter.
- mRowsAdapter.add(new ListRow(header, row));
+ default:
+ headerName = "Error";
+ break;
}
- mBrowseFragment.setAdapter(mRowsAdapter);
+ // Create a header for this row.
+ HeaderItem header = new HeaderItem(platform, headerName);
+
+ // Create the row, passing it the filled adapter and the header, and give it to the master adapter.
+ return new ListRow(header, row);
}
+
+ /*private ListRow buildSettingsRow()
+ {
+
+ }*/
}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/Game.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/Game.java
index 2068f01f08..33a9f27c54 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/Game.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/Game.java
@@ -8,6 +8,7 @@ public final class Game
public static final int PLATFORM_GC = 0;
public static final int PLATFORM_WII = 1;
public static final int PLATFORM_WII_WARE = 2;
+ public static final int PLATFORM_ALL = 3;
// Copied from IVolume::ECountry. Update these if that is ever modified.
public static final int COUNTRY_EUROPE = 0;