[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.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<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() {

View File

@ -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();