mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-26 09:41:15 +00:00
[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.
This commit is contained in:
parent
8fb23d0fcc
commit
ac2c9840ff
@ -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));
|
||||
|
@ -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<T extends IconAdapterItem> extends ArrayAdapter<T> {
|
||||
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<T extends IconAdapterItem> extends ArrayAdapter<T
|
||||
}
|
||||
}
|
||||
|
||||
ImageView imageView = (ImageView) aConvertView.findViewById(R.id.icon);
|
||||
ImageView imageView = (ImageView) convertView.findViewById(R.id.icon);
|
||||
if (null != imageView) {
|
||||
if (enabled) {
|
||||
final int id = item.getIconResourceId();
|
||||
@ -67,12 +67,11 @@ public final class IconAdapter<T extends IconAdapterItem> extends ArrayAdapter<T
|
||||
}
|
||||
}
|
||||
|
||||
return aConvertView;
|
||||
return convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int aPosition) {
|
||||
return getItem(aPosition).isEnabled();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user