Example usage for android.content DialogInterface cancel

List of usage examples for android.content DialogInterface cancel

Introduction

In this page you can find the example usage for android.content DialogInterface cancel.

Prototype

void cancel();

Source Link

Document

Cancels the dialog, invoking the OnCancelListener .

Usage

From source file:chat.client.gui.ChatActivity.java

private void showAlertDialog(String message, final boolean fatal) {
    AlertDialog.Builder builder = new AlertDialog.Builder(ChatActivity.this);
    builder.setMessage(message).setCancelable(false).setPositiveButton("Ok",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                    if (fatal)
                        finish();/*www .  j  a v a 2 s.  c o  m*/
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.sourcey.materiallogindemo.PostItemActivity.java

private void DialogRequest(final String map_id, final String passenger) {
    View dialogBoxView = View.inflate(this, R.layout.dialog_request, null);
    final Button btnMap = (Button) dialogBoxView.findViewById(R.id.btnMap);
    final Button btnRequest = (Button) dialogBoxView.findViewById(R.id.btnRequest);

    btnMap.setOnClickListener(new View.OnClickListener() {
        @Override/*  w  ww  . j  a va 2s . c  om*/
        public void onClick(View v) {
            DialogMap();
        }
    });
    btnRequest.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if ("CAR".equals(type)) {
                saveRequest(map_id, user_id);
            } else if ("NOCAR".equals(type)) {
                saveRequest(map_id, passenger);
            } else {
                MessageDialog("!!");
            }
        }
    });
    /* String url = getString(R.string.url_map)+"index.php?poinFrom="+txtStart.getText().toString().trim()+"&poinTo="+txtEnd.getText().toString().trim();
            
     map.getSettings().setLoadsImagesAutomatically(true);
     map.getSettings().setJavaScriptEnabled(true);
     map.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
     map.loadUrl(url);*/

    AlertDialog.Builder builderInOut = new AlertDialog.Builder(this);
    builderInOut.setTitle("?");
    builderInOut.setMessage("").setView(dialogBoxView).setCancelable(false)
            .setPositiveButton("Close", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            }).show();
}

From source file:com.greatnowhere.radar.MainRadarActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (D)//w w  w. ja v a  2s  . c  om
        Log.e(TAG, "+++ ON CREATE +++");

    // Set up the window layout
    setContentView(R.layout.main_radar_view);

    rootView = findViewById(R.id.mainViewLayout);

    eventBus = EventBus.getDefault();
    eventBus.register(this);

    uiModeManager = (UiModeManager) getApplicationContext().getSystemService(UI_MODE_SERVICE);

    Preferences.init(getApplicationContext());

    log = (TextView) findViewById(R.id.logScroll);
    log.setMovementMethod(new ScrollingMovementMethod());
    alert = (TextView) findViewById(R.id.radarState);
    alertCredibility = (TextView) findViewById(R.id.radarThreatCredibility);
    connState = (TextView) findViewById(R.id.connStatus);
    voltage = (TextView) findViewById(R.id.voltageText);
    btnReconnect = (Button) findViewById(R.id.btnReconnect);
    uiMode = (TextView) findViewById(R.id.mainViewTextuiMode);
    roadInfo = (TextView) findViewById(R.id.mainViewTextLocationInfo);
    location = (TextView) findViewById(R.id.mainViewLocation);
    speedLimit = (TextView) findViewById(R.id.mainViewTextSpeedLimit);
    activity = (TextView) findViewById(R.id.mainViewTextActivityMode);
    btnReconnect.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            attemptConnect();
        }
    });
    btnQuit = (Button) findViewById(R.id.btnQuit);
    btnQuit.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            finish();
        }
    });

    // If BT is not on, request that it be enabled.
    // setupChat() will then be called during onActivityResult
    if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
        showDialog("Bluetooth not available!", new Dialog.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
                finish();
            }
        });
    } else {
        initialize();
        if (getIntent().getBooleanExtra(INTENT_BACKGROUND, false)) {
            goHome();
        }
    }
}

From source file:com.kircherelectronics.fusedgyroscopeexplorer.sensor.GyroscopeSensor.java

private void showGyroscopeNotAvailableAlert() {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);

    // set title// w  w w . j  ava2s  .  c  o  m
    alertDialogBuilder.setTitle("Gyroscope Not Available");

    // set dialog message
    alertDialogBuilder.setMessage("Your device is not equipped with a gyroscope or it is not responding...")
            .setCancelable(false)
            .setNegativeButton("I'll look around...", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // if this button is clicked, just close
                    // the dialog box and do nothing
                    dialog.cancel();
                }
            });

    // create alert dialog
    AlertDialog alertDialog = alertDialogBuilder.create();

    // show it
    alertDialog.show();
}

From source file:ch.jeda.platform.android.InputDialogFragment.java

@Override
public void onClick(final DialogInterface dialogInterface, final int which) {
    switch (which) {
    case Dialog.BUTTON_POSITIVE:
        this.request.setResult(this.request.getInputType().parse(this.input.getText().toString()));
        dialogInterface.dismiss();/*from   w  w  w.j  ava 2  s. co m*/
        break;
    case Dialog.BUTTON_NEGATIVE:
        this.request.cancelRequest();
        dialogInterface.cancel();
        break;
    }
}

From source file:com.springsource.greenhouse.twitter.TweetDetailsActivity.java

private void showRetweetDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage("Are you sure you want to Retweet?").setCancelable(false)
            .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    retweet();/*from  ww w.ja v  a 2 s  . c  o  m*/
                }
            }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.bringcommunications.etherpay.SendActivity.java

private void do_help(int title, int msg) {
    android.support.v7.app.AlertDialog.Builder alertDialogBuilder = new android.support.v7.app.AlertDialog.Builder(
            context);//  w  w  w  .j a  va  2 s .  c  o  m
    alertDialogBuilder.setTitle(getResources().getString(title));
    alertDialogBuilder.setMessage(getResources().getString(msg));
    alertDialogBuilder.setCancelable(false);
    alertDialogBuilder.setNeutralButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    android.support.v7.app.AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();
}

From source file:de.tudresden.inf.rn.mobilis.groups.overlays.GroupsOverlay.java

@Override
protected boolean onTap(int index) {
    OverlayItem item = mOverlays.get(index);
    GroupItemInfo gii = groupItemInfos.get(index);

    LayoutInflater inflater = (LayoutInflater) mainActivity
            .getSystemService(mainActivity.LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.groups_details_dialog,
            (ViewGroup) mainActivity.findViewById(R.id.groups_details_layout_root));

    TextView text = (TextView) layout.findViewById(R.id.groups_details_text);
    text.setText(Html.fromHtml("<b>Latitude:</b> " + gii.latitudeE6 / 1E6 + "<br><b>Longitude:</b> "
            + gii.longitudeE6 / 1E6 + "<br><b>Number of Members:</b> " + gii.memberCount));

    //Prepare the Intent for creating a group at this foursquare venue
    final Intent i = new Intent(mainActivity.getApplicationContext(), GroupInfoActivity.class);
    i.putExtra("group_id", gii.groupId);

    String title = gii.name;//from w w  w  . ja  v  a 2s  .  com
    if (title == null || title.equals(""))
        title = " ";
    AlertDialog.Builder builder = new AlertDialog.Builder(mainActivity);
    builder.setTitle(title).setView(layout).setIcon(R.drawable.group_marker_24).setCancelable(true)
            .setPositiveButton("Details", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    mainActivity.startActivity(i);
                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
    builder.show();
    return true;
}

From source file:com.application.treasurehunt.ScanQRCodeActivity.java

private void showFailedScanMessage() {

    Builder alertForNoData = new Builder(ScanQRCodeActivity.this);
    alertForNoData.setTitle("Invalid Code");
    alertForNoData.setMessage("This was an invalid scan for this particular treasure hunt. Please try again.");
    alertForNoData.setCancelable(false);
    alertForNoData.setNegativeButton("OK", new DialogInterface.OnClickListener() {

        @Override//from w  w  w.  ja  v  a  2  s  .co m
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    alertForNoData.create();
    alertForNoData.show();

    Log.w("ScanQRCode", "Invalid scan for hunt: " + mCurrentHuntId);
}

From source file:tm.veriloft.mapsplayground.MapsActivity.java

private void fetchAndDrawRoute(final LatLng... latLngs) {
    final AsyncHttpClient asyncHttpClient = new AsyncHttpClient(SERVER_PORT);

    final ProgressDialog progressDialog = new ProgressDialog(this);
    progressDialog.setMessage("Loading..");
    progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
        @Override/* ww  w  .ja  va 2s  . co m*/
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            asyncHttpClient.cancelRequests(MapsActivity.this, true);
            showCenteredToast("Drawing route got cancelled");
        }
    });

    final RequestParams requestParams = new RequestParams();

    for (LatLng latLng : latLngs) {
        requestParams.add("loc", latLng.latitude + "," + latLng.longitude);
        l("Added latLng to request, " + latLng);
    }

    asyncHttpClient.get(this, SERVER, requestParams, new JsonHttpResponseHandler() {
        @Override
        public void onStart() {
            progressDialog.show();
        }

        @Override
        public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
            try {
                ArrayList<LatLng> route = MapUtils.decodePoly(response.getString("route_geometry"));
                PolylineOptions routeOptions = new PolylineOptions();

                for (int i = 0; i < route.size(); i++) {
                    routeOptions.add(route.get(i));
                    l("Returned point " + route.get(i));
                    if (returnedPointsMarkers)
                        addedMarkers.add(mMap.addMarker(new MarkerOptions().position(route.get(i))
                                .title("#" + i + " point of #" + drawnRoutes.size())));
                }

                routeOptions.width(ROUTE_WIDTH).color(ROUTE_COLOR);
                drawnRoutes.add(mMap.addPolyline(routeOptions));

                List<LatLng> points = routeOptions.getPoints();

                if (focusAfterRouteDraw)
                    focusTo(points.get(0), 13);

                if (endMarkerRouteDraw) {
                    LatLng trueEndPoint = MapUtils.findTrueEndPoint(latLngs[latLngs.length - 1], route.get(0),
                            route.get(route.size() - 1));
                    addedMarkers.add(mMap.addMarker(
                            new MarkerOptions().position(trueEndPoint).title("End of #" + drawnRoutes.size())));
                }

                if (requestedPointMarkerRouteDraw)
                    addedMarkers.add(mMap.addMarker(new MarkerOptions().position(latLngs[latLngs.length - 1])
                            .title("Requested point of #" + drawnRoutes.size())));

            } catch (JSONException exception) {
                exception.printStackTrace();
                showCenteredToast("Exception while parsing! Error: " + exception.getLocalizedMessage());
            }
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONArray errorResponse) {
            showCenteredToast("Network error! Error: " + throwable.getLocalizedMessage());
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
            showCenteredToast("Network error! Server returned non-json response, response: " + responseString
                    + ", Error: " + throwable.getLocalizedMessage());
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {
            showCenteredToast("Network error! Error: " + throwable.getLocalizedMessage());
        }

        @Override
        public void onFinish() {
            progressDialog.dismiss();
        }
    });
}