private String getSelectedLanguage() {
   String language;
   if (mLanguageChooser.getSelectedView() == null) {
     Log.w(TAG, "Could not get language; using 'en'");
     language = "en";
   } else {
     language = ((TextView) mLanguageChooser.getSelectedView()).getText().toString();
   }
   return language;
 }
  /** Saves the preferences which are selected on-screen by the user into shared preferences. */
  private void saveSelectedPreferences(boolean saveInList) {
    android.util.Log.i(TAG, "Saving current settings to file: " + currentSelectedConnection);

    String u = user.getText().toString();
    String h = hostname.getText().toString();

    // Only if a username and a hostname were entered, save the connection to list of connections.
    if (saveInList && !(u.equals("") || h.equals(""))) {
      saveConnections();
    }

    // Then, save the connection to a separate SharedPreferences file.
    currentConnection.setUser(u);
    currentConnection.setHostname(h);
    currentConnection.setVmname(vmname.getText().toString());
    currentConnection.setPassword(password.getText().toString());
    TextView selection = null;
    if (layoutMapSpinner != null) {
      selection = (TextView) layoutMapSpinner.getSelectedView();
    }
    if (selection != null) {
      currentConnection.setLayoutMap(selection.getText().toString());
    }
    currentConnection.saveToSharedPreferences(appContext);
  }
Esempio n. 3
0
  private void updateFps(int fps) {
    // It's better to not save the view returned for R.id.fps
    // because it's impossible to know when Spinner does change
    // the selected view; especially when the adapter changes
    // which may update the spinner not immediately.
    // Anyway, getSelectedView() and findViewById() are just
    // lookups and this method is only called every
    // ShaderRenderer.FPS_UPDATE_FREQUENCY milliseconds and if
    // fps did actually change so that shoudln't be problem
    View v = shaderSpinner.getSelectedView();
    TextView tv;

    if (v == null || (tv = (TextView) v.findViewById(R.id.fps)) == null) return;

    tv.setText(String.valueOf(fps) + " fps");
  }
Esempio n. 4
0
  /**
   * Checks if all inputs are filled and shows error if not.
   *
   * @return if all inputs are filled
   */
  private boolean validateInputs() {
    homeValueInput.setError(null);
    downPaymentInput.setError(null);
    interestRateInput.setError(null);
    propertyTaxRateInput.setError(null);

    boolean error = false;
    View focusView = null;

    if (isEmpty(homeValueInput)) {
      homeValueInput.setError(getString(R.string.error_field_required));
      focusView = homeValueInput;
      error = true;
    } else if (isEmpty(downPaymentInput)) {
      downPaymentInput.setError(getString(R.string.error_field_required));
      focusView = downPaymentInput;
      error = true;
    } else if (isEmpty(interestRateInput)) {
      interestRateInput.setError(getString(R.string.error_field_required));
      focusView = interestRateInput;
      error = true;
    } else if (termsSpinner.getSelectedItemPosition() == 0) {
      TextView errorText = (TextView) termsSpinner.getSelectedView();
      errorText.setError("");
      errorText.setTextColor(Color.RED);
      errorText.setText(R.string.error_field_required);
      focusView = termsSpinner;
      error = true;
    } else if (isEmpty(propertyTaxRateInput)) {
      propertyTaxRateInput.setError(getString(R.string.error_field_required));
      focusView = propertyTaxRateInput;
      error = true;
    }

    if (error) {
      focusView.requestFocus();
    }

    return !error;
  }
Esempio n. 5
0
 /**
  * Returns the selected contact
  *
  * @return Contact
  */
 private String getSelectedContact() {
   // get selected phone number
   ContactListAdapter adapter = (ContactListAdapter) mSpinner.getAdapter();
   return adapter.getSelectedNumber(mSpinner.getSelectedView());
 }
 protected boolean isValidEnergyVersion() {
   return isValidRequired((TextView) spinnerEnergyVersion.getSelectedView());
 }
Esempio n. 7
0
  // register view validate
  public void validateRegisterInfo() {

    firstNameEditView.setError(null);
    lastNameEditView.setError(null);
    emailIdEditView.setError(null);
    cityEditView.setError(null);
    zipEditView.setError(null);

    firstName = firstNameEditView.getText().toString();
    lastName = lastNameEditView.getText().toString();
    emilId = emailIdEditView.getText().toString();
    city = cityEditView.getText().toString();
    zip = zipEditView.getText().toString();
    state = stateSpinner.getSelectedItem().toString();
    try {
      specialty = specialtySpinner.getSelectedItem().toString();
    } catch (Exception e) {
      e.printStackTrace();
    }

    boolean cancel = false;
    View focusView = null;

    try {
      if (specialty.equals("Specialty")) {
        TextView specialtyTextView = (TextView) specialtySpinner.getSelectedView();
        focusView = specialtyTextView;
        specialtyTextView.setError("");
        //            specialtyTextView.setTextColor(Color.RED);
        specialtyTextView.setText("Specialty");
        cancel = true;
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    if (TextUtils.isEmpty(zip)) {
      zipEditView.setError(getString(R.string.error_field_required));
      focusView = zipEditView;
      cancel = true;
    }
    if (state.equals("State")) {
      TextView stateTextView = (TextView) stateSpinner.getSelectedView();
      focusView = stateTextView;
      stateTextView.setError("");
      //            stateTextView.setTextColor(Color.RED);
      stateTextView.setText("State");
      cancel = true;
    }
    if (TextUtils.isEmpty(city)) {
      cityEditView.setError(getString(R.string.error_field_required));
      focusView = cityEditView;
      cancel = true;
    }
    if (TextUtils.isEmpty(emilId)) {
      emailIdEditView.setError(getString(R.string.error_field_required));
      focusView = emailIdEditView;
      cancel = true;
    } else if (!isEmailValid(emilId)) {
      emailIdEditView.setError("This email address is invalid");
      focusView = emailIdEditView;
      cancel = true;
    }
    if (TextUtils.isEmpty(lastName)) {
      lastNameEditView.setError(getString(R.string.error_field_required));
      focusView = lastNameEditView;
      cancel = true;
    }
    if (TextUtils.isEmpty(firstName)) {
      firstNameEditView.setError(getString(R.string.error_field_required));
      focusView = firstNameEditView;
      cancel = true;
    }

    // cancel = false;

    if (cancel) {
      focusView.requestFocus();
    } else {
      Intent intent = new Intent(MainActivity.this, TrialActivity.class);
      finish();
      startActivity(intent);
    }
  }
Esempio n. 8
0
 /**
  * Returns the selected contact
  *
  * @return Contact
  */
 private ContactId getSelectedContact() {
   // get selected phone number
   ContactListAdapter adapter = (ContactListAdapter) mSpinner.getAdapter();
   return ContactUtil.formatContact(adapter.getSelectedNumber(mSpinner.getSelectedView()));
 }