Exemplo n.º 1
0
 @Override
 public void onClick(View view) {
   switch (view.getId()) {
     case R.id.ok:
       String user = userView.getText().toString();
       if ("".equals(user)) {
         Toast.makeText(this, getString(R.string.EMPTY_USER_NAME), Toast.LENGTH_LONG).show();
         return;
       }
       String account = (String) accountView.getSelectedItem();
       if (account == null) {
         Toast.makeText(this, getString(R.string.EMPTY_ACCOUNT), Toast.LENGTH_LONG).show();
         return;
       }
       try {
         RosterManager.getInstance()
             .createContact(account, user, nameView.getText().toString(), getSelected());
         PresenceManager.getInstance().requestSubscription(account, user);
       } catch (NetworkException e) {
         Application.getInstance().onError(e);
         finish();
         return;
       }
       MessageManager.getInstance().openChat(account, user);
       finish();
       break;
     default:
       break;
   }
 }
  /**
   * 验证信息是否为空
   *
   * @return
   */
  private boolean verification() {
    name = et_user_name.getText().toString();
    idcard = et_user_card.getText().toString();
    bankid = et_user_ban.getText().toString();
    phone = et_user_phone.getText().toString();
    bankname = tv_bank_name.getText().toString();

    if ("".equals(bankname)) {
      TXWLApplication.getInstance().showTextToast("银行不能为空");
      return false;
    }
    if (DataVeri.isBlank(name)) {
      TXWLApplication.getInstance().showTextToast("真实姓名不能为空");
      return false;
    }
    if (DataVeri.isBlank(idcard)) {
      TXWLApplication.getInstance().showTextToast("证件号码不能为空");
      return false;
    }
    if (DataVeri.isBlank(bankid)) {
      TXWLApplication.getInstance().showTextToast("银行卡号不能为空");
      return false;
    }
    return !DataVeri.isMobileNum(phone);
  }
Exemplo n.º 3
0
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   outState.putString(SAVED_ACCOUNT, (String) accountView.getSelectedItem());
   outState.putString(SAVED_USER, userView.getText().toString());
   outState.putString(SAVED_NAME, nameView.getText().toString());
 }
Exemplo n.º 4
0
 @Override
 public void onClick(View view) {
   switch (view.getId()) {
     case R.id.back:
       finish();
       break;
     case R.id.button_djs:
       // 点击获得验证码
       try {
         isMobileNet = HttpUtils.isMobileDataEnable(getApplicationContext());
         isWifiNet = HttpUtils.isWifiDataEnable(getApplicationContext());
         if (!isMobileNet && !isWifiNet) {
           Toast.makeText(this, R.string.network_error, Toast.LENGTH_SHORT).show();
           return;
         }
       } catch (Exception e) {
         e.printStackTrace();
       }
       mobile_str = mobile.getText().toString();
       if (StringUtil.isNullOrEmpty(mobile_str)) {
         Toast.makeText(this, R.string.reg_error_one, Toast.LENGTH_SHORT).show();
         return;
       }
       button_djs.setClickable(false); // 不可点击
       MyTimer myTimer = new MyTimer(60000, 1000);
       myTimer.start();
       getCard();
       break;
     case R.id.next:
       // 下一步
       try {
         isMobileNet = HttpUtils.isMobileDataEnable(getApplicationContext());
         isWifiNet = HttpUtils.isWifiDataEnable(getApplicationContext());
         if (!isMobileNet && !isWifiNet) {
           Toast.makeText(this, R.string.network_error, Toast.LENGTH_SHORT).show();
           return;
         }
       } catch (Exception e) {
         e.printStackTrace();
       }
       mobile_str = mobile.getText().toString();
       card_str = card.getText().toString();
       if (StringUtil.isNullOrEmpty(mobile_str)) {
         Toast.makeText(this, R.string.reg_error_one, Toast.LENGTH_SHORT).show();
         return;
       }
       if (StringUtil.isNullOrEmpty(card_str)) {
         Toast.makeText(this, R.string.reg_error_five, Toast.LENGTH_SHORT).show();
         return;
       }
       getReg();
       break;
     case R.id.quest:
       // 问题
       break;
   }
 }
 @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);
 }
 private double getEditValue(EditText etvalue) {
   try {
     if (etvalue.getVisibility() == View.VISIBLE) {
       double value = Double.parseDouble(etvalue.getText().toString());
       return value;
     }
   } catch (Exception e) {
     slog.e(TAG, "getMaxValue error mETValue1.getText() " + etvalue.getText());
     e.printStackTrace();
   }
   return -1;
 }
 private boolean checkPassphrase() {
   if (enterPassphraseEditText.getText().toString().length() == 0) {
     return false;
   }
   try {
     // Check the passphrase entered by the user
     cacheWordHandler.setPassphrase(enterPassphraseEditText.getText().toString().toCharArray());
   } catch (GeneralSecurityException e) {
     return handleIncorrectPassphrase(e);
   }
   return true;
 }
Exemplo n.º 8
0
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
          myYear = year;
          myMonth = monthOfYear;
          myDay = dayOfMonth;
          if (editTextDateStart.getText().length() == 0) {
            editTextDateStart.setText(myDay + "/" + myMonth + "/" + myYear);
            editTextDateStart.setTextColor(Color.BLACK);
          }

          if (editTextDateEnd.getText().length() == 0) {
            editTextDateEnd.setText(myDay + "/" + myMonth + "/" + myYear);
            editTextDateEnd.setTextColor(Color.BLACK);
          }
        }
Exemplo n.º 9
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.time_dialog);
    etxtTime = (EditText) findViewById(R.id.etxtTime);
    spTimeUnit = (Spinner) findViewById(R.id.spTimeUnit);
    butConfirm = (Button) findViewById(R.id.butConfirm);
    butCancel = (Button) findViewById(R.id.butCancel);

    butConfirm.setText(R.string.set_sleeptimer_label);
    butCancel.setText(R.string.cancel_label);
    setTitle(R.string.set_sleeptimer_label);
    ArrayAdapter<String> spinnerAdapter =
        new ArrayAdapter<String>(
            this.getContext(), android.R.layout.simple_spinner_item, spinnerContent);
    spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spTimeUnit.setAdapter(spinnerAdapter);
    spTimeUnit.setSelection(DEFAULT_SPINNER_POSITION);
    butCancel.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            dismiss();
          }
        });
    butConfirm.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            try {
              long input = readTimeMillis();
              onTimeEntered(input);
              dismiss();
            } catch (NumberFormatException e) {
              e.printStackTrace();
              Toast toast =
                  Toast.makeText(context, R.string.time_dialog_invalid_input, Toast.LENGTH_LONG);
              toast.show();
            }
          }
        });
    etxtTime.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void afterTextChanged(Editable s) {
            checkInputLength(s.length());
          }

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

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {}
        });
    checkInputLength(etxtTime.getText().length());
  }
Exemplo n.º 10
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);
 }
Exemplo n.º 11
0
  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;
  }
Exemplo n.º 12
0
 /** 有发送内容就显示发送按钮,没有就不显示 */
 private void checkSendState() {
   String input = mEdittext.getText().toString().trim();
   if (TextUtils.isEmpty(input)) {
     mSend.setVisibility(View.GONE);
   } else {
     mSend.setVisibility(View.VISIBLE);
   }
 }
Exemplo n.º 13
0
 private EditText createRenameEditText(String fileName) {
   EditText editText = new EditText(this);
   editText.setText(
       fileName.substring(0, fileName.length() - FileController.FILE_EXTENSION.length()));
   editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
   editText.setSelection(editText.getText().length());
   return editText;
 }
Exemplo n.º 14
0
  public void callAppForSentEmail() {
    String to[] = {"*****@*****.**"};
    String subject = "ATA App: Servicing Booking";
    String message =
        "Service Type: %s\n"
            + "Other Work: %s\n"
            + "Booking Date: %s\n"
            + "Name: %s\n"
            + "Rego: %s\n"
            + "Make: %s\n"
            + "Model: %s\n"
            + "Phone: %s\n"
            + "Address: %s\n"
            + "Rego Date: %s\n";

    message =
        String.format(
            message,
            tvDistance.getText().toString(),
            tvOtherWork.getText().toString(),
            tvBookDate.getText().toString(),
            etName.getText().toString(),
            edtRego.getText().toString(),
            edtMake.getText().toString(),
            edtModel.getText().toString(),
            edtPhone.getText().toString(),
            edtAddress.getText().toString(),
            edtRegoDate.getText().toString());
    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
    emailIntent.putExtra(Intent.EXTRA_TEXT, message);
    emailIntent.setType("message/rfc822");
    startActivity(Intent.createChooser(emailIntent, "email"));
  }
 private boolean isPasswordValid() {
   boolean valid =
       PassphraseUtil.validatePassphrase(newPassphraseEditText.getText().toString().toCharArray());
   if (!valid) {
     passwordError =
         getString(R.string.pass_err_length_part0)
             + MINIMUM_PASSPHRASE_LENGTH
             + getString(R.string.pass_err_length_part1);
   }
   return valid;
 }
Exemplo n.º 16
0
  @Override
  protected void onStop() {

    super.onStop();

    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    SharedPreferences.Editor editor = settings.edit();
    editor.putString("lastUrl", urlField.getText().toString());

    editor.commit();
  }
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
          EditText et = (EditText) v;

          // If the event is a key-down event on the "Enter" button
          if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
            // Perform action on key press
            Toast.makeText(HelloFormStuffActivity.this, et.getText(), Toast.LENGTH_SHORT).show();
            return true;
          }
          return false;
        }
 @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());
 }
Exemplo n.º 19
0
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
          myHour = hourOfDay;
          myMinute = minute;

          if (editTextTimeStart.getText().length() == 0) {
            if (myMinute < 10) {
              editTextTimeStart.setText(myHour + ":" + "0" + myMinute);
            } else {
              editTextTimeStart.setText(myHour + ":" + myMinute);
            }
            editTextTimeStart.setTextColor(Color.BLACK);
          }

          if (editTextTimeEnd.getText().length() == 0) {
            if (myMinute < 10) {
              editTextTimeEnd.setText(myHour + ":" + "0" + myMinute);
            } else {
              editTextTimeEnd.setText(myHour + ":" + myMinute);
            }
            editTextTimeEnd.setTextColor(Color.BLACK);
          }
        }
Exemplo n.º 20
0
  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();
    }
  }
Exemplo n.º 21
0
  public void onClick(View v) {
    if (v.equals(llTitle.getBtnBack())) {
      Platform plat = null;
      for (int i = 0; i < views.length; i++) {
        if (views[i].getVisibility() == View.INVISIBLE) {
          plat = platformList[i];
          break;
        }
      }

      // a statistics of Cancel-sharing
      if (plat != null) {
        ShareSDK.logDemoEvent(5, plat);
      }
      finish();
      return;
    }

    if (v.equals(llTitle.getBtnRight())) {
      String text = etContent.getText().toString();
      shareParamMap.put("text", text);

      platforms.clear();
      for (int i = 0; i < views.length; i++) {
        if (views[i].getVisibility() != View.VISIBLE) {
          platforms.add(platformList[i]);
        }
      }

      if (platforms.size() > 0) {
        setResultAndFinish();
      } else {
        int resId = getStringRes(activity, "ssdk_oks_select_one_plat_at_least");
        if (resId > 0) {
          Toast.makeText(getContext(), resId, Toast.LENGTH_SHORT).show();
        }
      }
      return;
    }

    if (v instanceof FrameLayout) {
      ((FrameLayout) v).getChildAt(1).performClick();
      return;
    }

    if (v.getVisibility() == View.INVISIBLE) {
      v.setVisibility(View.VISIBLE);
    } else {
      v.setVisibility(View.INVISIBLE);
    }
  }
  private void refreshList() {
    this.contact_adapter.clear();
    ContactRepositoryInterface datasource =
        ContactRepositoryFactory.getInstance().getContactRepository(this, this);
    datasource.open();
    for (Contact c : datasource.all()) {
      this.contact_adapter.add(c);
    }
    datasource.close();
    this.contact_adapter.notifyDataSetChanged();

    EditText search_box = (EditText) findViewById(R.id.search_box);
    contact_adapter.getFilter().filter(search_box.getText().toString());
  }
Exemplo n.º 23
0
  public void doNav() {

    String url = urlField.getText().toString();

    if (URLUtil.isValidUrl(url) == false) {
      url = "http://" + url;
    }

    urlField.setText(url);

    webView.requestFocus();

    webView.loadUrl(url);

    navbar.startAnimation(slideUp);
  }
Exemplo n.º 24
0
  private void tryRenameFile(EditText fileNameInput, String oldFile) {
    String newFileName = fileNameInput.getText().toString();
    if (!newFileName.endsWith(FileController.FILE_EXTENSION))
      newFileName += FileController.FILE_EXTENSION;

    File file = fileController.getFile(newFileName);

    if (file.exists()) {
      Toast.makeText(this, getString(R.string.fileNameInUse), Toast.LENGTH_SHORT).show();
      showRenameDialog(oldFile); // If filename is already in use, call this function recursively,
    } // until a valid name is typed, or the user cancel the alertdialog.
    else {
      String fileNames[] = {oldFile, newFileName};
      new RenameTask(this, fileController, this).execute(fileNames);
    }
  }
Exemplo n.º 25
0
  public void onCreate() {
    if (shareParamMap == null || platforms == null || platforms.size() < 1) {
      finish();
      return;
    }

    getBackground();
    activity.setContentView(getPageView());
    onTextChanged(etContent.getText(), 0, etContent.length(), 0);
    showThumb();

    // requests platform list and remove platforms share in their clients
    new Thread() {
      public void run() {
        try {
          platformList = ShareSDK.getPlatformList();
          if (platformList == null) {
            return;
          }

          ArrayList<Platform> list = new ArrayList<Platform>();
          for (Platform plat : platformList) {
            String name = plat.getName();
            if ((plat instanceof CustomPlatform) || ShareCore.isUseClientToShare(name)) {
              continue;
            }
            list.add(plat);
          }
          platformList = new Platform[list.size()];
          for (int i = 0; i < platformList.length; i++) {
            platformList[i] = list.get(i);
          }

          UIHandler.sendEmptyMessage(
              1,
              new Callback() {
                public boolean handleMessage(Message msg) {
                  afterPlatformListGot();
                  return false;
                }
              });
        } catch (Throwable t) {
          t.printStackTrace();
        }
      }
    }.start();
  }
 @Override
 public void onStop() {
   super.onStop();
   if (!sendSuccessful) {
     if (mMessage
         .getText()
         .toString()
         .replaceAll("\\s", "")
         .equalsIgnoreCase(originalReplyData.replaceAll("\\s", ""))) {
       Log.i(TAG, "Message unchanged, discarding.");
       deleteReply(); // if the reply is unchanged, throw it out.
     } else {
       Log.i(TAG, "Message Unsent, saving.");
       saveReply();
     }
   }
   cleanupTasks();
 }
  @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 saveReply() {
   if (getActivity() != null && mThreadId > 0) {
     ContentResolver cr = getActivity().getContentResolver();
     ContentValues post = new ContentValues();
     post.put(AwfulMessage.ID, mThreadId);
     post.put(AwfulMessage.TYPE, mReplyType);
     String content = mMessage.getText().toString();
     if (content.length() > 0) {
       post.put(AwfulMessage.REPLY_CONTENT, content);
     }
     if (cr.update(
             ContentUris.withAppendedId(AwfulMessage.CONTENT_URI_REPLY, mThreadId),
             post,
             null,
             null)
         < 1) {
       cr.insert(AwfulMessage.CONTENT_URI_REPLY, post);
     }
   }
 }
Exemplo n.º 29
0
  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");
    }
  }
Exemplo n.º 30
0
 @Override
 public void onClick(View v) {
   // TODO Auto-generated method stub
   switch (v.getId()) {
       // save button
     case R.id.bspref1:
       String str = getd.getText().toString();
       /*	File f=new File(FILENAME);
       try {
       	fos=new FileOutputStream(f);
       	fos.close();
       } catch (FileNotFoundException e) {
       	// TODO Auto-generated catch block
       	e.printStackTrace();
       } catch (IOException e) {
       	// TODO Auto-generated catch block
       	e.printStackTrace();
       }
       */
       try {
         fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
         fos.write(str.getBytes());
         fos.close();
       } catch (FileNotFoundException e1) {
         // TODO Auto-generated catch block
         e1.printStackTrace();
       } catch (IOException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
       break;
       // load button
     case R.id.bspref2:
       new LoadStuff().execute(FILENAME);
       break;
   }
 }