List of usage examples for android.text Editable append
public Editable append(char text);
From source file:com.robwilliamson.healthyesther.fragment.edit.EditMedicationFragment.java
@Override public void setRow(@Nonnull MedicationTable.Row row) { super.setRow(row); Editable editable = getNameView().getEditableText(); editable.clear();//from w w w.j a va2 s.c o m editable.append(row.getName()); }
From source file:org.miaowo.miaowo.util.Html.java
private static void handleBr(Editable text) { text.append('\n'); }
From source file:com.googlecode.eyesfree.brailleback.rule.DefaultBrailleRule.java
@Override public void format(Editable result, Context context, AccessibilityNodeInfoCompat node) { int oldLength = result.length(); CharSequence text = LabelingUtils.getNodeText(node, getLabelManager()); if (text == null) { text = ""; }/*from w w w. j a va2s.c o m*/ result.append(text); if (node.isCheckable() || node.isChecked()) { CharSequence mark; if (node.isChecked()) { mark = context.getString(R.string.checkmark_checked); } else { mark = context.getString(R.string.checkmark_not_checked); } StringUtils.appendWithSpaces(result, mark); } if (oldLength == result.length() && AccessibilityNodeInfoUtils.isActionableForAccessibility(node)) { result.append(getFallbackText(context, node)); } }
From source file:dev.drsoran.moloko.fragments.ChangeTagsFragment.java
private void onListItemClick(ListView l, View v, int position, long id) { final ChangeTag tag = (ChangeTag) l.getAdapter().getItem(position); final Editable tagsEdit = editView.getEditableText(); if (tag.isAvailable) { if (TextUtils.isEmpty(tagsEdit)) { tagsEdit.append(tag.tag); } else {// www . j a v a2 s. c o m final int trimmedLength = TextUtils.getTrimmedLength(tagsEdit); if (tagsEdit.charAt(trimmedLength - 1) == ',') { tagsEdit.append(tag.tag); } else { tagsEdit.append(", " + tag.tag); } } } else { // Cut the removed tag including any trailing , String content = UIUtils.getTrimmedText(editView); content = content.replaceAll(tag.tag + "\\,*\\s*", Strings.EMPTY_STRING); editView.setText(content); } Selection.setSelection(tagsEdit, tagsEdit.length()); updateTagList(); }
From source file:de.dmxcontrol.fragment.PanelSelectorFragment.java
private void appendToActive(String s) { Editable et; if (mActiveInputType == ACTIVE_INPUT_TYPE_DEVICE) { et = mEditDevice.getEditableText(); } else {/*w ww . j a va 2 s .c o m*/ et = mEditGroup.getEditableText(); } et.append(s); mIsEditing = true; updateEntitySelection(et); mIsEditing = false; }
From source file:com.bt.heliniumstudentapp.UpdateClass.java
@Override protected void onPostExecute(String html) { if (html != null) { try {//from ww w . j a va 2 s . co m final JSONObject json = (JSONObject) new JSONTokener(html).nextValue(); versionName = json.optString("version_name"); final int versionCode = json.optInt("version_code"); try { final int currentVersionCode = context.getPackageManager() .getPackageInfo(context.getPackageName(), 0).versionCode; if (versionCode > currentVersionCode) { if (!settings) updateDialog.show(); updateDialog.setTitle(context.getString(R.string.update) + ' ' + versionName); final TextView contentTV = (TextView) updateDialog.findViewById(R.id.tv_content_du); contentTV.setTextColor(ContextCompat.getColor(context, MainActivity.themePrimaryTextColor)); contentTV.setText(Html.fromHtml(json.optString("content"), null, new Html.TagHandler() { @Override public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) { if ("li".equals(tag)) if (opening) output.append(" \u2022 "); else output.append("\n"); } })); updateDialog.setCanceledOnTouchOutside(true); updateDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); updateDialog.getButton(AlertDialog.BUTTON_POSITIVE) .setTextColor(ContextCompat.getColor(context, MainActivity.accentSecondaryColor)); } else if (settings) { updateDialog.setTitle(context.getString(R.string.update_no)); final TextView contentTV = (TextView) updateDialog.findViewById(R.id.tv_content_du); contentTV.setTextColor(ContextCompat.getColor(context, MainActivity.themePrimaryTextColor)); contentTV.setText(Html.fromHtml(json.optString("content"), null, new Html.TagHandler() { @Override public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) { if ("li".equals(tag)) if (opening) output.append(" \u2022 "); else output.append("\n"); } })); updateDialog.setCanceledOnTouchOutside(true); } } catch (NameNotFoundException e) { Toast.makeText(context, R.string.error, Toast.LENGTH_SHORT).show(); } } catch (JSONException e) { Toast.makeText(context, R.string.error, Toast.LENGTH_SHORT).show(); } } else if (settings) { updateDialog.cancel(); final AlertDialog.Builder updateDialogBuilder = new AlertDialog.Builder( new ContextThemeWrapper(context, MainActivity.themeDialog)); updateDialogBuilder.setTitle(context.getString(R.string.update)); updateDialogBuilder.setMessage(R.string.error_update); updateDialogBuilder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { downloadAPK(); } }); updateDialogBuilder.setNegativeButton(android.R.string.no, null); final AlertDialog updateDialog = updateDialogBuilder.create(); updateDialog.setCanceledOnTouchOutside(true); updateDialog.show(); updateDialog.getButton(AlertDialog.BUTTON_POSITIVE) .setTextColor(ContextCompat.getColor(context, MainActivity.accentSecondaryColor)); updateDialog.getButton(AlertDialog.BUTTON_NEGATIVE) .setTextColor(ContextCompat.getColor(context, MainActivity.accentSecondaryColor)); } }
From source file:org.miaowo.miaowo.util.Html.java
private static void appendNewlines(Editable text, int minNewline) { final int len = text.length(); if (len == 0) { return;//from w w w .j a v a 2s . c o m } int existingNewlines = 0; for (int i = len - 1; i >= 0 && text.charAt(i) == '\n'; i--) { existingNewlines++; } for (int j = existingNewlines; j < minNewline; j++) { text.append("\n"); } }
From source file:com.ritul.truckshare.RegisterActivity.DriverLicenseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_driver_license); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); ProgDialog = new Prog_Dialog(this); setSupportActionBar(toolbar);//from w w w . j a va2 s . com getSupportActionBar().setDisplayHomeAsUpEnabled(true); preview = (ImageView) findViewById(R.id.imgLicence); Button b = (Button) findViewById(R.id.BtnDriverBrowse); staticSpinner = (Spinner) findViewById(R.id.txtLicenseIssue); txtLicenseNumber = (EditText) findViewById(R.id.txtLicenseNumber); txtLicenseExpire = (EditText) findViewById(R.id.txtLicenseExpire); userHierarchy = new ArrayList<>(); if (AppConstant.isNetworkAvailable(this)) { try { state_spiner(); } catch (JSONException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } else { AppConstant.showNetworkError(this); } staticSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { //CountryPosition = (userHierarchy.get(position).toString()); countryPosition = userHierarchy.get(position).getStateId(); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { /*Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show();*/ if (CheckValidation()) { LicenseIssuedStateId = countryPosition; LicenseNumber = txtLicenseNumber.getText().toString(); LicenseExpiryDate = txtLicenseExpire.getText().toString(); LicenseImageBase64String = imagedata; Intent intent = new Intent(getApplicationContext(), TruckActivity.class); startActivity(intent); } } }); txtLicenseExpire.addTextChangedListener(new TextWatcher() { int prevL = 0; @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { prevL = txtLicenseExpire.getText().toString().length(); } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { int length = editable.length(); if ((prevL < length) && (length == 2 || length == 5)) { editable.append("/"); } } }); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Image_Picker_Dialog(); } }); }
From source file:com.googlecode.eyesfree.brailleback.rule.VerticalContainerBrailleRule.java
@Override public void format(Editable result, Context context, AccessibilityNodeInfoCompat node) { boolean empty = (node.getChildCount() == 0); int res;/*from ww w . j a va2 s . c o m*/ if (AccessibilityNodeInfoUtils.nodeMatchesClassByType(context, node, GridView.class)) { res = empty ? R.string.type_emptygridview : R.string.type_gridview; } else if (AccessibilityNodeInfoUtils.nodeMatchesClassByType(context, node, ScrollView.class)) { res = empty ? R.string.type_emptyscrollview : R.string.type_scrollview; } else { res = empty ? R.string.type_emptylistview : R.string.type_listview; } result.append(context.getString(res)); }
From source file:org.miaowo.miaowo.util.Html.java
private static void startImg(Editable text, Attributes attributes, Html.ImageGetter img, Context context) { String src = attributes.getValue("", "src"); Drawable d = null;//from ww w.j a v a 2 s .c om if (img != null) { d = img.getDrawable(src); } if (d == null) { d = ResourcesCompat.getDrawable(context.getResources(), R.drawable.unknown_image, null); d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); } int len = text.length(); text.append("\uFFFC"); text.setSpan(new ImageSpan(d, src), len, text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); }