Fix duplicated fragments

This commit is contained in:
Cameron Gutman
2015-01-31 17:19:54 -05:00
parent 56f438fe47
commit b01f7c796e
2 changed files with 5 additions and 10 deletions

View File

@@ -110,7 +110,8 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
populateAppGridWithCache(); populateAppGridWithCache();
getFragmentManager().beginTransaction() getFragmentManager().beginTransaction()
.add(R.id.appFragmentContainer, new AdapterFragment()).commitAllowingStateLoss(); .replace(R.id.appFragmentContainer, new AdapterFragment())
.commitAllowingStateLoss();
} }
}.start(); }.start();
} }

View File

@@ -49,7 +49,6 @@ import android.widget.Toast;
import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.AdapterContextMenuInfo;
public class PcView extends Activity implements AdapterFragmentCallbacks { public class PcView extends Activity implements AdapterFragmentCallbacks {
private AdapterFragment adapterFragment;
private RelativeLayout noPcFoundLayout; private RelativeLayout noPcFoundLayout;
private PcGridAdapter pcGridAdapter; private PcGridAdapter pcGridAdapter;
private ComputerManagerService.ComputerManagerBinder managerBinder; private ComputerManagerService.ComputerManagerBinder managerBinder;
@@ -122,14 +121,9 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
} }
}); });
FragmentTransaction transaction = getFragmentManager().beginTransaction(); getFragmentManager().beginTransaction()
if (adapterFragment != null) { .replace(R.id.pcFragmentContainer, new AdapterFragment())
// Remove the old fragment .commitAllowingStateLoss();
transaction.remove(adapterFragment);
}
adapterFragment = new AdapterFragment();
transaction.add(R.id.pcFragmentContainer, adapterFragment);
transaction.commitAllowingStateLoss();
noPcFoundLayout = (RelativeLayout) findViewById(R.id.no_pc_found_layout); noPcFoundLayout = (RelativeLayout) findViewById(R.id.no_pc_found_layout);
if (pcGridAdapter.getCount() == 0) { if (pcGridAdapter.getCount() == 0) {