Search in sources :

Example 36 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project JamsMusicPlayer by psaravan.

the class SmallWidgetConfigActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    setTheme(android.R.style.Theme_Holo_Dialog);
    super.onCreate(savedInstanceState);
    setResult(RESULT_CANCELED, new Intent());
    sharedPreferences = this.getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE);
    //Retrieve the id of the widget that called this activity.
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    if (extras != null) {
        mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.select_widget_color);
    builder.setCancelable(false);
    builder.setSingleChoiceItems(R.array.widget_color_options, -1, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == 0) {
                //Light theme.
                sharedPreferences.edit().putString("" + mAppWidgetId, "LIGHT").commit();
            } else if (which == 1) {
                //Dark theme.
                sharedPreferences.edit().putString("" + mAppWidgetId, "DARK").commit();
            }
            updateWidgetConfig();
        }
    });
    builder.create().show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Bundle(android.os.Bundle) OnClickListener(android.content.DialogInterface.OnClickListener) Intent(android.content.Intent)

Example 37 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project qksms by moezbhatti.

the class LogTag method warnPossibleRecipientMismatch.

public static void warnPossibleRecipientMismatch(final String msg, final Activity activity) {
    Log.e(TAG, "WARNING!!!! " + msg, new RuntimeException());
    if (SHOW_SEVERE_WARNING_DIALOG) {
        dumpInternalTables(activity);
        activity.runOnUiThread(new Runnable() {

            public void run() {
                new AlertDialog.Builder(activity).setIconAttribute(android.R.attr.alertDialogIcon).setTitle(R.string.error_state).setMessage(msg + "\n\n" + activity.getString(R.string.error_state_text)).setPositiveButton(R.string.yes, new OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                }).show();
            }
        });
    }
}
Also used : DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener)

Example 38 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project qksms by moezbhatti.

the class MessageUtils method handleReadReport.

public static void handleReadReport(final Context context, final Collection<Long> threadIds, final int status, final Runnable callback) {
    StringBuilder selectionBuilder = new StringBuilder(Mms.MESSAGE_TYPE + " = " + PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF + " AND " + Mms.READ + " = 0" + " AND " + Mms.READ_REPORT + " = " + PduHeaders.VALUE_YES);
    String[] selectionArgs = null;
    if (threadIds != null) {
        String threadIdSelection = null;
        StringBuilder buf = new StringBuilder();
        selectionArgs = new String[threadIds.size()];
        int i = 0;
        for (long threadId : threadIds) {
            if (i > 0) {
                buf.append(" OR ");
            }
            buf.append(Mms.THREAD_ID).append("=?");
            selectionArgs[i++] = Long.toString(threadId);
        }
        threadIdSelection = buf.toString();
        selectionBuilder.append(" AND (" + threadIdSelection + ")");
    }
    final Cursor c = SqliteWrapper.query(context, context.getContentResolver(), Mms.Inbox.CONTENT_URI, new String[] { Mms._ID, Mms.MESSAGE_ID }, selectionBuilder.toString(), selectionArgs, null);
    if (c == null) {
        return;
    }
    final Map<String, String> map = new HashMap<>();
    try {
        if (c.getCount() == 0) {
            if (callback != null) {
                callback.run();
            }
            return;
        }
        while (c.moveToNext()) {
            Uri uri = ContentUris.withAppendedId(Mms.CONTENT_URI, c.getLong(0));
            map.put(c.getString(1), AddressUtils.getFrom(context, uri));
        }
    } finally {
        c.close();
    }
    OnClickListener positiveListener = new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            for (final Map.Entry<String, String> entry : map.entrySet()) {
                MmsMessageSender.sendReadRec(context, entry.getValue(), entry.getKey(), status);
            }
            if (callback != null) {
                callback.run();
            }
            dialog.dismiss();
        }
    };
    OnClickListener negativeListener = new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (callback != null) {
                callback.run();
            }
            dialog.dismiss();
        }
    };
    OnCancelListener cancelListener = new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            if (callback != null) {
                callback.run();
            }
            dialog.dismiss();
        }
    };
    confirmReadReportDialog(context, positiveListener, negativeListener, cancelListener);
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) DialogInterface(android.content.DialogInterface) Cursor(android.database.Cursor) Uri(android.net.Uri) OnClickListener(android.content.DialogInterface.OnClickListener) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) MimeTypeMap(android.webkit.MimeTypeMap) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 39 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project openkit-android by OpenKit.

the class OKLoginFragment method showLoginErrorMessage.

private void showLoginErrorMessage(String message) {
    AlertDialog.Builder builder = new AlertDialog.Builder(OKLoginFragment.this.getActivity());
    builder.setTitle("Error");
    builder.setMessage(message);
    builder.setNegativeButton("OK", new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialogDelegate.onLoginFailed();
        }
    });
    builder.setCancelable(false);
    // create alert dialog
    AlertDialog alertDialog = builder.create();
    // show it
    alertDialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener)

Example 40 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project openkit-android by OpenKit.

the class FacebookUtilities method showErrorMessage.

public static void showErrorMessage(String message, Context context) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle("Error");
    builder.setMessage(message);
    builder.setNegativeButton("OK", new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    // create alert dialog
    AlertDialog alertDialog = builder.create();
    // show it
    alertDialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener)

Aggregations

DialogInterface (android.content.DialogInterface)186 OnClickListener (android.content.DialogInterface.OnClickListener)186 AlertDialog (android.app.AlertDialog)122 View (android.view.View)49 TextView (android.widget.TextView)39 SuppressLint (android.annotation.SuppressLint)37 Intent (android.content.Intent)35 Context (android.content.Context)24 EditText (android.widget.EditText)22 Bundle (android.os.Bundle)21 LayoutInflater (android.view.LayoutInflater)18 Builder (android.app.AlertDialog.Builder)15 Paint (android.graphics.Paint)15 OnCancelListener (android.content.DialogInterface.OnCancelListener)14 KeyEvent (android.view.KeyEvent)12 CompoundButton (android.widget.CompoundButton)12 Point (android.graphics.Point)11 AlertDialog (android.support.v7.app.AlertDialog)11 ContextThemeWrapper (android.view.ContextThemeWrapper)11 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)11