Example usage for android.app AlertDialog dismiss

List of usage examples for android.app AlertDialog dismiss

Introduction

In this page you can find the example usage for android.app AlertDialog dismiss.

Prototype

@Override
public void dismiss() 

Source Link

Document

Dismiss this dialog, removing it from the screen.

Usage

From source file:io.github.msc42.masterthemaze.GameActivity.java

private void closeAllAlertDialogs() {
    for (AlertDialog alertDialog : mCausedByHandlerDialogsWhichCallFinish) {
        if (alertDialog != null) {
            alertDialog.dismiss();
        }// www.ja v a2 s  .c o m
    }
}

From source file:com.github.andrewlord1990.materialandroidsample.color.ColorChooserDialog.java

private View setupCustomView(final AlertDialog dialog) {
    Context context = dialog.getContext();
    View customView = LayoutInflater.from(context).inflate(R.layout.color_chooser, null);
    GridView grid = (GridView) customView.findViewById(R.id.colorChooserGrid);
    ColorGridAdapter adapter = new ColorGridAdapter(context, colors);
    grid.setAdapter(adapter);/*w  w  w . j a v a  2s  .  c om*/
    grid.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (listener != null) {
                listener.onColorSelected(requestCode, colors.get(position));
            }
            dialog.dismiss();
        }
    });
    return customView;
}

From source file:com.fa.mastodon.activity.LoginActivity.java

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

    if (PreferenceManager.getDefaultSharedPreferences(this).getString("theme_selection", "light")
            .equals("light")) {
        setTheme(R.style.AppTheme_Light);
    } else if (PreferenceManager.getDefaultSharedPreferences(this).getString("theme_selection", "light")
            .equals("black")) {
        setTheme(R.style.AppThemeAmoled);
    }/*from   ww w  . j  a v a  2  s .  c om*/

    setContentView(R.layout.activity_login);
    ButterKnife.bind(this);

    if (savedInstanceState != null) {
        domain = savedInstanceState.getString("domain");
        clientId = savedInstanceState.getString("clientId");
        clientSecret = savedInstanceState.getString("clientSecret");
    } else {
        domain = null;
        clientId = null;
        clientSecret = null;
    }

    preferences = getSharedPreferences(getString(R.string.preferences_file_key), Context.MODE_PRIVATE);

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onButtonClick(editText);
        }
    });

    final Context context = this;

    whatsAnInstance.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog dialog = new AlertDialog.Builder(context).setMessage(R.string.dialog_whats_an_instance)
                    .setPositiveButton(R.string.action_close, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    }).show();
            TextView textView = (TextView) dialog.findViewById(android.R.id.message);
            textView.setMovementMethod(LinkMovementMethod.getInstance());
        }
    });

    bp = new BillingProcessor(this, PublicValues.LICENSE_KEY, this);

    bp.loadOwnedPurchasesFromGoogle();
}

From source file:com.example.igorklimov.popularmoviesdemo.fragments.NoInternet.java

@Override
public void onStart() {
    super.onStart();
    final AlertDialog d = (AlertDialog) getDialog();
    if (d != null) {
        Button positiveButton = d.getButton(AlertDialog.BUTTON_POSITIVE);
        positiveButton.setOnClickListener(new View.OnClickListener() {
            @Override/*  w  w w . j a va 2s.c  o  m*/
            public void onClick(View v) {
                ConnectivityManager systemService = (ConnectivityManager) getActivity()
                        .getSystemService(Context.CONNECTIVITY_SERVICE);
                NetworkInfo activeNetworkInfo = systemService.getActiveNetworkInfo();
                if (activeNetworkInfo != null) {
                    if (getTag().equals("2"))
                        ((DetailFragment) getTargetFragment()).initLoader();
                    d.dismiss();
                }
            }
        });
    }
}

From source file:odoo.controls.OSelectionField.java

@Override
public void setValue(Object value) {
    mValue = value;//w w w  .  j a v a2s .c o m
    if (mValue == null || mValue.toString().equals("false")) {
        mValue = -1;
    }
    ODataRow row = new ODataRow();
    if (isEditable()) {
        if (mWidget != null) {
            switch (mWidget) {
            case RadioGroup:
                if (mResourceArray != -1) {
                    ((RadioButton) mRadioGroup.getChildAt(getPos())).setChecked(true);
                    row = items.get(getPos());
                } else {
                    Integer row_id;
                    if (mValue instanceof OM2ORecord) {
                        row = ((OM2ORecord) mValue).browse();
                        row_id = row.getInt(OColumn.ROW_ID);
                    } else
                        row_id = (Integer) mValue;
                    int index = 0;
                    for (int i = 0; i < items.size(); i++) {
                        if (items.get(i).getInt(OColumn.ROW_ID) == row_id) {
                            index = i;
                            break;
                        }
                    }
                    row = items.get(index);
                    ((RadioButton) mRadioGroup.getChildAt(index)).setChecked(true);
                }
                break;
            case Searchable:
            case SearchableLive:
            case SelectionDialog:
                if (mResourceArray != -1) {
                    row = items.get(getPos());
                } else {
                    if (mValue instanceof OM2ORecord)
                        row = ((OM2ORecord) mValue).browse();
                    else if (mValue instanceof Integer)
                        row = getRecordData((Integer) mValue);
                }
                if (row != null)
                    txvView.setText(row.getString(mModel.getDefaultNameColumn()));
                if (txvView.getTag() != null) {
                    AlertDialog dialog = (AlertDialog) txvView.getTag();
                    dialog.dismiss();
                }
                break;
            default:
                break;
            }
        } else {
            if (mResourceArray != -1) {
                mSpinner.setSelection(getPos());
                row = items.get(getPos());
            } else if (mCol.getType().isAssignableFrom(OSelection.class)) {
                int pos = getPos();
                mSpinner.setSelection(pos);
                if (pos != -1) {
                    row = mAdapter.getItem(pos);
                }
            } else {
                Integer row_id = null;
                if (mValue instanceof OM2ORecord) {
                    row = ((OM2ORecord) mValue).browse();
                    row_id = row.getInt(OColumn.ROW_ID);
                } else if (mValue instanceof Integer)
                    row_id = (Integer) mValue;
                int index = 0;
                for (int i = 0; i < items.size(); i++) {
                    if (items.get(i).getInt(OColumn.ROW_ID) == row_id) {
                        index = i;
                        break;
                    }
                }
                row = items.get(index);
                mSpinner.setSelection(index);
            }
        }
    } else {
        if (mResourceArray != -1 || mCol.getType().isAssignableFrom(OSelection.class)) {
            int position = getPos();
            // Ignoring if default value not set for field.
            if (position != -1)
                row = items.get(position);
        } else {
            if (mValue instanceof OM2ORecord) {
                row = ((OM2ORecord) mValue).browse();
                if (row == null) {
                    row = new ODataRow();
                }
            } else {
                if (!(mValue instanceof Boolean) && mValue != null && !mValue.toString().equals("false")) {
                    int row_id = (Integer) mValue;
                    row = getRecordData(row_id);
                } else {
                    row = new ODataRow();
                    row.put(mModel.getDefaultNameColumn(), "No " + mCol.getLabel() + " selected");
                }
            }
        }
        if (!row.getString(mModel.getDefaultNameColumn()).equals("false"))
            txvView.setText(row.getString(mModel.getDefaultNameColumn()));
    }
    if (isEditable() && mValueUpdateListener != null) {
        if (mValue instanceof Integer && (int) mValue == -1)
            return;
        mValueUpdateListener.onValueUpdate(row);
    }
}

From source file:com.ubuntuone.android.files.activity.StoreActivity.java

/**
 * Builds a "no network" alert dialog indicating we can't do much without
 * network connection.//from ww w .  j  a va  2 s . c o m
 * 
 * @return
 */
private Dialog buildNoNetworkDialog() {
    final AlertDialog dialog = new AlertDialog.Builder(StoreActivity.this)
            .setIcon(android.R.drawable.ic_dialog_alert)
            .setMessage(R.string.store_activity_no_network_to_purchase_storage).setCancelable(false)
            .setPositiveButton(R.string.ok, new OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    finish();
                }
            }).create();
    return dialog;
}

From source file:ti.modules.titanium.ui.widget.TiUIDialog.java

@Override
public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy) {
    Log.d(TAG, "Property: " + key + " old: " + oldValue + " new: " + newValue, Log.DEBUG_MODE);

    AlertDialog dialog = dialogWrapper.getDialog();
    if (key.equals(TiC.PROPERTY_TITLE)) {
        if (dialog != null) {
            dialog.setTitle((String) newValue);
        }//from  w  w w.j  a v a 2s  . co  m
    } else if (key.equals(TiC.PROPERTY_MESSAGE)) {
        if (dialog != null) {
            dialog.setMessage((String) newValue);
        }
    } else if (key.equals(TiC.PROPERTY_BUTTON_NAMES)) {
        if (dialog != null) {
            dialog.dismiss();
            dialog = null;
        }
        processButtons(TiConvert.toStringArray((Object[]) newValue));
    } else if (key.equals(TiC.PROPERTY_OK) && !proxy.hasProperty(TiC.PROPERTY_BUTTON_NAMES)) {
        if (dialog != null) {
            dialog.dismiss();
            dialog = null;
        }
        processButtons(new String[] { TiConvert.toString(newValue) });
    } else if (key.equals(TiC.PROPERTY_OPTIONS)) {
        if (dialog != null) {
            dialog.dismiss();
            dialog = null;
        }

        getBuilder().setView(null);
        int selectedIndex = -1;
        if (proxy.hasProperty(TiC.PROPERTY_SELECTED_INDEX)) {
            selectedIndex = TiConvert.toInt(proxy.getProperty(TiC.PROPERTY_SELECTED_INDEX));
        }
        processOptions(TiConvert.toStringArray((Object[]) newValue), selectedIndex);
    } else if (key.equals(TiC.PROPERTY_SELECTED_INDEX)) {
        if (dialog != null) {
            dialog.dismiss();
            dialog = null;
        }

        getBuilder().setView(null);
        if (proxy.hasProperty(TiC.PROPERTY_OPTIONS)) {
            processOptions(TiConvert.toStringArray((Object[]) proxy.getProperty(TiC.PROPERTY_OPTIONS)),
                    TiConvert.toInt(newValue));

        }
    } else if (key.equals(TiC.PROPERTY_ANDROID_VIEW)) {
        if (dialog != null) {
            dialog.dismiss();
            dialog = null;
        }
        if (newValue != null) {
            processView((TiViewProxy) newValue);
        } else {
            proxy.setProperty(TiC.PROPERTY_ANDROID_VIEW, null);
        }
    } else if (key.equals(TiC.PROPERTY_PERSISTENT) && newValue != null) {
        dialogWrapper.setPersistent(TiConvert.toBoolean(newValue));
    } else if (key.indexOf("accessibility") == 0) {
        if (dialog != null) {
            ListView listView = dialog.getListView();
            if (listView != null) {
                if (key.equals(TiC.PROPERTY_ACCESSIBILITY_HIDDEN)) {
                    int importance = ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO;
                    if (newValue != null && TiConvert.toBoolean(newValue)) {
                        importance = ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO;
                    }
                    ViewCompat.setImportantForAccessibility(listView, importance);
                } else {
                    listView.setContentDescription(composeContentDescription());
                }
            }
        }
    } else {
        super.propertyChanged(key, oldValue, newValue, proxy);
    }
}

From source file:com.aniruddhc.acemusic.player.WelcomeActivity.WelcomeActivity.java

/**
 * Ask the user to set up GMusic.//w  ww. j  a  v  a 2 s. c  om
 */
private void promptUserSetUpGooglePlayMusic() {
    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    AlertDialog dialog;
    builder.setTitle(R.string.tip);
    builder.setMessage(R.string.prompt_user_set_up_google_play_music);
    builder.setPositiveButton(R.string.let_me_check, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = getPackageManager().getLaunchIntentForPackage("com.google.android.music");
            startActivity(intent);
            dialog.dismiss();

        }

    });

    builder.setNeutralButton(R.string.sync_manually, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();

        }

    });

    builder.setNegativeButton(R.string.set_up_already, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();

        }

    });

    dialog = builder.create();
    dialog.show();
}

From source file:es.uja.photofirma.android.CameraActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.camera_activity);

    logger.appendLog(100, "login usuario satisfactorio");

    //Definicin de elementos visuales involucrados
    lycpt = (ImageView) findViewById(R.id.cameraActivityCameraPhotoTap);
    lyerr = (LinearLayout) findViewById(R.id.cameraActivityErrorHeader);
    lysuc = (LinearLayout) findViewById(R.id.cameraActivitySuccessHeaderTextView);
    lycan = (LinearLayout) findViewById(R.id.cameraActivityCancelHeader);
    lyinf = (LinearLayout) findViewById(R.id.cameraActivityInfoHeader);
    lyupl = (LinearLayout) findViewById(R.id.cameraActivityUploadingHeader);
    lyudone = (LinearLayout) findViewById(R.id.cameraActivitySuccesUploadHeader);
    lyuerr = (LinearLayout) findViewById(R.id.cameraActivityErrorUploadHeader);
    errorText = (TextView) findViewById(R.id.cameraActivityErrorTextView);

    //gestor de servicios de telefonia, para la obtencin del IMEI del terminal
    telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

    if (telephonyManager == null) {
        imeiNumber = getString(R.string.no_imei_available);
    } else {/*from   w w w .  j a v a2  s .  c  o m*/
        imeiNumber = telephonyManager.getDeviceId();
    }

    //Deteccin de los parametros necesarios tras un login exitoso
    if (getIntent().hasExtra("userName") && getIntent().hasExtra("userId")
            && getIntent().hasExtra("userEmail")) {
        userName = getIntent().getExtras().getString("userName");
        userId = getIntent().getExtras().getInt("userId");
        userEmail = getIntent().getExtras().getString("userEmail");
    } else {
        Toast.makeText(getApplicationContext(), getString(R.string.no_user_data_found), Toast.LENGTH_LONG)
                .show();
    }

    final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Aviso de privacidad");
    alertDialog.setMessage(getString(R.string.privacy_alert));
    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            alertDialog.dismiss();
        }
    });
    alertDialog.show();

    SharedPreferences prefs = getSharedPreferences("prefsfile", Context.MODE_PRIVATE);
    String myPrefServerIp = prefs.getString("prefIpAddress", "10.0.3.2");
    URL_CONTENT_UPLOAD = "https://" + myPrefServerIp + "/photo@firmaServices/content_upload.php";
}