[Android] Eliminate the need to hold a reference to the shown Fragment within GameListActivity. Now we only care about the numeric ID of the one being shown.
This commit is contained in:
parent
777b5a109b
commit
21a196f9af
|
@ -43,7 +43,6 @@ public final class GameListActivity extends Activity
|
||||||
implements GameListFragment.OnGameListZeroListener
|
implements GameListFragment.OnGameListZeroListener
|
||||||
{
|
{
|
||||||
private int mCurFragmentNum = 0;
|
private int mCurFragmentNum = 0;
|
||||||
private Fragment mCurFragment;
|
|
||||||
|
|
||||||
private ActionBarDrawerToggle mDrawerToggle;
|
private ActionBarDrawerToggle mDrawerToggle;
|
||||||
private DrawerLayout mDrawerLayout;
|
private DrawerLayout mDrawerLayout;
|
||||||
|
@ -108,9 +107,9 @@ public final class GameListActivity extends Activity
|
||||||
// but only if no previous states have been saved.
|
// but only if no previous states have been saved.
|
||||||
if (savedInstanceState == null)
|
if (savedInstanceState == null)
|
||||||
{
|
{
|
||||||
mCurFragment = new GameListFragment();
|
final GameListFragment gameList = new GameListFragment();
|
||||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||||
ft.replace(R.id.content_frame, mCurFragment);
|
ft.replace(R.id.content_frame, gameList);
|
||||||
ft.commit();
|
ft.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,9 +156,9 @@ public final class GameListActivity extends Activity
|
||||||
setTitle(R.string.app_name);
|
setTitle(R.string.app_name);
|
||||||
|
|
||||||
mCurFragmentNum = 0;
|
mCurFragmentNum = 0;
|
||||||
mCurFragment = new GameListFragment();
|
final GameListFragment gameList = new GameListFragment();
|
||||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||||
ft.replace(R.id.content_frame, mCurFragment);
|
ft.replace(R.id.content_frame, gameList, "");
|
||||||
ft.commit();
|
ft.commit();
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
@ -168,9 +167,9 @@ public final class GameListActivity extends Activity
|
||||||
case 1: // Folder Browser
|
case 1: // Folder Browser
|
||||||
{
|
{
|
||||||
mCurFragmentNum = 1;
|
mCurFragmentNum = 1;
|
||||||
mCurFragment = new FolderBrowser();
|
final FolderBrowser folderBrowser = new FolderBrowser();
|
||||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||||
ft.replace(R.id.content_frame, mCurFragment);
|
ft.replace(R.id.content_frame, folderBrowser);
|
||||||
ft.addToBackStack(null);
|
ft.addToBackStack(null);
|
||||||
ft.commit();
|
ft.commit();
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
|
@ -187,9 +186,9 @@ public final class GameListActivity extends Activity
|
||||||
case 3: // About
|
case 3: // About
|
||||||
{
|
{
|
||||||
mCurFragmentNum = 3;
|
mCurFragmentNum = 3;
|
||||||
mCurFragment = new AboutFragment();
|
final AboutFragment aboutFragment = new AboutFragment();
|
||||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||||
ft.replace(R.id.content_frame, mCurFragment);
|
ft.replace(R.id.content_frame, aboutFragment);
|
||||||
ft.addToBackStack(null);
|
ft.addToBackStack(null);
|
||||||
ft.commit();
|
ft.commit();
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
|
@ -278,7 +277,7 @@ public final class GameListActivity extends Activity
|
||||||
NativeLibrary.SetConfig("Dolphin.ini", "General", "GCMPathes", "0");
|
NativeLibrary.SetConfig("Dolphin.ini", "General", "GCMPathes", "0");
|
||||||
|
|
||||||
// Now finally, clear the game list.
|
// Now finally, clear the game list.
|
||||||
((GameListFragment) mCurFragment).clearGameList();
|
((GameListFragment) getFragmentManager().findFragmentById(R.id.content_frame)).clearGameList();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
||||||
|
@ -293,4 +292,26 @@ public final class GameListActivity extends Activity
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle outState)
|
||||||
|
{
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
|
||||||
|
outState.putInt("currentFragmentNum", mCurFragmentNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRestoreInstanceState(Bundle savedInstanceState)
|
||||||
|
{
|
||||||
|
super.onRestoreInstanceState(savedInstanceState);
|
||||||
|
|
||||||
|
mCurFragmentNum = savedInstanceState.getInt("currentFragmentNum");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed()
|
||||||
|
{
|
||||||
|
SwitchPage(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue