From ac2c9840ff155d95065d3fb40643e78656b9a929 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 8 Oct 2013 23:30:15 -0400 Subject: [PATCH] [Android] Simplify LayoutInflater retrieval within IconAdapter.java. Also removed abstract from the methods within the interface IconAdapterItem. Methods within an interface are implicitly abstract. Joined the declaration and assignment of an Intent within HistorySelection.java. --- .../retroarch/browser/HistorySelection.java | 3 +- .../org/retroarch/browser/IconAdapter.java | 41 +++++++++---------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/android/phoenix/src/org/retroarch/browser/HistorySelection.java b/android/phoenix/src/org/retroarch/browser/HistorySelection.java index 53124c9f50..d9a2547668 100644 --- a/android/phoenix/src/org/retroarch/browser/HistorySelection.java +++ b/android/phoenix/src/org/retroarch/browser/HistorySelection.java @@ -64,14 +64,13 @@ public final class HistorySelection extends Activity implements AdapterView.OnIt MainMenuActivity.getInstance().setModule(corePath, item.getCoreName()); - Intent myIntent; String current_ime = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD); UserPreferences.updateConfigFile(this); Toast.makeText(this, String.format(getString(R.string.loading_gamepath), gamePath), Toast.LENGTH_SHORT).show(); - myIntent = new Intent(this, RetroActivity.class); + Intent myIntent = new Intent(this, RetroActivity.class); myIntent.putExtra("ROM", gamePath); myIntent.putExtra("LIBRETRO", corePath); myIntent.putExtra("CONFIGFILE", UserPreferences.getDefaultConfigPath(this)); diff --git a/android/phoenix/src/org/retroarch/browser/IconAdapter.java b/android/phoenix/src/org/retroarch/browser/IconAdapter.java index e6f0f5d5c3..290c8cd4c3 100644 --- a/android/phoenix/src/org/retroarch/browser/IconAdapter.java +++ b/android/phoenix/src/org/retroarch/browser/IconAdapter.java @@ -2,48 +2,48 @@ package org.retroarch.browser; import org.retroarch.R; -import android.app.*; import android.content.*; import android.graphics.drawable.*; import android.view.*; import android.widget.*; interface IconAdapterItem { - public abstract boolean isEnabled(); - public abstract String getText(); - public abstract String getSubText(); - public abstract int getIconResourceId(); - public abstract Drawable getIconDrawable(); + public boolean isEnabled(); + public String getText(); + public String getSubText(); + public int getIconResourceId(); + public Drawable getIconDrawable(); } public final class IconAdapter extends ArrayAdapter { - private final int layout; + private final int resourceId; + private final Context context; - public IconAdapter(Activity aContext, int aLayout) { - super(aContext, aLayout); - layout = aLayout; + public IconAdapter(Context context, int resourceId) { + super(context, resourceId); + this.context = context; + this.resourceId = resourceId; } @Override - public View getView(int aPosition, View aConvertView, ViewGroup aParent) { + public View getView(int position, View convertView, ViewGroup parent) { // Build the view - if (aConvertView == null) { - LayoutInflater inflater = (LayoutInflater) aParent.getContext() - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - aConvertView = inflater.inflate(layout, aParent, false); + if (convertView == null) { + LayoutInflater inflater = LayoutInflater.from(context); + convertView = inflater.inflate(resourceId, parent, false); } // Fill the view - IconAdapterItem item = getItem(aPosition); + IconAdapterItem item = getItem(position); final boolean enabled = item.isEnabled(); - TextView textView = (TextView) aConvertView.findViewById(R.id.name); + TextView textView = (TextView) convertView.findViewById(R.id.name); if (null != textView) { textView.setText(item.getText()); textView.setEnabled(enabled); } - textView = (TextView) aConvertView.findViewById(R.id.sub_name); + textView = (TextView) convertView.findViewById(R.id.sub_name); if (null != textView) { String subText = item.getSubText(); if (null != subText) { @@ -53,7 +53,7 @@ public final class IconAdapter extends ArrayAdapter extends ArrayAdapter