List of usage examples for android.text Editable toString
public String toString();
From source file:org.mariotaku.twidere.activity.TwitterLoginActivity.java
private void saveEditedText() { Editable ed = mEditUsername.getText(); if (ed != null) { mUsername = ed.toString(); }//from ww w . ja v a 2s . c o m ed = mEditPassword.getText(); if (ed != null) { mPassword = ed.toString(); } }
From source file:com.liuwei1995.red.fragment.presenter.EyeFragmentPresenter.java
@Override public void afterTextChanged(Editable s) { if (type == H_TYPE_ZERO || type == H_TYPE_TWO) { getNativeData(s.toString()); } else if (type == H_TYPE_ONE) { handler.removeMessages(H_SHOW_RED_SNACKBAR); handler.removeMessages(H_DISMISS_RED_SNACKBAR); handler.sendEmptyMessage(H_DISMISS_RED_SNACKBAR); synchronized (this) { handler.removeMessages(H_TYPE_ONE); Message message = handler.obtainMessage(); message.obj = s;// ww w . ja v a 2 s. c om message.what = type; handler.sendMessageDelayed(message, 500); } } }
From source file:de.vanita5.twittnuker.fragment.support.DirectMessagesConversationFragment.java
private void sendDirectMessage() { final Editable text = mEditText.getText(); if (isEmpty(text) || mAccountId <= 0 || mRecipientId <= 0) return;/*w ww . ja v a 2 s. c o m*/ final String message = text.toString(); if (mValidator.isValidTweet(message)) { mTwitterWrapper.sendDirectMessageAsync(mAccountId, mRecipientId, message, mImageUri); text.clear(); mImageUri = null; updateAddImageButton(); } }
From source file:org.protocoder.fragments.EditorFragment.java
private int getCurrentCursorLine(Editable editable) { int selectionStartPos = Selection.getSelectionStart(editable); if (selectionStartPos < 0) { // There is no selection, so return -1 like getSelectionStart() does // when there is no seleciton. return -1; }//from www .j a v a 2 s. c o m String preSelectionStartText = editable.toString().substring(0, selectionStartPos); return StringUtils.countMatches(preSelectionStartText, "\n"); }
From source file:com.jlabs.peepaid.searchviewlay.SearchViewLayout.java
private void callSearchListener() { Editable editable = mSearchEditText.getText(); if (editable != null && editable.length() > 0) { if (mSearchListener != null) { mSearchListener.onFinished(editable.toString()); }/*ww w . j av a 2s . co m*/ } }
From source file:com.cmput301w15t15.travelclaimsapp.activitys.EditClaimActivity.java
@Override public void afterTextChanged(Editable s) { switch (getCurrentFocus().getId()) { case R.id.Edit_Claim_Name2: String newName = s.toString(); //if length of name in edittext is 0 or if claim name is already in claimlist //then do not save changes. Otherwise update the claim name if (s.length() == 0) { Toast.makeText(this, "Claim name cannot be null", Toast.LENGTH_SHORT).show(); } else if (claimList.getClaim(newName) != null) { Toast.makeText(this, "Claim name cannot be duplicate of another claim", Toast.LENGTH_SHORT).show(); } else {/* w ww. j ava2 s . co m*/ theClaim.setName(claimNameInput.getText().toString()); } case R.id.Claim_Start_Date: try { theClaim.setStartDate(sdf.parse(claimStartDate.getText().toString())); } catch (ParseException e) { //do nothing } case R.id.Claim_Finish_Date: try { theClaim.setEndDate(sdf.parse(claimEndDate.getText().toString())); } catch (ParseException e) { //do nothing } } }
From source file:org.bobstuff.bobball.ActivityStateEnum.java
private void promptUsername() { activityState = ActivityStateEnum.GAMELOST_TOPSCORE; final EditText input = new EditText(this); final String defaultName = Preferences.loadValue("defaultName", getString(R.string.defaultName)); input.setHint(defaultName);/*from w ww . j av a 2 s .c o m*/ new AlertDialog.Builder(this).setTitle(R.string.namePrompt).setMessage(R.string.highScoreAchieved) .setView(input).setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Editable value = input.getText(); String valueString = value.toString().trim(); if (valueString.isEmpty()) { valueString = defaultName; } scores.addScore(valueString, gameManager.getCurrGameState().getPlayer(playerId).getScore()); showTopScores(); } }).show(); }
From source file:circleplus.app.LocationFragment.java
@Override public void onClick(View v) { if (v == mGetLocationButton) { switch (mCurBtnType) { case LOC: requestLocClick();//from w ww . jav a 2 s .com break; case COMPASS: mLocationOverlay.setLocationMode(MyLocationOverlay.LocationMode.FOLLOWING); mGetLocationButton.setText("Follow"); mCurBtnType = ButtonType.FOLLOW; break; case FOLLOW: mLocationOverlay.setLocationMode(MyLocationOverlay.LocationMode.COMPASS); mGetLocationButton.setText("Compass"); mCurBtnType = ButtonType.COMPASS; break; default: break; } // // Manual click for searching } else if (v == mSearchButton) { /* Search nearby */ Editable text = mSearchText.getText(); String poiKey = text == null ? "" : text.toString(); /* * Search order: * (1) Search nearby when we have location data (lat lng) * (2) Search in city when we have city info */ mFragSearchListener.setRequestCode(FragSearchListener.REQ_CODE_SEARCH); mSearch.setPoiPageCapacity(20); if (mHasLocationData && !TextUtils.isEmpty(poiKey)) { mSearch.poiSearchNearBy(poiKey, new GeoPoint((int) (mLocationData.latitude * 1e6), (int) (mLocationData.longitude * 1e6)), LocationUtils.POI_DISTANCE); } else if (!TextUtils.isEmpty(mCurrentCity) && !TextUtils.isEmpty(poiKey)) { mSearch.poiSearchInCity(poiKey, mCurrentCity); } else if (!TextUtils.isEmpty(poiKey)) { Toast.makeText(getActivity(), "Can not get poi info", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getActivity(), "Can not get location or poi info", Toast.LENGTH_SHORT).show(); } } }
From source file:nz.ac.auckland.lablet.script.components.TextComponent.java
@Override public View createView(Context context, Fragment parent) { ScriptTreeNodeSheetBase.Counter counter = this.component.getCounter("QuestionCounter"); // Note: we have to do this programmatically because findViewById would find the wrong child // items if there is more than one text question. LinearLayout layout = new LinearLayout(context); layout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); layout.setOrientation(LinearLayout.VERTICAL); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { layout.setBackgroundColor(context.getResources().getColor(R.color.sc_question_background_color, null)); } else {//from w w w .j av a2 s.c o m layout.setBackgroundColor(context.getResources().getColor(R.color.sc_question_background_color)); } TextView textView = new TextView(context); textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { textView.setTextAppearance(android.R.style.TextAppearance_Medium); } else { textView.setTextAppearance(context, android.R.style.TextAppearance_Medium); } question_num = counter.increaseValue(); textView.setText("Q" + question_num + ": " + text); EditText editText = new EditText(context); editText.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); editText.setText(answer); editText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void afterTextChanged(Editable editable) { answer = editable.toString(); update(); } }); layout.addView(textView); layout.addView(editText); return layout; }
From source file:com.dirkgassen.wator.ui.fragment.NewWorld.java
/** * Validate the "initial fish count" {@link EditText}. The text is already provided as a parameter. * * If the text is valid the "initial shark count" {@link EditText} is validated as well to eventually remove an * error that previously existed (e.g., number of initial fish was reduced so that the number of shark are now valid). * * Note that the "initial shark count" {@link EditText} is not validated if the text is invalid to not add * an error message to the "initial shark count" {@link EditText} if this text value is invalid. * @param s text of the "initial fish count" {@link EditText} * @param worldSize size of the world/* www . j a va 2 s . c o m*/ */ private void validateInitialFishCount(Editable s, int worldSize) { if (s.length() == 0) { inputs[INITIAL_FISH_COUNT_INPUT].setError(getString(R.string.initial_fish_count_empty_error)); } else { Editable sharkCount = inputs[INITIAL_SHARK_COUNT_INPUT].getText(); int initialFishValue = Integer.valueOf(s.toString()); int initialSharkCount = sharkCount.length() == 0 ? 0 : Integer.valueOf(sharkCount.toString()); int max = worldSize - initialSharkCount; if (max < 0) { max = 0; } if (initialFishValue > max) { inputs[INITIAL_FISH_COUNT_INPUT].setError(getString(R.string.too_many_fish_error, max)); } else { inputs[INITIAL_FISH_COUNT_INPUT].setError(null); if (sharkCount.length() > 0 && initialSharkCount < worldSize - initialFishValue) { inputs[INITIAL_SHARK_COUNT_INPUT].setError(null); } } } }