@@ -27,6 +27,7 @@
import org.dolphinemu.dolphinemu.adapters.SettingsRowPresenter;
import org.dolphinemu.dolphinemu.model.Game;
import org.dolphinemu.dolphinemu.model.TvSettingsItem;
import org.dolphinemu.dolphinemu.ui.platform.Platform;
import org.dolphinemu.dolphinemu.ui.settings.SettingsActivity;
import org.dolphinemu.dolphinemu.utils.PermissionsHandler;
import org.dolphinemu.dolphinemu.utils.StartupHandler;
@@ -130,9 +131,9 @@ public void launchFileListActivity()
}

@Override
public void showGames(int platformIndex, Cursor games)
public void showGames(Platform platform, Cursor games)
{
ListRow row = buildGamesRow(platformIndex, games);
ListRow row = buildGamesRow(platform, games);

// Add row to the adapter only if it is not empty.
if (row != null)
@@ -187,13 +188,12 @@ private void buildRowsAdapter()
}

private void loadGames() {
// For each platform
for (int platformIndex = 0; platformIndex <= Game.PLATFORM_ALL; ++platformIndex) {
mPresenter.loadGames(platformIndex);
for (Platform platform : Platform.values()) {
mPresenter.loadGames(platform);
}
}

private ListRow buildGamesRow(int platform, Cursor games)
private ListRow buildGamesRow(Platform platform, Cursor games)
{
// Create an adapter for this row.
CursorObjectAdapter row = new CursorObjectAdapter(new GameRowPresenter());
@@ -220,32 +220,10 @@ protected Object bind(Cursor cursor)
}
});

String headerName;
switch (platform)
{
case Game.PLATFORM_GC:
headerName = "GameCube Games";
break;

case Game.PLATFORM_WII:
headerName = "Wii Games";
break;

case Game.PLATFORM_WII_WARE:
headerName = "WiiWare";
break;

case Game.PLATFORM_ALL:
headerName = "All Games";
break;

default:
headerName = "Error";
break;
}
String headerName = platform.getHeaderName();

// Create a header for this row.
HeaderItem header = new HeaderItem(platform, headerName);
HeaderItem header = new HeaderItem(platform.toInt(), platform.getHeaderName());

// Create the row, passing it the filled adapter and the header, and give it to the master adapter.
return new ListRow(header, row);
@@ -0,0 +1,47 @@
package org.dolphinemu.dolphinemu.ui.platform;

/** Enum to represent platform (eg GameCube, Wii). */
public enum Platform
{
GAMECUBE(0, "GameCube Games"),
WII(1, "Wii Games"),
WIIWARE(2, "WiiWare Games");

private final int value;
private final String headerName;

Platform(int value, String headerName)
{
this.value = value;
this.headerName = headerName;
}

public static Platform fromInt(int i)
{
return values()[i];
}

public static Platform fromNativeInt(int i)
{
// If the game's platform field is empty, file under Wiiware. // TODO Something less dum
if (i == -1) {
return Platform.WIIWARE;
}
return values()[i];
}

public static Platform fromPosition(int position)
{
return values()[position];
}

public int toInt()
{
return value;
}

public String getHeaderName()
{
return headerName;
}
}
@@ -22,12 +22,12 @@ public final class PlatformGamesFragment extends Fragment implements PlatformGam
private GameAdapter mAdapter;
private RecyclerView mRecyclerView;

public static PlatformGamesFragment newInstance(int platform)
public static PlatformGamesFragment newInstance(Platform platform)
{
PlatformGamesFragment fragment = new PlatformGamesFragment();

Bundle args = new Bundle();
args.putInt(ARG_PLATFORM, platform);
args.putSerializable(ARG_PLATFORM, platform);

fragment.setArguments(args);
return fragment;
@@ -38,7 +38,7 @@ public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);

mPresenter.onCreate(getArguments().getInt(ARG_PLATFORM));
mPresenter.onCreate((Platform) getArguments().getSerializable(ARG_PLATFORM));
}

@Nullable
@@ -15,14 +15,14 @@
{
private final PlatformGamesView mView;

private int mPlatform;
private Platform mPlatform;

public PlatformGamesPresenter(PlatformGamesView view)
{
mView = view;
}

public void onCreate(int platform)
public void onCreate(Platform platform)
{
mPlatform = platform;
}
@@ -25,8 +25,6 @@ public final class TvGameViewHolder extends Presenter.ViewHolder
public String company;
public String screenshotPath;

public int backgroundColor;

public TvGameViewHolder(View itemView)
{
super(itemView);
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="true"
android:drawable="@color/dolphin_accent_gamecube" />
<item
android:drawable="@color/tv_card_unselected" />
</selector>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="true"
android:drawable="@color/dolphin_accent_wii" />
<item
android:drawable="@color/tv_card_unselected" />
</selector>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="true"
android:drawable="@color/dolphin_accent_wiiware" />
<item
android:drawable="@color/tv_card_unselected" />
</selector>