コード例 #1
1
  public void addRow(View view) {

    EditText editText = (EditText) _popPopupWindow.getContentView().findViewById(R.id.skillInput);

    if (!_newsTopics.contains(editText.getText().toString())) {
      LinearLayout linear = (LinearLayout) findViewById(R.id.LinearLayout1);

      LayoutInflater inflater =
          (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View rowView = (View) inflater.inflate(R.layout.row, null, false);

      TextView skillName = (TextView) rowView.findViewById(R.id.skillName);
      skillName.setText(editText.getText().toString());
      final Context mainActivity = this;

      rowView.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              Intent intent = new Intent(mainActivity, NewsActivity.class);

              TextView skillName = (TextView) v.findViewById(R.id.skillName);
              intent.putExtra(SKILL_NAME, skillName.getText().toString());
              startActivity(intent);
            }
          });

      linear.addView(rowView);
      linear.addView(getHorSep());
    }

    _popPopupWindow.dismiss();
    _popPopupWindow = null;
  }
コード例 #2
0
  private boolean IsValid() {
    boolean ret = true;
    if (firstName.getText().toString().matches("")) {
      firstName.setError(null);
      firstName.setError("Please enter your first name");
      firstName.requestFocus();
      ret = false;
    } else if (lastName.getText().toString().matches("")) {
      lastName.setError(null);
      lastName.setError("Please enter your last name");
      lastName.requestFocus();
      ret = false;
    } else if (email.getText().toString().matches("")) {
      email.setError(null);
      email.setError("Please enter email");
      email.requestFocus();
      ret = false;
    }

    // finally lets validate the email we already checked for null
    if (ret == true) {
      ret = android.util.Patterns.EMAIL_ADDRESS.matcher(email.getText()).matches();
      if (ret != true) {
        email.setError(null);
        email.setError("Please enter valid email");
        email.requestFocus();
      }
    }

    return ret;
  }
コード例 #3
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
      return true;
    }

    if (id == R.id.confirm_create_group) {
      if (groupNameText.getText().toString().length() > 0
          && cityText.getText().toString().length() > 0) {
        nome = groupNameText.getText().toString();
        city = cityText.getText().toString();
        int selectedId = groupType.getCheckedRadioButtonId();
        if (selectedId == R.id.group_closed_radio) aperto = false;

        InfoGruppoBean gruppoBean = new InfoGruppoBean();
        gruppoBean.setNome(nome);
        gruppoBean.setCitta(city);
        gruppoBean.setAperto(aperto);
        if (checkNetwork())
          new CreaGruppoAT(getApplicationContext(), this, this, idSessione, gruppoBean).execute();

      } else {
        Toast.makeText(getApplicationContext(), "Compilare tutti i campi!", Toast.LENGTH_LONG)
            .show();
      }
    }

    return super.onOptionsItemSelected(item);
  }
コード例 #4
0
  public void accept(View view) {

    if (checkCorrectFill()) {

      if (atEdit) {
        Toast.makeText(this, "Product changed", Toast.LENGTH_SHORT).show();
        nutrientsDBAdapter.updateRowById(
            intent.getIntExtra(GlycemicIndexDBAdapter.KEY_ROWID, 0),
            newName.getText().toString().trim(),
            Float.parseFloat(newProteins.getText().toString()),
            Float.parseFloat(newFats.getText().toString()),
            Float.parseFloat(newCarbs.getText().toString()),
            Float.parseFloat(newCalories.getText().toString()));

        navigateBack();
      } else {
        Toast.makeText(this, "Product added", Toast.LENGTH_SHORT).show();
        // insert
        nutrientsDBAdapter.insertNewRow(
            newName.getText().toString().trim(),
            Float.parseFloat(newProteins.getText().toString()),
            Float.parseFloat(newFats.getText().toString()),
            Float.parseFloat(newCarbs.getText().toString()),
            Float.parseFloat(newCalories.getText().toString()));

        // clear forms
        newName.getEditableText().clear();
        newProteins.getEditableText().clear();
        newFats.getEditableText().clear();
        newCarbs.getEditableText().clear();
        newCalories.getEditableText().clear();
      }
    }
  }
コード例 #5
0
  public void disablePresenceClickEventHandler(View v) {
    EditText editTextServer = (EditText) findViewById(R.id.EditTextServer);
    EditText editTextApplicationKey = (EditText) findViewById(R.id.EditTextApplicationKey);
    EditText editTextChannel = (EditText) findViewById(R.id.EditTextChannel);
    CheckBox checkBoxIsCluster = (CheckBox) findViewById(R.id.CheckBoxIsCluster);

    Ortc.disablePresence(
        editTextServer.getText().toString(),
        checkBoxIsCluster.isChecked(),
        editTextApplicationKey.getText().toString(),
        defaultPrivateKey,
        editTextChannel.getText().toString(),
        new OnDisablePresence() {
          @Override
          public void run(Exception error, String result) {
            final Exception exception = error;
            final String resultText = result;
            runOnUiThread(
                new Runnable() {
                  @Override
                  public void run() {
                    if (exception != null) {
                      log(String.format("Error: %s", exception.getMessage()));
                    } else {
                      log(resultText);
                    }
                  }
                });
          }
        });
  }
コード例 #6
0
  public void apply(View v) {
    // read raw values from the input widgets
    master_switch = switch_master_switch.isChecked();
    left_margin = Integer.parseInt(ET_left_margin.getText().toString());
    right_margin = Integer.parseInt(ET_right_margin.getText().toString());
    top_margin = Integer.parseInt(ET_top_margin.getText().toString());
    bottom_margin = Integer.parseInt(ET_bottom_margin.getText().toString());

    // save the values
    Editor editor = pref.edit();
    editor.putBoolean(Keys.MASTER_SWITCH, master_switch);
    editor.putInt(Keys.LEFT_MARGIN, left_margin);
    editor.putInt(Keys.RIGHT_MARGIN, right_margin);
    editor.putInt(Keys.TOP_MARGIN, top_margin);
    editor.putInt(Keys.BOTTOM_MARGIN, bottom_margin);
    editor.apply();

    int viewH = (screen_height - top_margin - bottom_margin);
    Log.d("VIEW H", Integer.toString(viewH));

    int viewW = screen_width - left_margin - right_margin;
    Log.d("VIEW W", Integer.toString(viewW));

    Toast.makeText(this, "Changes applied!", Toast.LENGTH_SHORT).show();
    if (viewW < screen_width * 0.5 || viewH < screen_height * 0.5)
      Toast.makeText(this, "Warning, the view area may be too small!", Toast.LENGTH_LONG).show();
    if (left_margin > screen_width
        || top_margin > screen_height
        || right_margin < 0
        || bottom_margin < 0)
      Toast.makeText(this, "Your view area goes off the screen!", Toast.LENGTH_LONG).show();

    finish();
  }
コード例 #7
0
  public void register(View view) {
    EditText nameText = (EditText) findViewById(R.id.name);
    name = nameText.getText().toString().toLowerCase();
    EditText passText = (EditText) findViewById(R.id.pass);
    password = passText.getText().toString().toLowerCase();

    usersFirebase.addValueEventListener(
        new ValueEventListener() {

          @Override
          public void onDataChange(DataSnapshot snapshot) {
            userExists = false;
            for (DataSnapshot postSnapshot : snapshot.getChildren()) {
              User user = postSnapshot.getValue(User.class);
              if (user.getName().equals(name)) {
                userExists = true;
                break;
              }
            }
            // remove eventlistener to ignore redundant callbacks
            usersFirebase.removeEventListener(this);
            if (userExists) {
              Log.i("PvCProject", "User Exists");
            } else {
              User user = new User(name, password, null, null);
              usersFirebase.push().setValue(user);
              Log.i("PvCProject", "User Created");
            }
          }

          @Override
          public void onCancelled(FirebaseError firebaseError) {}
        });
  }
コード例 #8
0
ファイル: ChangeChannelDialog.java プロジェクト: Viruzix/IP
  public void onClick(View v) {
    int id = v.getId();
    DBStorage dbStorage;
    switch (id) {
      case R.id.dialog_delete:
        dbStorage = new DBStorage(context);
        dbStorage.deleteChannel(channel.id);
        dbStorage.destroy();
        listener.onDialogDismissed();
        break;
      case R.id.dialog_change:
        dbStorage = new DBStorage(context);
        channel.name = etName.getText().toString();
        channel.link = etLink.getText().toString();
        channel.encoding = etEncoding.getText().toString();
        dbStorage.changeChannel(channel);
        dbStorage.destroy();
        listener.onDialogDismissed();
        break;

      case R.id.dialog_cancel:
        break;
    }
    dismiss();
  }
コード例 #9
0
 @Override
 public void onRefresh(SyncedObject.LocationListSyncedObject locationListSyncedObject) {
   String location = locationListSyncedObject.getLocationName();
   String market = locationListSyncedObject.getLocationMarket();
   Resources res = getActivity().getResources();
   String titlewed = res.getString(R.string.ua_wedloctitle);
   String titlehome = res.getString(R.string.ua_homeloctitle);
   mIsNotifyTextChanged = false;
   if (!PlannerApplication.isEmptyOrNull(location)) {
     if (titlewed.equals(mLocationFrom)) {
       mWeddingLocationEditText.setText(location);
       mDefaultWeddingLocation = mWeddingLocationEditText.getText().toString();
       mWeddingLocationMarketCode = market;
     } else if (titlehome.equals(mLocationFrom)) {
       mCityStateEditText.setText(location);
       mDefaultCityState = mCityStateEditText.getText().toString();
       mHomeMarketCode = market;
     }
   } else {
     if (titlewed.equals(mLocationFrom) && mDefaultWeddingLocation != null) {
       mWeddingLocationEditText.setText(mDefaultWeddingLocation);
     } else if (titlehome.equals(mLocationFrom) && mDefaultCityState != null) {
       mCityStateEditText.setText(mDefaultCityState);
     }
   }
 }
コード例 #10
0
ファイル: Signup.java プロジェクト: josephcaxton/TutorVideos
  @Override
  public void onClick(View v) {

    if (v.getId() == R.id.btnsignuplogin) {

      v.setEnabled(false);
      UserName = EAddress.getText().toString();
      Password = Pwd.getText().toString();
      if (isValidEmail(UserName) && Password.length() > 4) {
        // alert("Username:"******"Password:"******"Productid:" + ProductIdentifier
        // + "Deviceid:" + Deviceid);
        Thread SecondThread =
            new Thread() {
              public void run() {

                SendInfoToLearnersCloud();
              }
            };
        SecondThread.start();
      } else {
        v.setEnabled(true);
        Message.setText("Email address or password entered is not valid. Try again");
      }
    }
  }
コード例 #11
0
  void generatePass() {
    url = mURLView.getText().toString();
    if (!url.startsWith("www.") && !url.startsWith("http://")) {
      url = "www." + url;
    }
    if (!url.startsWith("http://")) {
      url = "http://" + url;
    }

    if (!isUrl(url)) {
      mURLView.setError("Please enter a valid URL");
      return;
    }

    if (mPasswordView.getText().length() < 8) {
      mPasswordView.setError("Please use a longer password");
      return;
    }

    saveUrl(url);

    Snackbar.make(mScrollView, "Password generated", Snackbar.LENGTH_LONG)
        .setAction(
            "Copy",
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                GeneratePassActivity.this.copyPassToClipboard();
              }
            })
        .show();
  }
コード例 #12
0
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.bRegister:
        String name = etName.getText().toString();
        String username = etUsername.getText().toString();
        String password = etPassword.getText().toString();
        int age = Integer.parseInt(etAge.getText().toString());
        String verify = etVerify.getText().toString();

        if (!password.equals(verify)) {
          showMessage("Password and verify does not match.");
          return;
        }

        User user = new User(name, age, username, password);

        registerUser(user);
        break;

      case R.id.bBackToLogin:
        startActivity(new Intent(this, Login.class));
        break;
    }
  }
コード例 #13
0
 private void saveProfile() {
   mSettings.name = mName.getText().toString();
   mSettings.school = mSchool.getText().toString();
   mSettings.grade = mGrade.getText().toString();
   mSettings.group = mGroup.getText().toString();
   mSettings.saveSettings();
 }
コード例 #14
0
 // 传输数据
 public boolean editinfo() {
   String edit_kc_name1 = edit_kc_name.getText().toString().trim();
   String edit_kc_teacher1 = edit_kc_teacher.getText().toString().trim();
   String edit_kc_cj1 = edit_kc_cj.getText().toString().trim();
   if (edit_kc_name1.length() == 0) {
     HttpHelper.showMsg(EditInfo_Show.this, " 课程名不能为空");
     return false;
   }
   if (edit_kc_teacher1.length() == 0) {
     HttpHelper.showMsg(EditInfo_Show.this, "任课教师不能为空");
     return false;
   }
   if (edit_kc_cj1.length() == 0) {
     HttpHelper.showMsg(EditInfo_Show.this, "课程成绩不能为空");
     return false;
   }
   List<NameValuePair> editinfo = new ArrayList<NameValuePair>();
   NameValuePair kc_name = new BasicNameValuePair("edit_kc_name", edit_kc_name1);
   NameValuePair kc_teacher = new BasicNameValuePair("edit_kc_teacher", edit_kc_teacher1);
   NameValuePair kc_cj = new BasicNameValuePair("edit_kc_cj", edit_kc_cj1);
   editinfo.add(kc_name);
   editinfo.add(kc_teacher);
   editinfo.add(kc_cj);
   httpresponse = httphelper.sendpost(editurl, editinfo);
   httpentity = httpresponse.getEntity();
   String result = httphelper.handle(httpentity);
   if (result.equals("true")) {
     return true;
   } else {
     return false;
   }
 }
コード例 #15
0
ファイル: SearchNews.java プロジェクト: 643063150/CityCircle
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.back:
       finish();
       break;
     case R.id.searchbt:
       if (search.getText().toString().length() == 0) {
         Toast.makeText(SearchNews.this, "请输入内容", Toast.LENGTH_SHORT).show();
       } else {
         page = 1;
         key = search.getText().toString();
         try {
           url =
               GlobalVariables.urlstr
                   + "News.search&keyword="
                   + URLEncoder.encode(key, "UTF-8")
                   + "&page="
                   + page;
         } catch (UnsupportedEncodingException e) {
           e.printStackTrace();
         }
         getJson(1);
       }
       break;
   }
 }
コード例 #16
0
  @Override
  public void onSaveInstanceState(Bundle savedInstanceState) {

    // Saving title field
    if (titleEditText != null) {
      savedInstanceState.putString(STATE_TITLE, titleEditText.getText().toString());
    }

    // Saving description field
    if (descriptionEditText != null) {
      savedInstanceState.putString(STATE_DESCRIPTION, descriptionEditText.getText().toString());
    }

    // Saving time field
    if (time != null) {
      savedInstanceState.putInt(STATE_TIME_HOUR, time.first);
      savedInstanceState.putInt(STATE_TIME_MINUTES, time.second);
    }

    // Saving week days field
    if (weekDays != null) {
      savedInstanceState.putBooleanArray(STATE_WEEK_DAYS, weekDays);
    }

    // The call to super method must be at the end here
    super.onSaveInstanceState(savedInstanceState);
  }
コード例 #17
0
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.btn_sub:
       String extend_msg = et_extend_msg.getText().toString();
       String refund_amount = et_pay_price.getText().toString();
       if (Double.valueOf(refund_amount) > Double.valueOf(goods_pay_price)) {
         Toast.makeText(E3_Activity_Returns.this, "金额输入错误", Toast.LENGTH_LONG).show();
       } else {
         loadingPDialog.show();
         HttpUtils.refund(
             res, order_id, rec_id, refund_type, refund_amount, goods_num, extend_msg);
       }
       break;
     case R.id.ll_check_1:
       check_1.setChecked(true);
       check_2.setChecked(false);
       refund_type = "1";
       break;
     case R.id.ll_check_2:
       check_2.setChecked(true);
       check_1.setChecked(false);
       refund_type = "2";
       break;
     case R.id.iv_back:
       this.finish();
       break;
     default:
       break;
   }
 }
コード例 #18
0
ファイル: Setting.java プロジェクト: ems123/freeminder
  /** ** validation *** */
  private boolean setActionValidation() {

    String strName = "" + eTxtAcName.getText().toString().trim();
    String strContent = "" + eTxtAcContent.getText().toString().trim();
    String strSince = "" + eTxtAcSince.getText().toString().trim();

    if (strName.length() == 0) {
      eTxtAcName.setError("Enter Name");
      return false;
    }

    if (strContent.length() == 0) {

      eTxtAcContent.setError("Enter Content");
      return false;
    }

    if (strSince.length() > 0) {

    } else {
      eTxtAcSince.setError("Set Since Date");
      return false;
    }

    return true;
  }
コード例 #19
0
  private void getAccountInfo() {
    if (api.isAuthenticated()) {
      // If we're already authenticated, we don't need to get the login info

      dialog.show();
      LoginAsyncTask login = new LoginAsyncTask(this, null, null, getConfig(), dialog);
      login.execute();
    } else {

      String email = mLoginEmail.getText().toString();

      if (email.length() < 5 || email.indexOf("@") < 0 || email.indexOf(".") < 0) {
        showToast("Error, invalid e-mail");
        return;
      }

      String password = mLoginPassword.getText().toString();

      if (password.length() < 6) {
        showToast("Error, password too short");
        return;
      }

      // It's good to do Dropbox API (and any web API) calls in a separate thread,
      // so we don't get a force-close due to the UI thread stalling.

      dialog.show();
      LoginAsyncTask login = new LoginAsyncTask(this, email, password, getConfig(), dialog);
      login.execute();
    }
  }
コード例 #20
0
ファイル: CopyEssay.java プロジェクト: mafuvadze/EasyA
 private void submitEssay() {
   final ProgressDialog progress = new ProgressDialog(CopyEssay.this);
   progress.setMessage(getString(R.string.please_wait_message));
   progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
   progress.setCancelable(false);
   progress.show();
   String t = title.getText().toString();
   String s = subject.getText().toString();
   ParseObject essay = new ParseObject("essays");
   essay.put("title", t);
   essay.put("subject", s);
   essay.put("content", essay_txt.getText().toString());
   essay.saveInBackground(
       new SaveCallback() {
         @Override
         public void done(com.parse.ParseException e) {
           if (e != null) {
             e.printStackTrace();
           } else {
             progress.dismiss();
             displaySnackbar();
             Intent intent = new Intent(CopyEssay.this, HomeScreen.class);
             startActivity(intent);
           }
         }
       });
 }
コード例 #21
0
ファイル: LoginActivity.java プロジェクト: Carbs0126/TeamTalk
  public void attemptLogin() {
    String loginName = mNameView.getText().toString();
    String mPassword = mPasswordView.getText().toString();
    boolean cancel = false;
    View focusView = null;

    if (TextUtils.isEmpty(mPassword)) {
      Toast.makeText(this, getString(R.string.error_pwd_required), Toast.LENGTH_SHORT).show();
      focusView = mPasswordView;
      cancel = true;
    }

    if (TextUtils.isEmpty(loginName)) {
      Toast.makeText(this, getString(R.string.error_name_required), Toast.LENGTH_SHORT).show();
      focusView = mNameView;
      cancel = true;
    }

    if (cancel) {
      focusView.requestFocus();
    } else {
      showProgress(true);
      if (imService != null) {
        //				boolean userNameChanged = true;
        //				boolean pwdChanged = true;
        loginName = loginName.trim();
        mPassword = mPassword.trim();
        imService.getLoginManager().login(loginName, mPassword);
      }
    }
  }
コード例 #22
0
  public void apply(View v) {
    // read raw values from the input widgets
    master_switch = switch_master_switch.isChecked();
    left_margin = Integer.parseInt(ET_left_margin.getText().toString());
    right_margin = Integer.parseInt(ET_right_margin.getText().toString());
    top_margin = Integer.parseInt(ET_top_margin.getText().toString());
    bottom_margin = Integer.parseInt(ET_bottom_margin.getText().toString());
    leave_actionbar = CB_leave_actionbar.isChecked();
    // move_statusbar = CB_move_statusbar.isChecked();

    // check for bad margins
    int viewH = (screen_height - top_margin - bottom_margin);
    int viewW = screen_width - left_margin - right_margin;

    String message = null;

    if (viewW < screen_width * 0.5 || viewH < screen_height * 0.5)
      message =
          "The view area is less than half your screen. It may be too small. Are you "
              + "sure you want to save?";
    else if (left_margin > screen_width
        || top_margin > screen_height
        || right_margin < 0
        || bottom_margin < 0)
      message = "The view area does not fit on the screen. Are you sure you want to apply?";
    else save();

    if (message != null) {
      AlertDialog.Builder alert = new AlertDialog.Builder(this);
      alert.setTitle("Warning");
      alert.setMessage(message);
    }

    finish();
  }
コード例 #23
0
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.reset_btn:
        if (reset_password1.getText().toString().trim().length() < 8) {
          Toast.makeText(this, "密码须大于8位", Toast.LENGTH_SHORT).show();
        } else if (!reset_password1
            .getText()
            .toString()
            .equals(reset_password2.getText().toString())) {
          Toast.makeText(this, "输入的两次密码不相等", Toast.LENGTH_SHORT).show();
        } else {
          HttpUtils.resetPassword(
              res,
              phone.replaceAll(" ", ""),
              reset_password2.getText().toString().replaceAll(" ", ""));
        }
        break;
      case R.id.register_back:
        super.finish();
        overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
        break;
      case R.id.policy:
        Intent intent = new Intent(E8_ResetPwdActivity.this, E13_User_policy_Activity.class);
        startActivity(intent);
        this.overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
        break;

      default:
        break;
    }
  }
コード例 #24
0
  private void save() {
    final String oldName;
    final boolean oldHide;
    final Context context = this;

    Log.d(TAG, "Saving context!");

    // Must have a name
    if (_name.length() <= 0) {
      Log.w(TAG, "Attempted to save with no name");
      Toast.makeText(context, R.string.ERR_savecontext_baddata, Toast.LENGTH_LONG).show();
      return;
    }

    if (_context == null) {
      Log.d(TAG, "Creating a new context");
      _context = new TodoContext(_name.getText().toString(), 0, _hide.isChecked());
      oldName = _context.getName();
      oldHide = _context.isHidden();
    } else {
      Log.d(TAG, "Updating an existing context");
      oldName = _context.setName(_name.getText().toString());
      oldHide = _context.setHidden(_hide.isChecked());
    }

    final ProgressDialog p = ProgressDialog.show(context, "", getString(R.string.MSG_saving), true);
    TracksAction a =
        new TracksAction(
            TracksAction.ActionType.UPDATE_CONTEXT,
            _context,
            new Handler() {
              @Override
              public void handleMessage(Message msg) {
                switch (msg.what) {
                  case TracksCommunicator.SUCCESS_CODE:
                    Log.d(TAG, "Saved successfully");
                    _context.setOutdated(false);
                    TodoContext.save(_context);
                    p.dismiss();
                    setResult(SAVED);
                    finish();
                    break;
                  case TracksCommunicator.UPDATE_FAIL_CODE:
                    Log.w(TAG, "Save failed");
                    _context.setOutdated(true);
                    TodoContext.save(_context);
                    p.dismiss();
                    // Toast.makeText(context, R.string.ERR_savecontext_general,
                    // Toast.LENGTH_LONG).show();
                    // Reset task data to stay synced with server.
                    //						_context.setName(oldName);
                    //						_context.setHidden(oldHide);
                    setResult(SAVED);
                    finish();
                    break;
                }
              }
            });
    _commHandler.obtainMessage(0, a).sendToTarget();
  }
コード例 #25
0
  /**
   * Method for registering the user based on credentials placed into EditText views.
   *
   * @param view The view housing the EditTexts for simplicity.
   */
  private void registerUser(View view) {
    // ensure view isnt null
    if (view != null) {
      // retrieve the values within the edit texts
      // final TextView errorText = (TextView) view.findViewById(R.id.register_error_label);
      final EditText usernameField = (EditText) view.findViewById(R.id.register_username);
      final EditText password = (EditText) view.findViewById(R.id.register_password);
      final EditText passwordCheck = (EditText) view.findViewById(R.id.register_password_redo);

      String username = usernameField.getText().toString();
      String pwd = password.getText().toString();
      String pwdCheck = passwordCheck.getText().toString();

      // Ensure the fields are not empty and the passwords match
      if (username.length() != 0 && pwd.length() != 0 && pwd.equals(pwdCheck)) {
        // hash the password to increase security a bit
        String pwdHash = String.valueOf(password.getText().toString().hashCode());
        String regUrl = url;
        regUrl += "?username="******"&password="******"Attempting to Register Account!");
        new AddUserWebTask().execute(regUrl);
      }

      // a field is empty
      if (username.length() == 0 || pwd.length() == 0 || pwdCheck.length() == 0) {
        errorText.setText("Error: Cannot leave a field blank!");
      }

      // passwords do not match
      if (!pwd.equals(pwdCheck)) {
        errorText.setText("Error: Passwords do not match!");
      }
    }
  }
コード例 #26
0
 @Override
 public void onClick(View view) {
   String nmul1 = erFirst.getText().toString();
   String nmul2 = erSecond.getText().toString();
   switch (view.getId()) {
     case R.id.Add:
       int addition = Integer.parseInt(nmul1) + Integer.parseInt(nmul2);
       erResult.setText(String.valueOf(addition));
       break;
     case R.id.Subtract:
       int subtraction = Integer.parseInt(nmul1) - Integer.parseInt(nmul2);
       erResult.setText(String.valueOf(subtraction));
       break;
     case R.id.Divide:
       try {
         int devision = Integer.parseInt(nmul1) / Integer.parseInt(nmul2);
         erResult.setText(String.valueOf(devision));
       } catch (Exception e) {
         erResult.setText("Cannot Divide");
       }
       break;
     case R.id.Multiply:
       int multiply = Integer.parseInt(nmul1) * Integer.parseInt(nmul2);
       erResult.setText(String.valueOf(multiply));
       break;
   }
 }
コード例 #27
0
 private boolean isMatching(EditText etText1, EditText etText2) {
   if (etText1.getText().toString().equals(etText2.getText().toString())) {
     return true;
   } else {
     return false;
   }
 }
コード例 #28
0
ファイル: ItemFragment.java プロジェクト: guillemc/futuredays
 private void saveItem() {
   mItem.setTitle(mTitle.getText().toString());
   mItem.setDetails(mDetails.getText().toString());
   // date is already set
   mItem.setAutodelete(mAutoDelete.isChecked());
   ItemManager.get(getActivity()).saveItem(mItem);
 }
コード例 #29
0
  private void processLogin() {

    final ProgressDialog pd =
        ProgressDialog.show(LoginScreen.this, "Please wait", "Fetching user data", false);
    String push =
        String.format("%s/%s", edName.getText().toString(), edPassword.getText().toString());
    new CallWebService(Constants.API_LOGIN + push, CallWebService.TYPE_JSONOBJECT) {
      @Override
      public void response(String response) {

        pd.dismiss();
        Functions.logD("Response Login", response);
        User currentUser = new GsonBuilder().create().fromJson(response, User.class);

        if (currentUser.loginState.success.equalsIgnoreCase("1")) {

          Functions.displayMessage(LoginScreen.this, "Login Successfull");
          PrefUtils.setUser(LoginScreen.this, currentUser);
          Functions.fireIntent(LoginScreen.this, AddArtWorkScreen.class);
          PrefUtils.setLogin(LoginScreen.this, true);
          finish();

        } else {
          Functions.displayMessage(LoginScreen.this, "Login Failed");
        }
      }

      @Override
      public void error(VolleyError error) {
        pd.dismiss();
        Functions.displayMessage(LoginScreen.this, error.getMessage());
      }
    }.start();
  }
コード例 #30
0
 public void oblicz(View view) {
   // wynik.setText(Math.pow(Double.parseDouble(bok.getText().toString()), 2)+"");
   wynik.setText(
       Double.parseDouble(bok1.getText().toString())
               * Double.parseDouble(bok2.getText().toString())
           + "");
 }