Search in sources :

Example 6 with OnDismissListener

use of android.content.DialogInterface.OnDismissListener in project Android-DialogFragments by wada811.

the class AbstractDialogFragment method setOnDismissListener.

protected void setOnDismissListener(Dialog dialog) {
    useOnDismissListener = true;
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            bindDismissListener();
        }
    });
}
Also used : DialogInterface(android.content.DialogInterface) OnDismissListener(android.content.DialogInterface.OnDismissListener)

Example 7 with OnDismissListener

use of android.content.DialogInterface.OnDismissListener in project android-app by spark.

the class TinkerFragment method showTinkerSelect.

private void showTinkerSelect(Pin pin) {
    // No current action on the pin
    mutePinsExcept(pin);
    toggleViewVisibilityWithFade(R.id.tinker_logo, false);
    final View selectDialogView = getActivity().getLayoutInflater().inflate(R.layout.tinker_select, null);
    selectDialog = new AlertDialog.Builder(getActivity(), R.style.AppTheme_DialogNoDimBackground).setView(selectDialogView).setCancelable(true).setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            dialog.dismiss();
        }
    }).create();
    selectDialog.setCanceledOnTouchOutside(true);
    selectDialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            unmutePins();
            toggleViewVisibilityWithFade(R.id.tinker_logo, true);
            selectDialog = null;
        }
    });
    final View analogRead = Ui.findView(selectDialogView, R.id.tinker_button_analog_read);
    final View analogWrite = Ui.findView(selectDialogView, R.id.tinker_button_analog_write);
    final View digitalRead = Ui.findView(selectDialogView, R.id.tinker_button_digital_read);
    final View digitalWrite = Ui.findView(selectDialogView, R.id.tinker_button_digital_write);
    final List<View> allButtons = list(analogRead, analogWrite, digitalRead, digitalWrite);
    analogRead.setOnTouchListener(new OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                setTinkerSelectButtonSelected(analogRead, allButtons);
            }
            return false;
        }
    });
    analogWrite.setOnTouchListener(new OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                setTinkerSelectButtonSelected(analogWrite, allButtons);
            }
            return false;
        }
    });
    digitalRead.setOnTouchListener(new OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                setTinkerSelectButtonSelected(digitalRead, allButtons);
            }
            return false;
        }
    });
    digitalWrite.setOnTouchListener(new OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                setTinkerSelectButtonSelected(digitalWrite, allButtons);
            }
            return false;
        }
    });
    digitalWrite.setOnClickListener(this);
    digitalRead.setOnClickListener(this);
    analogRead.setOnClickListener(this);
    analogWrite.setOnClickListener(this);
    if (!digitalWritePins.contains(pin)) {
        digitalWrite.setVisibility(View.INVISIBLE);
    } else {
        digitalWrite.setVisibility(View.VISIBLE);
    }
    if (!digitalReadPins.contains(pin)) {
        digitalRead.setVisibility(View.INVISIBLE);
    } else {
        digitalRead.setVisibility(View.VISIBLE);
    }
    if (!analogReadPins.contains(pin)) {
        analogRead.setVisibility(View.INVISIBLE);
    } else {
        analogRead.setVisibility(View.VISIBLE);
    }
    if (!analogWritePins.contains(pin)) {
        analogWrite.setVisibility(View.INVISIBLE);
    } else {
        analogWrite.setVisibility(View.VISIBLE);
    }
    ((TextView) selectDialogView.findViewById(R.id.tinker_select_pin)).setText(pin.name);
    PinAction action = pin.getConfiguredAction();
    switch(action) {
        case ANALOG_READ:
            setTinkerSelectButtonSelected(analogRead, allButtons);
            break;
        case ANALOG_WRITE:
            setTinkerSelectButtonSelected(analogWrite, allButtons);
            break;
        case DIGITAL_READ:
            setTinkerSelectButtonSelected(digitalRead, allButtons);
            break;
        case DIGITAL_WRITE:
            setTinkerSelectButtonSelected(digitalWrite, allButtons);
            break;
        case NONE:
            setTinkerSelectButtonSelected(null, allButtons);
            break;
    }
    selectDialog.show();
    View decorView = selectDialog.getWindow().getDecorView();
    noIReallyMeanItIWantThisToBeTransparent(decorView);
}
Also used : AlertDialog(android.app.AlertDialog) OnTouchListener(android.view.View.OnTouchListener) DialogInterface(android.content.DialogInterface) OnDismissListener(android.content.DialogInterface.OnDismissListener) TextView(android.widget.TextView) View(android.view.View) TextView(android.widget.TextView) OnCancelListener(android.content.DialogInterface.OnCancelListener) MotionEvent(android.view.MotionEvent)

Example 8 with OnDismissListener

use of android.content.DialogInterface.OnDismissListener in project platform_frameworks_base by android.

the class PowerNotificationWarnings method showStartSaverConfirmation.

private void showStartSaverConfirmation() {
    if (mSaverConfirmation != null)
        return;
    final SystemUIDialog d = new SystemUIDialog(mContext);
    d.setTitle(R.string.battery_saver_confirmation_title);
    d.setMessage(com.android.internal.R.string.battery_saver_description);
    d.setNegativeButton(android.R.string.cancel, null);
    d.setPositiveButton(R.string.battery_saver_confirmation_ok, mStartSaverMode);
    d.setShowForAllUsers(true);
    d.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            mSaverConfirmation = null;
        }
    });
    d.show();
    mSaverConfirmation = d;
}
Also used : SystemUIDialog(com.android.systemui.statusbar.phone.SystemUIDialog) DialogInterface(android.content.DialogInterface) OnDismissListener(android.content.DialogInterface.OnDismissListener)

Example 9 with OnDismissListener

use of android.content.DialogInterface.OnDismissListener in project LiveSDK-for-Android by liveservices.

the class SkyDriveActivity method onCreateDialog.

@Override
protected Dialog onCreateDialog(final int id, final Bundle bundle) {
    Dialog dialog = null;
    switch(id) {
        case DIALOG_DOWNLOAD_ID:
            {
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setTitle("Download").setMessage("This file will be downloaded to the sdcard.").setPositiveButton("OK", new Dialog.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        final ProgressDialog progressDialog = new ProgressDialog(SkyDriveActivity.this);
                        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
                        progressDialog.setMessage("Downloading...");
                        progressDialog.setCancelable(true);
                        progressDialog.show();
                        String fileId = bundle.getString(JsonKeys.ID);
                        String name = bundle.getString(JsonKeys.NAME);
                        File file = new File(Environment.getExternalStorageDirectory(), name);
                        final LiveDownloadOperation operation = mClient.downloadAsync(fileId + "/content", file, new LiveDownloadOperationListener() {

                            @Override
                            public void onDownloadProgress(int totalBytes, int bytesRemaining, LiveDownloadOperation operation) {
                                int percentCompleted = computePrecentCompleted(totalBytes, bytesRemaining);
                                progressDialog.setProgress(percentCompleted);
                            }

                            @Override
                            public void onDownloadFailed(LiveOperationException exception, LiveDownloadOperation operation) {
                                progressDialog.dismiss();
                                showToast(exception.getMessage());
                            }

                            @Override
                            public void onDownloadCompleted(LiveDownloadOperation operation) {
                                progressDialog.dismiss();
                                showToast("File downloaded.");
                            }
                        });
                        progressDialog.setOnCancelListener(new OnCancelListener() {

                            @Override
                            public void onCancel(DialogInterface dialog) {
                                operation.cancel();
                            }
                        });
                    }
                }).setNegativeButton("Cancel", new Dialog.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
                dialog = builder.create();
                break;
            }
    }
    if (dialog != null) {
        dialog.setOnDismissListener(new OnDismissListener() {

            @Override
            public void onDismiss(DialogInterface dialog) {
                removeDialog(id);
            }
        });
    }
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnDismissListener(android.content.DialogInterface.OnDismissListener) LiveDownloadOperationListener(com.microsoft.live.LiveDownloadOperationListener) ProgressDialog(android.app.ProgressDialog) LiveOperationException(com.microsoft.live.LiveOperationException) LiveDownloadOperation(com.microsoft.live.LiveDownloadOperation) AlertDialog(android.app.AlertDialog) Dialog(android.app.Dialog) ProgressDialog(android.app.ProgressDialog) OnClickListener(android.view.View.OnClickListener) File(java.io.File) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 10 with OnDismissListener

use of android.content.DialogInterface.OnDismissListener in project android_frameworks_base by ResurrectionRemix.

the class PowerNotificationWarnings method showStartSaverConfirmation.

private void showStartSaverConfirmation() {
    if (mSaverConfirmation != null)
        return;
    final SystemUIDialog d = new SystemUIDialog(mContext);
    d.setTitle(R.string.battery_saver_confirmation_title);
    d.setMessage(com.android.internal.R.string.battery_saver_description);
    d.setNegativeButton(android.R.string.cancel, null);
    d.setPositiveButton(R.string.battery_saver_confirmation_ok, mStartSaverMode);
    d.setShowForAllUsers(true);
    d.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            mSaverConfirmation = null;
        }
    });
    d.show();
    mSaverConfirmation = d;
}
Also used : SystemUIDialog(com.android.systemui.statusbar.phone.SystemUIDialog) DialogInterface(android.content.DialogInterface) OnDismissListener(android.content.DialogInterface.OnDismissListener)

Aggregations

DialogInterface (android.content.DialogInterface)13 OnDismissListener (android.content.DialogInterface.OnDismissListener)13 AlertDialog (android.app.AlertDialog)5 SystemUIDialog (com.android.systemui.statusbar.phone.SystemUIDialog)5 View (android.view.View)3 Dialog (android.app.Dialog)2 OnCancelListener (android.content.DialogInterface.OnCancelListener)2 OnClickListener (android.content.DialogInterface.OnClickListener)2 TextView (android.widget.TextView)2 SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1 PendingIntent (android.app.PendingIntent)1 ProgressDialog (android.app.ProgressDialog)1 ComponentName (android.content.ComponentName)1 Intent (android.content.Intent)1 ActivityInfo (android.content.pm.ActivityInfo)1 PackageManager (android.content.pm.PackageManager)1 ResolveInfo (android.content.pm.ResolveInfo)1 Paint (android.graphics.Paint)1 AlertDialog (android.support.v7.app.AlertDialog)1