private void showSetLeaveTimeDialog() {
    final AlertDialog updateDialogDlg = new AlertDialog.Builder(this).create();
    updateDialogDlg.show();
    Window win = updateDialogDlg.getWindow();
    win.setContentView(R.layout.dialog_setleavetime);
    WheelView wheelView = (WheelView) win.findViewById(R.id.wv_leavetime);
    TextView titleTextView = (TextView) win.findViewById(R.id.update_title);
    titleTextView.setText(R.string.setleavetimetitle);
    AbstractWheelTextAdapter adapter =
        new AbstractWheelTextAdapter(getApplicationContext()) {

          @Override
          public int getItemsCount() {
            // TODO Auto-generated method stub
            return leaveTimeStrings.size();
          }

          @Override
          protected CharSequence getItemText(int index) {
            // TODO Auto-generated method stub
            return leaveTimeStrings.get(index);
          }
        };
    OnWheelChangedListener wheelListener =
        new OnWheelChangedListener() {
          public void onChanged(WheelView wheel, int oldValue, int newValue) {
            String setTimeString = leaveTimeStrings.get(wheel.getCurrentItem());
            appLockApplication.setAllowedLeaveTime(setTimeString);
          }
        };
    adapter.setItemResource(R.layout.item_wheel_leavetime);
    adapter.setItemTextResource(R.id.tv_text);
    wheelView.setViewAdapter(adapter);
    wheelView.setCyclic(true);
    wheelView.addChangingListener(wheelListener);

    ImageView closeImageView = (ImageView) win.findViewById(R.id.updateclose);
    closeImageView.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            updateDialogDlg.dismiss();
            Message msg = new Message();
            msg.what = SETLEAVEDIALOG_DISS;
            mHandler.sendMessage(msg);
          }
        });

    updateDialogDlg.setOnDismissListener(
        new OnDismissListener() {

          @Override
          public void onDismiss(DialogInterface dialog) {
            // TODO Auto-generated method stub
            Message msg = new Message();
            msg.what = SETLEAVEDIALOG_DISS;
            mHandler.sendMessage(msg);
          }
        });
  }
Exemplo n.º 2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.cities_layout);

    googleUnits.put("Hour", "hr");
    googleUnits.put("Minutes", "minutes");
    googleUnits.put("Seconds", "sec");
    googleUnits.put("Millisecond", "millisecond");
    googleUnits.put("Day", "day");
    googleUnits.put("Week", "week");
    googleUnits.put("Year", "year");

    final String cities[][] =
        new String[][] {
          new String[] {"Hour", "Minutes", "Seconds", "Millisecond", "Day", "Week", "Year"}
        };

    BtnCalc = (Button) findViewById(R.id.btnCalc);
    etFrom = (EditText) findViewById(R.id.edittext_from);
    etTo = (EditText) findViewById(R.id.edittext_to);

    final WheelView city = (WheelView) findViewById(R.id.city);
    final WheelView country = (WheelView) findViewById(R.id.country);

    BtnCalc.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            String element1 = (String) googleUnits.get(cities[0][country.getCurrentItem()]);
            String element2 = (String) googleUnits.get(cities[0][city.getCurrentItem()]);
            System.out.println(
                country.getCurrentItem() + "selected item in else::" + city.getCurrentItem());
            result = etFrom.getText().toString();
            new GetData().execute(result + element1 + "=?" + element2);
          }
        });

    city.setVisibleItems(cities[0].length);
    updateCities(country, cities, 0);
    updateCities(city, cities, 0);

    country.addChangingListener(
        new OnWheelChangedListener() {
          public void onChanged(WheelView wheel, int oldValue, int newValue) {
            if (!scrolling) {
              updateCities(city, cities, 0);
            }
          }
        });

    city.addChangingListener(
        new OnWheelChangedListener() {
          public void onChanged(WheelView wheel, int oldValue, int newValue) {
            if (!scrolling) {
              System.out.println(
                  "CitiesActivity.onCreate(...).new OnWheelChangedListener() {...}.onChanged()");
            }
          }
        });

    country.addScrollingListener(
        new OnWheelScrollListener() {
          public void onScrollingStarted(WheelView wheel) {
            scrolling = true;
          }

          public void onScrollingFinished(WheelView wheel) {
            scrolling = false;
            // updateCities(city, cities, country.getCurrentItem());
          }
        });

    System.out.println("sElected ::" + 0);
    country.setCurrentItem(0);

    etFrom.addTextChangedListener(
        new TextWatcher() {
          public void afterTextChanged(Editable s) {}

          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          public void onTextChanged(CharSequence s, int start, int before, int count) {

            String element1 = (String) googleUnits.get(cities[0][country.getCurrentItem()]);
            String element2 = (String) googleUnits.get(cities[0][city.getCurrentItem()]);
            System.out.println(
                country.getCurrentItem() + "selected item in else::" + city.getCurrentItem());
            result = etFrom.getText().toString();
            new GetData().execute(result + element1 + "=?" + element2);
          }
        });
  }