From 0170050cad3a28ca4fdf0f34ff2f4414dd6b013a Mon Sep 17 00:00:00 2001 From: Eder Bastos Date: Fri, 4 Jul 2014 15:48:12 -0400 Subject: [PATCH] Use the "No Banner" graphic as a Drawable resource, instead of as an asset. --- .../drawable/no_banner.png} | Bin .../dolphinemu/gamelist/GameListAdapter.java | 17 ++++++++++++++- .../dolphinemu/gamelist/GameListItem.java | 20 +----------------- 3 files changed, 17 insertions(+), 20 deletions(-) rename Source/Android/{assets/NoBanner.png => res/drawable/no_banner.png} (100%) diff --git a/Source/Android/assets/NoBanner.png b/Source/Android/res/drawable/no_banner.png similarity index 100% rename from Source/Android/assets/NoBanner.png rename to Source/Android/res/drawable/no_banner.png diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListAdapter.java index 30796593ca..aabd4f2bc3 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListAdapter.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListAdapter.java @@ -7,6 +7,7 @@ package org.dolphinemu.dolphinemu.gamelist; import android.content.Context; +import android.graphics.Bitmap; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -75,7 +76,21 @@ public final class GameListAdapter extends ArrayAdapter { holder.title.setText(item.getName()); holder.subtitle.setText(item.getData()); - holder.icon.setImageBitmap(item.getImage()); + + Bitmap icon = item.getImage(); + + if (icon != null) + { + holder.icon.setImageBitmap(item.getImage()); + } + else + { + holder.icon.setImageResource(R.drawable.no_banner); + } + + String subtitle = String.format(context.getString(R.string.file_size_gib), item.getFilesize()); + + holder.subtitle.setText(subtitle); } // Make every other game in the list grey diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListItem.java b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListItem.java index 1b72da7b9b..b804337781 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListItem.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListItem.java @@ -45,25 +45,7 @@ public final class GameListItem implements Comparable if (!file.isDirectory() && !path.isEmpty()) { int[] Banner = NativeLibrary.GetBanner(path); - if (Banner[0] == 0) - { - try - { - // Open the no banner icon. - InputStream noBannerPath = ctx.getAssets().open("NoBanner.png"); - - // Decode the bitmap. - image = BitmapFactory.decodeStream(noBannerPath); - - // Scale the bitmap to match other banners. - image = Bitmap.createScaledBitmap(image, 96, 32, false); - } - catch (IOException e) - { - Log.e("GameListItem", e.toString()); - } - } - else + if (Banner[0] != 0) { image = Bitmap.createBitmap(Banner, 96, 32, Bitmap.Config.ARGB_8888); }