示例#1
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mSoundArrays = getResources().getStringArray(R.array.frequency_array);
    resolver = getActivity().getContentResolver();

    mView = inflater.inflate(R.layout.keysounds_settings, container, false);
    soundSpinner = (TextView) mView.findViewById(R.id.soundsSpinner);

    mIndexSound = getKeySoundVal();
    mDropMenu = new DropdownMenu(getActivity(), mView, mHandler);
    mDropMenu.setListViewListener();
    mDropMenu.setButtonListener(soundSpinner, mSoundArrays[mIndexSound]);

    LenovoSettingsActivity.setTitleFocus(false);
    soundSpinner.requestFocus();

    return mView;
  }
示例#2
0
        @Override
        public void handleMessage(Message msg) {
          super.handleMessage(msg);
          switch (msg.what) {
            case DropdownMenu.DROPDOWN_MENU_GET_ADAPTER:
              if (msg.arg1 == DropdownMenu.DROPDOWN_MENU_BUTTON_NOT_EDIT) {
                TextView text = (TextView) msg.obj;
                if (text == soundSpinner) {
                  mDropMenu.setListViewPosition(0, 2);
                  mDropMenu.setListViewAdapter(mSoundArrays, mIndexSound);
                } else {
                  break;
                }
                mDropMenu.showDropdownListEnable(true);
              }
              break;

            case DropdownMenu.DROPDOWN_MENU_ITEM_CHICK:
              if (msg.arg1 == DropdownMenu.DROPDOWN_MENU_BUTTON_NOT_EDIT) {
                TextView text = (TextView) msg.obj;
                int position = msg.arg2;
                System.out.println(
                    "position and text:" + position + "---" + getKeySoundVal() + "--" + text);
                System.out.println("ext == soundSpinner--->" + (text == soundSpinner));
                if (text == soundSpinner) {
                  if (getKeySoundVal() != position) {
                    setKeySoundVal(position);
                    System.out.println("getKeySoundVal()-->" + getKeySoundVal());
                  }
                } else {
                  break;
                }
              }
              break;
          }
        }
  public void main(IWContext iwc) throws Exception {
    // TODO eiki cache countries
    // some caching made by aron
    super.main(iwc);
    // System.out.println( "country dropdown main start "+
    // com.idega.util.IWTimestamp.RightNow().toString());
    List localeCountries = Arrays.asList(Locale.getISOCountries());

    // List locales = Arrays.asList( java.util.Locale.getAvailableLocales());
    // List locales = ICLocaleBusiness.listOfAllLocalesJAVA();
    Locale currentLocale = iwc.getCurrentLocale();

    // Iterator iter = locales.iterator();
    Iterator iter = localeCountries.iterator();

    Country country = null;
    String countryDisplayName = null;
    Map countries = new HashMap();
    String lang = currentLocale.getISO3Language();
    Locale locale;
    List smallCountries = new Vector();
    // CountryHome countryHome = getAddressBusiness(iwc).getCountryHome();
    while (iter.hasNext()) {
      // Locale locale = (Locale) iter.next();

      String ISOCountry = (String) iter.next();
      try {
        locale = new Locale(lang, ISOCountry);

        countryDisplayName = locale.getDisplayCountry(currentLocale);
        // country = countryHome.findByIsoAbbreviation(locale.getCountry());
        country = getCountryByISO(locale.getCountry());

        if (countryDisplayName != null
            && country != null
            && !countries.containsKey(country.getPrimaryKey())) {
          countries.put(country.getPrimaryKey(), country); // cache
          SmallCountry sCountry =
              new SmallCountry(
                  (Integer) country.getPrimaryKey(), countryDisplayName, ISOCountry, currentLocale);
          smallCountries.add(sCountry);
          // addMenuElement(((Integer)country.getPrimaryKey()).intValue(),countryDisplayName);
        }
      } catch (Exception e1) {
        // e1.printStackTrace();
      }
    }
    Collections.sort(smallCountries);

    for (Iterator iterator = smallCountries.iterator(); iterator.hasNext(); ) {
      SmallCountry sCountry = (SmallCountry) iterator.next();
      // we dont want the ISO code into the list
      if (!sCountry.name.equalsIgnoreCase(sCountry.code)) {
        addMenuElement(sCountry.getID().intValue(), sCountry.getName());
      }
    }

    try {
      if (!StringUtil.isEmpty(this.selectedCountryName)) {
        this.selectedCountry =
            getAddressBusiness(iwc).getCountryHome().findByCountryName(this.selectedCountryName);
      }
      // we must ensure no external selected country is set
      else if (this.selectedCountry == null && !StringUtil.isEmpty(currentLocale.getCountry())) {
        this.selectedCountry =
            getAddressBusiness(iwc)
                .getCountryHome()
                .findByIsoAbbreviation(currentLocale.getCountry());
      }
    } catch (RemoteException e) {
      e.printStackTrace();
    } catch (EJBException e) {
      e.printStackTrace();
    } catch (FinderException e) {
      e.printStackTrace();
    }

    if (this.selectedCountry != null) {
      setSelectedElement(((Integer) this.selectedCountry.getPrimaryKey()).intValue());
    }
    // System.out.println( "country dropdown main end "+
    // com.idega.util.IWTimestamp.RightNow().toString());
  }