List of usage examples for java.lang CharSequence toString
public String toString();
From source file:com.sam_chordas.android.stockhawk.ui.MyStocksActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = this; ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE); setContentView(R.layout.activity_my_stocks); // The intent service is for executing immediate pulls from the Yahoo API // GCMTaskService can only schedule tasks, they cannot execute immediately mServiceIntent = new Intent(this, StockIntentService.class); if (savedInstanceState == null) { // Run the initialize task service so that some stocks appear upon an empty database mServiceIntent.putExtra("tag", "init"); if (Utils.isNetworkAvailable(mContext)) { startService(mServiceIntent); } else {// w ww. j a v a 2 s . c o m networkToast(); } } RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(this)); getLoaderManager().initLoader(CURSOR_LOADER_ID, null, this); mCursorAdapter = new QuoteCursorAdapter(this, null); recyclerView.addOnItemTouchListener( new RecyclerViewItemClickListener(this, new RecyclerViewItemClickListener.OnItemClickListener() { @Override public void onItemClick(View v, int position) { // CursorAdapter returns a cursor at the correct position for getItem(), or null // if it cannot seek to that position. Intent intent = new Intent(getApplicationContext(), LineGraphActivity.class); intent.putExtra(STOCK_ITEM, mCursorAdapter.getItemSymbol(position)); startActivity(intent); } })); recyclerView.setAdapter(mCursorAdapter); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.attachToRecyclerView(recyclerView); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (Utils.isNetworkAvailable(mContext)) { new MaterialDialog.Builder(mContext).title(R.string.symbol_search) .content(R.string.content_test).inputType(InputType.TYPE_CLASS_TEXT) .input(R.string.input_hint, R.string.input_prefill, new MaterialDialog.InputCallback() { @Override public void onInput(MaterialDialog dialog, CharSequence input) { // On FAB click, receive user input. Make sure the stock doesn't already exist // in the DB and proceed accordingly Cursor c = getContentResolver().query(QuoteProvider.Quotes.CONTENT_URI, new String[] { QuoteColumns.SYMBOL }, QuoteColumns.SYMBOL + "= ?", new String[] { input.toString() }, null); if (c.getCount() != 0) { Toast toast = Toast.makeText(MyStocksActivity.this, "This stock is already saved!", Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, Gravity.CENTER, 0); toast.show(); return; } else { // Add the stock to DB mServiceIntent.putExtra("tag", "add"); mServiceIntent.putExtra("symbol", input.toString()); startService(mServiceIntent); } } }).show(); } else { networkToast(); } } }); ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(mCursorAdapter); mItemTouchHelper = new ItemTouchHelper(callback); mItemTouchHelper.attachToRecyclerView(recyclerView); mTitle = getTitle(); if (Utils.isNetworkAvailable(mContext)) { long period = 30L; long flex = 10L; String periodicTag = "periodic"; // create a periodic task to pull stocks once every hour after the app has been opened. This // is so Widget data stays up to date. PeriodicTask periodicTask = new PeriodicTask.Builder().setService(StockTaskService.class) .setPeriod(period).setFlex(flex).setTag(periodicTag) .setRequiredNetwork(Task.NETWORK_STATE_CONNECTED).setRequiresCharging(false).build(); // Schedule task with tag "periodic." This ensure that only the stocks present in the DB // are updated. GcmNetworkManager.getInstance(this).schedule(periodicTask); } if (!Utils.isNetworkAvailable(getApplicationContext())) { networkToast(); } }
From source file:net.agkn.field_stripe.record.reader.PGTextRecordReader.java
private final String readStringField() throws IllegalStateException, InvalidDataException { if (isClosed) throw new IllegalStateException("The record reader has already been closed.")/*by contract*/; if (nestingStack.isEmpty()) throw new IllegalStateException("A record has not been started in the record reader.")/*by contract*/; final IState state = nestingStack.peek(); final CharSequence field = state.readField(); if (field == null) return null/*by definition*/; return field.toString(); }
From source file:com.sawyer.advadapters.widget.JSONAdapter.java
/** * Determines whether the provided constraint filters out the given item. Subclass to provide * you're own logic. It's incorrect to modify the adapter or the contents of the item itself. * Any alterations will lead to undefined behavior or crashes. Internally, this method is only * ever invoked from a background thread. * * @param item The String item to compare against the constraint * @param constraint The constraint used to filter the item * * @return True if the item is filtered out by the given constraint. False if the item will * continue to display in the adapter./* w w w . ja v a2 s . c o m*/ */ protected boolean isFilteredOut(String item, CharSequence constraint) { return !item.toLowerCase().contains(constraint.toString().toLowerCase()); }
From source file:com.taobao.android.repatch.ClassReIClassDef.java
@Override protected Annotation reAnnotation(Annotation annotation) { String type = annotation.getType(); boolean isArray = false; if (type.startsWith("[")) { isArray = true;/*from w ww. j a v a 2 s. co m*/ } String newType = DefineUtils.getDefineClassName( classProcessor.classProcess(DefineUtils.getDalvikClassName(type)).className, isArray); Set<? extends AnnotationElement> sets = annotation.getElements(); Set<ImmutableAnnotationElement> newAnnotationElement = new HashSet<ImmutableAnnotationElement>(); for (AnnotationElement annotationElement : sets) { String name = annotationElement.getName(); EncodedValue encodedValue = annotationElement.getValue(); if (encodedValue instanceof ArrayEncodedValue) { List<EncodedValue> lists = new ArrayList<EncodedValue>(); for (EncodedValue encodedValueSub : ((ArrayEncodedValue) encodedValue).getValue()) { if (encodedValueSub instanceof StringEncodedValue) { String newValue = null; boolean isArray1 = false; String value = ((StringEncodedValue) encodedValueSub).getValue(); if (value.startsWith("[")) { isArray1 = true; } if (basicValue.contains(value)) { newValue = value; } else if (value.startsWith("Ljava/util/") || value.startsWith("Ljava/lang/") || !value.endsWith(";")) { newValue = value; } else { newValue = DefineUtils.getDefineClassName( classProcessor.classProcess(DefineUtils.getDalvikClassName(value)).className, isArray1); } ImmutableStringEncodedValue immutableStringEncodedValue = new ImmutableStringEncodedValue( newValue); lists.add(immutableStringEncodedValue); } else if (encodedValueSub instanceof TypeEncodedValue) { String newValueSub = null; String value = ((TypeEncodedValue) encodedValueSub).getValue(); boolean isArray2 = false; if (value.startsWith("[")) { isArray2 = true; } if (basicValue.contains(value)) { newValueSub = value; } else if (value.startsWith("Ljava/util/") || !value.endsWith(";")) { newValueSub = value; } else { newValueSub = DefineUtils.getDefineClassName( classProcessor.classProcess(DefineUtils.getDalvikClassName(value)).className, isArray2); } ImmutableTypeEncodedValue immutableTypeEncodedValue = new ImmutableTypeEncodedValue( newValueSub); lists.add(immutableTypeEncodedValue); } else { lists.add(encodedValue); } } ImmutableArrayEncodedValue immutableArrayEncodedValue = new ImmutableArrayEncodedValue(lists); ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableArrayEncodedValue); newAnnotationElement.add(immutableAnnotationElement); } else if (encodedValue instanceof StringEncodedValue) { String value = ((StringEncodedValue) encodedValue).getValue(); String newValue = null; isArray = false; if (value.startsWith("[")) { isArray = true; } if (basicValue.contains(value)) { newValue = value; } else if (value.startsWith("Ljava/util/") || !value.endsWith(";")) { newValue = value; } else { newValue = DefineUtils.getDefineClassName( classProcessor.classProcess(DefineUtils.getDalvikClassName(value)).className, isArray); } ImmutableStringEncodedValue immutableStringEncodedValue = new ImmutableStringEncodedValue(newValue); ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableStringEncodedValue); newAnnotationElement.add(immutableAnnotationElement); } else if (encodedValue instanceof TypeEncodedValue) { String newValue = null; String value = ((TypeEncodedValue) encodedValue).getValue(); boolean isArray2 = false; if (value.startsWith("[")) { isArray2 = true; } if (basicValue.contains(value)) { newValue = value; } else if (value.startsWith("Ljava/util/") || !value.endsWith(";")) { newValue = value; } else { newValue = DefineUtils.getDefineClassName( classProcessor.classProcess(DefineUtils.getDalvikClassName(value)).className, isArray2); } ImmutableTypeEncodedValue immutableTypeEncodedValue = new ImmutableTypeEncodedValue(newValue); ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableTypeEncodedValue); newAnnotationElement.add(immutableAnnotationElement); } else if (encodedValue instanceof MethodEncodedValue) { MethodReference methodReference = ((MethodEncodedValue) encodedValue).getValue(); String returnType = methodReference.getReturnType(); boolean isBasic = false; List<? extends CharSequence> paramTypes = methodReference.getParameterTypes(); List<CharSequence> dalvikParamTypes = new ArrayList<CharSequence>(); List<CharSequence> newParamTypes = new ArrayList<CharSequence>(); for (CharSequence charSequence : paramTypes) { if (basicType.containsKey(charSequence.toString())) { newParamTypes.add(charSequence); dalvikParamTypes.add(basicType.get(charSequence.toString())); continue; } dalvikParamTypes .add(DefineUtils.getDalvikClassName(charSequence.toString()) + (isArray ? "[]" : "")); newParamTypes .add(DefineUtils.getDefineClassName( classProcessor.classProcess( DefineUtils.getDalvikClassName(charSequence.toString())).className, isArray)); } final ImmutableMethodReference immutableReference = new ImmutableMethodReference( DefineUtils .getDefineClassName( classProcessor.classProcess(DefineUtils .getDalvikClassName(methodReference.getDefiningClass())).className, false), classProcessor .methodProcess(DefineUtils.getDalvikClassName(methodReference.getDefiningClass()), methodReference.getName(), isBasic ? basicType.get(methodReference.getReturnType()) : DefineUtils.getDalvikClassName(methodReference.getReturnType()) + (isArray ? "[]" : ""), StringUtils.join(dalvikParamTypes.toArray(), ",")).methodName, newParamTypes, isBasic ? returnType : DefineUtils.getDefineClassName( classProcessor.classProcess(DefineUtils .getDalvikClassName(methodReference.getReturnType())).className, methodReference.getReturnType().startsWith("["))); ImmutableMethodEncodedValue immutableMethodEncodedValue = new ImmutableMethodEncodedValue( immutableReference); ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableMethodEncodedValue); newAnnotationElement.add(immutableAnnotationElement); } else { newAnnotationElement.add(ImmutableAnnotationElement.of(annotationElement)); } } return new ImmutableAnnotation(annotation.getVisibility(), newType, newAnnotationElement); }
From source file:com.sawyer.advadapters.widget.JSONAdapter.java
/** * Determines whether the provided constraint filters out the given item. Subclass to provide * you're own logic. It's incorrect to modify the adapter or the contents of the item itself. * Any alterations will lead to undefined behavior or crashes. Internally, this method is only * ever invoked from a background thread. * * @param item The Boolean item to compare against the constraint * @param constraint The constraint used to filter the item * * @return True if the item is filtered out by the given constraint. False if the item will * continue to display in the adapter.//from www . j a v a2 s . co m */ protected boolean isFilteredOut(Boolean item, CharSequence constraint) { return !item.toString().equalsIgnoreCase(constraint.toString()); }
From source file:org.archive.modules.extractor.ExtractorHTML.java
/** * Consider a query-string-like collections of key=value[&key=value] * pairs for URI-like strings in the values. Where URI-like strings are * found, add as discovered outlink. //from w w w . j av a 2s.c o m * * @param curi origin CrawlURI * @param queryString query-string-like string * @param valueContext page context where found */ protected void considerQueryStringValues(CrawlURI curi, CharSequence queryString, CharSequence valueContext, Hop hop) { for (String pairString : queryString.toString().split("&")) { String[] encodedKeyVal = pairString.split("="); if (encodedKeyVal.length == 2) try { String value = URLDecoder.decode(encodedKeyVal[1], "UTF-8"); considerIfLikelyUri(curi, value, valueContext, hop); } catch (IllegalArgumentException e) { // still consider values rejected by URLDecoder considerIfLikelyUri(curi, encodedKeyVal[1], valueContext, hop); } catch (UnsupportedEncodingException e) { throw new AssertionError("all jvms must support UTF-8, and yet somehow this happened: " + e); } } }
From source file:com.taobao.android.repatch.ClassReIClassDef.java
public Set<? extends Annotation> getAnnotation(Set<? extends Annotation> annotations) { Set<ImmutableAnnotation> newAnnotations = new HashSet<ImmutableAnnotation>(); for (Annotation annotation : annotations) { String type = annotation.getType(); boolean isArray = false; if (type.startsWith("[")) { isArray = true;// w w w . j ava 2s . c o m } String newType = DefineUtils.getDefineClassName( classProcessor.classProcess(DefineUtils.getDalvikClassName(type)).className, isArray); Set<? extends AnnotationElement> sets = annotation.getElements(); Set<ImmutableAnnotationElement> newAnnotationElement = new HashSet<ImmutableAnnotationElement>(); for (AnnotationElement annotationElement : sets) { String name = annotationElement.getName(); EncodedValue encodedValue = annotationElement.getValue(); if (encodedValue instanceof ArrayEncodedValue) { List<EncodedValue> lists = new ArrayList<EncodedValue>(); for (EncodedValue encodedValueSub : ((ArrayEncodedValue) encodedValue).getValue()) { if (encodedValueSub instanceof StringEncodedValue) { String newValue = null; boolean isArray1 = false; String value = ((StringEncodedValue) encodedValueSub).getValue(); if (value.startsWith("[")) { isArray1 = true; } if (basicValue.contains(value)) { newValue = value; } else if (value.startsWith("Ljava/util/") || !value.endsWith(";") || value.startsWith("Ljava/lang/")) { newValue = value; } else { newValue = DefineUtils.getDefineClassName( classProcessor .classProcess(DefineUtils.getDalvikClassName(value)).className, isArray1); } ImmutableStringEncodedValue immutableStringEncodedValue = new ImmutableStringEncodedValue( newValue); lists.add(immutableStringEncodedValue); } else if (encodedValueSub instanceof TypeEncodedValue) { String newValueSub = null; String value = ((TypeEncodedValue) encodedValueSub).getValue(); boolean isArray2 = false; if (value.startsWith("[")) { isArray2 = true; } if (basicValue.contains(value)) { newValueSub = value; } else if (value.startsWith("Ljava/util/") || value.startsWith("Ljava/lang/") || !value.endsWith(";")) { newValueSub = value; } else { newValueSub = DefineUtils.getDefineClassName( classProcessor .classProcess(DefineUtils.getDalvikClassName(value)).className, isArray2); } ImmutableTypeEncodedValue immutableTypeEncodedValue = new ImmutableTypeEncodedValue( newValueSub); lists.add(immutableTypeEncodedValue); } else { lists.add(encodedValue); } } ImmutableArrayEncodedValue immutableArrayEncodedValue = new ImmutableArrayEncodedValue(lists); ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableArrayEncodedValue); newAnnotationElement.add(immutableAnnotationElement); } else if (encodedValue instanceof StringEncodedValue) { String value = ((StringEncodedValue) encodedValue).getValue(); boolean isArray3 = false; if (value.startsWith("[")) { isArray3 = true; } String newValue = null; if (basicValue.contains(value)) { newValue = value; } else if (value.startsWith("Ljava/util/") || value.startsWith("Ljava/lang/") || !value.endsWith(";")) { newValue = value; } else { newValue = DefineUtils.getDefineClassName( classProcessor.classProcess(DefineUtils.getDalvikClassName(value)).className, isArray3); } ImmutableStringEncodedValue immutableStringEncodedValue = new ImmutableStringEncodedValue( newValue); ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableStringEncodedValue); newAnnotationElement.add(immutableAnnotationElement); } else if (encodedValue instanceof MethodEncodedValue) { MethodReference methodReference = ((MethodEncodedValue) encodedValue).getValue(); String returnType = methodReference.getReturnType(); boolean isBasic = false; List<? extends CharSequence> paramTypes = methodReference.getParameterTypes(); List<CharSequence> dalvikParamTypes = new ArrayList<CharSequence>(); List<CharSequence> newParamTypes = new ArrayList<CharSequence>(); for (CharSequence charSequence : paramTypes) { if (basicType.containsKey(charSequence.toString())) { newParamTypes.add(charSequence); dalvikParamTypes.add(basicType.get(charSequence.toString())); continue; } dalvikParamTypes.add( DefineUtils.getDalvikClassName(charSequence.toString()) + (isArray ? "[]" : "")); newParamTypes.add(DefineUtils.getDefineClassName( classProcessor.classProcess( DefineUtils.getDalvikClassName(charSequence.toString())).className, isArray)); } final ImmutableMethodReference immutableReference = new ImmutableMethodReference( DefineUtils.getDefineClassName( classProcessor.classProcess(DefineUtils .getDalvikClassName(methodReference.getDefiningClass())).className, false), classProcessor.methodProcess( DefineUtils.getDalvikClassName(methodReference.getDefiningClass()), methodReference.getName(), isBasic ? basicType.get(methodReference.getReturnType()) : DefineUtils.getDalvikClassName(methodReference.getReturnType()) + (isArray ? "[]" : ""), StringUtils.join(dalvikParamTypes.toArray(), ",")).methodName, newParamTypes, isBasic ? returnType : DefineUtils.getDefineClassName( classProcessor.classProcess(DefineUtils .getDalvikClassName(methodReference.getReturnType())).className, methodReference.getReturnType().startsWith("["))); ImmutableMethodEncodedValue immutableMethodEncodedValue = new ImmutableMethodEncodedValue( immutableReference); ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableMethodEncodedValue); newAnnotationElement.add(immutableAnnotationElement); } else if (encodedValue instanceof TypeEncodedValue) { String newValueSub = null; String value = ((TypeEncodedValue) encodedValue).getValue(); boolean isArray2 = false; if (value.startsWith("[")) { isArray2 = true; } if (basicValue.contains(value)) { newValueSub = value; } else if (value.startsWith("Ljava/util/") || value.startsWith("Ljava/lang/") || !value.endsWith(";")) { newValueSub = value; } else { newValueSub = DefineUtils.getDefineClassName( classProcessor.classProcess(DefineUtils.getDalvikClassName(value)).className, isArray2); } ImmutableTypeEncodedValue immutableTypeEncodedValue = new ImmutableTypeEncodedValue( newValueSub); ImmutableAnnotationElement immutableAnnotationElement = new ImmutableAnnotationElement(name, immutableTypeEncodedValue); newAnnotationElement.add(immutableAnnotationElement); } else { newAnnotationElement.add(ImmutableAnnotationElement.of(annotationElement)); } } ImmutableAnnotation immutableAnnotation = new ImmutableAnnotation(annotation.getVisibility(), newType, newAnnotationElement); newAnnotations.add(immutableAnnotation); } return newAnnotations; }
From source file:com.sawyer.advadapters.widget.JSONAdapter.java
/** * Determines whether the provided constraint filters out the given item. Subclass to provide * you're own logic. It's incorrect to modify the adapter or the contents of the item itself. * Any alterations will lead to undefined behavior or crashes. Internally, this method is only * ever invoked from a background thread. * * @param item The Long item to compare against the constraint * @param constraint The constraint used to filter the item * * @return True if the item is filtered out by the given constraint. False if the item will * continue to display in the adapter.//from ww w .j ava 2 s . co m */ protected boolean isFilteredOut(Long item, CharSequence constraint) { try { return !item.equals(Long.valueOf(constraint.toString())); } catch (NumberFormatException e) { return true; } }
From source file:com.sawyer.advadapters.widget.JSONAdapter.java
/** * Determines whether the provided constraint filters out the given item. Subclass to provide * you're own logic. It's incorrect to modify the adapter or the contents of the item itself. * Any alterations will lead to undefined behavior or crashes. Internally, this method is only * ever invoked from a background thread. * * @param item The Double item to compare against the constraint * @param constraint The constraint used to filter the item * * @return True if the item is filtered out by the given constraint. False if the item will * continue to display in the adapter.//from w ww . j a v a2s. c om */ protected boolean isFilteredOut(Double item, CharSequence constraint) { try { return !item.equals(Double.valueOf(constraint.toString())); } catch (NumberFormatException e) { return true; } }
From source file:com.sawyer.advadapters.widget.JSONAdapter.java
/** * Determines whether the provided constraint filters out the given item. Subclass to provide * you're own logic. It's incorrect to modify the adapter or the contents of the item itself. * Any alterations will lead to undefined behavior or crashes. Internally, this method is only * ever invoked from a background thread. * * @param item The Integer item to compare against the constraint * @param constraint The constraint used to filter the item * * @return True if the item is filtered out by the given constraint. False if the item will * continue to display in the adapter.//from w w w . j ava 2 s . co m */ protected boolean isFilteredOut(Integer item, CharSequence constraint) { try { return !item.equals(Integer.valueOf(constraint.toString())); } catch (NumberFormatException e) { return true; } }