Example usage for android.app AlertDialog.Builder setButton3

List of usage examples for android.app AlertDialog.Builder setButton3

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder setButton3.

Prototype

@Deprecated
public void setButton3(CharSequence text, final OnClickListener listener) 

Source Link

Document

Set a listener to be invoked when button 3 of the dialog is pressed.

Usage

From source file:com.TakeTaxi.jy.OnrouteScreen.java

public void pingpicked(JSONObject json) {

    try {/*from  ww  w.j a  v  a  2  s.com*/

        int driverpicked = json.getInt("picked");
        int drivercancelled = json.getInt("dcancel");
        int starttime = json.getInt("datetime");

        // /////////////////////////////// DRIVER CANCEL ////////
        if (drivercancelled == 1) {

            // //// DRIVER CANCEL LATE /////

            if (starttime + 300 <= Query.getServerTime()) {
                handlerboolean = false;
                handler.removeCallbacks(r);

                AlertDialog dcancelbuilder = new AlertDialog.Builder(OnrouteScreen.this).create();
                dcancelbuilder
                        .setMessage("Job has been cancelled.\nWould you like to report a late cancellation?.");

                // //// DRIVER CANCEL LATE - NO REPORT LATE/////
                button_cancelJob_noquery(dcancelbuilder);
                // //// DRIVER CANCEL LATE - REPORT LATE /////
                button_drivercancel_reportlate(dcancelbuilder);

                dcancelbuilder.show();

            } else {
                // /////////////////////////////// DRIVER CANCEL NO ALERTS -
                // WITHIN TIME LIMIT///////////////
                handlerboolean = false;
                handler.removeCallbacks(r);

                alertdialog_drivercancelintime();

            }
        }
        if (driverpicked == 1) {
            // /////////////////////////////// CONFIRM PICK UP
            // ///////////////////////////////////////////

            handlerboolean = false;
            handler.removeCallbacks(r);
            AlertDialog.Builder alert = new AlertDialog.Builder(OnrouteScreen.this);
            final Drawable thumbsup = getResources().getDrawable(R.drawable.thumbsup);
            final Drawable thumbsupwhite = getResources().getDrawable(R.drawable.thumbsupwhite);
            final Drawable thumbsdown = getResources().getDrawable(R.drawable.thumbsdown);
            final Drawable thumbsdownwhite = getResources().getDrawable(R.drawable.thumbsdownwhite);
            LinearLayout layout = new LinearLayout(OnrouteScreen.this);
            layout.setOrientation(1);
            layout.setGravity(17);

            TextView tx1 = new TextView(OnrouteScreen.this);
            tx1.setText("Driver says you have been picked up");
            tx1.setGravity(17);
            tx1.setTextSize(20);
            tx1.setTextColor(Color.WHITE);
            tx1.setPadding(10, 10, 10, 10);

            TextView tx2 = new TextView(OnrouteScreen.this);
            tx2.setText("Please rate your driver");
            tx2.setGravity(17);
            tx2.setTextSize(16);

            LinearLayout imglayout = new LinearLayout(OnrouteScreen.this);
            imglayout.setOrientation(0);
            imglayout.setGravity(17);

            final ImageView ivup = new ImageView(OnrouteScreen.this);
            ivup.setImageDrawable(thumbsupwhite);
            ivup.setClickable(true);
            ivup.setPadding(0, 5, 30, 5);
            final ImageView ivdown = new ImageView(OnrouteScreen.this);
            ivdown.setImageDrawable(thumbsdownwhite);
            ivdown.setClickable(true);
            ivup.setPadding(30, 5, 0, 5);
            imglayout.addView(ivup);
            imglayout.addView(ivdown);

            layout.addView(tx1);
            layout.addView(tx2);

            layout.addView(imglayout);
            // /////////////////////////////// CONFIRM PICK UP - RATINGS
            // ///////////////////////////////////////////

            ivup.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    if (thumbsupboolean == false) {
                        thumbsupboolean = true;
                        thumbsdownboolean = false;
                        ivup.setImageDrawable(thumbsup);
                        ivdown.setImageDrawable(thumbsdownwhite);
                        rating = 1;
                    } else {
                        thumbsupboolean = false;
                        ivup.setImageDrawable(thumbsupwhite);
                        rating = 0;
                    }

                }
            });

            ivdown.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    if (thumbsdownboolean == false) {
                        thumbsdownboolean = true;
                        thumbsupboolean = false;
                        ivdown.setImageDrawable(thumbsdown);
                        ivup.setImageDrawable(thumbsupwhite);

                        AlertDialog alert = new AlertDialog.Builder(OnrouteScreen.this).create();

                        alert.setMessage("Please pick one");
                        alert.setButton("No show", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                rating = -1;
                            }
                        });
                        alert.setButton2("Driver late", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                rating = -2;
                            }
                        });
                        alert.setButton3("Poor service", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                rating = -3;
                            }
                        });
                        alert.show();

                    } else {
                        thumbsupboolean = false;
                        ivdown.setImageDrawable(thumbsdownwhite);
                        rating = 0;
                    }

                }
            });

            button_completed_finish(alert);

            alert.setView(layout);
            alert.create();
            alert.show();
        } else {
        }

    } catch (JSONException e) {
    }
}