@Override
 public void onClick(View inButton) {
   boolean isErr = false;
   if (mTitle.getText().toString().length() == 0) {
     mTitle.setError("Required");
     mTitle.setEms(10);
     isErr = true;
   }
   if (mDesc.getText().toString().length() == 0) {
     mDesc.setActivated(true);
     mDesc.setError("Required");
     isErr = true;
   }
   if (inButton.getId() == openWeb.getId()) web.setVisibility(View.VISIBLE);
   else if (inButton.getId() == mAvail.getId())
     startActivity(new Intent(this, CheckActivity.class));
   else if (inButton.getId() == mBack.getId()) finish();
   else if (inButton.getId() == mSub.getId()) {
     AlertDialog.Builder al = new AlertDialog.Builder(this);
     if (isErr) return;
     else
       al.setTitle("Continue?")
           .setIcon(R.drawable.ornament)
           .setMessage("Your listing is going to be submitted to your chosen category.")
           .setPositiveButton(
               "OK",
               new DialogInterface.OnClickListener() {
                 public void onClick(DialogInterface d, int x) {
                   payment = new ArrayList<String>();
                   if (mCard.isChecked()) payment.add("Card");
                   if (mCheck.isChecked()) payment.add("Check");
                   if (mOnline.isChecked()) payment.add("Online");
                   if (mCash.isChecked()) payment.add("Cash");
                   //			Toast.makeText(getApplicationContext(), payment.toString(),
                   // Toast.LENGTH_LONG).show();
                   Intent intent = new Intent(getApplicationContext(), StartActivity.class);
                   intent.putExtra("Payment", payment);
                   intent.putExtra("Category", mChosenCategory);
                   intent.putExtra("Title", mTitle.getText().toString());
                   intent.putExtra("Price", mPrice.getText().toString());
                   intent.putExtra("Description", mDesc.getText().toString());
                   intent.putExtra("Location", mLocation.getText().toString());
                   intent.putExtra("Photo", jpegData);
                   startActivity(intent);
                 }
               })
           .setNegativeButton(
               "Cancel",
               new DialogInterface.OnClickListener() {
                 public void onClick(DialogInterface d, int x) {}
               })
           .show();
   } else
     startActivityForResult(
         new Intent(this, com.lightbox.android.camera.activities.Camera.class), REQ);
 }
Example #2
0
 /** Called when the user selects the Send button */
 public void sendMessage(View view) {
   Intent intent = new Intent(this, DisplayMessageActivity.class);
   EditText editText = (EditText) findViewById(R.id.edit_message);
   String message = editText.getText().toString();
   intent.putExtra(EXTRA_MESSAGE, message);
   startActivity(intent);
 }
  private void saveNote() {
    Log.d(TAG, "saveNote() called");

    String title = titleEditText.getText().toString();
    String body = bodyEditText.getText().toString();

    if (title.isEmpty()) {
      if (!body.isEmpty()) {
        note.setTitle(body.substring(0, DEFAULT_TITLE_LENGTH));
      } else {
        note.setTitle(PLACEHOLDER_TEXT_FOR_DATABASE);
      }
    }
    if (body.isEmpty()) {
      note.setBody(PLACEHOLDER_TEXT_FOR_DATABASE);
    }

    note.setTitle(title);
    note.setBody(body);

    if (noteExistsInDatabase == false) {
      Log.d(TAG, "Adding the following note: " + note.toString());
      noteProvider.addNote(note);
    } else {
      Log.d(TAG, "Updating the following note: " + note.toString());
      noteProvider.updateNote(note);
    }

    noteExistsInDatabase = true;
  }
 @Override
 public void onExprItemClick(String exprInfo, boolean isDel) {
   SpannableString ss;
   int textSize = (int) editText.getTextSize();
   if (isDel) {
     HashMap<String, Integer> mExprFilenameIdData =
         XWExpressionManager.getInstance().getmExprInfoIdValuesCN(getActivity());
     ss =
         XWExpressionUtil.generateSpanComment(
             getActivity().getApplicationContext(),
             XWExpressionUtil.deleteOneWord(editText.getText().toString(), mExprFilenameIdData),
             textSize);
   } else {
     String content = editText.getText() + exprInfo;
     ss =
         XWExpressionUtil.generateSpanComment(
             getActivity().getApplicationContext(), content, textSize);
   }
   editText.setText(ss);
   editText.setSelection(ss.length());
 }
  private void saveNoteIfNotEmpty() {

    Log.d(TAG, "saveNoteIfNotEmpty() called");

    String title = titleEditText.getText().toString();
    String body = bodyEditText.getText().toString();

    if (title.isEmpty() && body.isEmpty()) {
      return;
    } else {
      saveNote();
    }
  }
  @OnClick(R.id.comment_sendbtn)
  public void senAction() {
    String infoid = getArguments().getString("infoid");
    String userid = getArguments().getString("userid");
    String commentid = getArguments().getString("commentid");
    String content = editText.getText().toString().trim();
    if (TextUtils.isEmpty(content)) {
      showToast("请输入内容");
      return;
    }
    KeyboardUtil.hideSoftInput(getActivity());

    if (isCompanyCircle) {
      companyZoneCommentSub(infoid, userid, commentid, content);
    } else {
      String infouserid = getArguments().getString("infouserid");
      friendZoneCommentSub(infoid, userid, commentid, content, infouserid);
    }
  }
  private void calculate() {
    String[] tempArray;
    String resultString;
    massConvert = new MassConverter();

    dataIn = (EditText) findViewById(R.id.TextInput);
    try {
      input = Double.valueOf(dataIn.getText().toString());

      int fromType = (int) spinnerFrom.getSelectedItemId();
      int toType = (int) spinnerTo.getSelectedItemId();

      output = massConvert.convert(fromType, toType, input);

      tempArray = getResources().getStringArray(R.array.weights);
      resultString = new DecimalFormat("#.########").format(output);
      resultString = (resultString + " " + tempArray[toType]);
      System.out.println(resultString);
      displayResult(resultString, context);
    } catch (NumberFormatException e) {
      displayNotice("Invalid Input");
    }
  }
  public void tryLogin() {
    mName = mEtAccount.getText().toString();
    mPassword = mEtPassword.getText().toString();

    if (mName.equals("") || mPassword.length() < 5) { // Please Specify Your Name and Sex"
      Toast.makeText(
              MainActivity.this,
              "Please Specify Your Name and Password correctly",
              Toast.LENGTH_LONG)
          .show();
    } else {
      mUserInfo = new UserInfo(mName, 0, 0, 0, 0, 0, 0);

      /*  if mNetcon is connected already, close it first  */
      /*  here we use try because mNetCon might not have been instantiated yet  */
      /*			try {
      				NetConnect.getnetConnect().closeNetConnect();
      			} catch (Exception e) {}
      			try {
      				InitData.closeInitData();
      				FriendListInfo.closeFriendListInfo();
      				ChatServiceData.closeChatServiceData();
      			} catch (Exception e) {}
      */
      CloseAll.closeAll();
      /*  to establish a new connect  */

      NetworkService.getInstance().onInit(this);
      NetworkService.getInstance().setupConnection();
      if (NetworkService.getInstance().getIsConnected()) {
        String usrInfo =
            mUserInfo.toString()
                + GlobalStrings.signinDivider
                + mPassword
                + GlobalStrings.signinDivider;
        NetworkService.getInstance().sendUpload(GlobalMsgTypes.msgHandShake, usrInfo);
      } else {
        NetworkService.getInstance().closeConnection();
        Toast.makeText(this, "failed to connect to Server", Toast.LENGTH_LONG).show();
        return;
      }

      InitData initData = InitData.getInitData();
      initData.start();
      try {
        initData.join();
      } catch (Exception e) {
      }
      mUserInfo = initData.getUserInfo();

      Log.d(
          "connectedApp isonline : ",
          ""
              + mUserInfo.getIsOnline()
              + "+++++++++++++"
              + "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");

      if (mUserInfo.getId() < 0) {
        Toast.makeText(this, "invalid username or password", Toast.LENGTH_SHORT).show();
        return;
      }

      Log.d(
          "connectedApp isonline : ",
          ""
              + mUserInfo.getIsOnline()
              + "+++++++++++++"
              + "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");

      ConnectedApp connected_app0 = ConnectedApp.getInstance();
      //		    connected_app0.setConnect(mNetCon);
      connected_app0.setUserInfo(mUserInfo);
      connected_app0.clearListActivity();
      connected_app0.instantiateListActivity();

      Intent intent0 = new Intent(MainActivity.this, MainBodyActivity.class);
      //			intent0.putExtra("username", mUserInfo.getName());
      //			intent0.putExtra("usersex", mUserInfo.getSex());
      startActivity(intent0);

      finish();
    }
  }
Example #9
0
File: Main.java Project: hsbp/urc
 public void setTarget(View v) {
   EditText et = (EditText) findViewById(R.id.target);
   sender.setAddress(et.getText().toString());
 }
  private void publishRun(final String key) {
    final String contentStr = face_content.getText().toString();
    String uri =
        InternetURL.ADD_RECORD_URL
            + "?uid="
            + getGson().fromJson(getSp().getString("uid", ""), String.class)
            + "&type="
            + "2"
            + "&content="
            + contentStr
            + "&url="
            + key;
    StringRequest request =
        new StringRequest(
            Request.Method.POST,
            InternetURL.ADD_RECORD_URL,
            new Response.Listener<String>() {
              @Override
              public void onResponse(String s) {
                if (StringUtil.isJson(s)) {
                  try {
                    JSONObject jo = new JSONObject(s);
                    String code = jo.getString("code");
                    if (Integer.parseInt(code) == 200) {
                      Toast.makeText(PublishVideoActivity.this, "发布视频成功", Toast.LENGTH_SHORT)
                          .show();
                      // 调用广播,刷新主页
                      Intent intent1 = new Intent(Constants.SEND_INDEX_SUCCESS);
                      sendBroadcast(intent1);
                      ActivityTack.getInstanse().popUntilActivity(MainActivity.class);
                    }
                  } catch (JSONException e) {
                    e.printStackTrace();
                  }
                }
                if (pd != null && pd.isShowing()) {
                  pd.dismiss();
                }
              }
            },
            new Response.ErrorListener() {
              @Override
              public void onErrorResponse(VolleyError volleyError) {
                if (pd != null && pd.isShowing()) {
                  pd.dismiss();
                }
                Toast.makeText(PublishVideoActivity.this, "发布视频失败", Toast.LENGTH_SHORT).show();
              }
            }) {
          @Override
          protected Map<String, String> getParams() {
            Map<String, String> params = new HashMap<String, String>();
            params.put("uid", getGson().fromJson(getSp().getString("uid", ""), String.class));
            params.put("type", "2");
            params.put("content", contentStr);
            params.put("url", key);
            return params;
          }

          @Override
          public Map<String, String> getHeaders() throws AuthFailureError {
            Map<String, String> params = new HashMap<String, String>();
            params.put("Content-Type", "application/x-www-form-urlencoded");
            return params;
          }
        };
    getRequestQueue().add(request);
  }
    private boolean validateFields(UserBean userBean) {
      boolean validate = true;
      AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
      alert.setNegativeButton("OK", null);
      // DADOS PESSOAIS

      if (validate && (userBean.getUserName().equals(""))
          || (userBean.getEmail().equals(""))
          || (userBean.getLogin().equals(""))) {
        validate = false;
        Log.e(
            AppHelper.getClassError(UserCrudActivity.class),
            "Favor preencher todos os dados Pessoais");
        alert
            .setTitle("Erro - Cadastro de Usuário")
            .setMessage("Favor preencher todos os dados Pessoais");
        alert.show();
      }

      if (validate && (userBean.getGender() == null || userBean.getGender().equals(""))) {
        validate = false;
        Log.e(AppHelper.getClassError(UserCrudActivity.class), "Favor selecionar o Gênero");
        alert
            .setTitle("Erro - Cadastro de Usuário")
            .setMessage("Favor preencher todos os dados Pessoais");
        alert.show();
      }

      // só valido a senha se for cadastro novo
      if (userBean.getId() == null
          && validate
          && (userBean.getPassword().equals("")
              || editTextConfirmPassword.getText().toString().equals(""))) {
        validate = false;
        Log.e(
            AppHelper.getClassError(UserCrudActivity.class), "Favor preencher os campos da Senha");
        alert
            .setTitle("Erro - Cadastro de Usuário")
            .setMessage("Favor preencher os campos da Senha");
        alert.show();
      } else if (userBean.getId() == null
          && validate
          && !userBean.getPassword().equals(editTextConfirmPassword.getText().toString())) {
        validate = false;
        Log.e(AppHelper.getClassError(UserCrudActivity.class), "As Senhas não coincidem");
        alert.setTitle("Erro - Cadastro de Usuário").setMessage("As Senhas não coincidem");
        alert.show();
      }

      // ENDERECO
      if (validate
          && (userBean.getZipCode().equals("")
              || userBean.getAddress().equals("")
              || userBean.getNumberAddress().equals("")
              || userBean.getNeighborhood().equals("")
              || userBean.getCity().equals(""))) {
        validate = false;
        Log.e(
            AppHelper.getClassError(UserCrudActivity.class),
            "Favor preencher todos os dados de Endereço");
        alert
            .setTitle("Erro - Cadastro de Usuário")
            .setMessage("Favor preencher todos os dados de Endereço");
        alert.show();
      }

      return validate;
    }