Example usage for android.content DialogInterface.OnClickListener DialogInterface.OnClickListener

List of usage examples for android.content DialogInterface.OnClickListener DialogInterface.OnClickListener

Introduction

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

Prototype

DialogInterface.OnClickListener

Source Link

Usage

From source file:og.android.tether.MainActivity.java

@Override
public boolean onTrackballEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        Log.d(MSG_TAG, "Trackball pressed ...");
        String tetherStatus = this.application.coretask.getProp("tether.status");
        if (!tetherStatus.equals("running")) {
            new AlertDialog.Builder(this).setMessage(getString(R.string.main_activity_trackball_pressed_start))
                    .setPositiveButton(getString(R.string.main_activity_confirm),
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    Log.d(MSG_TAG, "Trackball press confirmed ...");
                                    MainActivity.currentInstance.startBtnListener
                                            .onClick(MainActivity.currentInstance.startBtn);
                                }/*  w ww.  j  a va  2  s  . c  o m*/
                            })
                    .setNegativeButton(getString(R.string.main_activity_cancel), null).show();
        } else {
            if (MainActivity.this.lockBtn.isChecked()) {
                Log.d(MSG_TAG, "Tether was locked ...");
                MainActivity.this.application.displayToastMessage(getString(R.string.main_activity_locked));
                return false;
            }
            new AlertDialog.Builder(this).setMessage(getString(R.string.main_activity_trackball_pressed_stop))
                    .setPositiveButton(getString(R.string.main_activity_confirm),
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    Log.d(MSG_TAG, "Trackball press confirmed ...");
                                    MainActivity.currentInstance.stopBtnListener
                                            .onClick(MainActivity.currentInstance.startBtn);
                                }
                            })
                    .setNegativeButton(getString(R.string.main_activity_cancel), null).show();
        }
    }
    return true;
}

From source file:com.cttapp.bby.mytlc.layer8apps.MyTlc.java

/************
 *  PURPOSE: This creates a dialog for our user to choose their
 *      calendar from./*www  . j a v  a  2 s .  c om*/
 *  ARGUMENTS: String[][]
 *  RETURNS: boolean
 *      TRUE: We successfully created a calendar dialog
 *      FALSE: We failed to create a calendar dialog
 *  AUTHOR: Devin Collins <agent14709@gmail.com>
 *************/
private boolean createCalendarDialog(final String[][] calendars) {
    try {
        // Get the names for each calendar
        String names[] = new String[calendars.length];
        for (int i = 0; i < calendars.length; i++) {
            names[i] = calendars[i][1];
        }

        // Create a new alert dialog and set the options
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Choose a calendar");
        builder.setCancelable(true);
        builder.setSingleChoiceItems(names, -1, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialoginterface, int i) {
                // When we choose a calendar, get the ID and then get the events
                calID = Integer.parseInt(calendars[i][0]);
                dialoginterface.dismiss();
                runEvents();
            }
        });
        AlertDialog alert = builder.create();
        alert.show();
        return true;
    } catch (Exception e) {
        return false;
    }
}

From source file:net.kourlas.voipms_sms.activities.ConversationActivity.java

public void deleteMessages(final Long[] databaseIds) {
    Utils.showAlertDialog(this, getString(R.string.conversation_delete_confirm_title),
            getString(R.string.conversation_delete_confirm_message), getString(R.string.delete),
            new DialogInterface.OnClickListener() {
                @Override//from  w  ww .java 2s.  c  om
                public void onClick(DialogInterface dialog, int which) {
                    for (long databaseId : databaseIds) {
                        Message message = database.getMessageWithDatabaseId(preferences.getDid(), databaseId);
                        if (message.getVoipId() == null) {
                            database.removeMessage(databaseId);
                        } else {
                            message.setDeleted(true);
                            database.insertMessage(message);
                        }
                        adapter.refresh();
                    }
                }
            }, getString(R.string.cancel), null);
}

From source file:com.denel.facepatrol.MainActivity.java

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    // TODO: Implement this method
    switch (item.getItemId()) {
    case R.id.action_settings:
        Intent intent1 = new Intent(this, Settings.class);
        startActivity(intent1);/*from   w ww . j  av a 2  s  .c  o  m*/
        return true;
    case R.id.action_download:
        try {
            downloadunzip();
        } catch (IOException e) {
        }
        return true;
    case R.id.main_help:
        // start activity using dummy class
        run_quick_tips();
        //Intent intent = new Intent(this,dummypage.class);
        //intent.putExtra("title","Help");
        //startActivity(intent); 
        return true;
    case R.id.main_about:
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("About").setMessage(R.string.about).setPositiveButton("OK",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        // FIRE ZE MISSILES! 
                    }
                });
        //.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { 
        //   public void onClick(DialogInterface dialog, int id) { 
        // User cancelled the dialog 
        //} });
        builder.show();
        return true;
    case R.id.action_exit:
        // exit the application
        finish();
        return true;
    }
    return super.onMenuItemSelected(featureId, item);
}

From source file:org.sandholm.max.juttele.activity.ConversationActivity.java

/**
 * On server status update//from  w  w w.j a v a  2  s .c om
 */
@Override
public void onStatusUpdate() {
    EditText input = (EditText) findViewById(R.id.input);
    input.setHint(binder.getService().getConnection(serverId).getNick());

    if (server.isConnected()) {
        input.setEnabled(true);
    } else {
        input.setEnabled(false);

        if (server.getStatus() == Status.CONNECTING) {
            return;
        }

        // Service is not connected or initialized yet - See #54
        if (binder == null || binder.getService() == null || binder.getService().getSettings() == null) {
            return;
        }

        if (!binder.getService().getSettings().isReconnectEnabled() && !reconnectDialogActive) {
            reconnectDialogActive = true;
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setMessage(getResources().getString(R.string.reconnect_after_disconnect, server.getTitle()))
                    .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int id) {
                            if (!server.isDisconnected()) {
                                reconnectDialogActive = false;
                                return;
                            }
                            binder.getService().getConnection(server.getId())
                                    .setAutojoinChannels(server.getCurrentChannelNames());
                            server.setStatus(Status.CONNECTING);
                            binder.connect(server);
                            reconnectDialogActive = false;
                        }
                    }).setNegativeButton(getString(R.string.negative_button),
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int id) {
                                    server.setMayReconnect(false);
                                    reconnectDialogActive = false;
                                    dialog.cancel();
                                }
                            });
            AlertDialog alert = builder.create();
            alert.show();
        }
    }
}

From source file:com.denel.facepatrol.MainActivity.java

public void run_quick_tips() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Quick Tips").setMessage(R.string.quick_tips).setPositiveButton("OK",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // FIRE ZE MISSILES! 
                }/*from w w  w  . j  av  a  2 s . c om*/
            });
    //.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { 
    //   public void onClick(DialogInterface dialog, int id) { 
    // User cancelled the dialog 
    //} });
    builder.show();
}

From source file:net.networksaremadeofstring.rhybudd.ViewZenossEventsListActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    //Forces our onResume() function to do a DB call rather than a full HTTP request just cos we returned
    //from one of our subscreens
    //resumeOnResultPollAPI = false;
    BackupManager bm = null;/*from  w w w  .java  2 s. c  o m*/
    try {
        bm = new BackupManager(this);
    } catch (Exception e) {
        BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "onActivityResult BackupManager",
                e);
    }

    switch (requestCode) {
    case LAUNCHSETTINGS: {
        settings = PreferenceManager.getDefaultSharedPreferences(this);

        try {
            Intent intent = new Intent(this, ZenossPoller.class);
            intent.putExtra("settingsUpdate", true);
            startService(intent);
        } catch (Exception e) {
            BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity",
                    "onActivityResult startService", e);
        }

        try {
            bm.dataChanged();
        } catch (Exception e) {
            BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity",
                    "onActivityResult bm.dataChanged()", e);
        }

        //SyncAdapter stuff
        if (null != mAccount) {
            try {
                mResolver = getContentResolver();
                Bundle bndle = new Bundle();
                ContentResolver.addPeriodicSync(mAccount, AUTHORITY, bndle, 86400);

                ContentResolver.setSyncAutomatically(mAccount, AUTHORITY,
                        settings.getBoolean("refreshCache", true));

                /*bndle.putBoolean(
                        ContentResolver.SYNC_EXTRAS_MANUAL, true);
                bndle.putBoolean(
                        ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
                        
                Log.e("addPeriodicSync","Requesting a full sync!");
                ContentResolver.requestSync(mAccount, AUTHORITY, bndle);*/
            } catch (Exception e) {
                BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity",
                        "onActivityResult LAUNCHSETTINGS", e);
            }
        } else {
            //Log.e("addPeriodicSync","mAccount was null");
        }
    }
        break;

    case ZenossAPI.ACTIVITYRESULT_PUSHCONFIG: {
        try {
            GCMRegistrar.unregister(this);

            if (PreferenceManager.getDefaultSharedPreferences(ViewZenossEventsListActivity.this)
                    .getBoolean(ZenossAPI.PREFERENCE_PUSH_ENABLED, false))
                doGCMRegistration();
        } catch (Exception e) {
            BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity",
                    "onActivityResult ACTIVITYRESULT_PUSHCONFIG", e);
        }
    }
        break;

    default: {
        if (resultCode == 1) {
            try {
                SharedPreferences.Editor editor = settings.edit();
                editor.putBoolean("FirstRun", false);
                editor.commit();
            } catch (Exception e) {
                BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "onActivityResult default",
                        e);
            }

            //Also update our onResume helper bool although it should already be set
            firstRun = false;
            AlertDialog.Builder builder = null;
            AlertDialog welcomeDialog = null;
            try {
                builder = new AlertDialog.Builder(this);
                builder.setMessage(
                        "Additional settings and functionality can be found by pressing the Action bar overflow.\r\n"
                                + "\r\nIf you experience issues please email;\r\nGareth@DataSift.com before leaving negative reviews.")
                        .setTitle("Welcome to Rhybudd!").setCancelable(true)
                        .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                finishStart();
                            }
                        });
                welcomeDialog = builder.create();
            } catch (Exception e) {
                BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "onActivityResult default",
                        e);
            }

            try {
                welcomeDialog.show();
            } catch (Exception e) {
                finishStart();
                BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity",
                        "OnActivityResult welcomedialog", e);
            }

            try {
                bm.dataChanged();
            } catch (Exception e) {
                BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "onActivityResult default",
                        e);
            }
        } else if (resultCode == 2) {
            try {
                Toast.makeText(ViewZenossEventsListActivity.this,
                        getResources().getString(R.string.FirstRunNeedSettings), Toast.LENGTH_LONG).show();
            } catch (Exception e) {
                BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity",
                        "onActivityResult resultcode 2", e);
            }
            finish();
        }
        //Who knows what happened here - quit
        else {
            //Toast.makeText(ViewZenossEventsListActivity.this, getResources().getString(R.string.FirstRunNeedSettings), Toast.LENGTH_LONG).show();
            //finish();
        }
    }
        break;
    }
}

From source file:com.free.searcher.MainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup viewContainer, Bundle savedInstanceState) {

    super.onCreateView(inflater, viewContainer, savedInstanceState);
    this.activity = getActivity();
    actionBar = activity.getActionBar();

    View v = inflater.inflate(R.layout.main, viewContainer, false);
    v.setOnSystemUiVisibilityChangeListener(this);

    webView = (WebView) v.findViewById(R.id.webView1);
    statusView = (TextView) v.findViewById(R.id.statusView);

    if (webViewBundle != null) {
        webView.restoreState(webViewBundle);
        Log.d("onCreateView.webView.restoreState", webViewBundle + "");
    } else if (currentUrl.length() > 0) {
        Log.d("onCreateView.locX, locY", locX + ", " + locY + ", " + currentUrl);
        webView.loadUrl(currentUrl);//w w  w .  j  av a2s .  c om
        webView.setScrollX(locX);
        webView.setScrollY(locY);
        Log.d("currentUrl 8", currentUrl);
    }
    statusView.setText(status);

    Log.d("onCreateView.savedInstanceState", savedInstanceState + "vvv");
    mNotificationManager = (NotificationManager) activity.getSystemService(activity.NOTIFICATION_SERVICE);

    webView.setFocusable(true);
    webView.setFocusableInTouchMode(true);
    webView.requestFocus();
    webView.requestFocusFromTouch();
    webView.getSettings().setAllowContentAccess(false);
    webView.getSettings().setPluginState(WebSettings.PluginState.OFF);
    // webView.setBackgroundColor(LIGHT_BLUE);
    webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    webView.setBackgroundColor(getResources().getColor(R.color.lightyellow));

    webView.setOnLongClickListener(this);
    statusView.setOnLongClickListener(this);

    webView.setWebViewClient(new WebViewClient() {

        private void jumpTo(final int xLocation, final int yLocation) {
            webView.postDelayed(new Runnable() {
                @Override
                public void run() {
                    Log.d("jumpTo1.locX, locY", xLocation + ", " + yLocation + ", " + currentUrl);
                    try {
                        webView.scrollTo(xLocation, yLocation);
                        webView.setScrollX(xLocation);
                        webView.setScrollY(yLocation);
                        //                           locX = 0;
                        //                           locY = 0;
                    } catch (RuntimeException e) {
                        Log.e("error jumpTo2.locX, locY", locX + ", " + locY + ", " + currentUrl);
                    }
                }
            }, 100);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, final String url) {
            if (currentZipFileName.length() > 0 && (extractFile == null || extractFile.isClosed())) {
                try {
                    extractFile = new ExtractFile(currentZipFileName,
                            MainFragment.PRIVATE_PATH + currentZipFileName);
                } catch (RarException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            int ind = url.indexOf("?deleteFile=");
            if (ind >= 0) {
                if (dupTask == null) {
                    showToast("Please do duplicate finding again.");
                    return true;
                }

                String urlStatus = Util.getUrlStatus(url);
                final String selectedFile = urlStatus.substring(urlStatus.indexOf("?deleteFile=") + 12,
                        urlStatus.length());
                Log.d("deleteFile", "url=" + url + ", urlStatus=" + urlStatus);

                AlertDialog.Builder alert = new AlertDialog.Builder(activity);
                alert.setTitle("Delete File?");
                alert.setMessage("Do you really want to delete file \"" + selectedFile + "\"?");
                alert.setCancelable(true);
                alert.setNegativeButton("Yes", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        try {
                            locX = webView.getScrollX();
                            locY = webView.getScrollY();
                            webView.loadUrl(
                                    new File(dupTask.deleteFile(selectedFile)).toURI().toURL().toString());
                        } catch (IOException e) {
                            statusView.setText(e.getMessage());
                            Log.d("deleteFile", e.getMessage(), e);
                        }
                    }
                });
                alert.setPositiveButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
                AlertDialog alertDialog = alert.create();
                alertDialog.show();
                return true;
            }

            ind = url.indexOf("?deleteGroup=");
            if (ind >= 0) {
                if (dupTask == null) {
                    showToast("Please do duplicate finding again.");
                    return true;
                }

                String urlStatus = Util.getUrlStatus(url);
                final String groupFile = urlStatus.substring(urlStatus.indexOf("?deleteGroup=") + 13,
                        urlStatus.length());
                int indexOf = groupFile.indexOf(",");
                final int group = Integer.parseInt(groupFile.substring(0, indexOf));
                final String selectedFile = groupFile.substring(indexOf + 1);
                Log.d("groupFile", ",groupFile=" + groupFile + ", url=" + url + ", urlStatus=" + urlStatus);

                AlertDialog.Builder alert = new AlertDialog.Builder(activity);
                alert.setTitle("Delete Group of Files?");
                alert.setMessage(
                        "Do you really want to delete this group, except file \"" + selectedFile + "\"?");
                alert.setCancelable(true);
                alert.setNegativeButton("Yes", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        locX = webView.getScrollX();
                        locY = webView.getScrollY();
                        webView.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                try {
                                    webView.loadUrl(new File(dupTask.deleteGroup(group, selectedFile)).toURI()
                                            .toURL().toString());
                                } catch (Throwable e) {
                                    statusView.setText(e.getMessage());
                                    Log.e("Delete Group", e.getMessage(), e);
                                    Log.e("Delete Group", locX + ", " + locY + ", " + currentUrl);
                                }
                            }
                        }, 0);
                    }
                });
                alert.setPositiveButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
                AlertDialog alertDialog = alert.create();
                alertDialog.show();
                return true;
            }

            ind = url.indexOf("?deleteFolder=");
            if (ind >= 0) {
                if (dupTask == null) {
                    showToast("Please do duplicate finding again.");
                    return true;
                }

                String urlStatus = Util.getUrlStatus(url);
                final String selectedFile = urlStatus.substring(urlStatus.indexOf("?deleteFolder=") + 14,
                        urlStatus.length());
                Log.d("deleteFolder",
                        ",deleteFolder=" + selectedFile + ", url=" + url + ", urlStatus=" + urlStatus);
                AlertDialog.Builder alert = new AlertDialog.Builder(activity);
                alert.setTitle("Delete folder?");
                alert.setMessage("Do you really want to delete duplicate in folder \""
                        + selectedFile.substring(0, selectedFile.lastIndexOf("/")) + "\"?");
                alert.setCancelable(true);
                alert.setNegativeButton("Yes", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        locX = webView.getScrollX();
                        locY = webView.getScrollY();
                        webView.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                try {
                                    webView.loadUrl(new File(dupTask.deleteFolder(selectedFile)).toURI().toURL()
                                            .toString());
                                } catch (Throwable e) {
                                    statusView.setText(e.getMessage());
                                    Log.e("Delete folder", e.getMessage(), e);
                                    Log.e("Delete folder", locX + ", " + locY + ", " + currentUrl);
                                }
                            }
                        }, 0);
                    }
                });
                alert.setPositiveButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
                AlertDialog alertDialog = alert.create();
                alertDialog.show();
                return true;
            }

            ind = url.indexOf("?deleteSub=");
            if (ind >= 0) {
                if (dupTask == null) {
                    showToast("Please do duplicate finding again.");
                    return true;
                }

                String urlStatus = Util.getUrlStatus(url);

                final String selectedFile = urlStatus.substring(urlStatus.indexOf("?deleteSub=") + 11,
                        urlStatus.length());
                Log.d("deleteSub", ",deleteSub=" + selectedFile + ", url=" + url + ", urlStatus=" + urlStatus);
                AlertDialog.Builder alert = new AlertDialog.Builder(activity);
                alert.setTitle("Delete sub folder?");
                alert.setMessage("Do you really want to delete duplicate files in sub folder of \""
                        + selectedFile.substring(0, selectedFile.lastIndexOf("/")) + "\"?");
                alert.setCancelable(true);
                alert.setNegativeButton("Yes", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        locX = webView.getScrollX();
                        locY = webView.getScrollY();
                        webView.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                try {
                                    webView.loadUrl(new File(dupTask.deleteSubFolder(selectedFile)).toURI()
                                            .toURL().toString());
                                } catch (Throwable e) {
                                    statusView.setText(e.getMessage());
                                    Log.e("Delete sub folder", e.getMessage(), e);
                                    Log.e("Delete sub folder", locX + ", " + locY + ", " + currentUrl);
                                }
                            }
                        }, 0);
                    }
                });
                alert.setPositiveButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
                AlertDialog alertDialog = alert.create();
                alertDialog.show();
                return true;
            }

            ind = url.indexOf("?viewName");
            if (ind >= 0) {
                if (dupTask == null) {
                    showToast("Please do duplicate finding again.");
                    return true;
                }
                nameOrder = !nameOrder;
                locX = 0;
                locY = 0;
                Log.d("url=", url + ", viewName");
                try {
                    webView.loadUrl(new File(dupTask.genFile(dupTask.groupList, dupTask.NAME_VIEW)).toURI()
                            .toURL().toString());
                } catch (IOException e) {
                    Log.e("viewName", e.getMessage(), e);
                }
                return true;
            }

            ind = url.indexOf("?viewGroup");
            if (ind >= 0) {
                if (dupTask == null) {
                    showToast("Please do duplicate finding again.");
                    return true;
                }
                groupViewChanged = true;
                locX = 0;
                locY = 0;
                Log.d("url=", url + ", viewGroup");
                try {
                    webView.loadUrl(new File(dupTask.genFile(dupTask.groupList, dupTask.GROUP_VIEW)).toURI()
                            .toURL().toString());
                } catch (IOException e) {
                    Log.e("viewGroup", e.getMessage(), e);
                }
                return true;
            }
            if (zextr == null) {
                locX = 0;
                locY = 0;
            } else {
                zextr = null;
            }

            if (MainActivity.popup) {
                final MainFragment frag = ((MainActivity) activity).addFragmentToStack();
                frag.status = Util.getUrlStatus(url);
                frag.load = load;
                frag.currentSearching = currentSearching;
                frag.selectedFiles = selectedFiles;
                frag.files = files;
                frag.currentZipFileName = currentZipFileName;
                if (extractFile != null) {
                    try {
                        frag.extractFile = new ExtractFile();
                        extractFile.copyTo(frag.extractFile);
                    } catch (RarException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }

                frag.home = home;
                //                  if (mSearchView != null && mSearchView.getQuery().length() > 0) {
                //                     frag.mSearchView.setQuery(mSearchView.getQuery(), false);
                //                  }
                view.getHandler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        frag.webTask = new WebTask(MainFragment.this);
                        frag.webTask.init(frag.webView, url);
                        frag.webTask.execute();
                        frag.statusView.setText(frag.status);
                    }
                }, 100);
            } else {
                currentUrl = url;
                Log.d("currentUrl 19", currentUrl);
                status = Util.getUrlStatus(url);
                statusView.setText("Opening " + url + "...");
                webTask = new WebTask(MainFragment.this, webView, url, status.toString());
                webTask.execute();
            }
            //               setNavVisibility(false);
            return true;
        }

        //         @Override
        //         public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
        //         }

        @Override
        public void onPageFinished(WebView view, String url) {
            if (container != null) {
                if (showFind) {
                    container.setVisibility(View.VISIBLE);
                    webView.findAllAsync(findBox.getText().toString());
                } else {
                    container.setVisibility(View.INVISIBLE);
                }
            }
            Log.d("onPageFinished", locX + ", " + locY + ", currentUrl=" + currentUrl + ", url=" + url);
            setNavVisibility(false);
            if (!backForward) { //if (zextr != null) {
                // zextr = null;
                jumpTo(locX, locY);
            } else {
                backForward = false;
            }
            //               locX = 0;
            //               locY = 0;
            Log.d("onPageFinished", url);
            /* This call inject JavaScript into the page which just finished loading. */
            //              webView.loadUrl("javascript:window.HTMLOUT.processHTML(" +
            //                    "'<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
        }
    });

    WebSettings settings = webView.getSettings();
    //      webView.setWebViewClient(new WebViewClient());
    //      webView.setWebChromeClient(new WebChromeClient());
    //      webView.addJavascriptInterface(new HtmlSourceViewJavaScriptInterface(), "HTMLOUT");
    settings.setMinimumFontSize(13);
    settings.setJavaScriptEnabled(true);
    settings.setDefaultTextEncodingName("UTF-8");
    settings.setBuiltInZoomControls(true);
    // settings.setSansSerifFontFamily("Tahoma");
    settings.setEnableSmoothTransition(true);

    return v;
}

From source file:net.networksaremadeofstring.rhybudd.ViewZenossEventsListActivity.java

@Override
public void fetchError() {
    AlertDialog.Builder builder = null;/*w w  w .jav  a  2  s.  c o m*/

    try {
        builder = new AlertDialog.Builder(this);
        builder.setMessage("Unable to get any events from the DB or from the API.\nCheck settings?")
                .setCancelable(false).setPositiveButton("Edit Settings", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        Intent SettingsIntent = new Intent(ViewZenossEventsListActivity.this,
                                SettingsFragment.class);
                        startActivityForResult(SettingsIntent, 99);
                        alertDialog.cancel();
                    }
                }).setNeutralButton("Run Diagnostics", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        Intent DiagIntent = new Intent(ViewZenossEventsListActivity.this,
                                DiagnosticActivity.class);
                        startActivity(DiagIntent);
                        alertDialog.cancel();
                    }
                }).setNegativeButton("Close", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        alertDialog.cancel();
                    }
                });
        alertDialog = builder.create();
    } catch (Exception e) {
        BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "fetchError", e);
    }

    if (!isFinishing()) {
        try {
            alertDialog.show();
        } catch (Exception e) {
            //BugSenseHandler.log("alertDialog", e);
            BugSenseHandler.sendExceptionMessage("ViewZenossEventsListActivity", "fetcherror alertdialog", e);
        }
    }
}

From source file:net.networksaremadeofstring.rhybudd.RhybuddHome.java

private void ConfigureHandlers() {
    handler = new Handler() {
        public void handleMessage(Message msg) {
            if (msg.what == 0) {
                try {
                    if (dialog != null && dialog.isShowing()) {
                        dialog.dismiss();
                    }/*  ww w. j  av  a  2  s  .co m*/
                } catch (NullPointerException npe) {
                    //Sigh
                }

                try {
                    ((ProgressBar) findViewById(R.id.backgroundWorkingProgressBar)).setVisibility(4);
                } catch (NullPointerException npe) {
                    //Sigh
                }

                OnClickListener listener = new OnClickListener() {
                    public void onClick(View v) {
                        try {
                            //Check if we are in a big layout
                            FrameLayout EventDetailsFragmentHolder = (FrameLayout) findViewById(
                                    R.id.EventDetailsFragment);
                            if (EventDetailsFragmentHolder == null) {
                                ManageEvent(v.getTag(R.id.EVENTID).toString(),
                                        (Integer) v.getTag(R.id.EVENTPOSITIONINLIST), v.getId());
                            } else {
                                LoadEventDetailsFragment((Integer) v.getTag(R.id.EVENTPOSITIONINLIST));
                            }
                        } catch (Exception e) {
                            Toast.makeText(getApplicationContext(),
                                    "There was an internal error. A report has been sent.", Toast.LENGTH_SHORT)
                                    .show();
                            //BugSenseHandler.log("EventListOnclick", e);
                        }
                    }
                };

                OnLongClickListener listenerLong = new OnLongClickListener() {
                    public boolean onLongClick(View v) {
                        try {
                            selectForCAB((Integer) v.getTag(R.id.EVENTPOSITIONINLIST));
                        } catch (Exception e) {
                            Toast.makeText(getApplicationContext(),
                                    "There was an internal error. A report has been sent.", Toast.LENGTH_SHORT)
                                    .show();
                            //BugSenseHandler.log("RhybuddHome-onDestroy", e);
                        }
                        return true;
                    }
                };

                OnClickListener addCAB = new OnClickListener() {
                    public void onClick(View v) {
                        try {
                            addToCAB((Integer) v.getTag(R.id.EVENTPOSITIONINLIST));
                        } catch (Exception e) {
                            Toast.makeText(getApplicationContext(),
                                    "There was an internal error. A report has been sent.", Toast.LENGTH_SHORT)
                                    .show();
                            //BugSenseHandler.log("RhybuddHome-onDestroy", e);
                        }
                    }
                };

                //adapter = new ZenossEventsAdaptor(RhybuddHome.this, listOfZenossEvents,listener,listenerLong,addCAB);
                list.setAdapter(adapter);
            } else if (msg.what == 1) {
                try {
                    if (dialog != null && dialog.isShowing())
                        dialog.setMessage("Refresh Complete!");
                } catch (NullPointerException npe) {
                    //Sigh
                }
                this.sendEmptyMessageDelayed(0, 1000);
            } else if (msg.what == 2) {
                if (dialog != null && dialog.isShowing()) {
                    dialog.setMessage("DB Cache incomplete.\r\nQuerying Zenoss directly.\r\nPlease wait....");
                } else {
                    dialog = new ProgressDialog(RhybuddHome.this);
                    dialog.setMessage("DB Cache incomplete.\r\nQuerying Zenoss directly.\r\nPlease wait....");
                    dialog.setCancelable(false);
                    dialog.show();
                }
            } else if (msg.what == 50) {
                if (dialog != null && dialog.isShowing())
                    dialog.dismiss();

                try {
                    if (listOfZenossEvents != null)
                        listOfZenossEvents.clear();

                    if (adapter != null)
                        adapter.notifyDataSetChanged();
                } catch (Exception e) {
                    BugSenseHandler.sendExceptionMessage("RhybuddHome", "handler-50", e);
                }

                Toast.makeText(RhybuddHome.this, "There are no events to display", Toast.LENGTH_LONG).show();
            } else if (msg.what == 3 || msg.what == 999) {
                if (dialog != null && dialog.isShowing())
                    dialog.dismiss();

                AlertDialog.Builder builder = new AlertDialog.Builder(RhybuddHome.this);
                builder.setMessage("An error was encountered. Please check your settings and try again.")
                        .setCancelable(false)
                        .setPositiveButton("Edit Settings", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                Intent SettingsIntent = new Intent(RhybuddHome.this, SettingsFragment.class);
                                startActivityForResult(SettingsIntent, 99);
                                alertDialog.cancel();
                            }
                        }).setNegativeButton("Close", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                alertDialog.cancel();
                            }
                        });
                alertDialog = builder.create();
                if (!isFinishing()) {
                    try {
                        alertDialog.show();
                    } catch (Exception e) {
                        //BugSenseHandler.log("alertDialog", e);
                    }
                }
            } else if (msg.what == ZenossAPI.HANDLER_REDOREFRESH) {
                Refresh();
            } else {
                if (dialog != null && dialog.isShowing()) {
                    dialog.dismiss();
                }
                Toast.makeText(RhybuddHome.this,
                        "Timed out communicating with host. Please check protocol, hostname and port.",
                        Toast.LENGTH_LONG).show();
            }
        }
    };

    AckEventHandler = new Handler() {
        public void handleMessage(Message msg) {
            try {
                if (msg.what == 0) {
                    if (adapter != null)
                        adapter.notifyDataSetChanged();
                } else if (msg.what == 1) {
                    for (ZenossEvent evt : listOfZenossEvents) {
                        if (!evt.getEventState().equals("Acknowledged") && evt.getProgress()) {
                            evt.setProgress(false);
                            evt.setAcknowledged();
                        }
                    }

                    RhybuddDataSource datasource = null;

                    try {
                        //TODO maybe do this with the bunch of ack id's we have in the thread?
                        datasource = new RhybuddDataSource(RhybuddHome.this);
                        datasource.open();
                        datasource.UpdateRhybuddEvents(listOfZenossEvents);

                    } catch (Exception e) {
                        e.printStackTrace();
                        BugSenseHandler.sendExceptionMessage("RhybuddHome", "AckEventsHandler", e);
                    } finally {
                        if (null != datasource)
                            datasource.close();
                    }

                    if (adapter != null)
                        adapter.notifyDataSetChanged();
                } else if (msg.what == 2) {
                    for (Integer i : selectedEvents) {
                        if (listOfZenossEvents.get(i).getProgress()) {
                            listOfZenossEvents.get(i).setProgress(false);
                            listOfZenossEvents.get(i).setAcknowledged();
                        }
                    }

                    if (adapter != null)
                        adapter.notifyDataSetChanged();
                } else if (msg.what == 99) {
                    for (ZenossEvent evt : listOfZenossEvents) {
                        if (!evt.getEventState().equals("Acknowledged") && evt.getProgress()) {
                            evt.setProgress(false);
                        }
                    }

                    if (adapter != null)
                        adapter.notifyDataSetChanged();

                    Toast.makeText(getApplicationContext(), "There was an error trying to ACK those events.",
                            Toast.LENGTH_SHORT).show();
                } else {

                    Toast.makeText(getApplicationContext(), "There was an error trying to ACK that event.",
                            Toast.LENGTH_SHORT).show();
                }
            } catch (Exception e) {
                //BugSenseHandler.log("AckEventsHandler", e);
            }
        }
    };
}