mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
Android TV: Add row listing all games
This commit is contained in:
parent
7c14996e3e
commit
0b1212b77d
@ -78,22 +78,57 @@ public final class TvMainActivity extends Activity
|
|||||||
{
|
{
|
||||||
mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
|
mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
|
||||||
|
|
||||||
// For each row
|
// For each platform
|
||||||
for (int platformIndex = 0; platformIndex <= Game.PLATFORM_WII_WARE; ++platformIndex)
|
for (int platformIndex = 0; platformIndex <= Game.PLATFORM_ALL; ++platformIndex)
|
||||||
|
{
|
||||||
|
ListRow row = buildGamesRow(platformIndex);
|
||||||
|
|
||||||
|
// 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.
|
// Create an adapter for this row.
|
||||||
CursorObjectAdapter row = new CursorObjectAdapter(new GamePresenter(platformIndex));
|
CursorObjectAdapter row = new CursorObjectAdapter(new GamePresenter(platform));
|
||||||
|
|
||||||
// Add items to the adapter.
|
Cursor games;
|
||||||
Cursor games = getContentResolver().query(
|
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
|
GameProvider.URI_GAME, // URI of table to query
|
||||||
null, // Return all columns
|
null, // Return all columns
|
||||||
GameDatabase.KEY_GAME_PLATFORM + " = ?", // Select by platform
|
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
|
GameDatabase.KEY_GAME_TITLE + " asc" // Sort by game name, ascending order
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
row.swapCursor(games);
|
// If cursor is empty, don't return a Row.
|
||||||
|
if (!games.moveToFirst())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
row.changeCursor(games);
|
||||||
row.setMapper(new CursorMapper()
|
row.setMapper(new CursorMapper()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -110,7 +145,7 @@ public final class TvMainActivity extends Activity
|
|||||||
});
|
});
|
||||||
|
|
||||||
String headerName;
|
String headerName;
|
||||||
switch (platformIndex)
|
switch (platform)
|
||||||
{
|
{
|
||||||
case Game.PLATFORM_GC:
|
case Game.PLATFORM_GC:
|
||||||
headerName = "GameCube Games";
|
headerName = "GameCube Games";
|
||||||
@ -124,18 +159,24 @@ public final class TvMainActivity extends Activity
|
|||||||
headerName = "WiiWare";
|
headerName = "WiiWare";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Game.PLATFORM_ALL:
|
||||||
|
headerName = "All Games";
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
headerName = "Error";
|
headerName = "Error";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a header for this row.
|
// Create a header for this row.
|
||||||
HeaderItem header = new HeaderItem(platformIndex, headerName);
|
HeaderItem header = new HeaderItem(platform, headerName);
|
||||||
|
|
||||||
// Create the row, passing it the filled adapter and the header, and give it to the master adapter.
|
// Create the row, passing it the filled adapter and the header, and give it to the master adapter.
|
||||||
mRowsAdapter.add(new ListRow(header, row));
|
return new ListRow(header, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
mBrowseFragment.setAdapter(mRowsAdapter);
|
/*private ListRow buildSettingsRow()
|
||||||
}
|
{
|
||||||
|
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ public final class Game
|
|||||||
public static final int PLATFORM_GC = 0;
|
public static final int PLATFORM_GC = 0;
|
||||||
public static final int PLATFORM_WII = 1;
|
public static final int PLATFORM_WII = 1;
|
||||||
public static final int PLATFORM_WII_WARE = 2;
|
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.
|
// Copied from IVolume::ECountry. Update these if that is ever modified.
|
||||||
public static final int COUNTRY_EUROPE = 0;
|
public static final int COUNTRY_EUROPE = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user