From 615bac7ebc91723e2588000e2d97d432e31429f8 Mon Sep 17 00:00:00 2001 From: lioncash Date: Thu, 10 Oct 2013 17:08:46 -0400 Subject: [PATCH] [Android] Replace the getter for the adapter backing the GameListFragment with a function that simply clears the array adapter. Maintains encapsulation this way. Simplified the actual setting of the backing ArrayAdapter for GameListFragment; this allows us to make a class variable a method variable now. Also fixed up the Javadoc for the OnGameListZeroListener. --- .../dolphinemu/gamelist/GameListActivity.java | 8 ++++---- .../dolphinemu/gamelist/GameListFragment.java | 19 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListActivity.java b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListActivity.java index 23233b37cb..96f1783310 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListActivity.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListActivity.java @@ -18,8 +18,8 @@ import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.widget.DrawerLayout; import android.view.*; import android.widget.AdapterView; -import android.widget.ArrayAdapter; import android.widget.ListView; + import java.util.ArrayList; import java.util.List; @@ -239,11 +239,11 @@ public final class GameListActivity extends Activity NativeLibrary.SetConfig("Dolphin.ini", "General", "GCMPath" + i, ""); } + // Since we flushed all paths, we signify this in the ini. NativeLibrary.SetConfig("Dolphin.ini", "General", "GCMPathes", "0"); - ArrayAdapter adapter = ((GameListFragment)GameListActivity.this.mCurFragment).getAdapter(); - adapter.clear(); - adapter.notifyDataSetChanged(); + // Now finally, clear the game list. + ((GameListFragment) mCurFragment).clearGameList(); } }); builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListFragment.java index 4be6c180bc..41eb271b99 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListFragment.java @@ -34,14 +34,13 @@ import org.dolphinemu.dolphinemu.emulation.EmulationActivity; */ public final class GameListFragment extends ListFragment { - private ListView mMainList; private GameListAdapter mGameAdapter; private static GameListActivity mMe; private OnGameListZeroListener mCallback; /** * Interface that defines how to handle the case - * when there are zero game. + * when there are zero games in the game list. */ public interface OnGameListZeroListener { @@ -51,15 +50,15 @@ public final class GameListFragment extends ListFragment */ void onZeroFiles(); } - + /** - * Gets the adapter for this fragment. - * - * @return the adapter for this fragment. + * Clears all entries from the {@link GameListAdapter} + * backing this GameListFragment. */ - public GameListAdapter getAdapter() + public void clearGameList() { - return mGameAdapter; + mGameAdapter.clear(); + mGameAdapter.notifyDataSetChanged(); } private void Fill() @@ -96,7 +95,7 @@ public final class GameListFragment extends ListFragment Collections.sort(fls); mGameAdapter = new GameListAdapter(mMe, R.layout.gamelist_folderbrowser_list, fls); - mMainList.setAdapter(mGameAdapter); + setListAdapter(mGameAdapter); if (fls.isEmpty()) { @@ -108,7 +107,7 @@ public final class GameListFragment extends ListFragment public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.gamelist_listview, container, false); - mMainList = (ListView) rootView.findViewById(R.id.gamelist); + ListView mMainList = (ListView) rootView.findViewById(R.id.gamelist); Fill();