Java Code Examples for android.support.v7.app.AlertDialog.BUTTON_POSITIVE

The following are Jave code examples for showing how to use BUTTON_POSITIVE of the android.support.v7.app.AlertDialog class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: chromium-for-android-56-debug-video   File: OMADownloadHandler.java   Source Code and License Vote up 6 votes
/**
 * Shows a warning dialog indicating that download has failed. When user confirms
 * the warning, a message will be sent to the notification server to  inform about the
 * error.
 *
 * @param titleId The resource identifier for the title.
 * @param omaInfo Information about the OMA content.
 * @param downloadInfo Information about the download.
 * @param statusMessage Message to be sent to the notification server.
 */
private void showDownloadWarningDialog(
        int titleId, final OMAInfo omaInfo, final DownloadInfo downloadInfo,
        final String statusMessage) {
    DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                sendInstallNotificationAndNextStep(omaInfo, downloadInfo,
                        DownloadItem.INVALID_DOWNLOAD_ID, statusMessage);
            }
        }
    };
    new AlertDialog.Builder(
            ApplicationStatus.getLastTrackedFocusedActivity(), R.style.AlertDialogTheme)
            .setTitle(titleId)
            .setPositiveButton(R.string.ok, clickListener)
            .setCancelable(false)
            .show();
}
 
Example 2
Project: IelloAndroidAdminApp   File: DialogAPIKey.java   Source Code and License Vote up 6 votes
@Override
public void onClick(DialogInterface dialogInterface, int which) {
    switch (which)
    {
        case AlertDialog.BUTTON_POSITIVE:
            break;

        case AlertDialog.BUTTON_NEGATIVE:
            // se era gia presente una key, allora chiudo semplicmente il dialog,
            // altrimenti significa che non è mai stata inserita alcuna chiave, quindi chiudo l'app
            if(!SharedPrefsHelper.getInstance().isApiKeyRegistered(getActivity()))
                getActivity().finish();
            else
                dismiss();
            break;
    }
}
 
Example 3
Project: chromium-for-android-56-debug-video   File: OMADownloadHandler.java   Source Code and License Vote up 5 votes
/**
 * Shows a dialog to ask whether user wants to open the nextURL.
 *
 * @param omaInfo Information about the OMA content.
 */
private void showNextUrlDialog(OMAInfo omaInfo) {
    if (omaInfo.isValueEmpty(OMA_NEXT_URL)) {
        return;
    }
    final String nextUrl = omaInfo.getValue(OMA_NEXT_URL);
    final Activity activity = ApplicationStatus.getLastTrackedFocusedActivity();
    DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(nextUrl));
                intent.putExtra(Browser.EXTRA_APPLICATION_ID, activity.getPackageName());
                intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
                intent.setPackage(mContext.getPackageName());
                activity.startActivity(intent);
            }
        }
    };
    new AlertDialog.Builder(activity)
            .setTitle(R.string.open_url_post_oma_download)
            .setPositiveButton(R.string.ok, clickListener)
            .setNegativeButton(R.string.cancel, clickListener)
            .setMessage(nextUrl)
            .setCancelable(false)
            .show();
}
 
Example 4
Project: chromium-for-android-56-debug-video   File: SignOutDialogFragment.java   Source Code and License Vote up 5 votes
@Override
public void onClick(DialogInterface dialog, int which) {
    if (which == AlertDialog.BUTTON_POSITIVE) {
        AccountManagementScreenHelper.logEvent(
                ProfileAccountManagementMetrics.SIGNOUT_SIGNOUT, mGaiaServiceType);

        mSignOutClicked = true;
        SignOutDialogListener targetFragment = (SignOutDialogListener) getTargetFragment();
        targetFragment.onSignOutClicked();
    }
}
 
Example 5
Project: OpenPad-for-Android   File: FolderActivity.java   Source Code and License Vote up 5 votes
@Override
public boolean onOptionsItemSelected(MenuItem _item) {
    if (_item.getItemId() == R.id.menu_folderAdd) {
        AlertDialog.Builder dialog = new AlertDialog.Builder(this);
        dialog.setTitle(R.string.folder_dialog_title_create);
        View layout = LayoutInflater.from(mContextThis).inflate(R.layout.dialog_folder_create, null);
        mEditText = (EditText) layout.findViewById(R.id.dialog_folder_input);
        dialog.setView(layout);
        DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface _dialog, int _which) {
                if (_which == AlertDialog.BUTTON_POSITIVE) {
                    mNewFolderName = mEditText.getText().toString();
                    if (!mNewFolderName.equals("")) {
                        File file = new File(Constant.APP_INTERNAL_URL + File.separator + mNewFolderName);
                        if (file.exists())
                            Snackbar.make(mContextView, R.string.folder_dialog_toast_exist, Snackbar.LENGTH_SHORT).show();
                        else {
                            file.mkdir();
                            runOnUiThread(mRefreshRunnable);
                        }
                    }
                }
                _dialog.dismiss();
            }
        };
        dialog.setNegativeButton(R.string.folder_dialog_button_cancel, clickListener);
        dialog.setPositiveButton(R.string.folder_dialog_button_create, clickListener);
        dialog.show();
    }
    return super.onOptionsItemSelected(_item);
}
 
Example 6
Project: OpenPad-for-Android   File: FolderActivity.java   Source Code and License Vote up 5 votes
/**
 * 폴더를 삭제하는 메소드
 * @param _index 삭제할 폴더의 인덱스
 */
private void deleteFolder(final int _index) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setTitle(R.string.folder_dialog_title_delete);
    dialog.setMessage(R.string.folder_dialog_message_question_delete);
    DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface _dialog, int _which) {
            if (_which == AlertDialog.BUTTON_POSITIVE) {
                File file = new File(mFolders.get(_index).mFolderPath);
                if (file.exists()) {
                    if (!file.getName().equals(Constant.FOLDER_DEFAULT_NAME) && !file.getName().equals(Constant.FOLDER_WIDGET_NAME)
                            && file.delete()) {
                        Snackbar.make(mContextView, R.string.folder_dialog_toast_delete, Snackbar.LENGTH_LONG).show();
                        runOnUiThread(mRefreshRunnable);
                    } else {
                        Snackbar.make(mContextView, R.string.folder_toast_remove_defaultfolder, Snackbar.LENGTH_SHORT).show();
                    }
                } else {
                    Snackbar.make(mContextView, R.string.error_folder_not_exist, Snackbar.LENGTH_SHORT).show();
                }
            }
            _dialog.dismiss();
        }
    };
    dialog.setNegativeButton(R.string.folder_dialog_button_cancel, clickListener);
    dialog.setPositiveButton(R.string.folder_dialog_button_delete, clickListener);
    dialog.show();
}
 
Example 7
Project: OpenPad-for-Android   File: MainActivity.java   Source Code and License Vote up 5 votes
/**
 * 메인 리스트에서 파일을 제거하는 메소드
 * @param _index 제거할 파일의 인덱스
 */
private void deleteFile(final int _index) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setTitle(R.string.file_dialog_title_delete);
    dialog.setMessage(R.string.file_dialog_message_question_delete);
    DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface _dialog, int _which) {
            if (_which == AlertDialog.BUTTON_POSITIVE) {
                File file = new File(mCurFolderFileList.get(_index).mFilePath);
                if (file.exists()) {
                    if (file.delete()) {
                        Snackbar.make(mContextView, R.string.file_dialog_toast_delete, Snackbar.LENGTH_SHORT).show();
                        mCurFolderFileList.remove(_index);
                        mCurFolderGridView.removeViewAt(_index);
                        mCurFileAdapter.notifyItemRemoved(_index);
                        mCurFileAdapter.notifyItemRangeChanged(_index, mCurFolderFileList.size());
                        mCurFileAdapter.notifyDataSetChanged();
                    } else {
                        Snackbar.make(mContextView, R.string.error_folder_not_exist, Snackbar.LENGTH_SHORT).show();
                    }
                }
            }
            _dialog.dismiss();
        }
    };
    dialog.setNegativeButton(R.string.folder_dialog_button_cancel, clickListener);
    dialog.setPositiveButton(R.string.folder_dialog_button_delete, clickListener);
    dialog.show();
}
 
Example 8
Project: chromium-for-android-56-debug-video   File: ConfirmImportantSitesDialogFragment.java   Source Code and License Vote up 4 votes
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // We check the domains and urls as well due to crbug.com/622879.
    if (savedInstanceState != null) {
        // The important domains and favicon URLs aren't currently saved, so if this dialog
        // is recreated from a saved instance they will be null. This method must return a
        // valid dialog, so these two array's are initialized, then the dialog is dismissed.
        // TODO(dmurph): save mImportantDomains and mFaviconURLs so that they can be restored
        // from a savedInstanceState and the dialog can be properly recreated rather than
        // dismissed.
        mImportantDomains = new String[0];
        mFaviconURLs = new String[0];
        dismiss();
    }
    mProfile = Profile.getLastUsedProfile().getOriginalProfile();
    mLargeIconBridge = new LargeIconBridge(mProfile);
    ActivityManager activityManager =
            ((ActivityManager) ContextUtils.getApplicationContext().getSystemService(
                    Context.ACTIVITY_SERVICE));
    int maxSize = Math.min(
            activityManager.getMemoryClass() / 16 * 25 * 1024, FAVICON_MAX_CACHE_SIZE_BYTES);
    mLargeIconBridge.createCache(maxSize);

    mAdapter = new ClearBrowsingDataAdapter(mImportantDomains, mFaviconURLs, getResources());
    DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                Intent data = new Intent();
                List<String> deselectedDomains = new ArrayList<>();
                List<Integer> deselectedDomainReasons = new ArrayList<>();
                List<String> ignoredDomains = new ArrayList<>();
                List<Integer> ignoredDomainReasons = new ArrayList<>();
                for (Entry<String, Boolean> entry : mCheckedState.entrySet()) {
                    Integer reason = mImportantDomainsReasons.get(entry.getKey());
                    if (entry.getValue()) {
                        ignoredDomains.add(entry.getKey());
                        ignoredDomainReasons.add(reason);
                    } else {
                        deselectedDomains.add(entry.getKey());
                        deselectedDomainReasons.add(reason);
                    }
                }
                data.putExtra(DESELECTED_DOMAINS_TAG, deselectedDomains.toArray(new String[0]));
                data.putExtra(
                        DESELECTED_DOMAIN_REASONS_TAG, toIntArray(deselectedDomainReasons));
                data.putExtra(IGNORED_DOMAINS_TAG, ignoredDomains.toArray(new String[0]));
                data.putExtra(IGNORED_DOMAIN_REASONS_TAG, toIntArray(ignoredDomainReasons));
                getTargetFragment().onActivityResult(
                        getTargetRequestCode(), Activity.RESULT_OK, data);
            } else {
                getTargetFragment().onActivityResult(getTargetRequestCode(),
                        Activity.RESULT_CANCELED, getActivity().getIntent());
            }
        }
    };
    // We create our own ListView, as AlertDialog doesn't let us set a message and a list
    // adapter at the same time.
    View messageAndListView = getActivity().getLayoutInflater().inflate(
            R.layout.clear_browsing_important_dialog_listview, null);
    mSitesListView = (ListView) messageAndListView.findViewById(R.id.select_dialog_listview);
    mSitesListView.setAdapter(mAdapter);
    mSitesListView.setOnItemClickListener(mAdapter);
    final AlertDialog.Builder builder =
            new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
                    .setTitle(R.string.storage_clear_site_storage_title)
                    .setPositiveButton(R.string.clear_browsing_data_important_dialog_button,
                            listener)
                    .setNegativeButton(R.string.cancel, listener)
                    .setView(messageAndListView);
    mDialog = builder.create();

    return mDialog;
}