Example usage for android.app AlertDialog.Builder show

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

Introduction

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

Prototype

public void show() 

Source Link

Document

Start the dialog and display it on screen.

Usage

From source file:com.xmobileapp.rockplayer.RockPlayer.java

/*************************************
 * //from  w w w.java 2 s  .c  o  m
 * showSongList
 * 
 *************************************/
private void showSongList() {

    /*
     * Move album Cursor
     */
    try {
        albumCursor.moveToPosition(playerServiceIface.getAlbumCursorPosition());
    } catch (RemoteException e) {
        e.printStackTrace();
    }
    albumNavigatorItemLongClickIndex = albumCursor.getPosition();

    /*
     * getSongCursor
     */
    songCursor = initializeSongCursor(
            albumCursor.getString(albumCursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM)));

    /*
     * populate song list
     */
    String[] fieldsFrom = new String[1];
    int[] fieldsTo = new int[1];
    fieldsFrom[0] = MediaStore.Audio.Media.TITLE;
    fieldsTo[0] = R.id.songlist_item_song_name;
    SongCursorAdapter songAdapter = new SongCursorAdapter(this, R.layout.songlist_dialog_item, songCursor,
            fieldsFrom, fieldsTo);

    /*
     * Create Dialog
     */
    AlertDialog.Builder aD = new AlertDialog.Builder(context);
    aD.create();
    aD.setTitle(albumCursor.getString(albumCursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM)) + "\n"
            + albumCursor.getString(albumCursor.getColumnIndexOrThrow(MediaStore.Audio.Albums.ARTIST)));
    aD.setAdapter(songAdapter, songListDialogClickListener);
    aD.show();
}

From source file:com.xmobileapp.rockplayer.RockPlayer.java

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    /*/* w  w  w .ja  v a2 s.c  om*/
     * Shuffle
     */
    case 0:
        if (this.SHUFFLE)
            this.SHUFFLE = false;
        else
            this.SHUFFLE = true;
        try {
            playerServiceIface.setShuffle(this.SHUFFLE);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
        RockOnPreferenceManager settings = new RockOnPreferenceManager(FILEX_PREFERENCES_PATH);
        settings.putBoolean("Shuffle", this.SHUFFLE);
        return true;
    /*
     * Search
     */
    case 1:
        if (GRATIS) {
            showLitePopup();
            return true;
        }

        //this.hideMainUI();
        this.showSongSearch();
        this.songSearchTextView.requestFocus();
        Cursor allSongsCursor = contentResolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, SONG_COLS, // we should minimize the number of columns
                null, // all songs
                null, // parameters to the previous parameter - which is null also 
                null // sort order, SQLite-like
        );
        SimpleCursorAdapter songAdapter = new SimpleCursorAdapter(this, R.layout.simple_dropdown_item_2line,
                allSongsCursor, new String[] { MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.ARTIST },
                new int[] { R.id.text1, R.id.text2 });
        FilterQueryProvider songSearchFilterProvider = new FilterQueryProvider() {
            @Override
            public Cursor runQuery(CharSequence constraint) {
                String whereClause = MediaStore.Audio.Media.TITLE + " LIKE '%" + constraint + "%'" + " OR "
                        + MediaStore.Audio.Media.ARTIST + " LIKE '%" + constraint + "%'";
                Log.i("SEARCH", whereClause);
                //whereClause = null;
                Cursor songsCursor = contentResolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                        SONG_COLS, // we should minimize the number of columns
                        whereClause, // songs where the title or artist name matches
                        null, // parameters to the previous parameter - which is null also 
                        null // sort order, SQLite-like
                );
                return songsCursor;
            }
        };
        songAdapter.setFilterQueryProvider(songSearchFilterProvider);
        this.songSearchTextView.setAdapter(songAdapter);
        songAdapter
                .setStringConversionColumn(allSongsCursor.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE));
        //this.songSearchTextView.setOnKeyListener(songSearchKeyListener);
        return true;
    /*
     * Share
     */
    case 5:
        if (GRATIS) {
            showLitePopup();
            return true;
        }

        ShareSong shareSong = new ShareSong(context, songCursor);
        shareSong.shareByMail();
        return true;
    /*
     * Get Art
     */
    case 3:
        //           if(GRATIS){
        //              showLitePopup();
        //              return true;
        //           }
        albumReloadProgressDialog = new ProgressDialog(this);
        albumReloadProgressDialog.setIcon(R.drawable.ic_menu_music_library);
        albumReloadProgressDialog.setTitle("Loading Album Art");
        albumReloadProgressDialog.setMessage("Waiting for Last.FM connection");
        // TODO: set powered by Last.FM
        albumReloadProgressDialog.show();
        Thread albumArtThread = new Thread() {
            public void run() {
                try {
                    LastFmAlbumArtImporter lastFmArtImporter = new LastFmAlbumArtImporter(context);
                    lastFmArtImporter.getAlbumArt();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        };
        //albumArtThread.setUncaughtExceptionHandler(albumArtUncaughtExceptionHandler);
        albumArtThread.start();
        //containerLayout.addView(albumReloadProgressDialog);
        return true;
    /*
     * Concerts
     */
    case 4:
        if (GRATIS) {
            showLitePopup();
            return true;
        }

        this.hideMainUI();
        this.mainUIContainer.setVisibility(View.GONE);
        //this.hideHelpUI();
        this.showEventUI();

        /*
         * Concert Radius Thing 
         */
        // TODO: need a metric
        //         SharedPreferences prefs = getSharedPreferences(PREFS_NAME, 0);
        RockOnPreferenceManager prefs = new RockOnPreferenceManager(FILEX_PREFERENCES_PATH);
        concertRadius = prefs.getLong("ConcertRadius", (long) (this.CONCERT_RADIUS_DEFAULT));
        this.eventListRadius.setText(String.valueOf(Math.round((float) concertRadius / 1000)));

        /*
         * Show a dialog to give some nice feedback to the user
         */
        concertAnalysisProgressDialog = new ProgressDialog(this);
        concertAnalysisProgressDialog.setIcon(android.R.drawable.ic_menu_today);
        concertAnalysisProgressDialog.setTitle("Analysing concert information");
        concertAnalysisProgressDialog.setMessage("Waiting for Last.FM connection");
        concertAnalysisProgressDialog.show();

        /*
         * Analyze concert info
         */
        lastFmEventImporter = new LastFmEventImporter(context);
        new Thread() {
            public void run() {
                try {
                    lastFmEventImporter.getArtistEvents();
                } catch (SAXException e) {
                    e.printStackTrace();
                } catch (ParserConfigurationException e) {
                    e.printStackTrace();
                }
            }
        }.start();
        return true;
    /*
     * Playlists
     */
    case 6:
        if (GRATIS) {
            showLitePopup();
            return true;
        }

        /*
         * Get the views and make them visible
         */
        String sortOrder = MediaStore.Audio.Playlists.NAME + " ASC";
        Cursor playlistAllCursor = contentResolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                this.PLAYLIST_COLS, null, null, sortOrder);

        /*
         * Create Array with custom playlist + system playlists
         */
        Playlist playlistTemp;
        ArrayList<Playlist> playlistArray = new ArrayList<Playlist>();
        /* ALL Playlist*/
        playlistTemp = new Playlist();
        playlistTemp.id = constants.PLAYLIST_ALL;
        playlistTemp.name = "All songs";
        playlistArray.add(playlistTemp);
        /* Recently Added */
        playlistTemp = new Playlist();
        playlistTemp.id = constants.PLAYLIST_RECENT;
        playlistTemp.name = "Recently Added";
        playlistArray.add(playlistTemp);
        /* ... other system playlists ... */

        /* add every playlist in the media store */
        while (playlistAllCursor.moveToNext()) {
            playlistTemp = new Playlist();
            playlistTemp.id = playlistAllCursor
                    .getLong(playlistAllCursor.getColumnIndexOrThrow(MediaStore.Audio.Playlists._ID));
            playlistTemp.name = playlistAllCursor
                    .getString(playlistAllCursor.getColumnIndexOrThrow(MediaStore.Audio.Playlists.NAME));
            playlistArray.add(playlistTemp);
            Log.i("PLAYLIST MENU", playlistTemp.id + " " + playlistTemp.name);
        }

        //           String[] fieldsFrom = new String[1];
        //          int[]   fieldsTo = new int[1];
        //           fieldsFrom[0] = MediaStore.Audio.Playlists.NAME;
        //          fieldsTo[0] = R.id.playlist_name;
        //           PlaylistCursorAdapter playlistAllAdapter = new PlaylistCursorAdapter(this.getApplicationContext(),
        //                                                                 R.layout.playlist_item, 
        //                                                                 playlistAllCursor, 
        //                                                                 fieldsFrom, 
        //                                                                 fieldsTo);
        PlaylistArrayAdapter playlistAllAdapter = new PlaylistArrayAdapter(getApplicationContext(),
                R.layout.playlist_item, playlistArray);

        /*
         * Create Dialog
         */
        AlertDialog.Builder aD = new AlertDialog.Builder(context);
        aD.create();
        aD.setTitle("Select Playlist");
        aD.setAdapter(playlistAllAdapter, playlistDialogClickListener);
        aD.show();

        //           playlistView.setAdapter(playlistAllAdapter);
        //           
        //           playlistView.setOnItemClickListener(playlistItemClickListener);

        //           /*
        //            * Animate scroll up of the listview
        //            */
        //           TranslateAnimation slideUp = new TranslateAnimation(0,0,display.getHeight(),0);
        //           slideUp.setFillAfter(true);
        //           slideUp.setDuration(250);
        //           playlistContainer.startAnimation(slideUp);
        //           
        //this.mainUIContainer.addView(playlistAllSpinner);
        return true;
    /*
     * Preferences
     */
    case 7:
        if (GRATIS) {
            showLitePopup();
            return true;
        }

        Intent i = new Intent();
        i.setClass(getApplicationContext(), RockOnSettings.class);
        //              this.recentPlaylistPeriod = getSharedPreferences(PREFS_NAME, 0)
        (new RockOnPreferenceManager(FILEX_PREFERENCES_PATH)).getInt(new Constants().PREF_KEY_RECENT_PERIOD,
                new Constants().RECENT_PERIOD_DEFAULT_IN_DAYS);
        startActivityForResult(i, new Constants().PREFERENCES_REQUEST);
        return true;
    /*
     * Help
     */
    case 8:
        this.hideMainUI();
        //this.mainUIContainer.setVisibility(View.GONE);
        this.showHelpUI();
        return true;
    /*
     * Exit
     */
    case 2:
        try {
            this.playerServiceIface.destroy();
            this.finish();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return true;
    }
    return false;
}

From source file:com.guardtrax.ui.screens.HomeScreen.java

@Override
public void onBackPressed() {
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);

    if (GTConstants.sendData) {
        dialog.setTitle("Warning");
        dialog.setMessage("You must end shift before exit!");
        dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            @Override//from  w w  w. ja  va  2 s .c o m
            public void onClick(DialogInterface dialog, int which) {
                return;
            }
        });
        dialog.show();
    } else {
        dialog.setTitle("Exit?");
        dialog.setMessage("Are you sure you want to exit?");
        dialog.setNegativeButton(android.R.string.no, null);
        dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();

                // Create a Dialog to let the User know that we're waiting for a GPS Fix
                pdialog = ProgressDialog.show(HomeScreen.this, "Please wait", "Exiting GT Android ...", true);

                Runnable showWaitDialog = new Runnable() {
                    @Override
                    public void run() {
                        try {
                            Looper.prepare();
                            MainService.closeLocationListener(); //close out GPS

                            //only send 92 if online
                            if (Utility.isOnline(HomeScreen.this)) {
                                GTConstants.sendData = true; //allow the exit event to be sent
                                send_event("92"); //send the event
                                Utility.Sleep(4000); //give time for the event to be sent before exiting
                            }

                            stopService();

                            Utility.Sleep(1000);
                            pdialog.dismiss();
                            Utility.Sleep(1000);

                            //terminating the running threads and finishing program must be run on the main thread
                            HomeScreen.this.runOnUiThread(new Runnable() {
                                public void run() {
                                    if (pdialog.isShowing())
                                        pdialog.dismiss();
                                    HomeScreen.super.onBackPressed();
                                    android.os.Process.killProcess(android.os.Process.myPid());
                                    finish();
                                }
                            });
                        } catch (Exception e) {

                            //terminating the running threads and finishing program must be run on the main thread
                            HomeScreen.this.runOnUiThread(new Runnable() {
                                public void run() {
                                    if (pdialog.isShowing())
                                        pdialog.dismiss();
                                    HomeScreen.super.onBackPressed();
                                    android.os.Process.killProcess(android.os.Process.myPid());
                                    finish();
                                }
                            });

                        }
                    }
                };

                Thread t = new Thread(showWaitDialog);
                t.start();
            }
        });

        dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (!Utility.deviceRegistered()) {
                    //send_data = true;
                    scan_click(false);
                }
            }
        });

        dialog.show();
    }
}

From source file:com.guardtrax.ui.screens.HomeScreen.java

private void showYesNoAlert(String title, String message, final Runnable func) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(HomeScreen.this);

    dialog.setTitle(title);//from   w ww  .  j a  v  a 2s . c  o  m
    dialog.setMessage(message);
    dialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int place) {
            func.run();
        }
    });

    dialog.setNegativeButton("No", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int place) {
            trafficIncident = false;
        }
    });
    dialog.show();
}

From source file:com.nest5.businessClient.Initialactivity.java

/**
 * //from   w  ww  . ja va 2 s .  c o m
 * FUNCIONES DE LECTOR DE TARJETAS MAGNETICAS ACR31 DE ADVANCE CARD SYSTEMS
 * LTD ACS LTD
 * 
 * 
 * 
 * 
 * Checks the reset volume.
 * 
 * @return true if current volume is equal to maximum volume.
 */

/* Set the reset complete callback. */

private void showMessageDialog(String titleId, String messageId) {

    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);

    builder.setMessage(messageId).setTitle(titleId).setPositiveButton("Aceptar",
            new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });

    builder.show();
}

From source file:com.guardtrax.ui.screens.HomeScreen.java

private void show_username_dialog() {
    AlertDialog.Builder dialog = new AlertDialog.Builder(HomeScreen.this);
    dialog.setTitle("User name: " + GTConstants.report_name);
    dialog.setMessage("Enter your name");
    final EditText input = new EditText(this);
    dialog.setView(input);/* w w  w .ja  va  2s . c om*/

    dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            //store in GTConstants for current use
            GTConstants.report_name = input.getText().toString().trim();

            //store in preferences for later use
            SharedPreferences settings = getSharedPreferences("GTPrefs", 0);
            SharedPreferences.Editor editor = settings.edit();
            editor.putString("userName", GTConstants.report_name);
            editor.commit();

            setuserBanner();
        }
    });

    //if no email to be sent then exit
    dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

        }
    });
    dialog.show();
}

From source file:com.guardtrax.ui.screens.HomeScreen.java

private void show_taa_scan(final boolean startShift, final boolean endShift) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(HomeScreen.this);
    dialog.setTitle("Time-Attendance");
    dialog.setMessage("Scan Location Tag?");

    dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override/*from  ww w . j  a v a 2s . co  m*/
        public void onClick(DialogInterface dialog, int which) {
            if (startShift)
                taa = 1;
            if (endShift)
                taa = 2;
            scan_click(true);
        }
    });

    //if no email to be sent then exit
    dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Utility.write_to_file(HomeScreen.this, GTConstants.dardestinationFolder + GTConstants.tarfileName,
                    "Tag Scan;No Location Scan" + "\r\n", true);

            //if starting a shift
            if (startShift) {
                taa = 0;
            }

            //if ending a shift
            if (endShift) {
                taa = 2; //this tells the onResume to execute the end shift code
                onResume();
            }

        }
    });
    dialog.show();
}

From source file:edu.mit.viral.shen.DroidFish.java

private final void initUI() {
    leftHanded = leftHandedView();//from www.  j a v a 2 s.  c  om
    setContentView(leftHanded ? R.layout.main_left_handed : R.layout.main);
    Util.overrideFonts(findViewById(android.R.id.content));

    // title lines need to be regenerated every time due to layout changes (rotations)
    secondTitleLine = findViewById(R.id.second_title_line);
    // whiteTitleText = (TextView)findViewById(R.id.white_clock);
    // whiteTitleText.setSelected(true);
    // blackTitleText = (TextView)findViewById(R.id.black_clock);
    // blackTitleText.setSelected(true);
    engineTitleText = (TextView) findViewById(R.id.title_text);
    whiteFigText = (TextView) findViewById(R.id.white_pieces);
    whiteFigText.setTypeface(figNotation);
    whiteFigText.setSelected(true);
    // whiteFigText.setTextColor(whiteTitleText.getTextColors());
    blackFigText = (TextView) findViewById(R.id.black_pieces);
    blackFigText.setTypeface(figNotation);
    blackFigText.setSelected(true);
    // blackFigText.setTextColor(blackTitleText.getTextColors());
    summaryTitleText = (TextView) findViewById(R.id.title_text_summary);

    status = (TextView) findViewById(R.id.status);
    //   server = (TextView)findViewById(R.id.server);
    moveListScroll = (ScrollView) findViewById(R.id.scrollView);
    moveList = (TextView) findViewById(R.id.moveList);
    defaultMoveListTypeFace = moveList.getTypeface();
    thinking = (TextView) findViewById(R.id.thinking);
    defaultThinkingListTypeFace = thinking.getTypeface();
    status.setFocusable(false);
    moveListScroll.setFocusable(false);
    moveList.setFocusable(false);
    moveList.setMovementMethod(LinkMovementMethod.getInstance());
    thinking.setFocusable(false);

    cb = (ChessBoardPlay) findViewById(R.id.chessboard);
    cb.setFocusable(true);
    cb.requestFocus();
    cb.setClickable(true);
    cb.setPgnOptions(pgnOptions);

    final GestureDetector gd = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {
        private float scrollX = 0;
        private float scrollY = 0;

        @Override
        public boolean onDown(MotionEvent e) {
            if (!boardGestures) {
                handleClick(e);
                return true;
            }
            scrollX = 0;
            scrollY = 0;
            return false;
        }

        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            if (!boardGestures)
                return false;
            cb.cancelLongPress();
            if (invertScrollDirection) {
                distanceX = -distanceX;
                distanceY = -distanceY;
            }
            if ((scrollSensitivity > 0) && (cb.sqSize > 0)) {
                scrollX += distanceX;
                scrollY += distanceY;
                float scrollUnit = cb.sqSize * scrollSensitivity;
                if (Math.abs(scrollX) >= Math.abs(scrollY)) {
                    // Undo/redo
                    int nRedo = 0, nUndo = 0;
                    while (scrollX > scrollUnit) {
                        nRedo++;
                        scrollX -= scrollUnit;
                    }
                    while (scrollX < -scrollUnit) {
                        nUndo++;
                        scrollX += scrollUnit;
                    }
                    if (nUndo + nRedo > 0)
                        scrollY = 0;
                    if (nRedo + nUndo > 1) {
                        boolean analysis = gameMode.analysisMode();
                        boolean human = gameMode.playerWhite() || gameMode.playerBlack();
                        if (analysis || !human)
                            ctrl.setGameMode(new GameMode(GameMode.TWO_PLAYERS));
                    }
                    for (int i = 0; i < nRedo; i++)
                        ctrl.redoMove();
                    for (int i = 0; i < nUndo; i++)
                        ctrl.undoMove();
                    ctrl.setGameMode(gameMode);
                } else {
                    // Next/previous variation
                    int varDelta = 0;
                    while (scrollY > scrollUnit) {
                        varDelta++;
                        scrollY -= scrollUnit;
                    }
                    while (scrollY < -scrollUnit) {
                        varDelta--;
                        scrollY += scrollUnit;
                    }
                    if (varDelta != 0)
                        scrollX = 0;
                    ctrl.changeVariation(varDelta);
                }
            }
            return true;
        }

        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            if (!boardGestures)
                return false;
            cb.cancelLongPress();
            handleClick(e);
            return true;
        }

        @Override
        public boolean onDoubleTapEvent(MotionEvent e) {
            if (!boardGestures)
                return false;
            if (e.getAction() == MotionEvent.ACTION_UP)
                handleClick(e);
            return true;
        }

        private final void handleClick(MotionEvent e) {
            if (ctrl.humansTurn()) {
                int sq = cb.eventToSquare(e);
                Move m = cb.mousePressed(sq);
                if (m != null) {
                    ctrl.makeHumanMove(m);
                    String longfen = TextIO.toFEN(cb.pos);
                    String sentout = utils.getSendMessageJSON(longfen);
                    sendJSON(sentout);
                    // String fen1=longfen.replaceAll("D","1");]
                    // commented out 04/12/15
                    // sendDataone(longfen, 1); 
                }

                setEgtbHints(cb.getSelectedSquare());
            }
        }

        @Override
        public void onLongPress(MotionEvent e) {
            if (!boardGestures)
                return;
            ((Vibrator) getSystemService(Context.VIBRATOR_SERVICE)).vibrate(20);
            removeDialog(BOARD_MENU_DIALOG);
            showDialog(BOARD_MENU_DIALOG);
        }
    });
    cb.setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            return gd.onTouchEvent(event);
        }
    });
    cb.setOnTrackballListener(new ChessBoard.OnTrackballListener() {
        public void onTrackballEvent(MotionEvent event) {
            if (ctrl.humansTurn()) {
                Move m = cb.handleTrackballEvent(event);
                if (m != null)
                    ctrl.makeHumanMove(m);
                setEgtbHints(cb.getSelectedSquare());

            }
        }
    });

    moveList.setOnLongClickListener(new OnLongClickListener() {
        public boolean onLongClick(View v) {
            removeDialog(MOVELIST_MENU_DIALOG);
            showDialog(MOVELIST_MENU_DIALOG);
            return true;
        }
    });
    thinking.setOnLongClickListener(new OnLongClickListener() {
        public boolean onLongClick(View v) {
            if (mShowThinking || gameMode.analysisMode()) {
                if (!pvMoves.isEmpty()) {
                    removeDialog(THINKING_MENU_DIALOG);
                    showDialog(THINKING_MENU_DIALOG);
                }
            }
            return true;
        }
    });

    custom1Button = (ImageButton) findViewById(R.id.custom1Button);
    custom1ButtonActions.setImageButton(custom1Button, this);
    custom2Button = (ImageButton) findViewById(R.id.custom2Button);
    custom2ButtonActions.setImageButton(custom2Button, this);
    custom3Button = (ImageButton) findViewById(R.id.custom3Button);
    custom3ButtonActions.setImageButton(custom3Button, this);

    /*        modeButton = (ImageButton)findViewById(R.id.modeButton);
            modeButton.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
        showDialog(GAME_MODE_DIALOG);
    }
            });
            */
    undoButton = (ImageButton) findViewById(R.id.undoButton);
    undoButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ctrl.undoMove();
            sendDataone(TextIO.toFEN(cb.pos), 1);

        }
    });
    undoButton.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            removeDialog(GO_BACK_MENU_DIALOG);
            showDialog(GO_BACK_MENU_DIALOG);
            return true;
        }
    });

    commentButton = (ImageButton) findViewById(R.id.commentbutton);
    commentButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(DroidFish.this);
            builder.setTitle(R.string.edit_comments);
            View content = View.inflate(DroidFish.this, R.layout.edit_comments, null);
            builder.setView(content);

            DroidChessController.CommentInfo commInfo = ctrl.getComments();

            final TextView preComment, moveView, nag, postComment;
            preComment = (TextView) content.findViewById(R.id.ed_comments_pre);
            moveView = (TextView) content.findViewById(R.id.ed_comments_move);
            nag = (TextView) content.findViewById(R.id.ed_comments_nag);
            postComment = (TextView) content.findViewById(R.id.ed_comments_post);

            preComment.setText(commInfo.preComment);
            postComment.setText(commInfo.postComment);
            moveView.setText(commInfo.move);
            String nagStr = Node.nagStr(commInfo.nag).trim();
            if ((nagStr.length() == 0) && (commInfo.nag > 0))
                nagStr = String.format(Locale.US, "%d", commInfo.nag);
            nag.setText(nagStr);

            builder.setNegativeButton(R.string.cancel, null);
            builder.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    String pre = preComment.getText().toString().trim();
                    String post = postComment.getText().toString().trim();
                    sendComment(post);
                    int nagVal = Node.strToNag(nag.getText().toString());

                    DroidChessController.CommentInfo commInfo = new DroidChessController.CommentInfo();
                    commInfo.preComment = pre;
                    commInfo.postComment = post;
                    commInfo.nag = nagVal;
                    ctrl.setComments(commInfo);

                }
            });

            builder.show();
        }
    });
    commentButton.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            removeDialog(GO_FORWARD_MENU_DIALOG);
            showDialog(GO_FORWARD_MENU_DIALOG);
            return true;
        }
    });

    redoButton = (ImageButton) findViewById(R.id.redoButton);
    redoButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ctrl.redoMove();
            //startNewGame(2);
        }
    });
    redoButton.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            removeDialog(GO_FORWARD_MENU_DIALOG);
            showDialog(GO_FORWARD_MENU_DIALOG);
            return true;
        }
    });
}

From source file:com.guardtrax.ui.screens.HomeScreen.java

private void report_click() {
    AlertDialog.Builder dialog = new AlertDialog.Builder(HomeScreen.this);
    dialog.setTitle("Reports - Documents");
    dialog.setMessage("Create Notes or review a Document?");

    dialog.setPositiveButton("Notes", new DialogInterface.OnClickListener() {
        @Override/*from  www. ja va2 s. c  o m*/
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent();
            intent.setClass(HomeScreen.this, ReportScreen.class);
            intent.putExtra("type", "Activity Report");
            intent.putExtra("incident", "");
            intent.putExtra("fromFile", "no");
            intent.putExtra("fileName", "");
            intent.putExtra("traffic", "no");
            startActivity(intent);
        }
    });

    dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
        }
    });

    dialog.setNeutralButton("Documents", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent();
            intent.setClass(HomeScreen.this, PostOrderScreen.class);

            if (new_document) {
                animation.cancel();
                new_document = false;
                intent.putExtra("new_document", Utility.getlastDocument());
            }

            startActivity(intent);
        }
    });
    dialog.show();
}

From source file:com.guardtrax.ui.screens.HomeScreen.java

private void show_license_dialog() {
    AlertDialog.Builder dialog = new AlertDialog.Builder(HomeScreen.this);
    dialog.setTitle("Traffic Violation Database");
    dialog.setMessage("Enter Plate #");
    final EditText input = new EditText(this);
    dialog.setView(input);// ww  w  .  j  a v a 2  s  .c om

    dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            Cursor c = Utility.getTrafficViolations(HomeScreen.this, input.getText().toString().trim());

            show_alert_title = "License Plate: " + input.getText().toString().trim().toUpperCase();
            if (c != null && c.moveToFirst()) {
                show_alert_message = "State: " + c.getString(1) + CRLF;
                show_alert_message = show_alert_message + "Number of Violations: " + c.getString(5) + CRLF;
                show_alert_message = show_alert_message + "Last Violation: " + c.getString(4) + CRLF;
                show_alert_message = show_alert_message + "Days since last violation: "
                        + Utility.getdayssincelastViolation(HomeScreen.this, input.getText().toString().trim());
            } else
                show_alert_message = "No Recorded Violations";

            showAlert(show_alert_title, show_alert_message, true);
        }
    });

    //if no email to be sent then exit
    dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

        }
    });
    dialog.show();
}