diff options
| author | Eder Bastos <bastos.eder@gmail.com> | 2015-05-16 20:52:55 -0400 |
|---|---|---|
| committer | Eder Bastos <bastos.eder@gmail.com> | 2015-05-20 19:46:19 -0400 |
| commit | 5b0c047e0bb9391883e33026798f9e401c8d911b (patch) | |
| tree | aed7c1730bf7faed9c11a52d4afb072aa7cbca82 /Source/Android/app/src/main/java | |
| parent | 4c786cb70c03c15183905586a7ff60cf52d92395 (diff) | |
Android: Remove inheritance from Game model, and improve the relevance of its content
Diffstat (limited to 'Source/Android/app/src/main/java')
9 files changed, 101 insertions, 182 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java index 64463fe072..a47ff9c8ed 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java @@ -134,9 +134,11 @@ public final class NativeLibrary public static native String GetGameId(String filename); public static native int GetCountry(String filename); - public static native String GetDate(String filename); + + public static native String GetCompany(String filename); public static native long GetFilesize(String filename); - public static native boolean IsWiiTitle(String filename); + + public static native int GetPlatform(String filename); /** * Gets the Dolphin version string. diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java index be8c703fd6..e75affe126 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java @@ -179,12 +179,14 @@ public final class GameGridActivity extends Activity // Check that the file has an appropriate extension before trying to read out of it. if (exts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.')))) { - GcGame game = new GcGame(NativeLibrary.GetTitle(entry.getAbsolutePath()), - NativeLibrary.GetDescription(entry.getAbsolutePath()).replace("\n", " "), - NativeLibrary.GetCountry(entry.getAbsolutePath()), - entry.getAbsolutePath(), - NativeLibrary.GetGameId(entry.getAbsolutePath()), - NativeLibrary.GetDate(entry.getAbsolutePath())); + String absolutePath = entry.getAbsolutePath(); + Game game = new Game(NativeLibrary.GetPlatform(absolutePath), + NativeLibrary.GetTitle(absolutePath), + NativeLibrary.GetDescription(absolutePath).replace("\n", " "), + NativeLibrary.GetCountry(absolutePath), + absolutePath, + NativeLibrary.GetGameId(absolutePath), + NativeLibrary.GetCompany(absolutePath)); gameList.add(game); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java index 883107a410..d1debf63f6 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java @@ -79,9 +79,9 @@ public class GameAdapter extends RecyclerView.Adapter<GameViewHolder> implements .into(holder.imageScreenshot); holder.textGameTitle.setText(game.getTitle()); - if (game.getDescription() != null) + if (game.getCompany() != null) { - holder.textDescription.setText(game.getDescription()); + holder.textCompany.setText(game.getCompany()); } holder.path = game.getPath(); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java index b52a017278..d673da22c9 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java @@ -39,7 +39,7 @@ public class GameDetailsDialog extends DialogFragment arguments.putString(ARGUMENT_GAME_TITLE, game.getTitle()); arguments.putString(ARGUMENT_GAME_DESCRIPTION, game.getDescription()); arguments.putInt(ARGUMENT_GAME_COUNTRY, game.getCountry()); - arguments.putString(ARGUMENT_GAME_DATE, game.getDate()); + arguments.putString(ARGUMENT_GAME_DATE, game.getCompany()); arguments.putString(ARGUMENT_GAME_PATH, game.getPath()); arguments.putString(ARGUMENT_GAME_SCREENSHOT_PATH, game.getScreenPath()); fragment.setArguments(arguments); @@ -57,7 +57,7 @@ public class GameDetailsDialog extends DialogFragment CircleImageView circleBanner = (CircleImageView) contents.findViewById(R.id.circle_banner); TextView textTitle = (TextView) contents.findViewById(R.id.text_game_title); - TextView textDescription = (TextView) contents.findViewById(R.id.text_game_description); + TextView textDescription = (TextView) contents.findViewById(R.id.text_company); TextView textCountry = (TextView) contents.findViewById(R.id.text_country); TextView textDate = (TextView) contents.findViewById(R.id.text_date); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/FileListItem.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/FileListItem.java index b9c8a571cf..4952412e9d 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/FileListItem.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/FileListItem.java @@ -10,10 +10,11 @@ import java.util.Set; public class FileListItem implements Comparable<FileListItem> { - public static final int TYPE_FOLDER = 0; - public static final int TYPE_GC = 1; - public static final int TYPE_WII = 2; - public static final int TYPE_OTHER = 3; + public static final int TYPE_GC = 0; + public static final int TYPE_WII = 1; + public static final int TYPE_WII_WARE = 2; + public static final int TYPE_OTHER = 4; + public static final int TYPE_FOLDER = 5; private int mType; private String mFilename; @@ -48,7 +49,7 @@ public class FileListItem implements Comparable<FileListItem> // Check that the file has an extension we care about before trying to read out of it. if (allowedExtensions.contains(fileExtension)) { - mType = NativeLibrary.IsWiiTitle(mPath) ? TYPE_WII : TYPE_GC; + mType = NativeLibrary.GetPlatform(mPath); } else { 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 b2ebb51d6f..4c4ea4fc04 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 @@ -1,6 +1,8 @@ package org.dolphinemu.dolphinemu.model; -public interface Game +import java.io.File; + +public class Game { public static final int PLATFORM_GC = 0; public static final int PLATFORM_WII = 1; @@ -22,19 +24,85 @@ public interface Game public static final int COUNTRY_WORLD = 12; public static final int COUNTRY_UNKNOWN = 13; - public int getPlatform(); + private static final String PATH_SCREENSHOT_FOLDER = "file:///sdcard/dolphin-emu/ScreenShots/"; + + private String mTitle; + private String mDescription; + private String mPath; + private String mGameId; + private String mScreenshotFolderPath; + private String mCompany; + + private int mPlatform; + private int mCountry; + + public Game(int platform, String title, String description, int country, String path, String gameId, String company) + { + mPlatform = platform; + mTitle = title; + mDescription = description; + mCountry = country; + mPath = path; + mGameId = gameId; + mCompany = company; + mScreenshotFolderPath = PATH_SCREENSHOT_FOLDER + getGameId() + "/"; + } + + public int getPlatform() + { + return mPlatform; + } + + public String getTitle() + { + return mTitle; + } + + public String getDescription() + { + return mDescription; + } + + public String getCompany() + { + return mCompany; + } + + public int getCountry() + { + return mCountry; + } - public String getDate(); + public String getPath() + { + return mPath; + } - public String getTitle(); + public String getGameId() + { + return mGameId; + } - public String getDescription(); + public String getScreenshotFolderPath() + { + return mScreenshotFolderPath; + } - public int getCountry(); + public String getScreenPath() + { + // Count how many screenshots are available, so we can use the most recent one. + File screenshotFolder = new File(mScreenshotFolderPath.substring(mScreenshotFolderPath.indexOf('s') - 1)); + int screenCount = 0; - public String getPath(); + if (screenshotFolder.isDirectory()) + { + screenCount = screenshotFolder.list().length; + } - public String getGameId(); + String screenPath = mScreenshotFolderPath + + getGameId() + "-" + + screenCount + ".png"; - public String getScreenPath(); + return screenPath; + } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GcGame.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GcGame.java deleted file mode 100644 index 72fa77d4c4..0000000000 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GcGame.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.dolphinemu.dolphinemu.model; - - -import java.io.File; - -public final class GcGame implements Game -{ - private String mTitle; - private String mDescription; - private String mPath; - private String mGameId; - private String mScreenshotFolderPath; - - private String mDate; - - private int mCountry; - private int mPlatform = PLATFORM_GC; - - private static final String PATH_SCREENSHOT_FOLDER = "file:///sdcard/dolphin-emu/ScreenShots/"; - - public GcGame(String title, String description, int country, String path, String gameId, String date) - { - mTitle = title; - mDescription = description; - mCountry = country; - mPath = path; - mGameId = gameId; - mDate = date; - mScreenshotFolderPath = PATH_SCREENSHOT_FOLDER + getGameId() + "/"; - } - - @Override - public int getPlatform() - { - return mPlatform; - } - - @Override - public String getTitle() - { - return mTitle; - } - - @Override - public String getDescription() - { - return mDescription; - } - - @Override - public String getDate() - { - return mDate; - } - - @Override - public int getCountry() - { - return mCountry; - } - - @Override - public String getPath() - { - return mPath; - } - - public String getGameId() - { - return mGameId; - } - - public String getScreenshotFolderPath() - { - return mScreenshotFolderPath; - } - - @Override - public String getScreenPath() - { - // Count how many screenshots are available, so we can use the most recent one. - File screenshotFolder = new File(mScreenshotFolderPath.substring(mScreenshotFolderPath.indexOf('s') - 1)); - int screenCount = 0; - - if (screenshotFolder.isDirectory()) - { - screenCount = screenshotFolder.list().length; - } - - String screenPath = mScreenshotFolderPath - + getGameId() + "-" - + screenCount + ".png"; - - return screenPath; - } -} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/WiiGame.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/WiiGame.java deleted file mode 100644 index d0678f4e95..0000000000 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/WiiGame.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.dolphinemu.dolphinemu.model; - - -public final class WiiGame implements Game -{ - @Override - public int getPlatform() - { - return 0; - } - - @Override - public String getDate() - { - return null; - } - - @Override - public String getTitle() - { - return null; - } - - @Override - public String getDescription() - { - return null; - } - - @Override - public int getCountry() - { - return 13; - } - - @Override - public String getPath() - { - return null; - } - - @Override - public String getGameId() - { - return null; - } - - @Override - public String getScreenPath() - { - return null; - } -} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/GameViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/GameViewHolder.java index 18e271e0f5..d578a7a8f2 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/GameViewHolder.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/GameViewHolder.java @@ -1,16 +1,11 @@ package org.dolphinemu.dolphinemu.viewholders; -import android.app.Activity; -import android.content.Intent; import android.support.v7.widget.RecyclerView; import android.view.View; -import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; import org.dolphinemu.dolphinemu.R; -import org.dolphinemu.dolphinemu.dialogs.GameDetailsDialog; -import org.dolphinemu.dolphinemu.emulation.EmulationActivity; import org.dolphinemu.dolphinemu.model.Game; @@ -18,7 +13,7 @@ public class GameViewHolder extends RecyclerView.ViewHolder { public ImageView imageScreenshot; public TextView textGameTitle; - public TextView textDescription; + public TextView textCompany; // Used to handle onClick(). Set this in onBindViewHolder(). public String path; @@ -33,6 +28,6 @@ public class GameViewHolder extends RecyclerView.ViewHolder imageScreenshot = (ImageView) itemView.findViewById(R.id.image_game_screen); textGameTitle = (TextView) itemView.findViewById(R.id.text_game_title); - textDescription = (TextView) itemView.findViewById(R.id.text_game_description); + textCompany = (TextView) itemView.findViewById(R.id.text_company); } } |
