List of usage examples for java.lang CharSequence toString
public String toString();
From source file:com.ichi2.anki.PreferenceContext.java
private void initPreference(Preference pref) { // Load stored values from Preferences which are stored in the Collection if (Arrays.asList(sCollectionPreferences).contains(pref.getKey())) { Collection col = getCol(); if (col != null) { try { JSONObject conf = col.getConf(); switch (pref.getKey()) { case "showEstimates": ((CheckBoxPreference) pref).setChecked(conf.getBoolean("estTimes")); break; case "showProgress": ((CheckBoxPreference) pref).setChecked(conf.getBoolean("dueCounts")); break; case "learnCutoff": ((NumberRangePreference) pref).setValue(conf.getInt("collapseTime") / 60); break; case "timeLimit": ((NumberRangePreference) pref).setValue(conf.getInt("timeLim") / 60); break; case "useCurrent": ((ListPreference) pref).setValueIndex(conf.optBoolean("addToCur", true) ? 0 : 1); break; case "newSpread": ((ListPreference) pref).setValueIndex(conf.getInt("newSpread")); break; case "dayOffset": Calendar calendar = new GregorianCalendar(); Timestamp timestamp = new Timestamp(col.getCrt() * 1000); calendar.setTimeInMillis(timestamp.getTime()); ((SeekBarPreference) pref).setValue(calendar.get(Calendar.HOUR_OF_DAY)); break; }//from w w w . j ava 2 s. c o m } catch (JSONException | NumberFormatException e) { throw new RuntimeException(); } } else { // Disable Col preferences if Collection closed pref.setEnabled(false); } } else if ("minimumCardsDueForNotification".equals(pref.getKey())) { updateNotificationPreference((ListPreference) pref); } // Set the value from the summary cache CharSequence s = pref.getSummary(); mOriginalSumarries.put(pref.getKey(), (s != null) ? s.toString() : ""); // Update summary updateSummary(pref); }
From source file:com.moto.miletus.application.DeviceListAdapter.java
@Override public Filter getFilter() { return new Filter() { @Override/*from w ww . j a v a 2 s . c o m*/ protected FilterResults performFiltering(final CharSequence constraint) { final FilterResults results = new FilterResults(); final List<DeviceWrapper> dataSetFilter = new ArrayList<>(); if (constraint.length() == 0) { dataSetFilter.addAll(getDataSetOriginal()); } else { for (final DeviceWrapper device : getDataSetOriginal()) { if (StringUtils.containsIgnoreCase(device.getDevice().getName(), constraint.toString())) { dataSetFilter.add(device); } } } results.values = dataSetFilter; results.count = dataSetFilter.size(); return results; } @Override protected void publishResults(final CharSequence constraint, final FilterResults results) { if (results.values instanceof List) { getDataSetFilter().clear(); setDataSetFilter((List<DeviceWrapper>) results.values); sort(); } } }; }
From source file:org.anhonesteffort.flock.SubscriptionStripeFragment.java
private void initCardNumberHelper() { final EditText cardNumberView = (EditText) subscriptionActivity.findViewById(R.id.card_number); final EditText cardExpirationView = (EditText) subscriptionActivity.findViewById(R.id.card_expiration); cardNumberView.setOnTouchListener(new View.OnTouchListener() { @Override// ww w . j ava2 s . c om public boolean onTouch(View v, MotionEvent event) { if (cardNumberView.getText() != null && cardNumberView.getText().toString().contains("*")) { cardNumberView.setText(""); } return false; } }); if (cardNumberTextWatcher != null) cardNumberView.removeTextChangedListener(cardNumberTextWatcher); cardNumberTextWatcher = new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { String cardNumber = s.toString().replace(" ", ""); String formattedCardNumber = ""; for (int i = 0; i < cardNumber.length(); i++) { if (i > 0 && i % 4 == 0) formattedCardNumber += " "; formattedCardNumber += cardNumber.charAt(i); } cardNumberView.removeTextChangedListener(this); cardNumberView.setText(formattedCardNumber); cardNumberView.setSelection(formattedCardNumber.length()); cardNumberView.addTextChangedListener(this); if (!cardNumber.contains("*") && cardNumber.length() == 16) cardExpirationView.requestFocus(); } }; cardNumberView.addTextChangedListener(cardNumberTextWatcher); }
From source file:org.anhonesteffort.flock.SubscriptionStripeFragment.java
private void initCardExpirationHelper() { final EditText cardExpirationView = (EditText) subscriptionActivity.findViewById(R.id.card_expiration); final EditText cardCvcView = (EditText) subscriptionActivity.findViewById(R.id.card_cvc); if (cardExpirationTextWatcher != null) cardExpirationView.removeTextChangedListener(cardExpirationTextWatcher); cardExpirationTextWatcher = new TextWatcher() { @Override/*from w ww . ja v a 2 s . com*/ public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { String formattedCardExpiration = s.toString(); if (lastCardExpirationLength <= formattedCardExpiration.length() && formattedCardExpiration.length() == 2) { formattedCardExpiration = formattedCardExpiration + "/"; } lastCardExpirationLength = formattedCardExpiration.length(); cardExpirationView.removeTextChangedListener(this); cardExpirationView.setText(formattedCardExpiration); cardExpirationView.setSelection(formattedCardExpiration.length()); cardExpirationView.addTextChangedListener(this); if (formattedCardExpiration.length() == 5) cardCvcView.requestFocus(); } }; cardExpirationView.addTextChangedListener(cardExpirationTextWatcher); }
From source file:de.schildbach.pte.AbstractTsiProvider.java
private Location jsonStationRequestCoord(final String id) throws IOException { final HttpUrl.Builder url = stopFinderEndpoint.newBuilder().addPathSegments("GetTripPoint/json"); appendCommonRequestParams(url);//from w ww . j av a 2 s . c om url.addQueryParameter("TripPointId", id); url.addQueryParameter("PointType", "Stop_Place"); final CharSequence page = httpClient.get(url.build()); try { final JSONObject head = new JSONObject(page.toString()); int status = head.getInt("StatusCode"); if (status != 200) return null; JSONObject data = head.getJSONObject("Data"); return parseJsonTransportLocation(data); } catch (final JSONException x) { throw new ParserException(x); } }
From source file:com.cyberway.issue.crawler.extractor.ExtractorHTML.java
protected void processEmbed(CrawlURI curi, final CharSequence value, CharSequence context, char hopType) { if (logger.isLoggable(Level.FINEST)) { logger.finest("embed (" + hopType + "): " + value.toString() + " from " + curi); }/*ww w . ja va 2 s.c om*/ addLinkFromString(curi, (value instanceof String) ? (String) value : value.toString(), context, hopType); this.numberOfLinksExtracted++; }
From source file:com.github.jknack.amd4j.ClosureMinifier.java
@Override public CharSequence minify(final Config config, final CharSequence source) { final CompilerOptions options = new CompilerOptions(); options.setCodingConvention(new ClosureCodingConvention()); options.setOutputCharset("UTF-8"); options.setWarningLevel(DiagnosticGroups.CHECK_VARIABLES, CheckLevel.WARNING); compilationLevel.setOptionsForCompilationLevel(options); Compiler.setLoggingLevel(Level.SEVERE); Compiler compiler = new Compiler(); compiler.disableThreads();//from ww w . j av a 2s .c om compiler.initOptions(options); String fname = removeExtension(config.getName()) + ".js"; Result result = compiler.compile(defaultExterns, Arrays.asList(SourceFile.fromCode(fname, source.toString())), options); if (result.success) { return compiler.toSource(); } JSError[] errors = result.errors; throw new IllegalStateException(errors[0].toString()); }
From source file:com.manzdagratiano.gobbledygook.Gobbledygook.java
/** * @brief Called after onCreate() (and onStart(), * when the activity begins interacting with the user) * @return Does not return a value/* w w w.ja v a2 s .c o m*/ */ @Override public void onResume() { Log.i(Env.LOG_CATEGORY, "onResume(): Configuring..."); super.onResume(); // ---------------------------------------------------------------- // Retrieve saved preferences // The SharedPreferences handle Log.i(Env.LOG_CATEGORY, "Reading saved preferences..."); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); // The salt key String saltKey = ""; Integer defaultIterations = Attributes.DEFAULT_ITERATIONS; String encodedAttributesList = ""; // Catch all exceptions when reading from SharedPreferences try { saltKey = sharedPrefs.getString(getString(R.string.pref_saltKey_key), ""); // The default number of PBKDF2 iterations. // Since the preference is an EditTextPreference, // even though it has the numeric attribute, // and is entered as an integer, // it is saved as a string. // Therefore, it must be retrieved as a string and then cast. String defaultIterationsStr = sharedPrefs.getString(getString(R.string.pref_defaultIterations_key), ""); // If non-empty, parse as an Integer. // The empty case will leave defaultIterations at // Attributes.DEFAULT_ITERATIONS. if (!defaultIterationsStr.isEmpty()) { defaultIterations = Integer.parseInt(defaultIterationsStr); } // The encoded siteAttributesList encodedAttributesList = sharedPrefs.getString(getString(R.string.pref_siteAttributesList_key), ""); } catch (Exception e) { Log.e(Env.LOG_CATEGORY, "ERROR: Caught " + e); e.printStackTrace(); } Log.d(Env.LOG_CATEGORY, "savedPreferences=[ saltKey='" + saltKey + "', " + "defaultIterations=" + defaultIterations.toString() + ", " + "siteAttributesList='" + encodedAttributesList + "' ]"); // ---------------------------------------------------------------- // Create the "actors" AttributesCodec codec = new AttributesCodec(); Configurator config = new Configurator(); // ---------------------------------------------------------------- // Read the url from the clipboard Log.i(Env.LOG_CATEGORY, "Reading url from clipboard..."); String url = ""; ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); if (clipboard.hasPrimaryClip()) { ClipData.Item clipItem = clipboard.getPrimaryClip().getItemAt(0); CharSequence clipText = clipItem.getText(); if (null != clipText) { url = clipText.toString(); } } Log.i(Env.LOG_CATEGORY, "url='" + url + "'"); // ---------------------------------------------------------------- // Extract the domain from the url String domain = config.extractDomain(url); Log.i(Env.LOG_CATEGORY, "domain='" + domain + "'"); // ---------------------------------------------------------------- // Saved and Proposed Attributes // Obtain the saved attributes for this domain, if any Attributes savedAttributes = codec.getSavedAttributes(domain, encodedAttributesList); Log.i(Env.LOG_CATEGORY, "savedAttributes='" + codec.encode(savedAttributes) + "'"); // The "proposed" attributes, // which would be used to generate the proxy password, // unless overridden Attributes proposedAttributes = new Attributes(config.configureDomain(domain, savedAttributes.domain()), config.configureIterations(defaultIterations, savedAttributes.iterations()), config.configureTruncation(savedAttributes.truncation())); config.configureHash(); }
From source file:eu.edisonproject.training.wsd.DisambiguatorImpl.java
private Set<String> getDocument(Term term) throws IOException, MalformedURLException, ParseException { Set<String> doc = new HashSet<>(); List<CharSequence> g = term.getGlosses(); if (g != null) { for (CharSequence s : g) { if (s != null && s.length() > 0) { s = s.toString().replaceAll("_", " "); tokenizer.setDescription(s.toString()); String cleanText = tokenizer.execute(); lematizer.setDescription(cleanText); String lematizedText = lematizer.execute(); // cleaner.setDescription(s.toString()); // String stemed = cleaner.execute(); doc.addAll(Arrays.asList(lematizedText.split(" "))); }//from w w w .j a va2 s . com } } List<CharSequence> al = term.getAltLables(); if (al != null) { for (CharSequence s : al) { if (s != null && s.length() > 0) { // cleaner.setDescription(s.toString()); // String stemed = cleaner.execute(); s = s.toString().replaceAll("_", " "); tokenizer.setDescription(s.toString()); String cleanText = tokenizer.execute(); lematizer.setDescription(cleanText); String lematizedText = lematizer.execute(); doc.addAll(Arrays.asList(lematizedText.split(" "))); } } } List<CharSequence> cat = term.getCategories(); if (cat != null) { for (CharSequence s : cat) { if (s != null && s.length() > 0) { s = s.toString().replaceAll("_", " "); // cleaner.setDescription(s.toString()); // String stemed = cleaner.execute(); tokenizer.setDescription(s.toString()); String cleanText = tokenizer.execute(); lematizer.setDescription(cleanText); String lematizedText = lematizer.execute(); doc.addAll(Arrays.asList(lematizedText.split(" "))); } } } return doc; }
From source file:com.cyberway.issue.crawler.extractor.ExtractorHTML.java
/** * Process metadata tags./*from ww w . ja v a 2 s . c o m*/ * @param curi CrawlURI we're processing. * @param cs Sequence from underlying ReplayCharSequence. This * is TRANSIENT data. Make a copy if you want the data to live outside * of this extractors' lifetime. * @return True robots exclusion metatag. */ protected boolean processMeta(CrawlURI curi, CharSequence cs) { Matcher attr = TextUtils.getMatcher(EACH_ATTRIBUTE_EXTRACTOR, cs); String name = null; String httpEquiv = null; String content = null; while (attr.find()) { int valueGroup = (attr.start(14) > -1) ? 14 : (attr.start(15) > -1) ? 15 : 16; CharSequence value = cs.subSequence(attr.start(valueGroup), attr.end(valueGroup)); if (attr.group(1).equalsIgnoreCase("name")) { name = value.toString(); } else if (attr.group(1).equalsIgnoreCase("http-equiv")) { httpEquiv = value.toString(); } else if (attr.group(1).equalsIgnoreCase("content")) { content = value.toString(); } // TODO: handle other stuff } TextUtils.recycleMatcher(attr); // Look for the 'robots' meta-tag if ("robots".equalsIgnoreCase(name) && content != null) { curi.putString(A_META_ROBOTS, content); RobotsHonoringPolicy policy = getSettingsHandler().getOrder().getRobotsHonoringPolicy(); String contentLower = content.toLowerCase(); if ((policy == null || (!policy.isType(curi, RobotsHonoringPolicy.IGNORE) && !policy.isType(curi, RobotsHonoringPolicy.CUSTOM))) && (contentLower.indexOf("nofollow") >= 0 || contentLower.indexOf("none") >= 0)) { // if 'nofollow' or 'none' is specified and the // honoring policy is not IGNORE or CUSTOM, end html extraction logger.fine("HTML extraction skipped due to robots meta-tag for: " + curi.toString()); return true; } } else if ("refresh".equalsIgnoreCase(httpEquiv) && content != null) { int urlIndex = content.indexOf("=") + 1; if (urlIndex > 0) { String refreshUri = content.substring(urlIndex); try { curi.createAndAddLinkRelativeToBase(refreshUri, "meta", Link.REFER_HOP); } catch (URIException e) { if (getController() != null) { getController().logUriError(e, curi.getUURI(), refreshUri); } else { logger.info("Failed createAndAddLinkRelativeToBase " + curi + ", " + cs + ", " + refreshUri + ": " + e); } } } } return false; }