mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-21 03:52:48 +00:00
Remove the old fragment when adding the new one
This commit is contained in:
parent
cba44b091b
commit
4d24c654b9
@ -25,6 +25,7 @@ import com.limelight.utils.Dialog;
|
||||
import com.limelight.utils.UiHelper;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.app.Service;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
@ -51,6 +52,7 @@ 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;
|
||||
@ -123,8 +125,14 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
|
||||
}
|
||||
});
|
||||
|
||||
getFragmentManager().beginTransaction()
|
||||
.add(R.id.pcFragmentContainer, new AdapterFragment()).commitAllowingStateLoss();
|
||||
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();
|
||||
|
||||
noPcFoundLayout = (RelativeLayout) findViewById(R.id.no_pc_found_layout);
|
||||
if (pcGridAdapter.getCount() == 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user