@Override public void onClick(View v) { switch (v.getId()) { case R.id.btn_enviar: try { if (etxt_destinatario.length() == 0 || Integer.parseInt(etxt_nota.getText().toString()) > 3 || etxt_mensaje.length() == 0) { Toast.makeText(NuevoObjeto.this, R.string.msgerror, Toast.LENGTH_SHORT).show(); } else { // AQUI LO CONVIERTE Intent i = new Intent(); i.putExtra("emisor", txt_useremisor.getText().toString()); i.putExtra("destinatario", etxt_destinatario.getText().toString()); i.putExtra("nota", Integer.parseInt(etxt_nota.getText().toString())); i.putExtra("mensaje", etxt_mensaje.getText().toString()); setResult(RESULT_OK, i); finish(); break; } } catch (java.lang.NumberFormatException e) { Toast.makeText(NuevoObjeto.this, e.getMessage(), Toast.LENGTH_SHORT).show(); } // FORMA QUE NO FUNCIONA /*Objeto nuevo_objeto = new Objeto(txt_useremisor.getText().toString(), etxt_destinatario.getText().toString(), Integer.parseInt(etxt_nota.getText().toString()), etxt_mensaje.getText().toString()); i.putExtra("NuevoObjeto", nuevo_objeto);*/ // startActivityForResult(i,1); } }
private boolean validateInputs() { validateError = ""; if (etName.length() < 2) { validateError = "Name cannot be empty or less than 2 characters"; return false; } if (etStopName.length() < 2) { validateError = "Stop Name cannot be empty or less than 2 characters"; return false; } if (etStreet.length() < 2) { validateError = "Street cannot be empty or less than 2 characters"; return false; } if (etCity.length() < 2) { validateError = "City cannot be empty or less than 2 characters"; return false; } if (etCountry.length() < 2) { validateError = "Country cannot be empty or less than 2 characters"; return false; } if (validateError != null && validateError.isEmpty()) { validateError = "Submitting Create Checkin Request"; tvResp.setText(validateError); return true; } else { return false; } }
@Override public boolean okForLogin() { if (!DeviceUtil.hasInternet()) { ToastUtil.toast(R.string.tip_no_internet); return false; } if (etUserName.length() == 0) { etUserName.setError("请输入邮箱/用户名"); etUserName.requestFocus(); return false; } else if (etUserName.length() < 4) { etUserName.setError("用户名长度过短"); etUserName.requestFocus(); return false; } if (etPassword.length() == 0) { etPassword.setError("请输入密码"); etPassword.requestFocus(); return false; } else if (etPassword.length() <= 7) { etPassword.setError("密码长度过短"); etPassword.requestFocus(); return false; } return true; }
public boolean setParameter() { int ibufnum, ibufsize, itransize; int ireadtimeout; if (d2xxDrvParameter == null) return false; // 2 ~ 16 if (bufnumValue.length() == 0x00) { ibufnum = d2xxDrvParameter.getBufferNumber(); } else { ibufnum = Integer.parseInt(bufnumValue.getText().toString()); if (ibufnum < 2) { ibufnum = 2; } else if (ibufnum > 16) { ibufnum = 16; } } // 64 ~ 16384 if (bufsizeValue.length() == 0x00) { ibufsize = d2xxDrvParameter.getMaxBufferSize(); } else { ibufsize = Integer.parseInt(bufsizeValue.getText().toString()); if (ibufsize < 64) { ibufsize = 64; } else if (ibufsize > 16384) { ibufsize = 16384; } } // 64 ~ 16384 if (transizeValue.length() == 0x00) { itransize = d2xxDrvParameter.getMaxTransferSize(); } else { itransize = Integer.parseInt(transizeValue.getText().toString()); if (itransize < 64) { itransize = 64; } else if (itransize > 16384) { itransize = 16384; } } if (readtimeValue.length() == 0x00) { ireadtimeout = d2xxDrvParameter.getReadTimeout(); } else { ireadtimeout = Integer.parseInt(readtimeValue.getText().toString()); } d2xxDrvParameter.setBufferNumber(ibufnum); d2xxDrvParameter.setMaxBufferSize(ibufsize); d2xxDrvParameter.setMaxTransferSize(itransize); d2xxDrvParameter.setReadTimeout(ireadtimeout); bufnumValue.setText("" + ibufnum); bufsizeValue.setText("" + ibufsize); transizeValue.setText("" + itransize); readtimeValue.setText("" + ireadtimeout); return true; }
private boolean validateInputs() { if (usernameInput.length() == 0 || passwordInput.length() == 0 || synckeyInput.length() == 0 || (serverCheckbox.isChecked() && serverInput.length() == 0)) { return false; } return true; }
private void toggle_eye() { if (img_eye.getDrawable().getLevel() == 0) { img_eye.setImageLevel(1); edt_password.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); edt_password.setSelection(edt_password.length()); } else { img_eye.setImageLevel(0); edt_password.setInputType(129); edt_password.setSelection(edt_password.length()); } }
@OnClick(R.id.enterpriseLogin) public void onLogin() { if (enterpriseUrl.length() > 0 && enterpriseToken.length() > 0) { Bundle bundle = new Bundle(); bundle.putString(EXTRA_ENTERPRISE_URL, enterpriseUrl.getText().toString()); bundle.putString(EXTRA_ENTERPRISE_TOKEN, enterpriseToken.getText().toString()); Intent intent = new Intent(); intent.putExtras(bundle); setResult(RESULT_OK, intent); finish(); } }
private boolean checkAccountInfor() { if (etUsername != null && etUsername.length() > 0 && etPassword != null && etPassword.length() > 0 && etServer != null && etServer.length() > 0 && etPort != null && etPort.length() > 0) { return true; } return false; }
private void retweetOrQuote(AsyncTwitterWrapper twitter, ParcelableStatus status) { final Dialog dialog = getDialog(); if (dialog == null) return; final EditText editComment = ((EditText) dialog.findViewById(R.id.edit_comment)); if (editComment.length() > 0) { final Menu menu = mPopupMenu.getMenu(); final MenuItem quoteOriginalStatus = menu.findItem(R.id.quote_original_status); final MenuItem linkToQuotedStatus = menu.findItem(R.id.link_to_quoted_status); final Uri statusLink; final long inReplyToStatusId; if (!status.is_quote || !quoteOriginalStatus.isChecked()) { inReplyToStatusId = status.id; statusLink = LinkCreator.getTwitterStatusLink(status.user_screen_name, status.id); } else { inReplyToStatusId = status.quoted_id; statusLink = LinkCreator.getTwitterStatusLink(status.quoted_user_screen_name, status.quoted_id); } final String commentText = editComment.getText() + " " + statusLink; twitter.updateStatusAsync( new long[] {status.account_id}, commentText, null, null, linkToQuotedStatus.isChecked() ? inReplyToStatusId : -1, status.is_possibly_sensitive); } else if (isMyRetweet(status)) { twitter.cancelRetweetAsync(status.account_id, status.id, status.my_retweet_id); } else { twitter.retweetStatusAsync(status.account_id, status.id); } }
private void sendMessage() { EditText messageTxt = (EditText) findViewById(R.id.txt); if (messageTxt.length() == 0) { return; } InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(messageTxt.getWindowToken(), 0); ReliUser user = MainActivity.user; String s = messageTxt.getText().toString(); final Message message = new Message(s, new Date(), user.getParseID(), user.getFullName()); messagesList.add(message); chatAdapter.notifyDataSetChanged(); messageTxt.setText(null); ParseObject po = new ParseObject(discussionTableName); po.put(Const.COL_MESSAGE_SENDER_ID, user.getParseID()); po.put(Const.COL_MESSAGE_SENDER_NAME, user.getFullName()); po.put(Const.COL_MESSAGE_CONTENT, s); po.saveEventually( new SaveCallback() { @Override public void done(ParseException e) { message.setStatus( (e == null) ? MessageStatus.STATUS_SENT : MessageStatus.STATUS_FAILED); chatAdapter.notifyDataSetChanged(); } }); }
/** Show a dialog, confirming the user's wish to save a ProductionSite. */ private void showDialogSave() { if (verifyForm()) { // ask for confirmation first AlertDialog.Builder builder = new AlertDialog.Builder(this); String siteStr = etOrg.getText().toString() + "-" + etPpnr.getText().toString(); if (etName.length() > 0) { siteStr += " " + etName.getText().toString(); } builder.setMessage(getString(R.string.dialog_ask_save) + " " + siteStr + "?"); builder.setCancelable(true); // YES button builder.setPositiveButton( R.string.dialog_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { saveForm(); } }); // NO button builder.setNegativeButton( R.string.dialog_no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // nothing? } }); builder.show(); } else { Toast.makeText(this, R.string.toast_form_not_correct, Toast.LENGTH_SHORT).show(); } }
private void showCustomEndpointDialog(final int originalSelection, String defaultUrl) { View view = LayoutInflater.from(app).inflate(R.layout.debug_drawer_network_endpoint, null); final EditText url = findById(view, R.id.debug_drawer_network_endpoint_url); url.setText(defaultUrl); url.setSelection(url.length()); new AlertDialog.Builder(getContext()) // .setTitle("Set Network Endpoint") .setView(view) .setNegativeButton( "Cancel", (dialog, i) -> { endpointView.setSelection(originalSelection); dialog.cancel(); }) .setPositiveButton( "Use", (dialog, i) -> { String theUrl = url.getText().toString(); if (!Strings.isBlank(theUrl)) { setEndpointAndRelaunch(theUrl); } else { endpointView.setSelection(originalSelection); } }) .setOnCancelListener( (dialogInterface) -> { endpointView.setSelection(originalSelection); }) .show(); }
@Override public void onKey(int primaryCode, int[] keyCodes) { Editable editable = ed.getText(); int start = ed.getSelectionStart(); if (primaryCode == Keyboard.KEYCODE_CANCEL) { // 完成 hideKeyboard(); } else if (primaryCode == Keyboard.KEYCODE_DELETE) { // 回退 if (editable != null && editable.length() > 0) { if (start > 0) { editable.delete(start - 1, start); } } } else if (primaryCode == Keyboard.KEYCODE_SHIFT) { // 大小写切换 changeKey(); keyboardView.setKeyboard(k1); } else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE) { // 数字键盘切换 if (isnun) { isnun = false; keyboardView.setKeyboard(k1); } else { isnun = true; keyboardView.setKeyboard(k2); } } else if (primaryCode == 57419) { // go left if (start > 0) { ed.setSelection(start - 1); } } else if (primaryCode == 57421) { // go right if (start < ed.length()) { ed.setSelection(start + 1); } } else { editable.insert(start, Character.toString((char) primaryCode)); } }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (fragmentView == null) { fragmentView = inflater.inflate(R.layout.chat_profile_change_name_layout, container, false); TLRPC.Chat currentChat = MessagesController.Instance.chats.get(chat_id); firstNameField = (EditText) fragmentView.findViewById(R.id.first_name_field); firstNameField.setOnEditorActionListener( new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_DONE) { doneButton.performClick(); return true; } return false; } }); firstNameField.setText(currentChat.title); firstNameField.setSelection(firstNameField.length()); TextView headerLabel = (TextView) fragmentView.findViewById(R.id.settings_section_text); headerLabel.setText(getStringEntry(R.string.EnterGroupNameTitle)); } else { ViewGroup parent = (ViewGroup) fragmentView.getParent(); if (parent != null) { parent.removeView(fragmentView); } } return fragmentView; }
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(); }
private void bindData() { task = (Task) getIntent().getSerializableExtra("task"); tv_name.setText(task.getName()); tv_name.setSelection(tv_name.length()); tv_time.setText(TaskUtil.getZixiTimeS(task.getTime())); int p = 4320 - TaskUtil.getDurationFromNow(task.getTime()); if (p <= 0) p = 1; pb.setText(TaskUtil.getDescriptionTimeFromTimestamp(task.getTime())); if (task.getTime() <= System.currentTimeMillis()) { pb.setRoundWidth(0); pb.setText(TaskUtil.getZixiDateS(task.getTime())); } else { pb.setRoundWidth(PixelUtil.dp2px(6)); } if (p < 100) p = 100; // 防止太小了 pb.setProgressNoAnim(p); if (task.getImageUrl() != null) { iv_home_bg.setImageURI(Uri.parse(task.getImageUrl())); } materialMenu.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); String path = task.getAudioUrl(); if (path != null) { final ImageButton ib_play = (ImageButton) ll_audio.findViewById(R.id.ib_play); final ProgressBar pb = (ProgressBar) ll_audio.findViewById(R.id.pb2); ib_play.setTag("play"); ib_play.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { ib_play.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (ib_play.getTag().equals("play")) { ib_play.setImageResource(R.drawable.pause_audio); ib_play.setTag("pause"); NotifyUtils.palyAudio(context, ib_play, pb, task.getAudioUrl()); } else { ib_play.setTag("play"); ib_play.setImageResource(R.drawable.play_audio); NotifyUtils.pauseAudio(ib_play); } } }); } }); } if (task.getNote() != null) { ((TextView) findViewById(R.id.tv_note)).setText(task.getNote()); } }
@OnClick(R.id.enterpriseGenerateToken) public void generateToken() { if (enterpriseUrl.length() > 0) { String url = enterpriseUrl.getText().toString() + "/settings/tokens"; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); } }
@Override public void onTextChanged(CharSequence s, int start, int before, int count) { switch (signUpStep) { case EMAIL: if (emailEditText.length() > 0) continueButton.setVisibility(View.VISIBLE); else continueButton.setVisibility(View.GONE); break; case NAME: if (nameEditText.length() > 0) continueButton.setVisibility(View.VISIBLE); else continueButton.setVisibility(View.GONE); break; case PASSWORD: if (passwordEditText.length() > 0) continueButton.setVisibility(View.VISIBLE); else continueButton.setVisibility(View.GONE); break; } }
private void login() { if (!isPhoneNumber(nameEdit.getText().toString())) { Notify.show("请输入正确的手机号"); } else if (passwordEdit.length() == 0) { Notify.show("请输入密码"); } else { loginUser(); } }
public void setQuery(CharSequence query, boolean submit) { mSearchEditText.setText(query); if (query != null) { mSearchEditText.setSelection(mSearchEditText.length()); mUserQuery = query; } if (submit && !TextUtils.isEmpty(query)) { onSubmitQuery(); } }
private void register() { if (nameEdit.length() == 0 || passwordEdit.length() == 0 || passwordConfirm.length() == 0) { Toast.makeText(getApplicationContext(), "用户名/密码 不能为空", Toast.LENGTH_LONG).show(); } if (!passwordEdit.getText().toString().equals(passwordConfirm.getText().toString())) { Log.d( "jy", "key1 =" + passwordEdit.getText().toString() + " key2 = " + passwordEdit.getText().toString()); Toast.makeText(getApplicationContext(), "密码输入不一致", Toast.LENGTH_LONG).show(); } else { String name = nameEdit.getText().toString(); String password = passwordEdit.getText().toString(); mRegisterTask = new RegisterTask(name, password, this); mRegisterTask.execute(); } }
public void checkLabelInput(View view) { EditText vintageField = (EditText) findViewById(R.id.vintage_value); EditText startDrinkingField = (EditText) findViewById(R.id.drinking_start_value); EditText finishDrinkingField = (EditText) findViewById(R.id.drinking_finish_value); EditText priceField = (EditText) findViewById(R.id.price_value); if (vintageField.length() == 0) { vintageField.setError("You cannot leave this field blank!"); } else if (startDrinkingField.length() == 0) { startDrinkingField.setError("You cannot leave this field blank!"); } else if (finishDrinkingField.length() == 0) { finishDrinkingField.setError("You cannot leave this field blank!"); } else if (priceField.length() == 0) { priceField.setError("You cannot leave this field blank!"); } else { validateLabelInput(vintageField, startDrinkingField, finishDrinkingField, priceField); } }
public boolean validateField() { RadioButton radioOriginalCur = (RadioButton) findViewById(R.id.radioButtonOriginal); RadioButton radioFinalCur = (RadioButton) findViewById(R.id.radioButtonCurrency); EditText textAmount = (EditText) findViewById(R.id.editTextAmount); if (radioOriginalCur.isChecked() && radioFinalCur.isChecked() && textAmount.length() > 0 && Float.parseFloat(textAmount.getText().toString()) >= 0) return true; else return false; }
/** 发送 */ @OnClick(R.id.reply_window_btn_tool_send) protected void onBtnToolSendClick() { if (edtContent.length() == 0) { Toast.makeText(TopicActivity.this, "内容不能为空", Toast.LENGTH_SHORT).show(); } else { String content = edtContent.getText().toString(); if (SettingShared.isEnableTopicSign(TopicActivity.this)) { // 添加小尾巴 content += "\n\n" + SettingShared.getTopicSignContent(TopicActivity.this); } replyTopicAsyncTask(content); } }
/** * 登录 */ private void confirmLogin() { // 检验 if (etUserName.length() == 0) { showError("请输入手机号"); return; } if (!CheckUtil.isPhoneNum(etUserName.getText().toString())) { showError("请输入正确的手机号码"); return; } if (etUserPaw.length() == 0) { showError("请输入密码"); return; } HashMap<String, String> hashmap = new HashMap<String, String>(); hashmap.put("uid", etUserName.getText().toString()); hashmap.put("password", etUserPaw.getText().toString()); hashmap.put("pw", etCode.getText().toString()); new RequestCommant().requestlogin(new requetHandle(this), this, hashmap); }
@Override protected void onCreate(Bundle arg0) { super.onCreate(arg0); setContentView(R.layout.activity_edit); editText = (EditText) findViewById(R.id.edittext); String title = getIntent().getStringExtra("title"); String data = getIntent().getStringExtra("data"); if (title != null) ((TextView) findViewById(R.id.tv_title)).setText(title); if (data != null) editText.setText(data); editText.setSelection(editText.length()); }
@Override public void onClick(View v) { int id = v.getId(); if (id == R.id.setup_apply) { if (login.getText() == null || login.length() == 0 || password.getText() == null || password.length() == 0) { Toast.makeText( getActivity(), getString(R.string.first_launch_no_login_password), Toast.LENGTH_LONG) .show(); return; } SetupActivity.instance() .genericLogIn(login.getText().toString(), password.getText().toString(), domain); } }
private void autosave() { if (!sendSuccessful && mMessage != null) { if (mMessage.length() < 1 || mMessage.getText().toString().replaceAll("\\s", "").length() < 1 || this.sendSuccessful) { Log.i(TAG, "Message unchanged, discarding."); deleteReply(); // if the reply is unchanged, throw it out. mMessage.setText(""); } else { Log.i(TAG, "Message Unsent, saving."); saveReply(); } } }
private void handleOK(EditText input, EditText inputTitle) { String novel = input.getText().toString(); String title = inputTitle.getText().toString(); if (novel != null && novel.length() > 0 && inputTitle != null && inputTitle.length() > 0) { PageModel temp = new PageModel(); temp.setPage(novel); temp.setTitle(title); temp.setType(PageModel.TYPE_NOVEL); temp.setParent("Main_Page"); executeAddTask(temp); } else { Toast.makeText(getSherlockActivity(), "Empty Input", Toast.LENGTH_LONG).show(); } }
private void addNewFriend() { if (mFriendUserNameText.length() > 0) { // TODO: A thread is really needed ? Thread thread = new Thread() { @Override public void run() { // TODO: Please check if the request is successful and raise a error message if // needed. mImService.addNewFriendRequest(mFriendUserNameText.getText().toString()); } }; thread.start(); // TODO: Show the toast only if the sent of the request is successful Toast.makeText(AddFriend.this, R.string.request_sent, Toast.LENGTH_SHORT).show(); finish(); } else { Log.e(LOG_TAG, "addNewFriend: username length (" + mFriendUserNameText.length() + ") is < 0"); Toast.makeText(AddFriend.this, R.string.type_friend_username, Toast.LENGTH_LONG).show(); } }