[Android] Simplify how ListActivities set their adapters. Since they are ListActivities, there is an underlying method for setting the adapters (setListAdapter()), so now we can remove calls that get the ListView object, since we don't need to directly access them now.

This commit is contained in:
Lioncash 2013-10-11 10:42:11 -04:00
parent baf694d4f6
commit 4b3f15c904
3 changed files with 12 additions and 11 deletions

View File

@ -33,13 +33,14 @@ public final class CoreSelection extends ListActivity {
final String cpuInfo = UserPreferences.readCPUInfo(); final String cpuInfo = UserPreferences.readCPUInfo();
final boolean cpuIsNeon = cpuInfo.contains("neon"); final boolean cpuIsNeon = cpuInfo.contains("neon");
// Setup the layout
setContentView(R.layout.line_list); setContentView(R.layout.line_list);
// Setup the list // Setup the list
adapter = new IconAdapter<ModuleWrapper>(this, R.layout.line_list_item); adapter = new IconAdapter<ModuleWrapper>(this, R.layout.line_list_item);
ListView list = getListView(); setListAdapter(adapter);
list.setAdapter(adapter);
// Set the activity title.
setTitle(R.string.select_libretro_core); setTitle(R.string.select_libretro_core);
// Populate the list // Populate the list

View File

@ -24,18 +24,19 @@ public final class HistorySelection extends ListActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// Setup the layout.
setContentView(R.layout.line_list); setContentView(R.layout.line_list);
// Setup the list // Setup the list
adapter = new IconAdapter<HistoryWrapper>(this, R.layout.line_list_item); adapter = new IconAdapter<HistoryWrapper>(this, R.layout.line_list_item);
ListView list = getListView(); setListAdapter(adapter);
list.setAdapter(adapter);
// Set activity title.
setTitle(R.string.recently_played_games); setTitle(R.string.recently_played_games);
File history = new File(getApplicationInfo().dataDir, "retroarch-history.txt"); File history = new File(getApplicationInfo().dataDir, "retroarch-history.txt");
try { try {
BufferedReader br = new BufferedReader(new InputStreamReader( BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(history))); new FileInputStream(history)));
@ -46,14 +47,14 @@ public final class HistorySelection extends ListActivity {
String name = br.readLine(); String name = br.readLine();
if (game == null || core == null || name == null) if (game == null || core == null || name == null)
break; break;
adapter.add(new HistoryWrapper(game, core, name)); adapter.add(new HistoryWrapper(game, core, name));
} }
br.close(); br.close();
} catch (IOException ex) { } catch (IOException ex) {
} }
} }
@Override @Override
public void onListItemClick(ListView listView, View view, int position, long id) { public void onListItemClick(ListView listView, View view, int position, long id) {
final HistoryWrapper item = adapter.getItem(position); final HistoryWrapper item = adapter.getItem(position);

View File

@ -80,8 +80,7 @@ public class DirectoryActivity extends ListActivity {
// Setup the list // Setup the list
adapter = new IconAdapter<FileWrapper>(this, R.layout.line_list_item); adapter = new IconAdapter<FileWrapper>(this, R.layout.line_list_item);
ListView list = getListView(); setListAdapter(adapter);
list.setAdapter(adapter);
// Load Directory // Load Directory
if (savedInstanceState != null) { if (savedInstanceState != null) {