[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 boolean cpuIsNeon = cpuInfo.contains("neon");
// Setup the layout
setContentView(R.layout.line_list);
// Setup the list
adapter = new IconAdapter<ModuleWrapper>(this, R.layout.line_list_item);
ListView list = getListView();
list.setAdapter(adapter);
setListAdapter(adapter);
// Set the activity title.
setTitle(R.string.select_libretro_core);
// Populate the list

View File

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

View File

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