Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Android] Replace the getter for the adapter backing the GameListFrag…
…ment 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.
  • Loading branch information
lioncash committed Oct 10, 2013
1 parent 511de71 commit 615bac7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
Expand Up @@ -18,8 +18,8 @@
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;

Expand Down Expand Up @@ -239,11 +239,11 @@ public void onClick(DialogInterface dialog, int which)
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<GameListItem> 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() {
Expand Down
Expand Up @@ -34,14 +34,13 @@
*/
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
{
Expand All @@ -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()
Expand Down Expand Up @@ -96,7 +95,7 @@ private void Fill()
Collections.sort(fls);

mGameAdapter = new GameListAdapter(mMe, R.layout.gamelist_folderbrowser_list, fls);
mMainList.setAdapter(mGameAdapter);
setListAdapter(mGameAdapter);

if (fls.isEmpty())
{
Expand All @@ -108,7 +107,7 @@ private void Fill()
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();

Expand Down

0 comments on commit 615bac7

Please sign in to comment.