[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.
This commit is contained in:
lioncash 2013-10-10 17:08:46 -04:00
parent 511de71736
commit 615bac7ebc
2 changed files with 13 additions and 14 deletions

View File

@ -18,8 +18,8 @@ import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
import android.view.*; import android.view.*;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView; import android.widget.ListView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -239,11 +239,11 @@ public final class GameListActivity extends Activity
NativeLibrary.SetConfig("Dolphin.ini", "General", "GCMPath" + i, ""); 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"); NativeLibrary.SetConfig("Dolphin.ini", "General", "GCMPathes", "0");
ArrayAdapter<GameListItem> adapter = ((GameListFragment)GameListActivity.this.mCurFragment).getAdapter(); // Now finally, clear the game list.
adapter.clear(); ((GameListFragment) mCurFragment).clearGameList();
adapter.notifyDataSetChanged();
} }
}); });
builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {

View File

@ -34,14 +34,13 @@ import org.dolphinemu.dolphinemu.emulation.EmulationActivity;
*/ */
public final class GameListFragment extends ListFragment public final class GameListFragment extends ListFragment
{ {
private ListView mMainList;
private GameListAdapter mGameAdapter; private GameListAdapter mGameAdapter;
private static GameListActivity mMe; private static GameListActivity mMe;
private OnGameListZeroListener mCallback; private OnGameListZeroListener mCallback;
/** /**
* Interface that defines how to handle the case * 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 public interface OnGameListZeroListener
{ {
@ -53,13 +52,13 @@ public final class GameListFragment extends ListFragment
} }
/** /**
* Gets the adapter for this fragment. * Clears all entries from the {@link GameListAdapter}
* * backing this GameListFragment.
* @return the adapter for this fragment.
*/ */
public GameListAdapter getAdapter() public void clearGameList()
{ {
return mGameAdapter; mGameAdapter.clear();
mGameAdapter.notifyDataSetChanged();
} }
private void Fill() private void Fill()
@ -96,7 +95,7 @@ public final class GameListFragment extends ListFragment
Collections.sort(fls); Collections.sort(fls);
mGameAdapter = new GameListAdapter(mMe, R.layout.gamelist_folderbrowser_list, fls); mGameAdapter = new GameListAdapter(mMe, R.layout.gamelist_folderbrowser_list, fls);
mMainList.setAdapter(mGameAdapter); setListAdapter(mGameAdapter);
if (fls.isEmpty()) if (fls.isEmpty())
{ {
@ -108,7 +107,7 @@ public final class GameListFragment extends ListFragment
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{ {
View rootView = inflater.inflate(R.layout.gamelist_listview, container, false); 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(); Fill();