Example usage for android.os AsyncTask THREAD_POOL_EXECUTOR

List of usage examples for android.os AsyncTask THREAD_POOL_EXECUTOR

Introduction

In this page you can find the example usage for android.os AsyncTask THREAD_POOL_EXECUTOR.

Prototype

Executor THREAD_POOL_EXECUTOR

To view the source code for android.os AsyncTask THREAD_POOL_EXECUTOR.

Click Source Link

Document

An Executor that can be used to execute tasks in parallel.

Usage

From source file:joshuatee.wx.SPCMesoActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    if (mDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }//from w  w  w .  j ava  2 s  .c  o  m

    switch (item.getItemId()) {
    case R.id.action_mslp:
        param = "pmsl";
        editor.putString("SPCMESO_LAST_USED", param);
        editor.commit();
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_500mb:
        param = "500mb";
        editor.putString("SPCMESO_LAST_USED", param);
        editor.commit();
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_scp:
        param = "scp";
        editor.putString("SPCMESO_LAST_USED", param);
        editor.commit();
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_eshr:
        param = "eshr";
        editor.putString("SPCMESO_LAST_USED", param);
        editor.commit();
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_mucp:
        param = "mucp";
        editor.putString("SPCMESO_LAST_USED", param);
        editor.commit();
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_US:
        img.resetZoom();
        sector = "19";
        editor.putString("SPCMESO_SECTOR_LAST_USED", sector);
        editor.commit();
        sector_str = "US";
        setTitle(param + " - US");
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_MW:
        img.resetZoom();
        sector = "20";
        editor.putString("SPCMESO_SECTOR_LAST_USED", sector);
        editor.commit();
        sector_str = "MW";
        setTitle(param + " - MW");
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_NC:
        img.resetZoom();
        sector = "13";
        editor.putString("SPCMESO_SECTOR_LAST_USED", sector);
        editor.commit();
        sector_str = "NC";
        setTitle(param + " - NC");
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_C:
        img.resetZoom();
        sector = "14";
        editor.putString("SPCMESO_SECTOR_LAST_USED", sector);
        editor.commit();
        sector_str = "C";
        setTitle(param + " - C");
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_SC:
        img.resetZoom();
        sector = "15";
        editor.putString("SPCMESO_SECTOR_LAST_USED", sector);
        editor.commit();
        sector_str = "SC";
        setTitle(param + " - SC");
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_NE:
        img.resetZoom();
        sector = "16";
        editor.putString("SPCMESO_SECTOR_LAST_USED", sector);
        editor.commit();
        sector_str = "NE";
        setTitle(param + " - NE");
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_CE:
        img.resetZoom();
        sector = "17";
        editor.putString("SPCMESO_SECTOR_LAST_USED", sector);
        editor.commit();
        sector_str = "CE";
        setTitle(param + " - CE");
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_SE:
        img.resetZoom();
        sector = "18";
        editor.putString("SPCMESO_SECTOR_LAST_USED", sector);
        editor.commit();
        sector_str = "SE";
        setTitle(param + " - SE");
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_SW:
        img.resetZoom();
        sector = "12";
        editor.putString("SPCMESO_SECTOR_LAST_USED", sector);
        editor.commit();
        sector_str = "SW";
        setTitle(param + " - SW");
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_NW:
        img.resetZoom();
        sector = "11";
        editor.putString("SPCMESO_SECTOR_LAST_USED", sector);
        editor.commit();
        sector_str = "NW";
        setTitle(param + " - NW");
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.spydiko.rotationmanager.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_settings: // Refresh button
        //            if(AppSpecificOrientation.LOG) Log.d(TAG, "action_settings");
        packageManager = getPackageManager();
        UpdateData updateData = new UpdateData();
        this.adapter = new InteractiveArrayAdapter(this, activities, (AppSpecificOrientation) getApplication());
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
            updateData.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null);
        else/*w ww  . jav  a2  s  . co  m*/
            updateData.execute((Void[]) null);
        //            if(AppSpecificOrientation.LOG) Log.d(TAG, "execute");
        lv.setAdapter(adapter);
        break;
    case R.id.itemToggleService: // Play - Stop Service
        //                if(AppSpecificOrientation.LOG) Log.d(TAG, "entered");
        if (AppSpecificOrientation.isServiceRunning()) {
            item.setTitle(R.string.titleServiceStop);
            //               item.setIcon(android.R.drawable.ic_media_play);
            stopService(new Intent(this, NewOrieService.class));
            AppSpecificOrientation.setServiceRunning(false);
            //                    if(AppSpecificOrientation.LOG) Log.d(TAG, "if");
            //               if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
            item.setIcon(R.drawable.ic_off_button_rotation_manager);
        } else {
            item.setTitle(R.string.titleServiceStart);
            //               item.setIcon(android.R.drawable.ic_media_pause);
            startService(new Intent(this, NewOrieService.class));
            Toast toast = Toast.makeText(this, getString(R.string.notification_text), Toast.LENGTH_LONG);
            toast.setGravity(Gravity.TOP | Gravity.LEFT, 0, 0);
            toast.show();
            //               if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
            item.setIcon(R.drawable.ic_on_button_rotation_manager);
            //                    if(AppSpecificOrientation.LOG) Log.d(TAG, "else");
        }
        break;

    case R.id.setOnBoot: // Set broadcast receiver on or off
        if (AppSpecificOrientation.getBoot()) {
            item.setChecked(false);
            AppSpecificOrientation.setBoot(false);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
                item.setIcon(android.R.drawable.button_onoff_indicator_off);
            //                    if(AppSpecificOrientation.LOG) Log.d(TAG, "onBoot set to false");
        } else {
            item.setChecked(true);
            AppSpecificOrientation.setBoot(true);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
                item.setIcon(android.R.drawable.button_onoff_indicator_on);
            //                    if(AppSpecificOrientation.LOG) Log.d(TAG, "onBoot set to true");
        }

        break;
    case R.id.howTo: // Open How To Activity
        startActivityForResult((new Intent(this, HowToActivity.class)), 1);
        break;
    case R.id.about: // Open About Activity
        startActivityForResult((new Intent(this, AboutActivity.class)), 1);
        break;
    case R.id.donate:
        startActivity(new Intent(this, DonateActivity.class));
        break;
    case R.id.permNotification:
        if (AppSpecificOrientation.isPermNotification()) {
            item.setChecked(false);
            AppSpecificOrientation.setPermNotification(false);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
                item.setIcon(android.R.drawable.button_onoff_indicator_off);
            //                    if(AppSpecificOrientation.LOG) Log.d(TAG, "onBoot set to false");
            if (AppSpecificOrientation.isServiceRunning())
                startService(new Intent(this, NewOrieService.class));
        } else {
            item.setChecked(true);
            AppSpecificOrientation.setPermNotification(true);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
                item.setIcon(android.R.drawable.button_onoff_indicator_on);
            //                    if(AppSpecificOrientation.LOG) Log.d(TAG, "onBoot set to true");
            if (AppSpecificOrientation.isServiceRunning())
                startService(new Intent(this, NewOrieService.class));
        }

        break;
    case R.id.license:
        startActivity(new Intent(this, License.class));
        break;
    case android.R.id.home:
        menu.toggle();
        return true;
    }
    return true;
}

From source file:de.enlightened.peris.IntroScreen.java

private void stealTapatalkLink(final String link) {
    final String queryLink;

    if (!link.startsWith("http://")) {
        queryLink = "http://" + link;
    } else {/*from   ww w.  ja  v a2s.  co  m*/
        queryLink = link;
    }

    if (!getString(R.string.server_location).contentEquals("0")) {
        if (queryLink.contentEquals(getString(R.string.server_location))) {
            this.connectToServer(this.selectedServer);
        } else {
            final AlertDialog.Builder builder = new AlertDialog.Builder(IntroScreen.this);
            builder.setTitle("Download Peris");
            builder.setCancelable(true);
            builder.setPositiveButton("Yep!", new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int which) {

                    final String perisURL = "https://github.com/McNetic/peris/";
                    final Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setData(Uri.parse(perisURL));
                    IntroScreen.this.startActivity(intent);

                    finish();
                }
            });
            builder.setNegativeButton("Nah.", new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int which) {
                    finish();
                }
            });
            builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
                public void onCancel(final DialogInterface dialog) {
                    finish();
                }
            });

            builder.setMessage("Do you want to download and view " + link
                    + " using Peris, the free mobile forum reader app that " + getString(R.string.app_name)
                    + " is based off of?");
            builder.create().show();
        }
    } else {
        this.selectedServer = ServerRepository.findOneByAddress(this.dbHelper.getReadableDatabase(), queryLink);
        if (this.selectedServer != null) {
            if (this.selectedServer.serverAddress != null) {
                this.connectToServer(this.selectedServer);
                return;
            }
        }

        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
            new ServerValidationTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, link.trim());
        } else {
            new ServerValidationTask().execute(link.trim());
        }
    }
}

From source file:eu.power_switch.gui.fragment.configure_geofence.ConfigureGeofenceDialogPage1LocationFragment.java

private void findAddress(LatLng latLng) {
    searchAddressEditText.setEnabled(false);
    searchAddressProgress.setVisibility(View.VISIBLE);

    new AsyncTask<LatLng, Void, AsyncTaskResult<String>>() {

        @Override//from  w  ww  .  java2 s.  co m
        protected AsyncTaskResult<String> doInBackground(LatLng... addresses) {
            try {
                String address = mapViewHandler.findAddress(addresses[0]);
                return new AsyncTaskResult<>(address);
            } catch (Exception e) {
                Log.e(e);
                return new AsyncTaskResult<>(e);
            }
        }

        @Override
        protected void onPostExecute(AsyncTaskResult<String> result) {
            searchAddressProgress.setVisibility(View.GONE);

            if (result.isSuccess()) {
                searchAddressTextInputLayout.setError(null);
                searchAddressTextInputLayout.setErrorEnabled(false);

                searchAddressEditText.setText(result.getResult().get(0));
            } else {
                searchAddressEditText.setText("");
            }

            searchAddressEditText.setEnabled(true);
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, latLng);
}

From source file:joshuatee.wx.USWarningsWithRadarActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    if (mDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }/*from  w  ww .  ja va2 s . com*/

    switch (item.getItemId()) {

    case R.id.action_br:
        new GetRadar().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_bv:
        new GetRadarBV().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_srm:
        new GetRadarSRM().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_map:
        new GetMap().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:org.transdroid.core.gui.TorrentsActivity.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void startAutoRefresh() {
    // Check if already running
    if (autoRefreshTask != null || stopRefresh || systemSettings.getRefreshIntervalMilliseconds() == 0) {
        return;//from  w  w  w.j a  v  a  2  s.com
    }

    autoRefreshTask = new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            while (!isCancelled()) {
                try {
                    Thread.sleep(systemSettings.getRefreshIntervalMilliseconds());
                } catch (InterruptedException e) {
                    // Ignore
                }
                // Just in case it was cancelled during sleep
                if (isCancelled()) {
                    return null;
                }

                refreshTorrents();
                if (Daemon.supportsStats(currentConnection.getType())) {
                    getAdditionalStats();
                }
            }
            return null;
        }

    };
    autoRefreshTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

From source file:org.brandroid.openmanager.fragments.ContentFragment.java

public void runUpdateTask(boolean reconnect) {
    if (mPath == null)
        return;/* w  ww . j  a  v  a2s . c  o  m*/
    if (mPath instanceof OpenPathUpdateListener) {
        try {
            ((OpenPathUpdateListener) mPath).list(new OpenContentUpdater() {
                public void addContentPath(OpenPath file) {
                    if (!mContentAdapter.contains(file)) {
                        mContentAdapter.add(file);
                    }
                }

                @Override
                public void doneUpdating() {
                    mContentAdapter.sort();
                    mContentAdapter.notifyDataSetChanged();
                }
            });
            return;
        } catch (IOException e) {
            Logger.LogError("Couldn't list with ContentUpdater");
        }
    }
    final String sPath = mPath.getPath();
    //NetworkIOTask.cancelTask(sPath);
    final NetworkIOTask task = new NetworkIOTask(this);
    if (NetworkIOTask.isTaskRunning(sPath))
        return;
    setProgressVisibility(true);
    if (reconnect && (mPath instanceof OpenNetworkPath))
        ((OpenNetworkPath) mPath).disconnect();
    Logger.LogDebug("Running Task for " + sPath);
    NetworkIOTask.addTask(sPath, task);
    if (OpenExplorer.BEFORE_HONEYCOMB)
        task.execute(mPath);
    else
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, mPath);
    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                Thread.sleep(30000);
            } catch (InterruptedException e) {
            }
            if (task.getStatus() == Status.RUNNING)
                task.doCancel(false);
        }
    }).start();
}

From source file:joshuatee.wx.USWXOGLRadarActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {

    case R.id.action_n0q:
        prod = "N" + tilt + "Q";
        setTitle(prod);/*w  ww.ja v  a  2  s. c  o  m*/
        tilt_option = true;
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_n0u:
        prod = "N" + tilt + "U";
        setTitle(prod);
        tilt_option = true;
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;

    case R.id.action_tv0:
        prod = "TV0";
        setTitle(prod);
        tilt_option = false;
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_tzl:
        prod = "TZL";
        setTitle(prod);
        tilt_option = false;
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;

    case R.id.action_n0s:
        prod = "N" + tilt + "S";
        setTitle(prod);
        tilt_option = false;
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_net:
        prod = "EET";
        setTitle(prod);
        tilt_option = false;

        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_DVL:
        prod = "DVL";
        setTitle(prod);
        tilt_option = false;

        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;

    case R.id.action_N0X:
        prod = "N" + tilt + "X";
        setTitle(prod);
        tilt_option = true;

        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_N0C:
        prod = "N" + tilt + "C";
        setTitle(prod);
        tilt_option = true;

        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_N0K:
        prod = "N" + tilt + "K";
        setTitle(prod);
        tilt_option = true;

        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;

    case R.id.action_about:
        ShowRadarScanInfo();
        return true;

    case R.id.action_vil:
        prod = "DVL";
        setTitle(prod);
        tilt_option = false;

        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;

    case R.id.action_dsp:
        prod = "DSP";
        setTitle(prod);
        tilt_option = false;
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;

    case R.id.action_n0r:
        prod = "N0R";
        setTitle(prod);
        tilt_option = false;
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_n0v:
        prod = "N0V";
        setTitle(prod);
        tilt_option = false;
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;

    case R.id.action_l2vel:
        prod = "L2VEL";
        setTitle(prod);
        tilt_option = false;
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;

    case R.id.action_l2ref:
        prod = "L2REF";
        setTitle(prod);
        tilt_option = false;

        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;

    case R.id.action_tilt1:
        tilt = "0";
        prod = prod.replaceAll("N[0-3]", "N" + tilt);
        setTitle(prod);
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_tilt2:
        tilt = "1";
        prod = prod.replaceAll("N[0-3]", "N" + tilt);
        setTitle(prod);
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_tilt3:
        tilt = "2";
        prod = prod.replaceAll("N[0-3]", "N" + tilt);
        setTitle(prod);
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_tilt4:
        tilt = "3";
        prod = prod.replaceAll("N[0-3]", "N" + tilt);
        setTitle(prod);
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;

    case R.id.action_animate_repeat:

        if (prod.equals("2k")) {

        } else {
            new AnimationRepeat().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }
        return true;

    case R.id.action_a12:
        setTitle(prod);
        if (prod.equals("2k")) {
            new AnimateRadarMosaic().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "12", prod);

        } else {
            new AnimateRadar().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "12", prod);
        }
        return true;
    case R.id.action_a18:
        setTitle(prod);
        if (prod.equals("2k")) {
            new AnimateRadarMosaic().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "18", prod);

        } else {
            new AnimateRadar().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "18", prod);
        }
        return true;
    case R.id.action_a6:
        setTitle(prod);
        if (prod.equals("2k")) {
            new AnimateRadarMosaic().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "6", prod);

        } else {
            new AnimateRadar().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "6", prod);
        }
        return true;

    case R.id.action_a36:
        setTitle(prod);
        if (prod.equals("2k")) {
            new AnimateRadarMosaic().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "36", prod);

        } else {
            new AnimateRadar().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "36", prod);
        }
        return true;

    case R.id.action_a3:
        setTitle(prod);
        if (prod.equals("2k")) {
            new AnimateRadarMosaic().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "3", prod);

        } else {
            new AnimateRadar().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "3", prod);
        }
        return true;

    case R.id.action_zoomout:
        setTitle(state + " Radar");
        img.resetZoom();
        if (zoom_level_radar == 0) {
            img_url = "http://climate.cod.edu/data/satellite/1km/" + onek + "/current/" + onek + ".rad.gif";
            zoom_level_radar++;
        } else if (zoom_level_radar == 1) {
            img_url = "http://climate.cod.edu/data/satellite/2km/" + state + "/current/" + state + ".rad.gif";
            zoom_level_radar++;
        } else if (zoom_level_radar == 2) {
            img_url = "http://climate.cod.edu/data/satellite/regional/" + sector + "/current/" + sector
                    + ".rad.gif";
            zoom_level_radar++;
        } else if (zoom_level_radar == 3) {
            img_url = "http://climate.cod.edu/data/satellite/regional/usa/current/usa.rad.gif";
            zoom_level_radar = 0;
        }
        prod = "2k";
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_vis:
        setTitle(state + " Vis");
        tilt_option = false;

        img.resetZoom();
        if (state.equals("HI") || state.equals("AK")) {
            zoom_level_vis = 3;
        }

        if (zoom_level_vis == 1) {
            img_url = "http://climate.cod.edu/data/satellite/1km/" + onek + "/current/" + onek + ".vis.gif";
            zoom_level_vis++;
        } else if (zoom_level_vis == 2) {
            img_url = "http://climate.cod.edu/data/satellite/2km/" + state + "/current/" + state + ".vis.gif";
            zoom_level_vis++;
        } else if (zoom_level_vis == 3) {
            img_url = "http://climate.cod.edu/data/satellite/regional/" + sector + "/current/" + sector
                    + ".vis.gif";
            zoom_level_vis++;
        } else if (zoom_level_vis == 4) {
            img_url = "http://climate.cod.edu/data/satellite/regional/usa/current/usa.vis.gif";
            zoom_level_vis = 1;
        }
        prod = "2k";
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_ir:
        setTitle(state + " IR");
        tilt_option = false;

        img.resetZoom();
        if (state.equals("HI") || state.equals("AK")) {
            zoom_level_ir = 2;
        }
        if (zoom_level_ir == 1) {
            img_url = "http://climate.cod.edu/data/satellite/2km/" + state + "/current/" + state + ".ir.gif";
            zoom_level_ir++;
        } else if (zoom_level_ir == 2) {
            img_url = "http://climate.cod.edu/data/satellite/regional/" + sector + "/current/" + sector
                    + ".ir.gif";
            zoom_level_ir++;
        } else if (zoom_level_ir == 3) {
            img_url = "http://climate.cod.edu/data/satellite/regional/usa/current/usa.ir.gif";
            zoom_level_ir = 1;
        }
        prod = "2k";
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_wv:
        setTitle(state + " WV");
        tilt_option = false;

        img.resetZoom();
        if (state.equals("HI") || state.equals("AK")) {
            zoom_level_wv = 2;
        }
        if (zoom_level_wv == 1) {
            img_url = "http://climate.cod.edu/data/satellite/2km/" + state + "/current/" + state + ".wv.gif";
            zoom_level_wv++;
        } else if (zoom_level_wv == 2) {
            img_url = "http://climate.cod.edu/data/satellite/regional/" + sector + "/current/" + sector
                    + ".wv.gif";
            zoom_level_wv++;
        } else if (zoom_level_wv == 3) {
            img_url = "http://climate.cod.edu/data/satellite/regional/usa/current/usa.wv.gif";
            zoom_level_wv = 1;
        }
        prod = "2k";
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;

    case R.id.action_NVW:
        prod = "2k";
        img_url = "NVW";
        setTitle("NVW");
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;

    case R.id.action_fav:
        ToggleFavorite();
        return true;

    case R.id.action_CMH:
        rid1 = "CMH";
        prod = "TZL";
        setTitle(prod);
        RIDMapSwitch(rid1);
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_CVG:
        rid1 = "CVG";
        prod = "TZL";
        setTitle(prod);
        RIDMapSwitch(rid1);
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_DAL:
        rid1 = "DAL";
        prod = "TZL";
        setTitle(prod);
        RIDMapSwitch(rid1);
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_DAY:
        rid1 = "DAY";
        prod = "TZL";
        setTitle(prod);
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_EWR:
        rid1 = "EWR";
        prod = "TZL";
        RIDMapSwitch(rid1);
        setTitle(prod);
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_FLL:
        rid1 = "FLL";
        prod = "TZL";
        RIDMapSwitch(rid1);
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_IAD:
        rid1 = "IAD";
        prod = "TZL";
        RIDMapSwitch(rid1);
        setTitle(prod);
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;

    case R.id.action_IAH:
        rid1 = "IAH";
        prod = "TZL";
        RIDMapSwitch(rid1);
        setTitle(prod);
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_MDW:
        rid1 = "MDW";
        prod = "TZL";
        RIDMapSwitch(rid1);
        setTitle(prod);
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
    case R.id.action_PBI:
        rid1 = "PBI";
        prod = "TZL";
        setTitle(prod);
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;

    /*case R.id.action_spotters:
    if ( spotters )
    {
    spotters=false;
    new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else
    {
    spotters=true;
    new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
    return true;*/

    case R.id.action_ridmap:

        if (!map_shown) {
            map_shown = true;

            setContentView(R.layout.activity_uswxoglradar);
            mImageMap = (ImageMap) findViewById(R.id.map);
            mImageMap.setVisibility(View.VISIBLE);
            ogl_in_view = false;

            mImageMap.addOnImageMapClickedHandler(new ImageMap.OnImageMapClickedHandler() {
                @Override
                public void onImageMapClicked(int id, ImageMap im2) {

                    switch (id) {

                    case R.id.CBW:
                        RIDMapSwitch("CBW");
                        break;
                    case R.id.GYX:
                        RIDMapSwitch("GYX");
                        break;
                    case R.id.CXX:
                        RIDMapSwitch("CXX");
                        break;
                    case R.id.BOX:
                        RIDMapSwitch("BOX");
                        break;
                    case R.id.ENX:
                        RIDMapSwitch("ENX");
                        break;
                    case R.id.BGM:
                        RIDMapSwitch("BGM");
                        break;
                    case R.id.BUF:
                        RIDMapSwitch("BUF");
                        break;
                    case R.id.TYX:
                        RIDMapSwitch("TYX");
                        break;
                    case R.id.OKX:
                        RIDMapSwitch("OKX");
                        break;
                    case R.id.DOX:
                        RIDMapSwitch("DOX");
                        break;
                    case R.id.DIX:
                        RIDMapSwitch("DIX");
                        break;
                    case R.id.PBZ:
                        RIDMapSwitch("PBZ");
                        break;
                    case R.id.CCX:
                        RIDMapSwitch("CCX");
                        break;
                    case R.id.RLX:
                        RIDMapSwitch("RLX");
                        break;
                    case R.id.AKQ:
                        RIDMapSwitch("AKQ");
                        break;
                    case R.id.FCX:
                        RIDMapSwitch("FCX");
                        break;
                    case R.id.LWX:
                        RIDMapSwitch("LWX");
                        break;
                    case R.id.MHX:
                        RIDMapSwitch("MHX");
                        break;
                    case R.id.RAX:
                        RIDMapSwitch("RAX");
                        break;
                    case R.id.LTX:
                        RIDMapSwitch("LTX");
                        break;
                    case R.id.CLX:
                        RIDMapSwitch("CLX");
                        break;
                    case R.id.CAE:
                        RIDMapSwitch("CAE");
                        break;
                    case R.id.GSP:
                        RIDMapSwitch("GSP");
                        break;
                    case R.id.FFC:
                        RIDMapSwitch("FFC");
                        break;
                    case R.id.VAX:
                        RIDMapSwitch("VAX");
                        break;
                    case R.id.JGX:
                        RIDMapSwitch("JGX");
                        break;
                    case R.id.EVX:
                        RIDMapSwitch("EVX");
                        break;
                    case R.id.JAX:
                        RIDMapSwitch("JAX");
                        break;
                    case R.id.BYX:
                        RIDMapSwitch("BYX");
                        break;
                    case R.id.MLB:
                        RIDMapSwitch("MLB");
                        break;
                    case R.id.AMX:
                        RIDMapSwitch("AMX");
                        break;
                    case R.id.TLH:
                        RIDMapSwitch("TLH");
                        break;
                    case R.id.TBW:
                        RIDMapSwitch("TBW");
                        break;
                    case R.id.BMX:
                        RIDMapSwitch("BMX");
                        break;
                    case R.id.EOX:
                        RIDMapSwitch("EOX");
                        break;
                    case R.id.HTX:
                        RIDMapSwitch("HTX");
                        break;
                    case R.id.MXX:
                        RIDMapSwitch("MXX");
                        break;
                    case R.id.MOB:
                        RIDMapSwitch("MOB");
                        break;
                    case R.id.DGX:
                        RIDMapSwitch("DGX");
                        break;
                    case R.id.GWX:
                        RIDMapSwitch("GWX");
                        break;
                    case R.id.MRX:
                        RIDMapSwitch("MRX");
                        break;
                    case R.id.NQA:
                        RIDMapSwitch("NQA");
                        break;
                    case R.id.OHX:
                        RIDMapSwitch("OHX");
                        break;
                    case R.id.HPX:
                        RIDMapSwitch("HPX");
                        break;
                    case R.id.JKL:
                        RIDMapSwitch("JKL");
                        break;
                    case R.id.LVX:
                        RIDMapSwitch("LVX");
                        break;
                    case R.id.PAH:
                        RIDMapSwitch("PAH");
                        break;
                    case R.id.ILN:
                        RIDMapSwitch("ILN");
                        break;
                    case R.id.CLE:
                        RIDMapSwitch("CLE");
                        break;
                    case R.id.DTX:
                        RIDMapSwitch("DTX");
                        break;
                    case R.id.APX:
                        RIDMapSwitch("APX");
                        break;
                    case R.id.GRR:
                        RIDMapSwitch("GRR");
                        break;
                    case R.id.MQT:
                        RIDMapSwitch("MQT");
                        break;
                    case R.id.VWX:
                        RIDMapSwitch("VWX");
                        break;
                    case R.id.IND:
                        RIDMapSwitch("IND");
                        break;
                    case R.id.IWX:
                        RIDMapSwitch("IWX");
                        break;
                    case R.id.LOT:
                        RIDMapSwitch("LOT");
                        break;
                    case R.id.ILX:
                        RIDMapSwitch("ILX");
                        break;
                    case R.id.GRB:
                        RIDMapSwitch("GRB");
                        break;
                    case R.id.ARX:
                        RIDMapSwitch("ARX");
                        break;
                    case R.id.MKX:
                        RIDMapSwitch("MKX");
                        break;
                    case R.id.DLH:
                        RIDMapSwitch("DLH");
                        break;
                    case R.id.MPX:
                        RIDMapSwitch("MPX");
                        break;
                    case R.id.DVN:
                        RIDMapSwitch("DVN");
                        break;
                    case R.id.DMX:
                        RIDMapSwitch("DMX");
                        break;
                    case R.id.EAX:
                        RIDMapSwitch("EAX");
                        break;
                    case R.id.SGF:
                        RIDMapSwitch("SGF");
                        break;
                    case R.id.LSX:
                        RIDMapSwitch("LSX");
                        break;
                    case R.id.SRX:
                        RIDMapSwitch("SRX");
                        break;
                    case R.id.LZK:
                        RIDMapSwitch("LZK");
                        break;
                    case R.id.POE:
                        RIDMapSwitch("POE");
                        break;
                    case R.id.LCH:
                        RIDMapSwitch("LCH");
                        break;
                    case R.id.LIX:
                        RIDMapSwitch("LIX");
                        break;
                    case R.id.SHV:
                        RIDMapSwitch("SHV");
                        break;
                    case R.id.AMA:
                        RIDMapSwitch("AMA");
                        break;
                    case R.id.EWX:
                        RIDMapSwitch("EWX");
                        break;
                    case R.id.BRO:
                        RIDMapSwitch("BRO");
                        break;
                    case R.id.CRP:
                        RIDMapSwitch("CRP");
                        break;
                    case R.id.FWS:
                        RIDMapSwitch("FWS");
                        break;
                    case R.id.DYX:
                        RIDMapSwitch("DYX");
                        break;
                    case R.id.EPZ:
                        RIDMapSwitch("EPZ");
                        break;
                    case R.id.GRK:
                        RIDMapSwitch("GRK");
                        break;
                    case R.id.HGX:
                        RIDMapSwitch("HGX");
                        break;
                    case R.id.DFX:
                        RIDMapSwitch("DFX");
                        break;
                    case R.id.LBB:
                        RIDMapSwitch("LBB");
                        break;
                    case R.id.MAF:
                        RIDMapSwitch("MAF");
                        break;
                    case R.id.SJT:
                        RIDMapSwitch("SJT");
                        break;
                    case R.id.FDR:
                        RIDMapSwitch("FDR");
                        break;
                    case R.id.TLX:
                        RIDMapSwitch("TLX");
                        break;
                    case R.id.INX:
                        RIDMapSwitch("INX");
                        break;
                    case R.id.VNX:
                        RIDMapSwitch("VNX");
                        break;
                    case R.id.DDC:
                        RIDMapSwitch("DDC");
                        break;
                    case R.id.GLD:
                        RIDMapSwitch("GLD");
                        break;
                    case R.id.TWX:
                        RIDMapSwitch("TWX");
                        break;
                    case R.id.ICT:
                        RIDMapSwitch("ICT");
                        break;
                    case R.id.UEX:
                        RIDMapSwitch("UEX");
                        break;
                    case R.id.LNX:
                        RIDMapSwitch("LNX");
                        break;
                    case R.id.OAX:
                        RIDMapSwitch("OAX");
                        break;
                    case R.id.ABR:
                        RIDMapSwitch("ABR");
                        break;
                    case R.id.UDX:
                        RIDMapSwitch("UDX");
                        break;
                    case R.id.FSD:
                        RIDMapSwitch("FSD");
                        break;
                    case R.id.BIS:
                        RIDMapSwitch("BIS");
                        break;
                    case R.id.MVX:
                        RIDMapSwitch("MVX");
                        break;
                    case R.id.MBX:
                        RIDMapSwitch("MBX");
                        break;
                    case R.id.BLX:
                        RIDMapSwitch("BLX");
                        break;
                    case R.id.GGW:
                        RIDMapSwitch("GGW");
                        break;
                    case R.id.TFX:
                        RIDMapSwitch("TFX");
                        break;
                    case R.id.MSX:
                        RIDMapSwitch("MSX");
                        break;
                    case R.id.CYS:
                        RIDMapSwitch("CYS");
                        break;
                    case R.id.RIW:
                        RIDMapSwitch("RIW");
                        break;
                    case R.id.FTG:
                        RIDMapSwitch("FTG");
                        break;
                    case R.id.GJX:
                        RIDMapSwitch("GJX");
                        break;
                    case R.id.PUX:
                        RIDMapSwitch("PUX");
                        break;
                    case R.id.ABX:
                        RIDMapSwitch("ABX");
                        break;
                    case R.id.FDX:
                        RIDMapSwitch("FDX");
                        break;
                    case R.id.HDX:
                        RIDMapSwitch("HDX");
                        break;
                    case R.id.FSX:
                        RIDMapSwitch("FSX");
                        break;
                    case R.id.IWA:
                        RIDMapSwitch("IWA");
                        break;
                    case R.id.EMX:
                        RIDMapSwitch("EMX");
                        break;
                    case R.id.YUX:
                        RIDMapSwitch("YUX");
                        break;
                    case R.id.ICX:
                        RIDMapSwitch("ICX");
                        break;
                    case R.id.MTX:
                        RIDMapSwitch("MTX");
                        break;
                    case R.id.CBX:
                        RIDMapSwitch("CBX");
                        break;
                    case R.id.SFX:
                        RIDMapSwitch("SFX");
                        break;
                    case R.id.LRX:
                        RIDMapSwitch("LRX");
                        break;
                    case R.id.ESX:
                        RIDMapSwitch("ESX");
                        break;
                    case R.id.RGX:
                        RIDMapSwitch("RGX");
                        break;
                    case R.id.BBX:
                        RIDMapSwitch("BBX");
                        break;
                    case R.id.EYX:
                        RIDMapSwitch("EYX");
                        break;
                    case R.id.BHX:
                        RIDMapSwitch("BHX");
                        break;
                    case R.id.VTX:
                        RIDMapSwitch("VTX");
                        break;
                    case R.id.DAX:
                        RIDMapSwitch("DAX");
                        break;
                    case R.id.NKX:
                        RIDMapSwitch("NKX");
                        break;
                    case R.id.MUX:
                        RIDMapSwitch("MUX");
                        break;
                    case R.id.HNX:
                        RIDMapSwitch("HNX");
                        break;
                    case R.id.SOX:
                        RIDMapSwitch("SOX");
                        break;
                    case R.id.VBX:
                        RIDMapSwitch("VBX");
                        break;
                    case R.id.HKI:
                        RIDMapSwitch("HKI");
                        break;
                    case R.id.HKM:
                        RIDMapSwitch("HKM");
                        break;
                    case R.id.HMO:
                        RIDMapSwitch("HMO");
                        break;
                    case R.id.HWA:
                        RIDMapSwitch("HWA");
                        break;
                    case R.id.MAX:
                        RIDMapSwitch("MAX");
                        break;
                    case R.id.PDT:
                        RIDMapSwitch("PDT");
                        break;
                    case R.id.RTX:
                        RIDMapSwitch("RTX");
                        break;
                    case R.id.LGX:
                        RIDMapSwitch("LGX");
                        break;
                    case R.id.ATX:
                        RIDMapSwitch("ATX");
                        break;
                    case R.id.OTX:
                        RIDMapSwitch("OTX");
                        break;
                    case R.id.ABC:
                        RIDMapSwitch("ABC");
                        break;
                    case R.id.APD:
                        RIDMapSwitch("APD");
                        break;
                    case R.id.AHG:
                        RIDMapSwitch("AHG");
                        break;
                    case R.id.AKC:
                        RIDMapSwitch("AKC");
                        break;
                    case R.id.AIH:
                        RIDMapSwitch("AIH");
                        break;
                    case R.id.AEC:
                        RIDMapSwitch("AEC");
                        break;
                    case R.id.ACG:
                        RIDMapSwitch("ACG");
                        break;
                    case R.id.GUA:
                        RIDMapSwitch("GUA");
                        break;
                    case R.id.JUA:
                        RIDMapSwitch("JUA");
                        break;

                    }

                }

                @Override
                public void onBubbleClicked(int id) {

                }
            });

        } else {
            map_shown = false;
            mImageMap.setVisibility(View.GONE);

            setContentView(view);
            ogl_in_view = true;
        }

        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:gov.cdc.epiinfo.RecordList.java

private void doCloudSync() {
    Toast.makeText(self, getString(R.string.cloud_sync_started), Toast.LENGTH_LONG).show();
    new CloudSynchronizer().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}