예제 #1
0
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.okbtn:
        LoginActivity.isSound = isbgSoundCb.isChecked();
        // Log.d("tong", "isbgSoundCb 1 :" + LoginActivity.isSound);
        Constants.isGameSound = isoundCb.isChecked();
        LoginActivity.isSave = isautologinCb.isChecked();

        if (isoundCb.isChecked() != LoginActivity.isSave) {
          SharedPreferences spf = c.getPreferences(Activity.MODE_PRIVATE);
          SharedPreferences.Editor edit = spf.edit();
          edit.putBoolean("isautoLogin", isautologinCb.isChecked());
          edit.commit();
        }

        View sv = findViewById(rg.getCheckedRadioButtonId());
        int index = rg.indexOfChild(sv);
        // ClientThread.sendMsg("update$" + emailtx.getText().toString() + "$"
        //			+ schooltx.getText().toString() + "$" + index);
        this.cancel();
        break;

      case R.id.cancelbtn:
        this.dismiss();
        break;
    }
  }
예제 #2
0
  /** Save results of the current view(question) into the result array. */
  private void saveResult() throws IllegalArgumentException {

    switch (viewTypeArray[currentView - 1]) {
      case MCQuestion:
        RadioGroup radioGroup = (RadioGroup) findViewById(R.id.mcRadioGroup);
        resultList[currentView - 1] = new ArrayList<Integer>();
        if (radioGroup.getCheckedRadioButtonId() == -1) throw new IllegalArgumentException();
        else
          resultList[currentView - 1].add(
              radioGroup.indexOfChild(findViewById(radioGroup.getCheckedRadioButtonId())));
        break;
      case ScalarQuestion:
        SeekBar seekBar = (SeekBar) findViewById(R.id.scalarSeekBar);
        resultList[currentView - 1] = new ArrayList<Integer>();
        resultList[currentView - 1].add(seekBar.getProgress() + 1);
        break;
      case MAQuestion:
        LinearLayout checkBoxView = (LinearLayout) findViewById(R.id.ma_checkBoxView);

        resultList[currentView - 1] = new ArrayList<Integer>();
        for (int i = 0; i < checkBoxView.getChildCount(); i++) {
          if (((CheckBox) checkBoxView.getChildAt(i)).isChecked())
            resultList[currentView - 1].add(i);
        }
        break;
      default:
        throw new IllegalArgumentException("Unknown view type");
    }
  }
예제 #3
0
 public void location() {
   checkedIdLocation = radioGroupLocation.getCheckedRadioButtonId();
   if (checkedIdLocation == -1) {
     loc = 0;
   } else {
     radioLocation = (RadioButton) radioGroupLocation.findViewById(checkedIdLocation);
     loc = radioGroupLocation.indexOfChild(radioLocation) + 1;
   }
 }
예제 #4
0
 public void price() {
   checkedIdBudget = radioGroupBudget.getCheckedRadioButtonId();
   if (checkedIdBudget == -1) {
     price = 0;
   } else {
     radioBudget = (RadioButton) radioGroupBudget.findViewById(checkedIdBudget);
     price = radioGroupBudget.indexOfChild(radioBudget) + 1;
     Log.i("Price is", String.valueOf(price));
   }
 }
예제 #5
0
  private void syncRadioButton(RadioGroup group, int checkedId) {
    int index = group.indexOfChild(group.findViewById(checkedId));

    if (shadow_user_info_tab.getVisibility() == View.VISIBLE) {
      shadow_uliv_user_info.setCurrentItem(index);

      ((RadioButton) rg_user_info.findViewById(checkedId)).setChecked(true);
      uliv_user_info.setCurrentItemWithoutAnim(index);
    } else {
      uliv_user_info.setCurrentItem(index);

      ((RadioButton) shadow_rg_user_info.findViewById(checkedId)).setChecked(true);
      shadow_uliv_user_info.setCurrentItemWithoutAnim(index);
    }
  }
  private void startGeoTrace() {
    RadioGroup rb = (RadioGroup) traceSettingsView.findViewById(R.id.radio_group);
    int radioButtonID = rb.getCheckedRadioButtonId();
    View radioButton = rb.findViewById(radioButtonID);
    int idx = rb.indexOfChild(radioButton);
    beenPaused = true;
    TRACE_MODE = idx;
    if (TRACE_MODE == 0) {
      setupManualMode();
    } else if (TRACE_MODE == 1) {
      setupAutomaticMode();
    } else {

    }
    play_button.setVisibility(View.GONE);
    pause_button.setVisibility(View.VISIBLE);
  }
  // the following method is based on the layouts example from class
  private void saveUserData() {
    String mKey = getString(R.string.preference);
    SharedPreferences mPreference = getSharedPreferences(mKey, MODE_PRIVATE);

    SharedPreferences.Editor mEditor = mPreference.edit();
    mEditor.clear();

    // save profile pic
    saveSnap();

    // save name
    mKey = getString(R.string.name_input);
    String mValue = (String) ((EditText) findViewById(R.id.editName)).getText().toString();
    mEditor.putString(mKey, mValue);

    // save email
    mKey = getString(R.string.email_input);
    mValue = (String) ((EditText) findViewById(R.id.editEmail)).getText().toString();
    mEditor.putString(mKey, mValue);

    // save phone
    mKey = getString(R.string.phone_input);
    mValue = (String) ((EditText) findViewById(R.id.editPhone)).getText().toString();
    mEditor.putString(mKey, mValue);

    // save gender
    mKey = getString(R.string.gender_input);
    RadioGroup mRadioGroup = (RadioGroup) findViewById(R.id.genderGroup);
    int mIntValue = mRadioGroup.indexOfChild(findViewById(mRadioGroup.getCheckedRadioButtonId()));
    mEditor.putInt(mKey, mIntValue);

    // save class
    mKey = getString(R.string.class_input);
    mValue = (String) ((EditText) findViewById(R.id.editClass)).getText().toString();
    mEditor.putString(mKey, mValue);

    // save major
    mKey = getString(R.string.major_input);
    mValue = (String) ((EditText) findViewById(R.id.editMajor)).getText().toString();
    mEditor.putString(mKey, mValue);

    mEditor.commit();

    Toast.makeText(getApplicationContext(), R.string.profile_saved, Toast.LENGTH_SHORT).show();
  }
  private void btnAction() {
    RadioGroup radioGroup = (RadioGroup) getView().findViewById(R.id.radioGroupActions);
    int selectedId = radioGroup.getCheckedRadioButtonId();
    View radioButton = radioGroup.findViewById(selectedId);
    int radioId = radioGroup.indexOfChild(radioButton);
    int action = ((RadioButton) radioGroup.getChildAt(radioId)).getId();

    if (action == R.id.radioPurchaseEvent) {
      SwrveSDK.purchase("BANANA_PACK", "gold", 120, 99);
      Snackbar.make(
              getView(), "Purchase BANANA_PACK, gold, 120 cost, 99 quantity", Snackbar.LENGTH_SHORT)
          .show();
    } else if (action == R.id.radioCurrencyGiven) {
      SwrveSDK.currencyGiven("gold", 99);
      Snackbar.make(getView(), "99 gold currency given", Snackbar.LENGTH_SHORT).show();
    } else if (action == R.id.radioIap) {
      SwrveIAPRewards rewards = new SwrveIAPRewards("gold", 200);
      SwrveSDK.iap(1, "CURRENCY_PACK", 9.99, "USD", rewards);
      Snackbar.make(getView(), "In App Purchase", Snackbar.LENGTH_SHORT).show();
    } else if (action == R.id.radioSendQueue) {
      SwrveSDK.sendQueuedEvents();
      Snackbar.make(getView(), "Queued events sent", Snackbar.LENGTH_SHORT).show();
    }
  }
 @Override
 public void onCheckedChanged(RadioGroup group, int checkedId) {
   mSelectedButtonIndex = group.indexOfChild(group.findViewById(checkedId));
   loadBarChartFragmentForIndex(mSelectedButtonIndex);
 }
  private Patient createPatient() {
    Person person = new Person();

    // Add address
    PersonAddress address = new PersonAddress();
    address.setAddress1(ViewUtils.getInput(edaddr1));
    address.setAddress2(ViewUtils.getInput(edaddr2));
    address.setCityVillage(ViewUtils.getInput(edcity));
    address.setPostalCode(ViewUtils.getInput(edpostal));
    address.setCountry(ViewUtils.getInput(edcountry));
    address.setStateProvince(ViewUtils.getInput(edstate));
    address.setPreferred(true);

    List<PersonAddress> addresses = new ArrayList<>();
    addresses.add(address);
    person.setAddresses(addresses);

    // Add names
    PersonName name = new PersonName();
    name.setFamilyName(ViewUtils.getInput(edlname));
    name.setGivenName(ViewUtils.getInput(edfname));
    name.setMiddleName(ViewUtils.getInput(edmname));

    List<PersonName> names = new ArrayList<>();
    names.add(name);
    person.setNames(names);

    // Add gender
    String[] genderChoices = {"M", "F"};
    int index = gen.indexOfChild(getActivity().findViewById(gen.getCheckedRadioButtonId()));
    if (index != -1) {
      person.setGender(genderChoices[index]);
    } else {
      person.setGender(null);
    }

    // Add birthdate
    String birthdate = null;
    if (ViewUtils.isEmpty(eddob)) {
      if (!StringUtils.isBlank(ViewUtils.getInput(edyr))
          || !StringUtils.isBlank(ViewUtils.getInput(edmonth))) {
        int yeardiff = ViewUtils.isEmpty(edyr) ? 0 : Integer.parseInt(edyr.getText().toString());
        int mondiff =
            ViewUtils.isEmpty(edmonth) ? 0 : Integer.parseInt(edmonth.getText().toString());
        LocalDate now = new LocalDate();
        bdt = now.toDateTimeAtStartOfDay().toDateTime();
        bdt = bdt.minusYears(yeardiff);
        bdt = bdt.minusMonths(mondiff);
        person.setBirthdateEstimated(true);
        birthdate = bdt.toString();
      }
    } else {
      birthdate = bdt.toString();
    }

    person.setBirthdate(birthdate);

    final Patient patient = new Patient();
    patient.setPerson(person);
    patient.setUuid(" ");
    return patient;
  }