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();
getFragmentManager().beginTransaction()
.add(R.id.appFragmentContainer, new AdapterFragment()).commitAllowingStateLoss();
.replace(R.id.appFragmentContainer, new AdapterFragment())
.commitAllowingStateLoss();
}
}.start();
}

View File

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