Search in sources :

Example 16 with AlertDialog

use of android.app.AlertDialog in project XPrivacy by M66B.

the class WhitelistTask method onPostExecute.

@Override
@SuppressLint({ "DefaultLocale", "InflateParams" })
protected void onPostExecute(Object result) {
    if (!mContext.isFinishing()) {
        // Build dialog
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext);
        alertDialogBuilder.setTitle(R.string.menu_whitelists);
        alertDialogBuilder.setIcon(mContext.getThemed(R.attr.icon_launcher));
        if (mListWhitelist.keySet().size() > 0) {
            LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View llWhitelists = inflater.inflate(R.layout.whitelists, null);
            int index = 0;
            int selected = -1;
            final List<String> localizedType = new ArrayList<String>();
            for (String type : mListWhitelist.keySet()) {
                String name = "whitelist_" + type.toLowerCase().replace("/", "");
                int id = mContext.getResources().getIdentifier(name, "string", mContext.getPackageName());
                if (id == 0)
                    localizedType.add(name);
                else
                    localizedType.add(mContext.getResources().getString(id));
                if (type.equals(mType))
                    selected = index;
                index++;
            }
            Spinner spWhitelistType = (Spinner) llWhitelists.findViewById(R.id.spWhitelistType);
            ArrayAdapter<String> whitelistTypeAdapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_spinner_dropdown_item, localizedType);
            spWhitelistType.setAdapter(whitelistTypeAdapter);
            spWhitelistType.setOnItemSelectedListener(new OnItemSelectedListener() {

                @Override
                public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                    mWhitelistAdapter.setType(mListWhitelist.keySet().toArray(new String[0])[position]);
                }

                @Override
                public void onNothingSelected(AdapterView<?> view) {
                }
            });
            if (selected >= 0)
                spWhitelistType.setSelection(selected);
            ListView lvWhitelist = (ListView) llWhitelists.findViewById(R.id.lvWhitelist);
            lvWhitelist.setAdapter(mWhitelistAdapter);
            int position = spWhitelistType.getSelectedItemPosition();
            if (position != AdapterView.INVALID_POSITION)
                mWhitelistAdapter.setType(mListWhitelist.keySet().toArray(new String[0])[position]);
            alertDialogBuilder.setView(llWhitelists);
        }
        alertDialogBuilder.setPositiveButton(mContext.getString(R.string.msg_done), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
            // Do nothing
            }
        });
        // Show dialog
        AlertDialog alertDialog = alertDialogBuilder.create();
        alertDialog.show();
    }
    super.onPostExecute(result);
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Spinner(android.widget.Spinner) ArrayList(java.util.ArrayList) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) ListView(android.widget.ListView) LayoutInflater(android.view.LayoutInflater) OnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener) ArrayAdapter(android.widget.ArrayAdapter) SuppressLint(android.annotation.SuppressLint)

Example 17 with AlertDialog

use of android.app.AlertDialog 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 18 with AlertDialog

use of android.app.AlertDialog 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)

Example 19 with AlertDialog

use of android.app.AlertDialog in project jmonkeyengine by jMonkeyEngine.

the class JmeAndroidSystem method showErrorDialog.

@Override
public void showErrorDialog(String message) {
    final String finalMsg = message;
    final String finalTitle = "Error in application";
    final Context context = JmeAndroidSystem.getView().getContext();
    view.getHandler().post(new Runnable() {

        @Override
        public void run() {
            AlertDialog dialog = new AlertDialog.Builder(context).setTitle(finalTitle).setMessage(finalMsg).create();
            dialog.show();
        }
    });
}
Also used : Context(android.content.Context) AlertDialog(android.app.AlertDialog)

Example 20 with AlertDialog

use of android.app.AlertDialog in project Klyph by jonathangerbaud.

the class StreamButtonBar method delete.

private void delete(View button, final Stream stream) {
    final Context context = getContext(button);
    final AlertDialog dialog = AlertUtil.showAlert(context, R.string.delete, R.string.deleting);
    new AsyncRequest(Query.DELETE_POST, stream.getPost_id(), "", new AsyncRequest.Callback() {

        @Override
        public void onComplete(Response response) {
            Log.d("onComplete", "" + response.getError());
            dialog.dismiss();
            if (response.getError() != null) {
                AlertUtil.showAlert(context, R.string.error, R.string.delete_post_error, R.string.ok);
            } else {
                Toast.makeText(context, R.string.post_deleted, Toast.LENGTH_SHORT).show();
                getParentAdapter().remove(stream, true);
            }
        }
    }).execute();
}
Also used : Context(android.content.Context) AlertDialog(android.app.AlertDialog) Response(com.abewy.android.apps.klyph.core.request.Response) AsyncRequest(com.abewy.android.apps.klyph.request.AsyncRequest) IFbPermissionCallback(com.abewy.android.apps.klyph.facebook.IFbPermissionCallback)

Aggregations

AlertDialog (android.app.AlertDialog)348 DialogInterface (android.content.DialogInterface)236 View (android.view.View)84 Intent (android.content.Intent)63 TextView (android.widget.TextView)63 EditText (android.widget.EditText)50 OnClickListener (android.content.DialogInterface.OnClickListener)34 Test (org.junit.Test)33 Context (android.content.Context)29 ListView (android.widget.ListView)28 ImageView (android.widget.ImageView)26 AdapterView (android.widget.AdapterView)25 LayoutInflater (android.view.LayoutInflater)24 SuppressLint (android.annotation.SuppressLint)23 Button (android.widget.Button)23 Activity (android.app.Activity)21 Paint (android.graphics.Paint)19 KeyEvent (android.view.KeyEvent)16 OnClickListener (android.view.View.OnClickListener)15 ArrayList (java.util.ArrayList)15