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:com.sourceallies.android.zonebeacon.ZoneBeaconRobolectricSuite.java

/**
 * Helper for displaying a dialog fragment.
 *
 * @param fragment the fragment to display.
 * @return the fragment.//  w ww . ja  v a2s .c  o m
 */
public Fragment startDialogFragment(DialogFragment fragment) {
    FragmentActivity activity = Robolectric.buildActivity(RoboFragmentActivity.class).create().start().get();

    FragmentManager fragmentManager = activity.getSupportFragmentManager();
    fragment.show(fragmentManager, "fragment");

    setActivityToBeTornDown(activity);

    return fragment;
}

From source file:io.github.carlorodriguez.alarmon.PrefsFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.app_settings);

    getActivity().setTitle(R.string.app_settings);

    Preference.OnPreferenceChangeListener refreshListener = new Preference.OnPreferenceChangeListener() {
        @Override/*from   w  ww.j  a  va  2 s. c  om*/
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            // Clear the lock screen text if the user disables the feature.
            if (preference.getKey().equals(AppSettings.LOCK_SCREEN)) {
                clearLockScreenText(getActivity());

                final String custom_lock_screen = getResources().getStringArray(R.array.lock_screen_values)[4];
                if (newValue.equals(custom_lock_screen)) {
                    DialogFragment dialog = new ActivityDialogFragment().newInstance(CUSTOM_LOCK_SCREEN);
                    dialog.show(getFragmentManager(), "ActivityDialogFragment");
                }
            }

            final Intent causeRefresh = new Intent(getActivity(), AlarmClockService.class);
            causeRefresh.putExtra(AlarmClockService.COMMAND_EXTRA,
                    AlarmClockService.COMMAND_NOTIFICATION_REFRESH);
            getActivity().startService(causeRefresh);
            return true;
        }
    };

    // Refresh the notification icon when the user changes these preferences.
    final Preference notification_icon = findPreference(AppSettings.NOTIFICATION_ICON);
    notification_icon.setOnPreferenceChangeListener(refreshListener);
    final Preference lock_screen = findPreference(AppSettings.LOCK_SCREEN);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getPreferenceScreen().removePreference(lock_screen);
    } else {
        lock_screen.setOnPreferenceChangeListener(refreshListener);
    }

    final Preference appTheme = findPreference(AppSettings.APP_THEME_KEY);

    appTheme.setOnPreferenceChangeListener(this);

    if (!BuildConfig.DEBUG) {
        getPreferenceScreen().removePreference(findPreference(AppSettings.DEBUG_MODE));
    }

    findPreference(AppSettings.NOTIFICATION_TEXT).setOnPreferenceChangeListener(this);

    findPreference(getString(R.string.settings_about_key)).setOnPreferenceClickListener(this);
}

From source file:com.semfapp.adamdilger.semf.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.menu_user_profile) {
        Intent i = new Intent(getApplicationContext(), userProfileActivity.class);
        startActivity(i);//from w  w w . ja va  2s  .  c o m
        return true;
    }

    if (id == R.id.menu_more_info) {
        DialogFragment dialog = new MoreInfoDialog();
        dialog.show(getSupportFragmentManager(), "tag");
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.sdrtouch.rtlsdr.StreamActivity.java

public void showDialog(final DialogManager.dialogs id, final String... args) {

    final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    final Fragment prev = getSupportFragmentManager().findFragmentByTag("dialog");
    if (prev != null) {
        ft.remove(prev);//ww  w . j  a va 2 s  . com
    }
    ft.addToBackStack(null);

    // Create and show the dialog.
    final DialogFragment newFragment = DialogManager.invokeDialog(id, args);
    try {
        newFragment.show(ft, "dialog");
    } catch (Throwable t) {
        t.printStackTrace();
    }
}

From source file:com.cerema.cloud2.ui.activity.ShareActivity.java

/**
 * Updates the view associated to the activity after the finish of some operation over files
 * in the current account.//from   ww  w  .j  a v  a2  s  . c om
 *
 * @param operation Removal operation performed.
 * @param result    Result of the removal.
 */
@Override
public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
    super.onRemoteOperationFinish(operation, result);

    if (result.isSuccess() || (operation instanceof GetSharesForFileOperation
            && result.getCode() == RemoteOperationResult.ResultCode.SHARE_NOT_FOUND)) {
        Log_OC.d(TAG, "Refreshing view on successful operation or finished refresh");
        refreshSharesFromStorageManager();
    }

    if (operation instanceof CreateShareViaLinkOperation && result.isSuccess()) {
        // Send link to the app
        String link = ((OCShare) (result.getData().get(0))).getShareLink();
        Log_OC.d(TAG, "Share link = " + link);

        Intent intentToShareLink = new Intent(Intent.ACTION_SEND);
        intentToShareLink.putExtra(Intent.EXTRA_TEXT, link);
        intentToShareLink.setType("text/plain");
        String[] packagesToExclude = new String[] { getPackageName() };
        DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intentToShareLink, packagesToExclude);
        chooserDialog.show(getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
    }

    if (operation instanceof UnshareOperation && result.isSuccess() && getEditShareFragment() != null) {
        getSupportFragmentManager().popBackStack();
    }

    if (operation instanceof UpdateSharePermissionsOperation && getEditShareFragment() != null
            && getEditShareFragment().isAdded()) {
        getEditShareFragment().onUpdateSharePermissionsFinished(result);
    }

}

From source file:com.enadein.carlogbook.core.CarLogbookMediator.java

public void showConfirmDeleteView() {
    DialogFragment confirmDeleteDialog = ConfirmDialog.newInstance();
    confirmDeleteDialog.show(activity.getSupportFragmentManager(), CONFIRM_DELETE);
}

From source file:com.techjoynt.android.nxt.fragment.NXTFragment.java

private void findBrick() {
    DialogFragment fragment = new NXTSelectionFragment();
    fragment.show(getFragmentManager(), "findBrick");
}

From source file:de.stkl.gbgvertretungsplan.fragments.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    /*/*from  ww  w .j a v  a 2s  .  c o  m*/
            mSpinnerList = new ArrayList<String>();
            mSpinnerList.add(getString(R.string.action_spinner_mainview_today));
            mSpinnerList.add(getString(R.string.action_spinner_mainview_tomorrow));
            mSpinnerAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_dropdown_item, mSpinnerList);
    */

    View rootView = inflater.inflate(R.layout.fragment_about, container, false).getRootView();

    final Resources res = getResources();
    String[] titles = res.getStringArray(R.array.about_item_titles);
    String[] summaries = res.getStringArray(R.array.about_item_summaries);

    if (titles.length == summaries.length) {
        for (int i = 0; i < titles.length; i++) {
            // format string
            switch (i) {
            // copyright and app information
            case 0:
                try {
                    titles[i] = String.format(titles[i], getString(R.string.app_name), getActivity()
                            .getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName);
                } catch (PackageManager.NameNotFoundException e) {
                    e.printStackTrace();
                }
                break;
            }

            View aboutItem = inflater.inflate(R.layout.item_about, (ViewGroup) rootView, false);
            ((TextView) aboutItem.findViewById(R.id.title)).setText(titles[i]);
            if (!summaries[i].equals(""))
                ((TextView) aboutItem.findViewById(R.id.summary)).setText(summaries[i]);
            else {
                View v = aboutItem.findViewById(R.id.summary);
                ((ViewGroup) v.getParent()).removeView(v);
            }

            // assign onclick handler
            switch (i) {
            // terms of use
            case 1:
                aboutItem.findViewById(R.id.container).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        DialogFragment newFragment = null;
                        newFragment = new PopupDialog(
                                Util.convertStreamToString(res.openRawResource(R.raw.tos)));
                        newFragment.show(getActivity().getSupportFragmentManager(), "tos");
                    }
                });
                break;
            // open source licenses
            case 2:
                aboutItem.findViewById(R.id.container).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        DialogFragment newFragment = null;
                        newFragment = new PopupDialog(
                                Util.convertStreamToString(res.openRawResource(R.raw.licenses)));
                        newFragment.show(getActivity().getSupportFragmentManager(), "license");
                    }
                });
                break;
            }

            ((ViewGroup) rootView).addView(aboutItem);
        }
    }
    return rootView;
}

From source file:com.wordpress.ebc81.rtl_ais_android.StreamActivity.java

public void showDialog(final DialogManager.dialogs id, final String... args) {

    final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    final Fragment prev = getSupportFragmentManager().findFragmentByTag("dialog");
    if (prev != null) {
        ft.remove(prev);/*from ww  w. ja  va2  s  .c  om*/
    }
    ft.addToBackStack(null);

    // Create and show the dialog.
    final DialogFragment newFragment = DialogManager.invokeDialog(id, args);
    try {
        newFragment.show(ft, "dialog");
    } catch (Throwable t) {
        t.printStackTrace();
    }
    ;
}

From source file:com.secretparty.app.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    SharedPreferences prefs = this.getPreferences(MODE_PRIVATE);

    thematicRepo = ((SecretPartyApplication) getApplication()).getThematicRepository();
    api = ((SecretPartyApplication) getApplication()).getApiService();

    //TODO : check if thematics are in the database. If so, launch a ThematicFragment. Otherwise, download them, save them to the db and launch TheamticFragment

    int userId = prefs.getInt(getString(R.string.SP_user_id), -1);
    int partyId = prefs.getInt(getString(R.string.SP_party_id), -1);
    long partyEnd = prefs.getLong(getString(R.string.SP_date_party_end), -1);
    Log.v("creation", new Date(partyEnd).toLocaleString() + "");
    api.listThematics(new OnReceivedThematics());

    if (userId == -1) {
        DialogFragment df = new UserCreationDialog();
        df.setCancelable(false);/*from  ww w .  j  av  a  2s  . com*/
        df.show(getSupportFragmentManager(), "dialog");
    }
}