From: kruland2607 Date: Fri, 17 Feb 2012 22:10:28 +0000 (+0000) Subject: Only create the motor list fragment once. If it already exists, don't create it... X-Git-Tag: upstream/12.03~1^2~45 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=b6751caebbea6d66caec292333e1d035d07c7b5b;p=debian%2Fopenrocket Only create the motor list fragment once. If it already exists, don't create it again. This was causing problems during orientation change by creating multiple overlapping lists. git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@426 180e2498-e6e9-4542-8430-84ac67f01cd8 --- diff --git a/android/src/net/sf/openrocket/android/motor/MotorBrowserActivity.java b/android/src/net/sf/openrocket/android/motor/MotorBrowserActivity.java index 34a92b98..56a43b73 100644 --- a/android/src/net/sf/openrocket/android/motor/MotorBrowserActivity.java +++ b/android/src/net/sf/openrocket/android/motor/MotorBrowserActivity.java @@ -19,8 +19,9 @@ implements MotorListFragment.OnMotorSelectedListener { MotorListFragment motorList; - + private final static int DOWNLOAD_REQUEST_CODE = 1; + private final static String MOTOR_LIST_FRAGMENT = "motor_list"; /** Called when the activity is first created. */ @Override @@ -28,13 +29,20 @@ implements MotorListFragment.OnMotorSelectedListener super.onCreate(savedInstanceState); setContentView(R.layout.motorbrowser); getActionBarHelper().setDisplayHomeAsUpEnabled(true); - getSupportFragmentManager().beginTransaction().add( R.id.motorBrowserList, new MotorListFragment()).commit(); + // Only create the motorBrowser fragment if it doesn't already exist. + Fragment motorBrowser = getSupportFragmentManager().findFragmentByTag(MOTOR_LIST_FRAGMENT); + if ( motorBrowser == null ) { + getSupportFragmentManager() + .beginTransaction() + .add( R.id.motorBrowserList, new MotorListFragment(), MOTOR_LIST_FRAGMENT) + .commit(); + } } @Override public boolean onCreateOptionsMenu(Menu menu) { - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.motor_browser_option_menu, menu); + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.motor_browser_option_menu, menu); return true; } @@ -66,10 +74,10 @@ implements MotorListFragment.OnMotorSelectedListener @Override public void onMotorSelected(long motorId) { - + View sidepane = findViewById(R.id.sidepane); if ( /* if multi pane */ sidepane != null ) { - + Fragment graph = BurnPlotFragment.newInstance(motorId); FragmentTransaction ft = getSupportFragmentManager().beginTransaction();