Search in sources :

Example 61 with DialogInterface

use of android.content.DialogInterface in project android-app-common-tasks by multidots.

the class Common method showNETWORDDisabledAlert.

public static void showNETWORDDisabledAlert(final Context ctx) {
    AlertDialog alert;
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx);
    alertDialogBuilder.setMessage("Let the app use data connectivity.").setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            Intent callGPSSettingIntent = new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS);
            ctx.startActivity(callGPSSettingIntent);
        }
    });
    alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    alert = alertDialogBuilder.create();
    alert.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint)

Example 62 with DialogInterface

use of android.content.DialogInterface in project android-app-common-tasks by multidots.

the class Common method showGPSDisabledAlert.

public static void showGPSDisabledAlert(@SuppressWarnings("SameParameterValue") String msg, final Context ctx) {
    AlertDialog alert;
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx);
    alertDialogBuilder.setMessage(msg).setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            Intent callGPSSettingIntent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            ctx.startActivity(callGPSSettingIntent);
        }
    });
    alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    alert = alertDialogBuilder.create();
    alert.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint)

Example 63 with DialogInterface

use of android.content.DialogInterface in project android-app-common-tasks by multidots.

the class Common method showAlertDialog.

/**
     * Function to display simple Alert Dialog or Toast
     *
     * @param context - application context
     * @param title   - alert dialog title
     * @param message - alert message
     * @param toast   - show as toast or dialog
     */
public static void showAlertDialog(Context context, String title, String message, boolean toast) {
    if (toast) {
        Toast.makeText(context, message, Toast.LENGTH_LONG).show();
    } else {
        if (!((Activity) context).isFinishing()) {
            AlertDialog alertDialog = new AlertDialog.Builder(context).create();
            // Setting Dialog Title
            alertDialog.setTitle(title);
            // Setting Dialog Message
            alertDialog.setMessage(message);
            // Setting OK Button
            alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
            // Showing Alert Message
            alertDialog.show();
        }
    }
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint)

Example 64 with DialogInterface

use of android.content.DialogInterface in project android-app-common-tasks by multidots.

the class SocialAuthDialog method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    handler = new Handler();
    Util.getDisplayDpi(getContext());
    mSpinner = new ProgressDialog(getContext());
    mSpinner.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mSpinner.setMessage("Loading...");
    mSpinner.setCancelable(true);
    mContent = new LinearLayout(getContext());
    mContent.setOrientation(LinearLayout.VERTICAL);
    setUpTitle();
    setUpWebView();
    Display display = getWindow().getWindowManager().getDefaultDisplay();
    final float scale = getContext().getResources().getDisplayMetrics().density;
    int orientation = getContext().getResources().getConfiguration().orientation;
    float[] dimensions = (orientation == Configuration.ORIENTATION_LANDSCAPE) ? DIMENSIONS_DIFF_LANDSCAPE : DIMENSIONS_DIFF_PORTRAIT;
    addContentView(mContent, new LinearLayout.LayoutParams(display.getWidth() - ((int) (dimensions[0] * scale + 0.5f)), display.getHeight() - ((int) (dimensions[1] * scale + 0.5f))));
    mSpinner.setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialogInterface) {
            mWebView.stopLoading();
            mListener.onBack();
            SocialAuthDialog.this.dismiss();
        }
    });
    this.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
                mWebView.stopLoading();
                dismiss();
                mListener.onBack();
                return true;
            }
            return false;
        }
    });
}
Also used : DialogInterface(android.content.DialogInterface) Handler(android.os.Handler) ProgressDialog(android.app.ProgressDialog) KeyEvent(android.view.KeyEvent) LinearLayout(android.widget.LinearLayout) Display(android.view.Display)

Example 65 with DialogInterface

use of android.content.DialogInterface in project android-app-common-tasks by multidots.

the class Common method showNETWORDDisabledAlertToUser.

private void showNETWORDDisabledAlertToUser(final Context ctx) {
    AlertDialog alert;
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx);
    alertDialogBuilder.setMessage("Let the app use data connectivity.").setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            Intent callGPSSettingIntent = new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS);
            ctx.startActivity(callGPSSettingIntent);
        }
    });
    alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    alert = alertDialogBuilder.create();
    alert.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint)

Aggregations

DialogInterface (android.content.DialogInterface)2727 AlertDialog (android.app.AlertDialog)1227 View (android.view.View)877 Intent (android.content.Intent)708 TextView (android.widget.TextView)653 AlertDialog (android.support.v7.app.AlertDialog)644 EditText (android.widget.EditText)426 ImageView (android.widget.ImageView)308 OnClickListener (android.content.DialogInterface.OnClickListener)285 LayoutInflater (android.view.LayoutInflater)242 SuppressLint (android.annotation.SuppressLint)225 AdapterView (android.widget.AdapterView)220 ListView (android.widget.ListView)220 ArrayList (java.util.ArrayList)213 Dialog (android.app.Dialog)179 Context (android.content.Context)179 File (java.io.File)160 OnClickListener (android.view.View.OnClickListener)157 Bundle (android.os.Bundle)146 Activity (android.app.Activity)143