Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Android] Fix the handling of orientation changes for the Fragments r…
…elated to the game list. Now screen orientation changes don't kick you back to the root view.
  • Loading branch information
lioncash committed Nov 16, 2013
1 parent e8a4cc0 commit 777b5a1
Showing 1 changed file with 23 additions and 17 deletions.
Expand Up @@ -9,7 +9,7 @@
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
Expand All @@ -23,6 +23,7 @@
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import org.dolphinemu.dolphinemu.AboutFragment;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
Expand Down Expand Up @@ -103,10 +104,16 @@ public void onDrawerOpened(View drawerView) {
};
mDrawerLayout.setDrawerListener(mDrawerToggle);

// Display the game list fragment.
mCurFragment = new GameListFragment();
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
// Display the game list fragment on activity creation,
// but only if no previous states have been saved.
if (savedInstanceState == null)
{
mCurFragment = new GameListFragment();
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.content_frame, mCurFragment);
ft.commit();
}


// Create an alert telling them that their phone sucks
if (Build.CPU_ABI.contains("arm") && !NativeLibrary.SupportsNEON())
Expand Down Expand Up @@ -151,8 +158,9 @@ public void SwitchPage(int toPage)

mCurFragmentNum = 0;
mCurFragment = new GameListFragment();
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.content_frame, mCurFragment);
ft.commit();
invalidateOptionsMenu();
}
break;
Expand All @@ -161,8 +169,10 @@ public void SwitchPage(int toPage)
{
mCurFragmentNum = 1;
mCurFragment = new FolderBrowser();
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.content_frame, mCurFragment);
ft.addToBackStack(null);
ft.commit();
invalidateOptionsMenu();
}
break;
Expand All @@ -178,8 +188,10 @@ public void SwitchPage(int toPage)
{
mCurFragmentNum = 3;
mCurFragment = new AboutFragment();
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.content_frame, mCurFragment);
ft.addToBackStack(null);
ft.commit();
invalidateOptionsMenu();
}
break;
Expand Down Expand Up @@ -281,10 +293,4 @@ public void onClick(DialogInterface dialog, int which)

return super.onOptionsItemSelected(item);
}

@Override
public void onBackPressed()
{
SwitchPage(0);
}
}

0 comments on commit 777b5a1

Please sign in to comment.