/**
   * The method which is called When add verse to project button is clicked. Get current wheel
   * position Get verse information by current wheel position Make Intent includes verse String Add
   * select project to DB
   *
   * @param
   * @return
   */
  public void addVerseThisVerse() {

    // Get current wheel position
    // Get verse from DB by current wheel position

    int b = bookWheel.getCurrentItem();
    int c = chapterWheel.getCurrentItem();
    int v = verseWheel.getCurrentItem() + 1;

    // Add project to DB
    // Show Toast text by result.
    // If the verse is already in the project, fail.
    // Otherwise, success.

    if (databaseManager.addVerseToProject(
        projectId, databaseManager.getVerseIdFromWidgetIndex(b, c, v), 0))
      Toast.makeText(
              this,
              getResources().getString(R.string.verse_chooser_add_verse_toast_success),
              Toast.LENGTH_LONG)
          .show();
    else
      Toast.makeText(
              this,
              getResources().getString(R.string.verse_chooser_add_verse_toast_fail),
              Toast.LENGTH_LONG)
          .show();
  }
  /**
   * The method which is called When memorize button is clicked. Get current wheel position Get
   * verse information by current wheel position Make Intent includes verse String Move to
   * ActivityChooserAct
   *
   * @param
   * @return
   */
  private void startActivityChooser() {

    // Get current wheel position
    // Get verse from DB by current wheel position
    // Get Reference and verse text from verse object

    int b = bookWheel.getCurrentItem();
    int c = chapterWheel.getCurrentItem();
    int v = verseWheel.getCurrentItem() + 1;
    VerseObject verse =
        databaseManager.getVerse(databaseManager.getVerseIdFromWidgetIndex(b, c, v));
    String refString =
        databaseManager.getBook(verse.getBook()).getName()
            + " "
            + (verse.getChapter() + 1)
            + ":"
            + verse.getVerse();
    String textString = verse.getContents();

    // Set Intent to ActivityChoosetAct

    Intent intent = new Intent(this, ActivityChooserAct.class);
    intent.putExtra(GlobalVariable.VERSE_REF, refString);
    intent.putExtra(GlobalVariable.VERSE_TEXT, textString);
    startActivity(intent);
  }
Пример #3
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;
  }
Пример #4
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);
  }
Пример #5
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);
  }
  /**
   * Refresh Widget by phone's bible edition setting
   *
   * @param
   * @return
   */
  private void refreshVerseListWidget() {

    // Set Title Bar Text

    TextView titleBarText = (TextView) findViewById(R.id.title_bar_text);
    titleBarText.setText(databaseManager.getBibleEditionName());

    // Chapter and Verst Widget List Setting

    updateChapterWheel(chapterWheel, books.get(bookWheel.getCurrentItem()).getChapterCount());
    updateVerseWheel(
        verseWheel, bookWheel.getCurrentItem(), Integer.valueOf(chapterWheel.getCurrentItem()));
  }
  /**
   * 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);
  }
Пример #9
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_squat);

    final WheelView whight = (WheelView) findViewById(R.id.whight);
    final WheelView reps = (WheelView) findViewById(R.id.reps);

    OnWheelChangedListener listener =
        new OnWheelChangedListener() {
          public void onChanged(WheelView wheel, int oldValue, int newValue) {
            updateWhight(whight);
          }
        };

    updateWhight(whight);
    whight.setCurrentItem(100);

    updateReps(reps);
    reps.setCurrentItem(5);
  }
Пример #10
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));
  }
Пример #11
0
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.sure:
        if (mOnTimeSelectedListener != null) {
          int dayIndex = day.getCurrentItem();
          int hour = hours.getCurrentItem();
          Calendar newCalendar = (Calendar) calendar.clone();
          newCalendar.roll(Calendar.DAY_OF_YEAR, dayIndex);
          newCalendar.set(Calendar.HOUR_OF_DAY, hour);
          //	            Log.d("time","time:"+(new SimpleDateFormat("MMMd EEE
          // hh").format(newCalendar.getTime())));
          mOnTimeSelectedListener.onTimeSelected(newCalendar.getTime());
        }
        break;
      case R.id.empty:
      case R.id.cancel:
        if (mOnTimeSelectedListener != null) {
          mOnTimeSelectedListener.onTimeSelected(null);
        }
        break;
        //		case R.id.feedback_tv:
        //			context.startActivity(new Intent(context,FeedBackActivity.class));
        //			break;
      case R.id.cargo_goods:
        context.startActivity(new Intent(context, CargoGoodsActivity.class));
        break;
      case R.id.cargo_home:
        context.startActivity(new Intent(context, CargoHomeActivity.class));

        break;

      default:
        break;
    }
  }
Пример #12
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;
  }
  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()));
            }
          }
        });
  }
Пример #15
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);
          }
        });
  }
Пример #16
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);
 }