diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListAdapter.java index ca30f4f284..d4dedd29aa 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListAdapter.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListAdapter.java @@ -12,11 +12,8 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; -import android.widget.ListView; import android.widget.TextView; -import java.util.List; - import org.dolphinemu.dolphinemu.R; /** @@ -28,28 +25,19 @@ public final class GameListAdapter extends ArrayAdapter { private final Context context; private final int id; - private final Listitems; /** * Constructor * * @param context The current {@link Context}. * @param resourceId The resource ID for a layout file containing a layout to use when instantiating views. - * @param objects The objects to represent in the {@link ListView}. */ - public GameListAdapter(Context context, int resourceId, List objects) + public GameListAdapter(Context context, int resourceId) { - super(context, resourceId, objects); + super(context, resourceId); this.context = context; this.id = resourceId; - this.items = objects; - } - - @Override - public GameListItem getItem(int i) - { - return items.get(i); } @Override @@ -61,7 +49,7 @@ public final class GameListAdapter extends ArrayAdapter convertView = vi.inflate(id, parent, false); } - final GameListItem item = items.get(position); + final GameListItem item = getItem(position); if (item != null) { TextView title = (TextView) convertView.findViewById(R.id.ListItemTitle); diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListFragment.java index 4224e16282..9dedf914dc 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListFragment.java @@ -35,7 +35,6 @@ import org.dolphinemu.dolphinemu.emulation.EmulationActivity; public final class GameListFragment extends ListFragment { private GameListAdapter mGameAdapter; - private static GameListActivity mMe; private OnGameListZeroListener mCallback; /** @@ -84,7 +83,7 @@ public final class GameListFragment extends ListFragment if (!entry.isHidden() && !entry.isDirectory()) { if (exts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.')))) - fls.add(new GameListItem(mMe, entryName, String.format(getString(R.string.file_size), entry.length()), entry.getAbsolutePath())); + fls.add(new GameListItem(getActivity(), entryName, String.format(getString(R.string.file_size), entry.length()), entry.getAbsolutePath())); } } } @@ -94,8 +93,9 @@ public final class GameListFragment extends ListFragment } Collections.sort(fls); - mGameAdapter = new GameListAdapter(mMe, R.layout.gamelist_folderbrowser_list_item, fls); - setListAdapter(mGameAdapter); + // Add all the items to the adapter + mGameAdapter.addAll(fls); + mGameAdapter.notifyDataSetChanged(); if (fls.isEmpty()) { @@ -106,12 +106,13 @@ public final class GameListFragment extends ListFragment @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.gamelist_listview, container, false); - ListView mMainList = (ListView) rootView.findViewById(R.id.gamelist); + ListView rootView = (ListView) inflater.inflate(R.layout.gamelist_listview, container, false); + mGameAdapter = new GameListAdapter(getActivity(), R.layout.gamelist_folderbrowser_list_item); + rootView.setAdapter(mGameAdapter); Fill(); - return mMainList; + return rootView; } @Override @@ -120,12 +121,12 @@ public final class GameListFragment extends ListFragment GameListItem item = mGameAdapter.getItem(position); // Show a toast indicating which game was clicked. - Toast.makeText(mMe, String.format(getString(R.string.file_clicked), item.getPath()), Toast.LENGTH_SHORT).show(); + Toast.makeText(getActivity(), String.format(getString(R.string.file_clicked), item.getPath()), Toast.LENGTH_SHORT).show(); // Start the emulation activity and send the path of the clicked ROM to it. - Intent intent = new Intent(mMe, EmulationActivity.class); + Intent intent = new Intent(getActivity(), EmulationActivity.class); intent.putExtra("SelectedGame", item.getPath()); - mMe.startActivity(intent); + startActivity(intent); } @Override @@ -138,7 +139,6 @@ public final class GameListFragment extends ListFragment try { mCallback = (OnGameListZeroListener) activity; - mMe = (GameListActivity) activity; } catch (ClassCastException e) {