List of usage examples for java.lang CharSequence toString
public String toString();
From source file:com.insthub.O2OMobile.Activity.C15_EditPriceActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.c15_edit_price); mMyService = (MY_SERVICE) getIntent().getSerializableExtra(SERVICE); nTitle = (TextView) findViewById(R.id.top_view_title); nTitle.setText(getString(R.string.modify_service)); mBack = (ImageView) findViewById(R.id.top_view_back); mType = (TextView) findViewById(R.id.service_type); mPrice = (EditText) findViewById(R.id.price); mSave = (Button) findViewById(R.id.save); if (mMyService != null) { mType.setText(mMyService.service_type.title); mPrice.setText(mMyService.price); mPrice.setSelection(mMyService.price.length()); }/*from w w w.jav a 2 s . c o m*/ mServiceModel = new ServiceModel(this); mServiceModel.addResponseListener(this); mSave.setOnClickListener(this); mBack.setOnClickListener(this); mPrice.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub if (s.toString().length() > 0) { if (s.toString().substring(0, 1).equals(".")) { s = s.toString().substring(1, s.length()); mPrice.setText(s); } } if (s.toString().length() > 1) { if (s.toString().substring(0, 1).equals("0")) { if (!s.toString().substring(1, 2).equals(".")) { s = s.toString().substring(1, s.length()); mPrice.setText(s); CharSequence charSequencePirce = mPrice.getText(); if (charSequencePirce instanceof Spannable) { Spannable spanText = (Spannable) charSequencePirce; Selection.setSelection(spanText, charSequencePirce.length()); } } } } boolean flag = false; for (int i = 0; i < s.toString().length() - 1; i++) { String getstr = s.toString().substring(i, i + 1); if (getstr.equals(".")) { flag = true; break; } } if (flag) { int i = s.toString().indexOf("."); if (s.toString().length() - 3 > i) { String getstr = s.toString().substring(0, i + 3); mPrice.setText(getstr); CharSequence charSequencePirce = mPrice.getText(); if (charSequencePirce instanceof Spannable) { Spannable spanText = (Spannable) charSequencePirce; Selection.setSelection(spanText, charSequencePirce.length()); } } } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }); }
From source file:com.huguesjohnson.sega32xcollector.ebay.EbayUtils.java
private String getRequestURL(String keyword) { CharSequence requestURL = TextUtils.expandTemplate(REQUEST_TEMPLATE, this.ebayURL, this.appID, keyword); return (requestURL.toString()); }
From source file:com.paic.zhifu.wallet.activity.modules.creditpayment.RealNameSignUpApplyActivity.java
private boolean isAvailableAmount(CharSequence s) { if (s == null || s.toString().equals("")) { return false; }/*from www. jav a 2 s . c o m*/ String inputStr = s.toString(); int expectedCreditLine = Integer.valueOf(inputStr); if (!inputStr.equals(String.valueOf(expectedCreditLine))) { amountET.setText(String.valueOf(expectedCreditLine)); } if (expectedCreditLine > PaymentByCreditIntents.PAYMENTBYCREDIT_APPLY_LIMIT_AMOUNT || expectedCreditLine < PaymentByCreditIntents.PAYMENTBYCREDIT_APPLY_LIMIT_AMOUNT_S) { return false; } return true; }
From source file:com.cyberway.issue.crawler.extractor.ExtractorJS.java
public static long considerStrings(CrawlURI curi, CharSequence cs, CrawlController controller, boolean handlingJSFile) { long foundLinks = 0; Matcher strings = TextUtils.getMatcher(JAVASCRIPT_STRING_EXTRACTOR, cs); while (strings.find()) { CharSequence subsequence = cs.subSequence(strings.start(2), strings.end(2)); Matcher uri = TextUtils.getMatcher(STRING_URI_DETECTOR, subsequence); if (uri.matches()) { String string = uri.group(); string = speculativeFixup(string, curi); foundLinks++;//w w w .j a v a 2s . co m try { if (handlingJSFile) { curi.createAndAddLinkRelativeToVia(string, Link.JS_MISC, Link.SPECULATIVE_HOP); } else { curi.createAndAddLinkRelativeToBase(string, Link.JS_MISC, Link.SPECULATIVE_HOP); } } catch (URIException e) { // There may not be a controller (e.g. If we're being run // by the extractor tool). if (controller != null) { controller.logUriError(e, curi.getUURI(), string); } else { LOGGER.info(curi + ", " + string + ": " + e.getMessage()); } } } else if (subsequence.toString().startsWith("/")) { try { curi.createAndAddLinkRelativeToBase(subsequence.toString(), Link.JS_MISC, Link.NAVLINK_HOP); } catch (URIException e) { if (controller != null) { controller.logUriError(e, curi.getUURI(), subsequence); } else { LOGGER.info(curi + ", " + subsequence + ": " + e.getMessage()); } } } else { foundLinks += considerStrings(curi, subsequence, controller, handlingJSFile); } TextUtils.recycleMatcher(uri); } TextUtils.recycleMatcher(strings); return foundLinks; }
From source file:com.capstone.transit.trans_it.PlacesAutoCompleteAdapter.java
@Override public Filter getFilter() { Filter filter = new Filter() { @Override//w w w .j a va 2s . c o m protected FilterResults performFiltering(CharSequence constraint) { FilterResults filterResults = new FilterResults(); if (constraint != null) { // Retrieve the autocomplete results. resultList = autocomplete(constraint.toString()); // Assign the data to the FilterResults filterResults.values = resultList; filterResults.count = resultList.size(); } return filterResults; } @Override protected void publishResults(CharSequence constraint, FilterResults results) { if (results != null && results.count > 0) { notifyDataSetChanged(); } else { notifyDataSetInvalidated(); } } }; return filter; }
From source file:org.callimachusproject.auth.FacebookAuthReader.java
public FacebookAuthReader(String self, String appId, CharSequence secret, HttpUriClient client) { this.client = client; this.appId = appId; this.secret = secret.toString(); }
From source file:org.deviceconnect.android.uiapp.fragment.profile.VibrationProfileFragment.java
/** * Vibration???./*from w w w .java 2s.c o m*/ * @param pattern ? */ private void sendVibration(final CharSequence pattern) { (new AsyncTask<Void, Void, DConnectMessage>() { public DConnectMessage doInBackground(final Void... args) { String p = null; if (pattern != null && pattern.length() > 0) { p = pattern.toString(); } try { URIBuilder builder = new URIBuilder(); builder.setProfile(VibrationProfileConstants.PROFILE_NAME); builder.setAttribute(VibrationProfileConstants.ATTRIBUTE_VIBRATE); builder.addParameter(DConnectMessage.EXTRA_DEVICE_ID, getSmartDevice().getId()); if (p != null) { builder.addParameter(VibrationProfileConstants.PARAM_PATTERN, p); } builder.addParameter(DConnectMessage.EXTRA_ACCESS_TOKEN, getAccessToken()); HttpResponse response = getDConnectClient().execute(getDefaultHost(), new HttpPut(builder.build())); return (new HttpMessageFactory()).newDConnectMessage(response); } catch (URISyntaxException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(final DConnectMessage result) { if (getActivity().isFinishing()) { return; } TextView tv = (TextView) getView().findViewById(R.id.fragment_vibration_result); if (result == null) { tv.setText("failed"); } else { tv.setText(result.toString()); } } }).execute(); }
From source file:org.shredzone.cilla.plugin.flattr.FlattrPublicationServiceImpl.java
/** * Prepares a {@link CharSequence}. Strips all HTML and limits its length to the given * maximum length./*w w w . j av a 2 s .co m*/ * * @param str * {@link CharSequence} to prepare * @param maxlen * maximum length * @return prepared {@link CharSequence} */ private CharSequence prepare(CharSequence str, int maxlen) { CharSequence result = textFormatter.stripHtml(str.toString().trim()); if (result.length() > maxlen) { return result.subSequence(0, maxlen); } else { return result; } }
From source file:com.mastfrog.netty.http.client.RequestBuilder.java
@Override public HttpRequestBuilder setBody(Object o, MediaType contentType) throws IOException { if (o instanceof CharSequence) { CharSequence seq = (CharSequence) o; setBody(seq.toString().getBytes(CharsetUtil.UTF_8), contentType); } else if (o instanceof byte[]) { byte[] b = (byte[]) o; ByteBuf buffer = alloc.buffer(b.length).writeBytes(b); setBody(buffer, contentType);// ww w. j av a 2 s . co m } else if (o instanceof ByteBuf) { body = (ByteBuf) o; if (send100Continue) { addHeader(Headers.stringHeader(HttpHeaders.Names.EXPECT), HttpHeaders.Values.CONTINUE); } addHeader(Headers.CONTENT_LENGTH, (long) body.readableBytes()); addHeader(Headers.CONTENT_TYPE, contentType); } else if (o instanceof InputStream) { ByteBuf buf = newByteBuf(); try (ByteBufOutputStream out = new ByteBufOutputStream(buf)) { try (InputStream in = (InputStream) o) { Streams.copy(in, out, 1024); } } setBody(buf, contentType); } else if (o instanceof RenderedImage) { ByteBuf buf = newByteBuf(); try (ByteBufOutputStream out = new ByteBufOutputStream(buf)) { String type = contentType.subtype(); if ("jpeg".equals(type)) { type = "jpg"; } ImageIO.write((RenderedImage) o, type, out); } setBody(buf, contentType); } else { try { setBody(new ObjectMapper().writeValueAsBytes(o), contentType); } catch (Exception ex) { throw new IllegalArgumentException(ex); } } return this; }
From source file:org.envirocar.app.dao.remote.BaseRemoteDAO.java
/** * Wrap content into an HTTP entity. a GZIP entity is used if * the content length exceeds {@link HTTPClient#MIN_GZIP_SIZE}. * //from w ww . j a v a 2 s.com * @param content the content to wrap * @return the entity * @throws UnsupportedEncodingException * @throws IOException */ protected HttpEntity preparePayload(CharSequence content) throws UnsupportedEncodingException, IOException { return preparePayload(content.toString().getBytes("UTF-8")); }