2
* Copyright 2013 Dolphin Emulator Project
4
* Refer to the license.txt file included.
7
package org.dolphinemu.dolphinemu.gamelist;
9
import android.content.Context;
10
import android.graphics.Bitmap;
11
import android.graphics.BitmapFactory;
12
import android.util.Log;
15
import java.io.IOException;
16
import java.io.InputStream;
18
import org.dolphinemu.dolphinemu.NativeLibrary;
21
* Represents an item in the game list.
23
public final class GameListItem implements Comparable<GameListItem>
26
private final String data;
27
private final String path;
33
* @param ctx The current {@link Context}
34
* @param name The name of this GameListItem.
35
* @param data The subtitle for this GameListItem
36
* @param path The file path for the game represented by this GameListItem.
38
public GameListItem(Context ctx, String name, String data, String path)
44
File file = new File(path);
45
if (!file.isDirectory() && !path.isEmpty())
47
int[] Banner = NativeLibrary.GetBanner(path);
52
// Open the no banner icon.
53
InputStream noBannerPath = ctx.getAssets().open("NoBanner.png");
56
image = BitmapFactory.decodeStream(noBannerPath);
58
// Scale the bitmap to match other banners.
59
image = Bitmap.createScaledBitmap(image, 96, 32, false);
63
Log.e("GameListItem", e.toString());
68
image = Bitmap.createBitmap(Banner, 96, 32, Bitmap.Config.ARGB_8888);
71
this.name = NativeLibrary.GetTitle(path);
76
* Gets the name of this GameListItem.
78
* @return the name of this GameListItem.
80
public String getName()
86
* Gets the subtitle of this GameListItem.
88
* @return the subtitle of this GameListItem.
90
public String getData()
96
* Gets the file path of the game represented by this GameListItem.
98
* @return the file path of the game represented by this GameListItem.
100
public String getPath()
106
* Gets the image data for this game as a {@link Bitmap}.
108
* @return the image data for this game as a {@link Bitmap}.
110
public Bitmap getImage()
116
public int compareTo(GameListItem o)
119
return name.toLowerCase().compareTo(o.getName().toLowerCase());
121
throw new NullPointerException("The name of this GameListItem is null");