Example usage for android.app FragmentTransaction remove

List of usage examples for android.app FragmentTransaction remove

Introduction

In this page you can find the example usage for android.app FragmentTransaction remove.

Prototype

public abstract FragmentTransaction remove(Fragment fragment);

Source Link

Document

Remove an existing fragment.

Usage

From source file:dtu.ds.warnme.app.activity.MainActivity.java

@Override
public void onApproachingEvent(Event event) {
    if (warningDialog != null && event.equals(warningDialog.getEvent())) {
        return;//from   w w w  . j  ava  2s  . co  m
    }

    if (alreadyWarned.contains(event)) {
        return;
    }
    alreadyWarned.add(event);

    if (warningDialog != null) {
        warningDialog.dismiss();
    }

    FragmentTransaction ft = getFragmentManager().beginTransaction();
    Fragment prev = getFragmentManager().findFragmentByTag(LoginDialog.class.getName());
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);

    Bundle args = new Bundle();
    args.putSerializable(KEY_EVENT, event);

    warningDialog = new WarningDialog();
    warningDialog.setEvent(event);
    warningDialog.setArguments(args);
    warningDialog.show(ft, WarningDialog.class.getName());
}

From source file:com.rubixconsulting.walletcracker.WalletCrackerMain.java

private void showError(Integer messageId) {
    if ((messageId == null) || (messageId == 0)) {
        Log.i(TAG, "Not showing invalid error");
        return;//from   w  ww .  j ava 2  s.co  m
    }

    Log.e(TAG, "Error: " + getString(messageId));

    FragmentTransaction ft = getFragmentManager().beginTransaction();

    // remove any previous error fragments
    Fragment prev = getFragmentManager().findFragmentByTag(ErrorDialogFragment.TAG);
    if (prev != null) {
        ft.remove(prev);
    }

    // add the new error
    ft.addToBackStack(null);
    ErrorDialogFragment fragment = ErrorDialogFragment.newInstance(messageId);
    fragment.show(ft, ErrorDialogFragment.TAG);

    // see note about this in showProgress
    getFragmentManager().executePendingTransactions();
}

From source file:dtu.ds.warnme.app.activity.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_login) {
        Log.d(TAG, "Showing login dialog...");

        FragmentTransaction ft = getFragmentManager().beginTransaction();
        Fragment prev = getFragmentManager().findFragmentByTag(LoginDialog.class.getName());
        if (prev != null) {
            ft.remove(prev);
        }/*from   ww  w .j a va2 s . co  m*/
        ft.addToBackStack(null);

        LoginDialog ld = new LoginDialog();
        ld.show(ft, LoginDialog.class.getName());
        return true;
    }
    if (id == R.id.action_register) {
        Log.d(TAG, "Showing register dialog...");

        FragmentTransaction ft = getFragmentManager().beginTransaction();
        Fragment prev = getFragmentManager().findFragmentByTag(RegisterDialog.class.getName());
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);

        RegisterDialog rd = new RegisterDialog();
        rd.show(ft, RegisterDialog.class.getName());
        return true;
    }
    if (id == R.id.action_logout) {
        Log.d(TAG, "Logging out...");

        UserProfileHolder.clear();
        Prefs.setUsername(StringUtils.EMPTY);
        Prefs.setPasswordHash(StringUtils.EMPTY);

        updateUserInterface();
        return true;
    }
    if (id == R.id.action_settings) {
        Log.d(TAG, "Moving to Settings activity...");

        Intent settingsActivityIntent = new Intent(this, SettingsActivity.class);
        startActivity(settingsActivityIntent);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:dtu.ds.warnme.app.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
    map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    map.setMyLocationEnabled(true);/*from   w  w  w . j av a 2 s.  co m*/
    map.getUiSettings().setAllGesturesEnabled(true);
    map.getUiSettings().setCompassEnabled(true);

    locationSource = new FollowMeLocationSource(this, getApplicationContext(), map);
    locationSource.getBestAvailableProvider();
    map.setLocationSource(locationSource);

    buttonReport = (Button) findViewById(R.id.button_report);
    buttonReport.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            buttonReport.setEnabled(false);

            FragmentTransaction ft = getFragmentManager().beginTransaction();
            Fragment prev = getFragmentManager().findFragmentByTag(ReportDialog.class.getName());
            if (prev != null) {
                ft.remove(prev);
            }
            ft.addToBackStack(null);

            Bundle args = new Bundle();
            args.putParcelable(KEY_CURRENT_LOCATION, locationSource.getCurrentLocation());

            ReportDialog reportDialog = new ReportDialog();
            reportDialog.setArguments(args);
            reportDialog.show(ft, ReportDialog.class.getName());
        }
    });

    verifyLogin();
}

From source file:com.ffmpeger.card.MainNativeActivity.java

private void openDialogFragment(DialogFragment dialogStandardFragment) {
    if (dialogStandardFragment != null) {
        FragmentManager fm = getFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        Fragment prev = fm.findFragmentByTag("carddemo_dialog");
        if (prev != null) {
            ft.remove(prev);
        }/*from  ww  w  .ja  va2 s.  com*/
        //ft.addToBackStack(null);

        dialogStandardFragment.show(ft, "carddemo_dialog");
    }
}

From source file:com.jlabs.peepaid.searchviewlay.SearchViewLayout.java

private void hideContentFragment() {
    if (mFragmentManager != null) {
        final android.app.FragmentTransaction transaction = mFragmentManager.beginTransaction();
        transaction.remove(mExpandedContentFragment).commit();
    } else if (mSupportFragmentManager != null) {
        final android.support.v4.app.FragmentTransaction transaction = mSupportFragmentManager
                .beginTransaction();/*  w w w  .  j  a  va  2  s  .  com*/
        transaction.remove(mExpandedContentSupportFragment).commit();
    } else {
        Log.e(LOG_TAG, "Fragment Manager is null. Returning");
    }
}

From source file:com.android.mail.ui.TwoPaneController.java

@Override
protected void hideWaitForInitialization() {
    final WaitFragment waitFragment = getWaitFragment();
    if (waitFragment == null) {
        // We aren't showing a wait fragment: nothing to do
        return;//www .j  a v  a 2s.c om
    }
    // Remove the existing wait fragment from the back stack.
    final FragmentTransaction fragmentTransaction = mActivity.getFragmentManager().beginTransaction();
    fragmentTransaction.remove(waitFragment);
    fragmentTransaction.commitAllowingStateLoss();
    super.hideWaitForInitialization();
    if (mViewMode.isWaitingForSync()) {
        // We should come out of wait mode and display the account inbox.
        loadAccountInbox();
    }
}

From source file:io.coldstart.android.TrapListActivity.java

public void ShowRegisterDialog() {
    if (dialogFragment != null)
        dialogFragment.dismiss();//from  ww  w .  j  av  a 2  s  .c  o  m

    FragmentTransaction ft = getFragmentManager().beginTransaction();
    Fragment prev = getFragmentManager().findFragmentByTag("dialog");
    if (prev != null) {
        ft.remove(prev);
        Log.i("prev", "Removing");
    }
    ft.addToBackStack(null);

    // Create and show the dialog.
    dialogFragment = StartupRegisterDialog.newInstance(GCMRegistrar.getRegistrationId(this));
    dialogFragment.setCancelable(true);
    dialogFragment.show(ft, "dialog");
}

From source file:io.coldstart.android.TrapListActivity.java

public void ShowLoginDialog() {
    if (dialogFragment != null)
        dialogFragment.dismiss();//from  ww  w .  j  a v  a 2 s  . c o m

    FragmentTransaction ft = getFragmentManager().beginTransaction();
    Fragment prev = getFragmentManager().findFragmentByTag("dialog");
    if (prev != null) {
        ft.remove(prev);
        Log.i("prev", "Removing");
    }
    ft.addToBackStack(null);

    // Create and show the dialog.
    dialogFragment = StartupLoginDialog.newInstance(GCMRegistrar.getRegistrationId(this));
    dialogFragment.setCancelable(true);
    dialogFragment.show(ft, "dialog");
}

From source file:io.coldstart.android.TrapListActivity.java

private void showChooseDialog() {
    if (dialogFragment != null) {
        dialogFragment.dismiss();//from  ww w.j  a v  a 2s .co m
    }

    // DialogFragment.show() will take care of adding the fragment
    // in a transaction.  We also want to remove any currently showing
    // dialog, so make our own transaction and take care of that here.
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    Fragment prev = getFragmentManager().findFragmentByTag("dialog");
    if (prev != null) {
        ft.remove(prev);
        Log.i("prev", "Removing");
    }
    ft.addToBackStack(null);

    // Create and show the dialog.
    //dialogFragment = StartupProcessDialog.newInstance(GCMRegistrar.getRegistrationId(this));
    dialogFragment = StartupChooseDialog.newInstance();
    dialogFragment.setCancelable(true);
    dialogFragment.show(ft, "dialog");
}