コード例 #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_information_flow);
    ButterKnife.bind(this);

    collegeField.addTextChangedListener(mTextWatcher);
    graduationDateField.addTextChangedListener(mTextWatcher);

    ParseUser user = ParseUser.getCurrentUser();
    String collegeText = user.getString(ParseConstants.KEY_COLLEGE_ATTENDED);
    Date graduationText = user.getDate(ParseConstants.KEY_GRADUATION_DATE);
    String employerText = user.getString(ParseConstants.KEY_EMPLOYER_NAME);
    Date examText = user.getDate(ParseConstants.KEY_EXAM_DATE);

    if (collegeText != null) {
      collegeField.setText(collegeText);
    }
    if (graduationText != null) {
      try {
        String currentDate = graduationText.toString(); // Tue May 01 00:00:00 EDT 2018
        SimpleDateFormat simpleDateFormat =
            new SimpleDateFormat("EEEE MMM dd HH:mm:ss z yyyy", Locale.US);
        Date tempDate = simpleDateFormat.parse(currentDate);
        SimpleDateFormat outputDateFormat = new SimpleDateFormat("MM/dd/yy", Locale.US);
        graduationDateField.setText(outputDateFormat.format(tempDate));
      } catch (ParseException ex) {
        Log.e(TAG, "Error converting dates");
        Log.e(TAG, graduationText.toString());
      }
    }
    if (employerText != null) {
      employerNameField.setText(employerText);
    }
    if (examText != null) {
      try {
        Log.d(TAG, examText.toString());
        String currentDate = examText.toString(); // Tue May 01 00:00:00 EDT 2018
        SimpleDateFormat simpleDateFormat =
            new SimpleDateFormat("EEEE MMM dd HH:mm:ss z yyyy", Locale.US);
        Date tempDate = simpleDateFormat.parse(currentDate);
        SimpleDateFormat outputDateFormat = new SimpleDateFormat("MM/dd/yy", Locale.US);
        examDateField.setText(outputDateFormat.format(tempDate));
      } catch (ParseException ex) {
        Log.e(TAG, "Error converting dates");
        Log.e(TAG, examText.toString());
      }
    }
  }
コード例 #2
0
ファイル: EditRecibo.java プロジェクト: cdiezmoran/Medidors
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_recibo);
    ButterKnife.bind(this);

    setSupportActionBar(mToolbar);

    assert getSupportActionBar() != null;
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    getTarifas();

    mDateFormatter = new SimpleDateFormat("dd/MM/yyyy", Locale.US);

    mSpinner.setSelection(0);
    mUltimaLectura.setText(mUser.getNumber(ParseConstants.KEY_LECTURA_ANTERIOR).toString());
    mUltimoPago.setText(mUser.getNumber(ParseConstants.KEY_ULTIMO_PAGO).toString());
    mFechaAnterior.setText(mDateFormatter.format(mUser.getDate(ParseConstants.KEY_FECHA_LECTURA)));

    mUltimaLectura.requestFocus();

    setDateField();
  }
コード例 #3
0
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootview = inflater.inflate(R.layout.activity_modif_profil, container, false);

    btn_modif_profil = (Button) rootview.findViewById(R.id.modif_info_profil);
    Typeface font =
        Typeface.createFromAsset(
            getActivity().getAssets(), "font-awesome-4.3.0/fonts/fontawesome-webfont.ttf");
    btn_modif_profil.append("    MODIFIER");
    btn_modif_profil.setTypeface(font);

    /** Recuperer les valeurs des composants dans des variables */
    pseudo = (TextView) rootview.findViewById(R.id.txt_modif_pseudo_userProfil);
    mail = (TextView) rootview.findViewById(R.id.txt_modif_courriel_userProfil);
    ancienMdp = (EditText) rootview.findViewById(R.id.txt_ancien_mdp);
    mdp = (EditText) rootview.findViewById(R.id.txtMdp_modif);
    confmdp = (EditText) rootview.findViewById(R.id.txtConfMdp_modif);
    dateNais = (EditText) rootview.findViewById(R.id.txt_modif_date_naiss_userProfil);
    nom = (EditText) rootview.findViewById(R.id.txt__modif_nom_userProfil);
    prenom = (EditText) rootview.findViewById(R.id.txt_modif_prenom_userProfil);

    radioM = (RadioButton) rootview.findViewById(R.id.radioM_modif);
    radioF = (RadioButton) rootview.findViewById(R.id.radioF_modif);

    // compteCree = (TextView) rootview.findViewById(R.id.compteCree);
    ((RadioButton) rootview.findViewById(R.id.radioF_modif))
        .setOnTouchListener(radioButtonListener);
    ((RadioButton) rootview.findViewById(R.id.radioM_modif))
        .setOnTouchListener(radioButtonListener);
    /** Obtenir l'heure courante du calendrier */
    final Calendar c = Calendar.getInstance();
    year = c.get(Calendar.YEAR);
    month = c.get(Calendar.MONTH);
    day = c.get(Calendar.DAY_OF_MONTH);

    /** gestion affichage calendrier */
    final EditText txtCalendar =
        (EditText) rootview.findViewById(R.id.txt_modif_date_naiss_userProfil);
    txtCalendar.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            datePickerDialog.show();
            return false;
          }
        });
    btn_modif_profil.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            // Perform action on click
            modifierUtilisateur(v);
          }
        });
    // Initialisation des champs

    ParseUser us = ParseUser.getCurrentUser();
    pseudo.setText(us.getString("username"));
    mail.setText(us.getString("email"));
    SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy");
    dateNais.setText(sdf.format(us.getDate("birthday")));
    nom.setText(us.getString("lastname"));
    prenom.setText(us.getString("firstname"));

    String gender = us.getString("gender");
    if (gender.equals("M")) {

      radioM.setChecked(true);
    } else {
      radioF.setChecked(true);
    }

    /** Controle sur l'ancien mdp saisie */
    //     strAncienMdp = ancienMdp.getText().toString();

    /** Controle sur la confirmation de Mdp */
    final EditText password1 = (EditText) rootview.findViewById(R.id.txtMdp_modif);
    final EditText password2 = (EditText) rootview.findViewById(R.id.txtConfMdp_modif);

    strMdp = password1.getText().toString();

    /** vérification du mot de passe et de la confirmation de mot de passe */
    password2.addTextChangedListener(
        new TextWatcher() {
          public void afterTextChanged(Editable s) {
            String strPass1 = password1.getText().toString();
            String strPass2 = password2.getText().toString();
            if (!strPass1.equals(strPass2)) {

              password2.setError("Confirmation invalide");
            } else {
              password2.setError(null);
            }
          }

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

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

    password1.addTextChangedListener(
        new TextWatcher() {
          public void afterTextChanged(Editable s) {
            String strPass1 = password1.getText().toString();
            String strPass2 = password2.getText().toString();
            if (!strPass1.equals(strPass2) && strPass2.length() > 0) {
              password2.setError("Confirmation invalide");
            } else {
              password2.setError(null);
            }
          }

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

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

    /** Controle sur la taille du Mdp */
    password1.setOnFocusChangeListener(
        new View.OnFocusChangeListener() {

          public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus && password1.getText().length() < 5 && password1.getText().length() > 0) {
              // code to execute when EditText loses focus
              password1.setError("mot de passe trop court: minimum 5 caractères");
            } else if (password1.getText().length() >= 5) {
              password1.setError(null);
            }
          }
        });

    /** Controle sur l'age de l'utilisateur min 18 ans */
    dateNais.addTextChangedListener(
        new TextWatcher() {
          public void afterTextChanged(Editable s) {
            int age = getYears(dateNais.getText().toString());
            if (age < 18) {
              dateNais.setError("Age min 18 ans");
            } else {
              dateNais.setError(null);
            }
          }

          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            dateNais.setError(null);
          }

          public void onTextChanged(CharSequence s, int start, int before, int count) {
            dateNais.setError(null);
          }
        });

    datePickerDialog = new DatePickerDialog(getActivity(), pickerListener, year, month, day);
    return rootview;
  }