public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {

    in_ogl_anim = false;

    if (pos == 0 || pos > 2) {
      rid1 = MyApplication.space.split(rid_arr_loc[pos])[0];

      tdwr_s = UtilityNexrad.GetTDWRFromRID(rid1);

      if (tdwr_s.equals("")) tdwr.setVisible(false);
      else tdwr.setVisible(true);

      if (tilt_option) tilt_menu.setVisible(true);
      else tilt_menu.setVisible(false);

      old_state = state;
      old_sector = sector;
      old_onek = onek;
      state =
          MyApplication.comma.split(MyApplication.preferences.getString("RID_LOC_" + rid1, ""))[0];
      sector = MyApplication.preferences.getString("COD_SECTOR_" + state, "");
      state = MyApplication.preferences.getString("STATE_CODE_" + state, "");
      onek = MyApplication.preferences.getString("COD_1KM_" + rid1, "");

      if (prod.equals("2k")) {
        img_url = img_url.replace(old_sector, sector);
        img_url = img_url.replace(old_state, state);
        img_url = img_url.replace(old_onek, onek);
      }
      if (!restarted && !(MyApplication.wxogl_remember_location && first_run)) {
        img.resetZoom();
        img.setZoom(init_zoom);
        OGLR.setZoom(((float) MyApplication.wxogl_size) / 10.0f);
        glview.mScaleFactor = ((float) MyApplication.wxogl_size / 10.0f);

        OGLR.mPositionX = 0.0f;
        OGLR.mPositionY = 0.0f;
      }
      restarted = false;
      rid_changed = true;
      new GetContent().execute();
    } else if (pos == 1) {
      Intent dtx_srm = new Intent(getApplicationContext(), RIDAddFavActivity.class);
      startActivity(dtx_srm);
    } else if (pos == 2) {
      Intent dtx_srm2 = new Intent(getApplicationContext(), RIDRemoveFavActivity.class);
      startActivity(dtx_srm2);
    }

    if (first_time) {
      UtilityToolbar.FullScreenMode(toolbar, toolbar_bottom);
      first_time = false;
    }
  }
Esempio n. 2
0
  public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {

    if (first_time) {
      UtilityToolbar.FullScreenMode(toolbar);
      first_time = false;
    }

    if (pos == (UtilityUSImgNWSMosaic.nws_sectors.length - 1)) {
      nws_radar_mosaic_sector_current = "latest";
      nws_radar_mosaic_sector_label_current = "CONUS";
    } else {
      nws_radar_mosaic_sector_current = UtilityUSImgNWSMosaic.nws_sectors[pos];
      nws_radar_mosaic_sector_label_current = UtilityUSImgNWSMosaic.nws_sectors_labels[pos];
    }
    img.resetZoom();
    new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
  }
  @Override
  public boolean onMenuItemClick(MenuItem item) {

    if (in_ogl_anim) {
      in_ogl_anim = false;
      anim.setIcon(play_icon);
      if (item.getItemId() == R.id.action_a6) return true;
    }

    switch (item.getItemId()) {
      case R.id.action_share:
        if (anim_ran) {
          if (!prod.equals("2k"))
            animDrawable = UtilityUSImgWX.AnimationFromFiles(this, rid1, prod, frame_cnt_str);

          UtilityShare.ShareAnimGif(
              this,
              rid1
                  + " ("
                  + MyApplication.preferences.getString("RID_LOC_" + rid1, "")
                  + ") "
                  + prod,
              animDrawable);

        } else {
          if (prod.equals("2k"))
            UtilityShare.ShareBitmap(
                this,
                rid1
                    + " ("
                    + MyApplication.preferences.getString("RID_LOC_" + rid1, "")
                    + ") "
                    + prod,
                bitmap);
          else
            UtilityShare.ShareBitmap(
                this,
                rid1
                    + " ("
                    + MyApplication.preferences.getString("RID_LOC_" + rid1, "")
                    + ") "
                    + prod,
                UtilityImg.LayerDrawableToBitmap(
                    UtilityUSImgWX.LayeredImgFromFile(getApplicationContext(), rid1, prod, false)));
        }
        return true;

      case R.id.action_settings:
        Intent intent = new Intent(this, SettingsRadarActivity.class);
        startActivity(intent);
        return true;

      case R.id.action_n0q:
        prod = "N" + tilt + "Q";
        setTitle(prod);
        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;
        rid_changed = true;
        new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        return true;
      case R.id.action_tzl:
        prod = "TZL";
        setTitle(prod);
        tilt_option = false;
        rid_changed = true;
        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_H0C:
        prod = "H" + tilt + "C";
        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_a12:
        setTitle(prod);
        if (prod.equals("2k")) {
          new AnimateRadarMosaic().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "12", prod);

        } else {
          anim.setIcon(stop_icon);
          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 {
          anim.setIcon(stop_icon);
          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 {
          anim.setIcon(stop_icon);
          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 {
          anim.setIcon(stop_icon);
          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 {
          anim.setIcon(stop_icon);
          new AnimateRadar().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "3", prod);
        }
        return true;
      case R.id.action_zoomout:
        setTitle(state + " Radar");
        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;
        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;
        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;
        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");
        img.resetZoom();
        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_ridmap:
        LayoutParams params_iv = mImageMap.getLayoutParams();
        params_iv.height =
            MyApplication.dm.heightPixels
                - toolbar.getHeight()
                - toolbar_bottom.getHeight()
                - getStatusBarHeight();
        params_iv.width = MyApplication.dm.widthPixels;
        mImageMap.setLayoutParams(params_iv);

        if (!map_shown) {
          map_shown = true;
          glview.setVisibility(View.GONE);
          img.setVisibility(View.GONE);
          mImageMap.setVisibility(View.VISIBLE);
          ogl_in_view = false;
          mImageMap.addOnImageMapClickedHandler(
              new ImageMap.OnImageMapClickedHandler() {
                @Override
                public void onImageMapClicked(int id, ImageMap im2) {

                  RIDMapSwitch(UtilityImageMap.MaptoRid(id));
                }

                @Override
                public void onBubbleClicked(int id) {}
              });

        } else {
          map_shown = false;
          mImageMap.setVisibility(View.GONE);
          img.setVisibility(View.GONE);
          glview.setVisibility(View.VISIBLE);
          ogl_in_view = true;
        }

        return true;

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