Example usage for android.app DialogFragment show

List of usage examples for android.app DialogFragment show

Introduction

In this page you can find the example usage for android.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:blackman.matt.infinitebrowser.InfinityBrowser.java

/**
 * Load a board using a variety of logics.
 *//*from   w  ww. j a v a2s . c o  m*/
private void loadUpABoard() {
    // Load preferences for activity
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    Boolean ageAccept = preferences.getBoolean("age_guard_accept", false);

    // Checks if age guard has been accepted
    if (!ageAccept) {
        DialogFragment ageGuardDialog = new AgeGuardDialogFragment();
        ageGuardDialog.show(getFragmentManager(), "ageGuardDialog");

    } else {
        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

        Board newBoard;
        Intent intent = getIntent();
        String defaultBoard = preferences.getString("default_board", "").toLowerCase();

        if (intent.getData() != null || intent.getExtras() != null) {
            newBoard = loadFromIntent(intent);

        } else if (!defaultBoard.equals("")) {
            newBoard = Board.newInstance(defaultBoard);
            mTitle = "/" + defaultBoard.toLowerCase() + "/";

        } else {
            newBoard = getFirstDrawerItem();

        }
        if (newBoard != null) {
            fragmentTransaction.replace(R.id.container, newBoard, mTitle.toString());
            findViewById(R.id.ll_help_add_boards).setVisibility(View.GONE);
            setTitle(mTitle);

        }
        fragmentTransaction.commit();
    }
}

From source file:com.digitalobstaclecourse.bluefinder.FindCar.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_find_car, menu);
    MenuItem _menuItemAction = menu.findItem(R.id.menu_ammo);
    View actionView = null;/*from  w  ww .j  a  v a2  s . com*/
    if (_menuItemAction != null) {
        actionView = _menuItemAction.getActionView();
    } else {
        //Log.e(TAG, "getActionView()");
    }
    assert actionView != null;
    mActionView = actionView;
    actionView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            //Log.d(TAG, "onclick actionView");
            if (get_data_access().hasPurchasedInfiniteUse()) {
                Toast.makeText(getApplicationContext(),
                        "No need to purchase anything else; you already own infinite uses", Toast.LENGTH_LONG)
                        .show();
            } else {
                DialogFragment newFragment = new BuyInAppDialogFragment();
                newFragment.show(getFragmentManager(), "miss");
            }
        }
    });
    TextView uses_remaining_textview = (TextView) actionView.findViewById(R.id.uses_remaining);
    if (hasInfiniteLicense()) {
        actionView.findViewById(R.id.infinity_icon).setVisibility(View.VISIBLE);
        uses_remaining_textview.setVisibility(View.INVISIBLE);
        uses_remaining_textview.setText(String.format("\u00ec"));
    } else {
        actionView.findViewById(R.id.infinity_icon).setVisibility(View.INVISIBLE);
        uses_remaining_textview.setVisibility(View.VISIBLE);
        int remaining_locations = getUsesRemaining();
        uses_remaining_textview.setText(String.format("%d", remaining_locations));
    }
    return true;
}

From source file:org.jmpm.ethbadge.MainActivity.java

public void runDialogPassword() {
    DialogFragment dialog = new DialogPassword();
    Bundle args = new Bundle();
    if (GlobalAppSettings.getInstance().usingDefaultSettings()) {
        args.putString("message",
                "WARNING: Your private key will be stored using this password. Choose a robust one!");
    }//from w w  w .ja v a 2s. co  m
    dialog.setArguments(args);
    dialog.show(getFragmentManager(), "DialogPassword");
}

From source file:no.hiof.anl.laundrybooking.MainActivity.java

@Override
protected void onResume() {
    super.onResume();
    boolean isFirstTimeOpenApp = settings.getBoolean("isFirstTimeOpenApp", true);

    if (isFirstTimeOpenApp) {
        messages = new ArrayList<>();
        updateMessages();//from   w  ww.  j a v  a  2s .c  o  m
        DialogFragment loginDialog = new LoginDialog();
        loginDialog.show(getFragmentManager(), "Fisrt Time Using");
        loginDialog.setCancelable(false);
    } else {
        int user_pin = settings.getInt("userPin", 0);
        //String json = settings.getString("userInfo", null);
        //
        current_user = Database.getUserByPin(user_pin);
        setDrawerUserInfo();
        displayUserInfo();

        String json = settings.getString("messages", null);
        //Log.i("Messages", json);
        Gson gson = new Gson();
        Type collectionType = new TypeToken<ArrayList<Info>>() {
        }.getType();
        messages = gson.fromJson(json, collectionType);
        updateMessages();
        displayUserInfo();
    }

}

From source file:se.leap.bitmaskclient.ConfigurationWizard.java

/**
 * Once selected a provider, this fragment offers the user to log in,
 * use it anonymously (if possible)/*  www  .j ava2 s  .c o  m*/
 * or cancel his/her election pressing the back button.
 *
 * @param view
 */
private void showProviderDetails() {
    if (setting_up_provider) {
        FragmentTransaction fragment_transaction = fragment_manager
                .removePreviousFragment(ProviderDetailFragment.TAG);

        DialogFragment newFragment = ProviderDetailFragment.newInstance();
        newFragment.show(fragment_transaction, ProviderDetailFragment.TAG);
        setting_up_provider = false;
    }
}

From source file:se.leap.bitmaskclient.ConfigurationWizard.java

/**
 * Once selected a provider, this fragment offers the user to log in,
 * use it anonymously (if possible)//from  w w w.  j  a  v  a 2s. c  o m
 * or cancel his/her election pressing the back button.
 *
 * @param reason_to_fail
 */
public void showDownloadFailedDialog(String reason_to_fail) {
    FragmentTransaction fragment_transaction = fragment_manager
            .removePreviousFragment(DownloadFailedDialog.TAG);

    DialogFragment newFragment = DownloadFailedDialog.newInstance(reason_to_fail);
    newFragment.show(fragment_transaction, DownloadFailedDialog.TAG);
}

From source file:com.ogunwale.android.app.yaps.ui.PhotosActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    mSourceSelection = SettingsManager.getInstance(getApplicationContext()).getAlbumSelection();

    setContentView(R.layout.activity_photos);

    // Set-up cursor adapter
    mAdapter = new PhotosSimpleCursorAdapter(this);

    // Set-up thumbnail grid
    mGridView = (TwoWayGridView) findViewById(R.id.photo_gridview);
    mGridView.setAdapter(mAdapter);/*from w  w  w  .  j  ava  2  s  .c o  m*/
    mGridView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(TwoWayAdapterView<?> parent, View view, int position, long id) {
            Cursor cursor = mAdapter.getCursor();
            if (cursor.moveToPosition(position)) {
                DialogFragment df = TransferDialogFragment.newInstance(cursor, id);
                df.show(getFragmentManager(), "transfer_dialog");
            } else {
                Log.e(sTAG, "Can not move cursor to: " + position);
            }
        }
    });

    // Prepare the database loader.
    getLoaderManager().initLoader(0, null, this);

    // Register for local broadcasts
    IntentFilter iFilter = new IntentFilter();
    iFilter.addAction(Extras.ACTION_SET_PHOTO_SOURCE_FACEBOOK);
    iFilter.addAction(Extras.ACTION_SET_PHOTO_SOURCE_PICASA);
    iFilter.addAction(Extras.ACTION_REMOTE_ALBUM_REQUEST_COMPLETE);
    LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(mLocalBroadcastReceiver,
            iFilter);
}

From source file:de.uulm.graphicalpasswords.openuyi.UYICreatePasswordActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_uyi_create_password);
    // Show the Up button in the action bar.
    setupActionBar();//  www . j  a  va2s .c o  m

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    length = Integer.parseInt(sharedPref.getString("uyi_length", "10"));

    originalViews = new ImageView[length];
    distortedViews = new ImageView[length];
    selectedPictures = new Picture[length];

    Bundle bundle = new Bundle();
    bundle.putInt("length", length);
    DialogFragment intro = new IntroDialogFragment();
    intro.setArguments(bundle);
    intro.show(getFragmentManager(), "intro");

    vibrator = (Vibrator) this.getSystemService(VIBRATOR_SERVICE);

    Arrays.fill(selectedPictures, null);

    gallery = (Gallery) findViewById(R.id.uyi_gallery_originals);
    gallery.setAdapter(new UYIImageAdapter(this));

    gallery.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            ImageView viewOriginal = new ImageView(UYICreatePasswordActivity.this);
            ImageView viewDistorted = new ImageView(UYICreatePasswordActivity.this);

            int i = 0;
            for (; i < selectedPictures.length; i++) {
                if (i == selectedPictures.length - 1 && selectedPictures[i] != null) {
                    removePicture(i);
                }
                if (selectedPictures[i] == null || i == selectedPictures.length - 1) {
                    viewOriginal = originalViews[i];
                    viewDistorted = distortedViews[i];
                    selectedPictures[i] = ((UYIImageAdapter) parent.getAdapter()).getPicture(position);
                    vibrator.vibrate(100);

                    ScrollView sv = (ScrollView) findViewById(R.id.uyi_choosepi_scrollview);
                    int height = originalViews[0].getMeasuredHeight();
                    sv.scrollTo(0, (i * height) - 200);

                    break;
                }
            }

            int originalImageResource = ((UYIImageAdapter) parent.getAdapter()).getImageResource(position);
            viewOriginal.setImageResource(originalImageResource);
            viewDistorted.setImageResource(
                    ((UYIImageAdapter) parent.getAdapter()).getDistortedImageResource(position));
            ((UYIImageAdapter) parent.getAdapter()).removePicture(position);

            OnLongClickListener listener = new OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    vibrator.vibrate(200);
                    int viewid = v.getId();
                    int index = -1;

                    for (int i = 0; i < originalViews.length; i++) {
                        if (originalViews[i].getId() == viewid) {
                            index = i;
                            break;
                        } else if (distortedViews[i].getId() == viewid) {
                            index = i;
                            break;
                        }
                    }
                    Bundle bundle = new Bundle();
                    bundle.putInt("index", index);
                    DialogFragment dialog = new DeleteImageDialogFragment();
                    dialog.setArguments(bundle);
                    dialog.show(getFragmentManager(), "delete");
                    return false;
                }
            };

            viewOriginal.setOnLongClickListener(listener);
            viewDistorted.setOnLongClickListener(listener);

            // Check
            int count = 0;
            for (int j = 0; j < selectedPictures.length; j++) {
                if (selectedPictures[j] != null) {
                    count++;
                }
            }
            if (count == selectedPictures.length) {
                findViewById(R.id.uyi_save).setClickable(true);
                findViewById(R.id.uyi_save).setEnabled(true);
            }
        }
    });

    table = (TableLayout) findViewById(R.id.uyi_choosepi_tablelayout);
    LayoutParams params = new LayoutParams(android.widget.TableRow.LayoutParams.WRAP_CONTENT,
            android.widget.TableRow.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.CENTER;
    for (int i = 0; i < length; i++) {
        TableRow row = new TableRow(table.getContext());

        originalViews[i] = new ImageView(row.getContext());
        originalViews[i].setAdjustViewBounds(true);
        originalViews[i].setScaleType(ScaleType.FIT_XY);
        originalViews[i].setPadding(3, 3, 3, 3);
        originalViews[i].setImageResource(R.drawable.oempty);
        originalViews[i].setId(100 + i);

        distortedViews[i] = new ImageView(row.getContext());
        distortedViews[i].setAdjustViewBounds(true);
        distortedViews[i].setScaleType(ScaleType.FIT_XY);
        distortedViews[i].setPadding(3, 3, 3, 3);
        distortedViews[i].setImageResource(R.drawable.wempty);
        distortedViews[i].setId(1000 + i);

        ImageView arrow = new ImageView(row.getContext());
        arrow.setAdjustViewBounds(true);
        arrow.setScaleType(ScaleType.FIT_XY);
        arrow.setMaxWidth(80);
        arrow.setPadding(3, 3, 3, 3);
        arrow.setImageResource(R.drawable.arrow_active);
        arrow.setLayoutParams(params);

        row.addView(originalViews[i]);
        row.addView(arrow);
        row.addView(distortedViews[i]);
        table.addView(row);
    }
}

From source file:org.dharmaseed.android.PlayTalkActivity.java

public void onDeleteTalkClicked(View view) {
    DialogFragment dialog = new DeleteTalkFragment();
    dialog.show(getFragmentManager(), "DeleteTalkFragment");
}

From source file:com.hybris.mobile.activity.AbstractProductDetailActivity.java

/**
 * Show the reviews in a new activity//from w  w w.java2  s .c om
 * 
 * @param view
 */
public void showReviews(View view) {
    DialogFragment fragment = ReviewDialogFragment.newInstance(mProduct, this);
    fragment.show(getFragmentManager(), "review_fragment");
}