Example usage for android.support.v4.app DialogFragment show

List of usage examples for android.support.v4.app DialogFragment show

Introduction

In this page you can find the example usage for android.support.v4.app DialogFragment show.

Prototype

public int show(FragmentTransaction transaction, String tag) 

Source Link

Document

Display the dialog, adding the fragment using an existing transaction and then committing the transaction.

Usage

From source file:de.eidottermihi.rpicheck.activity.CustomCommandActivity.java

private void parseNonPromptingAndShow(String keyPassphrase, CommandBean command) {
    final DialogFragment runCommandDialog = new RunCommandDialog();
    final Bundle args = new Bundle();
    String cmdString = command.getCommand();
    Map<String, String> nonPromptingPlaceholders = parseNonPromptingPlaceholders(command.getCommand(),
            currentDevice);/*  w  ww  . ja va  2  s.  co m*/
    for (Map.Entry<String, String> entry : nonPromptingPlaceholders.entrySet()) {
        cmdString = cmdString.replace(entry.getKey(), entry.getValue());
    }
    command.setCommand(cmdString);
    args.putSerializable("pi", currentDevice);
    args.putSerializable("cmd", command);
    if (keyPassphrase != null) {
        args.putString("passphrase", keyPassphrase);
    }
    runCommandDialog.setArguments(args);
    runCommandDialog.show(getSupportFragmentManager(), "runCommand");
}

From source file:jp.kyuuki.rensou.android.activity.BaseActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    FragmentManager manager = getSupportFragmentManager();
    DialogFragment dialog;

    Intent intent;/*w  w w  . ja v  a 2s  .  co m*/

    switch (item.getItemId()) {
    case R.id.action_ranking:
        // ?
        EasyTracker.getTracker().sendEvent(Analysis.GA_EC_UI_ACTION, Analysis.GA_EA_MENU_RANKING, null, null);
        intent = new Intent(this, RankingActivity.class);
        startActivity(intent);
        return true;
    case R.id.action_about:
        EasyTracker.getTracker().sendEvent(Analysis.GA_EC_UI_ACTION, Analysis.GA_EA_MENU_ABOUT, null, null);
        // ????
        //            AlertDialog.Builder ab = new AlertDialog.Builder(this);
        //            AlertDialog ad = ab.create();
        //            ad.setTitle(getString(R.string.action_about));
        //            ad.setMessage(getString(R.string.app_name) + " " + versionName);
        //            ad.show();
        dialog = new AboutDialogFragment();
        dialog.show(manager, "dialog");
        return true;
    case R.id.action_license:
        dialog = new LicenseInfomationDialogFragment();
        dialog.show(manager, "dialog");
        return true;
    case R.id.action_request:
        intent = new Intent();
        intent.setAction(Intent.ACTION_SENDTO);
        intent.setData(Uri.parse("mailto:" + getString(R.string.request_email)));
        //intent.putExtra(Intent.EXTRA_EMAIL, new String[] {"kyuuki.japan+rensou@gmail.com"});
        intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.request_subject));
        intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.request_text, Utils.getVersionName(this),
                Build.VERSION.RELEASE, Build.MANUFACTURER + " " + Build.MODEL));
        startActivity(intent);
        return true;
    case R.id.action_debug:
        Intent i = new Intent(this, AboutActivity.class);
        startActivity(i);
        return true;
    }

    return false;
}

From source file:com.shurik.droidzebra.DroidZebra.java

void showDialog(DialogFragment dialog, String tag) {
    if (mActivityActive) {
        dialog.show(getSupportFragmentManager(), tag);
    }
}

From source file:edu.cmu.cylab.starslinger.view.MessagesFragment.java

protected void showHelp(String title, String msg) {
    Bundle args = new Bundle();
    args.putString(extra.RESID_TITLE, title);
    args.putString(extra.RESID_MSG, msg);
    DialogFragment newFragment = MessagesAlertDialogFragment.newInstance(BaseActivity.DIALOG_HELP, args);
    newFragment.show(getFragmentManager(), "dialog");
}

From source file:net.cloudpath.xpressconnect.screens.ScreenBase.java

public void showMyDialog(DialogFragment paramDialogFragment, String paramString) {
      if ((DialogFragment) getSupportFragmentManager().findFragmentByTag(paramString) != null) {
          Util.log(this.mLogger, "*** Dialog fragment already exists.  Won't show again.");
          return;
      }/*from  ww  w. jav a 2  s  . c om*/
      try {
          paramDialogFragment.show(getSupportFragmentManager(), paramString);
          return;
      } catch (IllegalStateException localIllegalStateException) {
          Util.log(this.mLogger,
                  "Illegal state exception while trying to create a dialog.  The activity was probably in the process of closing.");
      }
  }

From source file:edu.sfsu.csc780.chathub.ui.activities.MainActivity.java

void showPhotoDialog(DialogFragment dialogFragment) {
    // 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 = getSupportFragmentManager().beginTransaction();
    android.support.v4.app.Fragment prev = getSupportFragmentManager().findFragmentByTag("dialog");
    if (prev != null) {
        ft.remove(prev);//from w  ww . ja v  a  2s  .  c o m
    }
    ft.addToBackStack(null);

    dialogFragment.show(ft, "dialog");
}

From source file:com.jaymullen.TrailJournal.EntryActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Intent intent = getIntent();//from w ww.java 2s.co  m

    String title;
    if (intent.getData() != null) {
        mEntryUri = intent.getData();
        Cursor c = getContentResolver().query(mEntryUri, HomeActivity.Entries.PROJECTION, null, null,
                JournalEntry.DEFAULT_SORT);

        if (c.moveToFirst()) {
            title = c.getString(HomeActivity.Entries.DATE);

            setPostType(c.getString(HomeActivity.Entries.TYPE));

            mIsPublished = c.getInt(HomeActivity.Entries.IS_PUBLISHED) == 1;

            setValuesOnPages(c);
        } else {
            title = "New Entry";
            mIsPublished = false;
        }
        c.close();

    } else {
        title = "New Entry";
        ContentValues cv = new ContentValues();
        cv.put(JournalEntry.JOURNAL_ID, Auth.getInstance(this).getJournalId());
        cv.put(JournalEntry.IS_PUBLISHED, 0);
        mEntryUri = getContentResolver().insert(JournalEntry.CONTENT_URI, cv);
        getIntent().setData(mEntryUri);
        mIsPublished = false;
    }

    getSupportActionBar().setTitle(title);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    if (savedInstanceState != null) {
        mWizardModel.load(savedInstanceState.getBundle("model"));
    }

    mWizardModel.registerListener(this);

    mPagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);
    mStepPagerStrip = (StepPagerStrip) findViewById(R.id.strip);
    mStepPagerStrip.setOnPageSelectedListener(new StepPagerStrip.OnPageSelectedListener() {
        @Override
        public void onPageStripSelected(int position) {
            position = Math.min(mPagerAdapter.getCount() - 1, position);
            if (mPager.getCurrentItem() != position) {
                mPager.setCurrentItem(position);
            }
        }
    });

    mNextButton = (Button) findViewById(R.id.next_button);
    mPrevButton = (Button) findViewById(R.id.prev_button);
    mSaveButton = (Button) findViewById(R.id.save_button);

    mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            mStepPagerStrip.setCurrentPage(position);

            if (mConsumePageSelectedEvent) {
                mConsumePageSelectedEvent = false;
                return;
            }

            mEditingAfterReview = false;
            updateBottomBar();
        }
    });

    mNextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mPager.getCurrentItem() == mCurrentPageSequence.size()) {

                if (Auth.getInstance(EntryActivity.this).isLoggedIn()) {
                    DialogFragment dg = new DialogFragment() {
                        @Override
                        public Dialog onCreateDialog(Bundle savedInstanceState) {
                            return new AlertDialog.Builder(getActivity())
                                    .setMessage(R.string.submit_confirm_message)
                                    .setPositiveButton(R.string.submit_confirm_button, mPublishListener)
                                    .setNegativeButton(android.R.string.cancel, null).create();
                        }
                    };
                    dg.show(getSupportFragmentManager(), "publish_entry_dialog");
                } else {
                    DialogFragment dg = new DialogFragment() {
                        @Override
                        public Dialog onCreateDialog(Bundle savedInstanceState) {
                            return new AlertDialog.Builder(getActivity())
                                    .setMessage(R.string.login_required_login)
                                    .setPositiveButton(R.string.login_confirm_button, mLoginListener)
                                    .setNegativeButton(android.R.string.cancel, null).create();
                        }
                    };
                    dg.show(getSupportFragmentManager(), "publish_entry_dialog");
                }
            } else {
                if (mEditingAfterReview) {
                    mPager.setCurrentItem(mPagerAdapter.getCount() - 1);
                } else {
                    mPager.setCurrentItem(mPager.getCurrentItem() + 1);
                }
            }
        }
    });

    mPrevButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mPager.setCurrentItem(mPager.getCurrentItem() - 1);
        }
    });

    mSaveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            saveEntry();
        }
    });

    onPageTreeChanged();

    if (intent.getAction() == Intent.ACTION_EDIT) {
        mPager.setCurrentItem(mPagerAdapter.getCount() - 1);
    }

    updateBottomBar();
}

From source file:co.uk.socialticker.ticker.TickerActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    // action with ID action_refresh was selected
    /*case R.id.settings:
    openSettings();/*w  w  w  .  ja v  a2s .  co  m*/
    break;
    case R.id.twitter:
    startActivity(new Intent(this,TwitterActivity.class));
    break;*/
    case R.id.menu_twitter_update:
        DialogFragment newFragment = new TwitterUpdateDialogFragment();
        Bundle args = new Bundle();
        newFragment.setArguments(args);
        newFragment.show(getSupportFragmentManager(), "sendTweet");
        break;
    case R.id.menu_twitter_logout:
        logoutFromTwitter();
        break;
    default:
        break;
    }
    return true;
}

From source file:com.topfeeds4j.sample.app.activities.MainActivity.java

/**
 * Show  {@link android.support.v4.app.DialogFragment}.
 *
 * @param dlgFrg//  w w  w.  j  a  v  a2  s  .  com
 *       An instance of {@link android.support.v4.app.DialogFragment}.
 * @param tagName
 *       Tag name for dialog, default is "dlg". To grantee that only one instance of {@link android.support.v4.app.DialogFragment} can been seen.
 */
private void showDialogFragment(DialogFragment dlgFrg, String tagName) {
    try {
        if (dlgFrg != null) {
            DialogFragment dialogFragment = dlgFrg;
            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            // Ensure that there's only one dialog to the user.
            Fragment prev = getSupportFragmentManager().findFragmentByTag("dlg");
            if (prev != null) {
                ft.remove(prev);
            }
            try {
                if (TextUtils.isEmpty(tagName)) {
                    dialogFragment.show(ft, "dlg");
                } else {
                    dialogFragment.show(ft, tagName);
                }
            } catch (Exception _e) {
            }
        }
    } catch (Exception _e) {
    }
}

From source file:com.quarterfull.newsAndroid.NewsReaderListActivity.java

@Override
public boolean onLongClick(ViewHolder vh, int position) {
    RssItem rssItem = vh.getRssItem();/*from  www  .j ava2s .c  o m*/
    DialogFragment newFragment = NewsDetailImageDialogFragment.newInstanceUrl(rssItem.getTitle(),
            rssItem.getLink());
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    Fragment prev = getSupportFragmentManager().findFragmentByTag("menu_fragment_dialog");
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);
    newFragment.show(ft, "menu_fragment_dialog");
    return true;
}