Android: Add type to game list (disc/psexe)

This commit is contained in:
Connor McLaughlin
2019-12-04 21:54:14 +10:00
parent dec475db62
commit 8c33163ef1
8 changed files with 233 additions and 23 deletions

View File

@ -7,13 +7,21 @@ import android.widget.TextView;
import androidx.core.content.ContextCompat;
public class GameListEntry {
public enum EntryType
{
Disc,
PSExe
}
private String mPath;
private String mCode;
private String mTitle;
private ConsoleRegion mRegion;
private EntryType mType;
private long mSize;
public GameListEntry(String path, String code, String title, String region, long size) {
public GameListEntry(String path, String code, String title, String region,
String type, long size) {
mPath = path;
mCode = code;
mTitle = title;
@ -24,6 +32,12 @@ public class GameListEntry {
} catch (IllegalArgumentException e) {
mRegion = ConsoleRegion.NTSC_U;
}
try {
mType = EntryType.valueOf(type);
} catch (IllegalArgumentException e) {
mType = EntryType.Disc;
}
}
public String getPath() {
@ -42,6 +56,8 @@ public class GameListEntry {
return mRegion;
}
public EntryType getType() { return mType; }
public void fillView(View view) {
((TextView) view.findViewById(R.id.game_list_view_entry_title)).setText(mTitle);
((TextView) view.findViewById(R.id.game_list_view_entry_path)).setText(mPath);
@ -49,21 +65,36 @@ public class GameListEntry {
String sizeString = String.format("%.2f MB", (double) mSize / 1048576.0);
((TextView) view.findViewById(R.id.game_list_view_entry_size)).setText(sizeString);
int drawableId;
int regionDrawableId;
switch (mRegion) {
case NTSC_J:
drawableId = R.drawable.flag_jp;
regionDrawableId = R.drawable.flag_jp;
break;
case NTSC_U:
default:
drawableId = R.drawable.flag_us;
regionDrawableId = R.drawable.flag_us;
break;
case PAL:
drawableId = R.drawable.flag_eu;
regionDrawableId = R.drawable.flag_eu;
break;
}
((ImageView) view.findViewById(R.id.game_list_view_entry_region_icon))
.setImageDrawable(ContextCompat.getDrawable(view.getContext(), drawableId));
.setImageDrawable(ContextCompat.getDrawable(view.getContext(), regionDrawableId));
int typeDrawableId;
switch (mType) {
case Disc:
default:
typeDrawableId = R.drawable.ic_media_cdrom;
break;
case PSExe:
typeDrawableId = R.drawable.ic_emblem_system;
break;
}
((ImageView) view.findViewById(R.id.game_list_view_entry_type_icon))
.setImageDrawable(ContextCompat.getDrawable(view.getContext(), typeDrawableId));
}
}