Example usage for android.app AlertDialog.Builder dismiss

List of usage examples for android.app AlertDialog.Builder dismiss

Introduction

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

Prototype

@Override
public void dismiss() 

Source Link

Document

Dismiss this dialog, removing it from the screen.

Usage

From source file:com.repay.android.StartFragment.java

public void showTotalDialog() {
    AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());
    dialog.setTitle(R.string.action_total);
    TextView txt = new TextView(getActivity());
    txt.setText(SettingsFragment.getCurrencySymbol(getActivity()) + calculateTotalDebt().toString());
    dialog.setView(txt);/*from www  . jav a2s. co  m*/
    txt.setTextAppearance(getActivity(), R.style.TotalDialog);
    txt.setGravity(Gravity.CENTER);
    dialog.setPositiveButton(R.string.done, new DialogInterface.OnClickListener() {

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

From source file:nu.firetech.android.pactrack.frontend.ParcelDetailsFragment.java

private void updateView(Cursor parcel) {
    ((NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE))
            .cancel(mRowId.hashCode());//from   ww  w.ja v  a  2s .c  om

    boolean isFullscreen = (getFragmentManager().findFragmentById(R.id.details_frag) == null);

    try {
        int error = parcel.getInt(parcel.getColumnIndexOrThrow(ParcelDbAdapter.KEY_ERROR));

        String status = parcel.getString(parcel.getColumnIndexOrThrow(ParcelDbAdapter.KEY_STATUS));

        if (error != Error.NONE && errorShown != error) {
            switch (error) {
            case Error.NOT_FOUND:
                status = getString(R.string.parcel_error_not_found);
                break;
            case Error.MULTI_PARCEL:
                status = getString(R.string.parcel_error_multi_parcel);
                break;
            case Error.SERVER:
                status = getString(R.string.parcel_error_server);
                break;
            default:
                status = getString(R.string.parcel_error_unknown, error);
            }

            AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity())
                    .setTitle(R.string.parcel_problem).setIconAttribute(android.R.attr.alertDialogIcon);

            if (isFullscreen) {
                dialog.setMessage(getString(R.string.parcel_error_message_question, status))
                        .setPositiveButton(R.string.yes, new OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                            }
                        }).setNegativeButton(R.string.no, new OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                                getFragmentManager().popBackStack();
                            }
                        });
            } else {
                dialog.setMessage(getString(R.string.parcel_error_message, status))
                        .setNegativeButton(R.string.ok, new OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                            }
                        });
            }

            dialog.create().show();
        }

        errorShown = error;

        String parcelId = parcel.getString(parcel.getColumnIndexOrThrow(ParcelDbAdapter.KEY_PARCEL));
        String parcelName = parcel.getString(parcel.getColumnIndexOrThrow(ParcelDbAdapter.KEY_NAME));
        if (parcelName == null) {
            parcelName = getString(R.string.generic_parcel_name, parcelId);
        }

        if (isFullscreen) {
            getActivity().setTitle(parcelName);
        }

        String lastUpdate = null, lastOkUpdate = null;
        int lastUpdateIndex = parcel.getColumnIndex(ParcelDbAdapter.KEY_UPDATE);
        if (lastUpdateIndex >= 0) {
            lastUpdate = parcel.getString(lastUpdateIndex);
        }
        int lastOkUpdateIndex = parcel.getColumnIndex(ParcelDbAdapter.KEY_OK_UPDATE);
        if (lastOkUpdateIndex >= 0) {
            lastOkUpdate = parcel.getString(lastOkUpdateIndex);
        }
        if (lastUpdate != null && lastUpdate.equals(lastOkUpdate)) {
            lastOkUpdate = getString(R.string.same_time);
        }

        findTextView(R.id.parcelid).setText(parcelId);
        findTextView(R.id.customer)
                .setText(parcel.getString(parcel.getColumnIndexOrThrow(ParcelDbAdapter.KEY_CUSTOMER)));
        findTextView(R.id.sent)
                .setText(parcel.getString(parcel.getColumnIndexOrThrow(ParcelDbAdapter.KEY_SENT)));
        findTextView(R.id.status).setText(status);
        findTextView(R.id.update_info).setText(getString(R.string.update_info_syntax,
                (lastUpdate == null ? getString(R.string.never) : lastUpdate),
                (lastOkUpdate == null ? getString(R.string.never) : lastOkUpdate)));
        findTextView(R.id.weight)
                .setText(parcel.getString(parcel.getColumnIndexOrThrow(ParcelDbAdapter.KEY_WEIGHT)));
        findTextView(R.id.postal)
                .setText(parcel.getString(parcel.getColumnIndexOrThrow(ParcelDbAdapter.KEY_POSTAL)));
        findTextView(R.id.service)
                .setText(parcel.getString(parcel.getColumnIndexOrThrow(ParcelDbAdapter.KEY_SERVICE)));

        ((ImageView) getView().findViewById(R.id.status_icon)).setImageResource(
                UICommon.getStatusImage(parcel, parcel.getColumnIndexOrThrow(ParcelDbAdapter.KEY_STATUSCODE)));
        updateAutoUpdateView(Preferences.getPreferences(getActivity()).getCheckInterval() == 0
                || parcel.getInt(parcel.getColumnIndexOrThrow(ParcelDbAdapter.KEY_AUTO)) == 1);
    } catch (Exception e) {
        Log.d(TAG, "Database error", e);
        UICommon.dbErrorDialog(getActivity());
    }
}

From source file:net.chuzarski.crowdednews.activities.MainActivity.java

private AlertDialog createFilterDialog() {
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setTitle(getResources().getString(R.string.select_filter));
    dialog.setSingleChoiceItems(getResources().getStringArray(R.array.news_sorting_strings), 0,
            new DialogInterface.OnClickListener() {
                @Override//w  w  w .jav a 2  s .c o  m
                public void onClick(DialogInterface dialog, int which) {
                    //TODO Fix this to somehow use the news_filter_values int array
                    articleFilterSwitch(which + 1); //add plus 1 to correspond with Reddit Filters
                    dialog.dismiss();
                }
            });
    return dialog.create();
}

From source file:com.fastbootmobile.encore.app.fragments.WelcomeFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // Step specifics
    if (mStep == 2) {
        View root = getView();//  w  ww  .j a v  a  2  s . c  o m
        if (root != null) {
            root.findViewById(R.id.btnSkip).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());
                    dialog.setTitle(R.string.welcome_skip_dialog_title);
                    dialog.setMessage(R.string.welcome_skip_dialog_body);
                    dialog.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            finishWizard();
                        }
                    });
                    dialog.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
                    dialog.show();
                }
            });

            root.findViewById(R.id.btnBrowse).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    ProviderDownloadDialog.newInstance(false).show(getFragmentManager(), "Download");
                }
            });
        }
    } else if (mStep == 3) {
        // Step 3: Configure plugins
        ListView lv = (ListView) view.findViewById(R.id.lvProviders);
        List<ProviderConnection> allProvs = PluginsLookup.getDefault().getAvailableProviders();
        final List<ProviderConnection> provs = new ArrayList<>();

        for (ProviderConnection prov : allProvs) {
            if (prov.getConfigurationActivity() != null
                    && !TextUtils.isEmpty(prov.getConfigurationActivity())) {
                provs.add(prov);
            }
        }

        mStep3Adapter = new ProvidersAdapter(provs);
        mStep3Adapter.setWhite(true);
        mStep3Adapter.setWashOutConfigure(true);
        lv.setAdapter(mStep3Adapter);

        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                ProviderConnection connection = provs.get(position);
                Intent intent = new Intent();
                intent.setPackage(connection.getPackage());
                intent.setClassName(connection.getPackage(), connection.getConfigurationActivity());
                mConfiguringProvider = connection;
                try {
                    startActivity(intent);
                } catch (ActivityNotFoundException e) {
                    Toast.makeText(getActivity(), R.string.toast_retry_plugin_not_ready, Toast.LENGTH_SHORT)
                            .show();
                }
            }
        });
    }
}

From source file:com.repay.android.frienddetails.FriendDetailsActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_settings:
        Intent intent = new Intent();
        intent.setClass(this, SettingsActivity.class);
        startActivity(intent);/*from  ww  w .j av  a  2  s.c  om*/
        return true;

    case R.id.action_delete:
        AlertDialog.Builder dialog = new AlertDialog.Builder(this);
        dialog.setTitle(R.string.activity_friendoverview_deletedialog_title);
        dialog.setMessage(R.string.activity_friendoverview_deletedialog_message);

        dialog.setPositiveButton(R.string.activity_friendoverview_deletedialog_yes, new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                deleteFriend();
            }
        });

        dialog.setNegativeButton(R.string.activity_friendoverview_deletedialog_no, new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        dialog.show();
        return true;

    case R.id.action_info:
        AlertDialog.Builder infoDialog = new AlertDialog.Builder(this);
        infoDialog.setTitle(R.string.activity_debtHistoryInfoDialog_title);
        infoDialog.setMessage(mInfoMessage);
        infoDialog.setPositiveButton(R.string.activity_debtHistoryInfoDialog_okayBtn, new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        infoDialog.show();
        return true;

    case R.id.action_addDebt:
        Intent i = new Intent();
        i.setClass(this, AddDebtActivity.class);
        Bundle bundle = new Bundle();
        bundle.putInt(AddDebtActivity.NO_OF_FRIENDS_SELECTED, 1);
        bundle.putString(AddDebtActivity.REPAY_ID + "1", mFriend.getRepayID());
        i.putExtras(bundle);
        startActivity(i);
        return true;

    case R.id.action_reLinkContact:
        Intent pickContactIntent = new Intent(Intent.ACTION_GET_CONTENT);
        pickContactIntent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
        startActivityForResult(pickContactIntent, PICK_CONTACT_REQUEST);
        return true;

    case R.id.action_unLinkContact:
        mFriend = new Friend(mFriend.getRepayID(), Uri.parse(""), mFriend.getName(), mFriend.getDebt());
        mDB.updateFriendRecord(mFriend);
        return true;
    }

    return false;
}

From source file:com.repay.android.frienddetails.FriendActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_settings:
        Intent intent = new Intent();
        intent.setClass(this, SettingsActivity.class);
        startActivity(intent);/*  w  w w  . j a  v  a 2  s  .  co m*/
        return true;

    case R.id.action_delete:
        AlertDialog.Builder dialog = new AlertDialog.Builder(this);
        dialog.setTitle(R.string.delete);
        dialog.setMessage(R.string.confirm_remove_person);

        dialog.setPositiveButton(R.string.delete, new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                try {
                    if (mDB != null) {
                        mDB.removeFriend(mFriend.getRepayID());
                        finish();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        dialog.setNegativeButton(R.string.cancel, new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        dialog.show();
        return true;

    case R.id.action_info:
        new AlertDialog.Builder(this).setTitle(R.string.info).setMessage(R.string.info_dialog_text)
                .setPositiveButton(R.string.okay, new OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                }).show();
        return true;

    case R.id.action_addDebt:
        Intent i = new Intent(this, AddDebtActivity.class);
        i.putExtra(DebtActivity.FRIEND, mFriend);
        startActivity(i);
        return true;

    case R.id.action_reLinkContact:
        Intent getContact = new Intent(Intent.ACTION_PICK);
        getContact.setType(ContactsContract.Contacts.CONTENT_TYPE);
        startActivityForResult(getContact, PICK_CONTACT_REQUEST);
        return true;

    case R.id.action_unLinkContact:
        mFriend = new Friend(mFriend.getRepayID(), null, mFriend.getName(), mFriend.getDebt());
        mDB.updateFriendRecord(mFriend);
        return true;
    }

    return false;
}

From source file:com.fjn.magazinereturncandidate.activities.SdmScannerActivity.java

/**
 * Show warning dialog when send data//  w w w  .  j a  va2  s  .  c o  m
 */
private void showDialogWarningSendData() {

    progress.show();
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setMessage(MESSAGE_CONFIRM_SEND_DATA).setCancelable(false)
            .setPositiveButton(MESSAGE_NO, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    progress.dismiss();
                    btnSend.setEnabled(true);
                    isEnableScan = true;
                    registerLicenseCommon.EnableOCROrJanCode(flagSwitchOCR, hsmDecoder);
                }
            }).setNegativeButton(MESSAGE_YES, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    LogManagerCommon.i(TAG, Message.TAG_SCANNER_ACTIVITY + Message.MESSAGE_SEND_DATA);
                    // print log end process
                    LogManagerCommon.i(TAG, Message.TAG_SCANNER_ACTIVITY + Message.MESSAGE_ACTIVITY_END);
                    // print log send file data
                    LogManagerCommon.i(TAG, Message.MESSAGE_SEND_DATA);

                    //Save csv and send list file to Bigquery
                    sendData();
                }
            });

    AlertDialog alert = dialog.show();
    TextView messageText = (TextView) alert.findViewById(android.R.id.message);
    assert messageText != null;
    messageText.setGravity(Gravity.CENTER);
}

From source file:com.fjn.magazinereturncandidate.activities.SdmScannerActivity.java

/**
 * Show message info list file csv/*from  w  w  w  .j a v a 2s. c om*/
 */
private void showDialogNotifyListCSVWhenLogin() {

    progress.show();
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setMessage(MESSAGE_SEND_LIST_FILE_CSV).setCancelable(false)
            .setPositiveButton(MESSAGE_NO, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    progress.dismiss();
                    btnSend.setEnabled(true);
                    //Enable scan
                    isEnableScan = true;
                    registerLicenseCommon.EnableOCROrJanCode(flagSwitchOCR, hsmDecoder);
                }
            }).setNegativeButton(MESSAGE_YES, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    LogManagerCommon.i(TAG, Message.TAG_SCANNER_ACTIVITY + Message.MESSAGE_SEND_DATA);
                    // print log end process
                    LogManagerCommon.i(TAG, Message.TAG_SCANNER_ACTIVITY + Message.MESSAGE_ACTIVITY_END);
                    // print log send file data
                    LogManagerCommon.i(TAG, Message.MESSAGE_SEND_DATA);

                    //Send list file csv to bigQuery
                    connectSendDataWhenLogin();
                }
            });
    AlertDialog alert = dialog.show();
    TextView messageText = (TextView) alert.findViewById(android.R.id.message);
    assert messageText != null;
    messageText.setGravity(Gravity.CENTER);
}

From source file:com.android.returncandidate.activities.SdmScannerActivity.java

/**
 * Show warning dialog when ? is clicked
 *///from ww  w .  j  a  v  a  2 s  .c  om
private void showDialog() {

    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setMessage(getString(R.string.cancel_msg)).setCancelable(false)
            .setPositiveButton(getString(R.string.logout_yes), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    cancelItem();
                    btnCancel.setEnabled(true);
                }
            }).setNegativeButton(getString(R.string.logout_no), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    btnCancel.setEnabled(true);
                }
            });
    AlertDialog alert = dialog.show();
    TextView messageText = (TextView) alert.findViewById(android.R.id.message);
    assert messageText != null;
    messageText.setGravity(Gravity.CENTER);
}

From source file:za.co.neilson.alarm.preferences.AlarmPreferencesActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_item_save:
        Database.init(getApplicationContext());
        Database.setEmail(email);/*ww  w  . j  a v  a2s  .c o m*/

        if (getMathAlarm().getId() < 1) {
            getMathAlarm().setEmail(email);
            Database.create(getMathAlarm());
            Bundle bundle = getIntent().getExtras();
            if (bundle != null && bundle.containsKey("user")) {
                User user = (User) bundle.getSerializable("user");
                Group group = new Group(getMathAlarm(), user);
                Database.addGroup(group);
            }
            params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("email", email));
            Log.d("??? ? : ", "" + email);
            params.add(new BasicNameValuePair("time", getMathAlarm().getAlarmTimeString()));
            params.add(new BasicNameValuePair("difficulty",
                    Integer.toString(getMathAlarm().getDifficulty().ordinal())));
            params.add(new BasicNameValuePair("tone", getMathAlarm().getAlarmTonePath()));
            params.add(new BasicNameValuePair("vibrate", Boolean.toString(getMathAlarm().getVibrate())));
            params.add(new BasicNameValuePair("name", getMathAlarm().getAlarmName()));
            //params.add(new BasicNameValuePair("days", Arrays.toString(getMathAlarm().getDays())));
            for (int i = 0; i < getMathAlarm().getDays().length; i++) {
                params.add(new BasicNameValuePair("days", getMathAlarm().getDays()[i].toString()));
            }
            ServerRequest sr = new ServerRequest();
            JSONObject json = sr.getJSON("http://168.188.123.218:8080/alarmdata", params);
            if (json != null) {
                try {
                    String jsonstr = json.getString("response");
                    //JSONObject json2 = sr.getJSON("http://168.188.123.218:8080/useralarm", params);

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

        } else {
            Database.update(getMathAlarm());
            Database.setEmail(email);

        }

        callMathAlarmScheduleService();
        Toast.makeText(AlarmPreferencesActivity.this, getMathAlarm().getTimeUntilNextAlarmMessage(),
                Toast.LENGTH_LONG).show();
        finish();
        break;
    case R.id.menu_item_delete:
        AlertDialog.Builder dialog = new AlertDialog.Builder(AlarmPreferencesActivity.this);
        dialog.setTitle("Delete");
        dialog.setMessage("Delete this alarm?");
        dialog.setPositiveButton("Ok", new OnClickListener() {

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

                Database.init(getApplicationContext());
                Database.setEmail(email);

                if (getMathAlarm().getId() < 1) {
                    // Alarm not saved
                } else {
                    params = new ArrayList<NameValuePair>();
                    params.add(new BasicNameValuePair("email", email));
                    params.add(new BasicNameValuePair("time", alarm.getAlarmTimeString()));
                    Log.d("??? ? : ", "" + email);
                    ServerRequest sr = new ServerRequest();
                    JSONObject json = sr.getJSON("http://168.188.123.218:8080/deletealarm", params);

                    Database.deleteEntry(alarm);
                    callMathAlarmScheduleService();
                }
                finish();
            }
        });
        dialog.setNegativeButton("Cancel", new OnClickListener() {

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

        break;
    }
    return super.onOptionsItemSelected(item);
}