Exemplo n.º 1
0
  /**
   * Creates an wheelView (Dialog) so the user can set the date and time. Requires wheel_src library
   * project.
   *
   * @param Context to show in
   * @param Time to show in milliseconds
   * @return Dialog
   */
  public Dialog showDateDialog(Context in, long timeinms) {
    Dialog timeDialog = new Dialog(in);
    timeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    timeDialog.setContentView(R.layout.time2_layout);
    LayoutParams params = timeDialog.getWindow().getAttributes();
    params.width = LayoutParams.FILL_PARENT;
    timeDialog.getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
    boolean tf = false;
    tf = sp.getBoolean("prefs_time_24", true);

    int nhours = 23;
    int startH = 0;
    if (tf) {
      nhours = 23;
      startH = 0;
    } else {
      startH = 1;
      nhours = 12;
    }

    final WheelView hours = (WheelView) timeDialog.findViewById(R.id.hour);
    NumericWheelAdapter hourAdapter = new NumericWheelAdapter(TimeClock.this, startH, nhours);
    hourAdapter.setItemResource(R.layout.wheel_text_item);
    hourAdapter.setItemTextResource(R.id.text);
    hours.setViewAdapter(hourAdapter);

    final WheelView mins = (WheelView) timeDialog.findViewById(R.id.mins);
    NumericWheelAdapter minAdapter = new NumericWheelAdapter(TimeClock.this, 0, 59, "%02d");
    minAdapter.setItemResource(R.layout.wheel_text_item);
    minAdapter.setItemTextResource(R.id.text);
    mins.setViewAdapter(minAdapter);
    mins.setCyclic(true);

    final WheelView ampm = (WheelView) timeDialog.findViewById(R.id.ampm);
    ArrayWheelAdapter<String> ampmAdapter =
        new ArrayWheelAdapter<String>(TimeClock.this, new String[] {"AM", "PM"});
    ampmAdapter.setItemResource(R.layout.wheel_text_item);
    ampmAdapter.setItemTextResource(R.id.text);
    ampm.setViewAdapter(ampmAdapter);

    // set current time
    Calendar calendar = Calendar.getInstance(Locale.US);
    calendar.setTimeInMillis(timeinms);

    mins.setCurrentItem(calendar.get(Calendar.MINUTE));

    ampm.setCurrentItem(calendar.get(Calendar.AM_PM));
    if (tf) {
      hours.setCurrentItem(calendar.get(Calendar.HOUR_OF_DAY));
      ampm.setVisibility(View.GONE);
    } else {
      hours.setCurrentItem(calendar.get(Calendar.HOUR) - 1);
      ampm.setVisibility(View.VISIBLE);
    }

    final WheelView day = (WheelView) timeDialog.findViewById(R.id.day);
    day.setViewAdapter(new DayArrayAdapter(TimeClock.this, calendar));
    day.setCurrentItem(20);
    return timeDialog;
  }
Exemplo n.º 2
0
  private Dialog createDialog() {

    Dialog dialog = new Dialog(this, R.style.NobackDialog);
    View view = LayoutInflater.from(this).inflate(R.layout.dialog_time_picker, null);
    Button btn_submit = (Button) view.findViewById(R.id.btn_dialog_submit);
    final WheelView hours = (WheelView) view.findViewById(R.id.wheel_hour);
    hours.setViewAdapter(new NumericWheelAdapter(this, 0, 23));
    hours.setCyclic(true);
    final WheelView mins = (WheelView) view.findViewById(R.id.wheel_mins);
    mins.setViewAdapter(new NumericWheelAdapter(this, 0, 59, "%02d"));
    mins.setCyclic(true);
    int curHours = 0;
    int curMinutes = 0;
    Map<String, uSDKDeviceAttribute> attrs = mDevice.getAttributeMap();
    switch (mCurrentType) {
      case 1:
        if (!TextUtils.isEmpty(getTime(attrs, 1))) {
          curHours = Integer.parseInt(getTime(attrs, 1).split(":")[0]);
          curMinutes = Integer.parseInt(getTime(attrs, 1).split(":")[1]);
        }
        break;
      case 2:
        if (!TextUtils.isEmpty(getTime(attrs, 2))) {
          curHours = Integer.parseInt(getTime(attrs, 2).split(":")[0]);
          curMinutes = Integer.parseInt(getTime(attrs, 2).split(":")[1]);
        }
        break;
    }
    hours.setCurrentItem(curHours);
    mins.setCurrentItem(curMinutes);
    OnWheelClickedListener click =
        new OnWheelClickedListener() {
          public void onItemClicked(WheelView wheel, int itemIndex) {
            wheel.setCurrentItem(itemIndex, true);
          }
        };
    hours.addClickingListener(click);
    mins.addClickingListener(click);
    btn_submit.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            mSetTime = formatTime(hours.getCurrentItem(), mins.getCurrentItem());
            mDialog.dismiss();
            switch (mCurrentType) {
              case 1:
                mSetTime0 = mSetTime;
                mOvenTime.setText(mSetTime0);
                sendCommand(mDevice, "20v00f", mSetTime0);
                break;
            }
          }
        });
    dialog.setContentView(view);
    dialog.setCanceledOnTouchOutside(true);
    return dialog;
  }
Exemplo n.º 3
0
  void updateReps(WheelView reps) {
    // Calendar calendar = Calendar.getInstance();
    // calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) + year.getCurrentItem());
    // calendar.set(Calendar.MONTH, month.getCurrentItem());

    int maxReps = 50;
    reps.setViewAdapter(new DateNumericAdapter(this, 1, maxReps, 10));
    int curDay = Math.min(maxReps, reps.getCurrentItem() + 1);
    reps.setCurrentItem(curDay - 1, true);
  }
Exemplo n.º 4
0
  void updateWhight(WheelView wheight) {
    // Calendar calendar = Calendar.getInstance();
    // calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) + year.getCurrentItem());
    // calendar.set(Calendar.MONTH, month.getCurrentItem());

    int maxDays = 500;
    wheight.setViewAdapter(new DateNumericAdapter(this, 1, maxDays, 100));
    int curDay = Math.min(maxDays, wheight.getCurrentItem() + 1);
    wheight.setCurrentItem(curDay - 1, true);
  }
Exemplo n.º 5
0
  public TimeSelectManager(Context context) {
    this.context = context;
    view = LayoutInflater.from(context).inflate(R.layout.time_select_layout, null);
    view.findViewById(R.id.empty).setOnClickListener(this);
    view.findViewById(R.id.cancel).setOnClickListener(this);
    view.findViewById(R.id.sure).setOnClickListener(this);

    hours = (WheelView) view.findViewById(R.id.hour);
    NumericWheelAdapter hourAdapter = new NumericWheelAdapter(context, 0, 23, "%s时");
    hourAdapter.setItemResource(R.layout.wheel_text_item);
    hourAdapter.setItemTextResource(R.id.text);
    hours.setViewAdapter(hourAdapter);

    //	    final WheelView mins = (WheelView) view.findViewById(R.id.mins);
    //	    NumericWheelAdapter minAdapter = new NumericWheelAdapter(context, 0, 59, "%02d");
    //	    minAdapter.setItemResource(R.layout.wheel_text_item);
    //	    minAdapter.setItemTextResource(R.id.text);
    //	    mins.setViewAdapter(minAdapter);
    //	    mins.setCyclic(true);
    //
    //	    final WheelView ampm = (WheelView) view.findViewById(R.id.ampm);
    //	    ArrayWheelAdapter<String> ampmAdapter =
    //	        new ArrayWheelAdapter<String>(context, new String[] {"AM", "PM"});
    //	    ampmAdapter.setItemResource(R.layout.wheel_text_item);
    //	    ampmAdapter.setItemTextResource(R.id.text);
    //	    ampm.setViewAdapter(ampmAdapter);

    // set current time
    calendar = Calendar.getInstance(Locale.US);
    hours.setCurrentItem(calendar.get(Calendar.HOUR));
    //	    mins.setCurrentItem(calendar.get(Calendar.MINUTE));
    //	    ampm.setCurrentItem(calendar.get(Calendar.AM_PM));

    day = (WheelView) view.findViewById(R.id.day);
    day.setViewAdapter(new DayArrayAdapter(context, calendar));
  }
  /**
   * Update chapter wheel by users hand scrolling
   *
   * @param wheel
   * @param total
   */
  private void updateChapterWheel(WheelView wheel, int total) {

    // Get String which is in current wheel position

    String[] totalItems = new String[total];
    for (int i = 0; i < total; i++) totalItems[i] = (String.valueOf(i + 1));

    // Make Adapter
    // Set String and position

    ArrayWheelAdapter<String> adapter = new ArrayWheelAdapter<String>(this, totalItems);
    adapter.setTextSize(18);
    wheel.setViewAdapter(adapter);
    wheel.setCurrentItem(0);
  }
  /**
   * Update verse wheel by users hand scrolling
   *
   * @param wheel
   * @param bid
   * @param chpid
   */
  private void updateVerseWheel(WheelView wheel, int bid, int chpid) {

    // Get total verse Strings from DB

    int versetotal = databaseManager.getVerseCount(bid, chpid);
    String[] totalItems = new String[versetotal];
    for (int i = 0; i < versetotal; i++) totalItems[i] = (String.valueOf(i + 1));

    // Make Adapter
    // Set String and position

    ArrayWheelAdapter<String> adapter = new ArrayWheelAdapter<String>(this, totalItems);
    adapter.setTextSize(18);
    wheel.setViewAdapter(adapter);
    wheel.setCurrentItem(0);
  }
  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);
          }
        });
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GlobalManager.setCustomContentView(this, R.layout.verse_chooser);

    // DB work

    try {
      databaseManager = GlobalFactory.getDatabaseManagerByLanguage(this);
      databaseManager.openDatabase();
    } catch (IOException e1) {
      e1.printStackTrace();
    }

    // Get Intent from previous Activity as a bundle form.
    // Intent includes the activity information.

    Bundle extras = getIntent().getExtras();
    projectId = extras.getInt(GlobalVariable.PROJECT_ID);
    boolean memorize = extras.getBoolean(GlobalVariable.MEMORIZE);
    boolean project = extras.getBoolean(GlobalVariable.PROJECT);

    // Find Wheel view resources

    bookWheel = (WheelView) findViewById(R.id.verse_chooser_wheel_book);
    chapterWheel = (WheelView) findViewById(R.id.verse_chooser_wheel_chapter);
    verseWheel = (WheelView) findViewById(R.id.verse_chooser_wheel_verse);

    // Buttons Setting
    // This Activity decides which buttons will be shown
    // by Activity information got from previous Activity intent.

    Button backbutton = (Button) findViewById(R.id.verse_chooser_back_button);
    backbutton.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View v) {
            finish();
          }
        });

    // if the previous Activity is MainAct, hide add project button.
    // Hide Title Text

    if (memorize) {
      Button button = (Button) findViewById(R.id.verse_chooser_add_verse_to_project_button);
      button.setVisibility(View.GONE);

      Button memorizeButton = (Button) findViewById(R.id.verse_chooser_memorize_button);
      memorizeButton.setOnClickListener(
          new Button.OnClickListener() {
            public void onClick(View v) {
              startActivityChooser();
            }
          });
    }

    // if the previous Activity is Project, hide memorize button.
    // Set title text with project name

    else if (project) {
      Button button = (Button) findViewById(R.id.verse_chooser_memorize_button);
      button.setVisibility(View.GONE);

      Button addVerseToProjectBtn =
          (Button) findViewById(R.id.verse_chooser_add_verse_to_project_button);
      addVerseToProjectBtn.setOnClickListener(
          new Button.OnClickListener() {
            public void onClick(View v) {
              addVerseThisVerse();
            }
          });

      backbutton.setText(getResources().getString(R.string.done_label));
    }

    // Get Book List
    // Book Widget List Setting
    // Wheel Event Setting

    books = databaseManager.getBookList();
    bookWheel.setViewAdapter(new BookAdapter(this, books));

    chapterWheel.addScrollingListener(
        new OnWheelScrollListener() {
          public void onScrollingStarted(WheelView wheel) {}

          public void onScrollingFinished(WheelView wheel) {
            if (!VerseChooserAct.this.isFinishing())
              updateVerseWheel(
                  verseWheel, Integer.valueOf(bookWheel.getCurrentItem()), wheel.getCurrentItem());
          }
        });

    bookWheel.addScrollingListener(
        new OnWheelScrollListener() {
          public void onScrollingStarted(WheelView wheel) {}

          public void onScrollingFinished(WheelView wheel) {
            if (!VerseChooserAct.this.isFinishing()) {
              updateChapterWheel(chapterWheel, books.get(wheel.getCurrentItem()).getChapterCount());
              updateVerseWheel(
                  verseWheel,
                  wheel.getCurrentItem(),
                  Integer.valueOf(chapterWheel.getCurrentItem()));
            }
          }
        });
  }
Exemplo n.º 10
0
 /** Updates the city wheel */
 private void updateCities(WheelView city, String cities[][], int index) {
   ArrayWheelAdapter<String> adapter = new ArrayWheelAdapter<String>(this, cities[index]);
   adapter.setTextSize(15);
   city.setViewAdapter(adapter);
   city.setCurrentItem(cities[index].length / 2);
 }