List of usage examples for java.lang CharSequence length
int length();
From source file:StringUtil.java
/** * Converts char sequence into ASCII array. *//*from w ww. ja va 2 s .c o m*/ public static byte[] toAsciiArray(CharSequence charSequence) { if (charSequence == null) { return null; } byte[] barr = new byte[charSequence.length()]; for (int i = 0; i < barr.length; i++) { barr[i] = (byte) toAscii(charSequence.charAt(i)); } return barr; }
From source file:zxing.util.CaptureActivity.java
License:asdf
/** * A valid barcode has been found, so give an indication of success and show * the results./* w ww . j a v a 2s . c om*/ * * @param rawResult * The contents of the barcode. * @param scaleFactor * amount by which thumbnail was scaled * @param barcode * A greyscale bitmap of the camera data which was decoded. */ public void handleDecode(Result rawResult, Bitmap barcode, float scaleFactor) { inactivityTimer.onActivity(); //lastResult = rawResult; String url = "http://192.168.1.105:8080/ExTraceWebService_war/REST/Domain"; beepManager.playBeepSoundAndVibrate(); String resultString = rawResult.getText(); Intent mIntent = getIntent(); if (mIntent.getStringExtra("Action").equals("Pkg")) { switch (Integer.parseInt(mIntent.getStringExtra("role").toString().substring(0, 1))) { //( // case 1: Log.i("teasdfjsadf", mIntent.getStringExtra("role").toString()); if (resultString.startsWith("1")) { url = url + "/receiveExpressSheetId/id/" + resultString + "/uid/" + mIntent.getStringExtra("role").toString(); startOnePkgExp(url);// // Intent intentTest=new Intent(this,BaiduActivity.class); // startActivity(intentTest); break; } else if (resultString.startsWith("8")) { url = url + "/dispatchExpressSheetId/id/" + resultString + "/uid/" + mIntent.getStringExtra("role").toString(); changePkgToStatus4(url);// break; } else { break; } // case 2: if (resultString.startsWith("8")) { url = url + "/receiveExpressSheetId/id/" + resultString + "/uid/" + mIntent.getStringExtra("role").toString(); startOnePkgExp(url);// // Intent intentTest=new Intent(this,BaiduActivity.class); // startActivity(intentTest); break; } break; // case 3: if (resultString.startsWith("1")) { url = url + "/packTransPackage/PackageID/" + "8001" + "/ExpressID/" + resultString; // Intent intentTest=new Intent(this,BaiduActivity.class); // startActivity(intentTest); break; } else if (resultString.startsWith("8")) { url = url + "/unpackTransPackage/" + resultString + "/uid/" + mIntent.getStringExtra("role").toString(); break; } else { break; } } } else if (mIntent.getStringExtra("Action").equals("exp")) { // switch (Integer.parseInt(mIntent.getStringExtra("role"))) { case 1: //finsh(); break; case 2: if (resultString.startsWith("8")) { url = url + "/unpackTransPackage/" + "8001"; // Intent intentTest=new Intent(this,BaiduActivity.class); // startActivity(intentTest); break; } else { } //finsh(); break; // case 3: } } drawResultPoints(barcode, scaleFactor, rawResult); statusView.setVisibility(View.GONE); viewfinderView.setVisibility(View.GONE); resultView.setVisibility(View.VISIBLE); ImageView barcodeImageView = (ImageView) findViewById(R.id.barcode_image_view); if (barcode == null) { barcodeImageView.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.launcher_icon)); } else { barcodeImageView.setImageBitmap(barcode); } ParsedResult result = ResultParser.parseResult(rawResult); String contents = result.getDisplayResult().replace("\r", ""); CharSequence displayContents = contents; lastResult = contents; TextView contentsTextView = (TextView) findViewById(R.id.contents_text_view); contentsTextView.setText(displayContents); int scaledSize = Math.max(22, 32 - displayContents.length() / 4); contentsTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, scaledSize); }
From source file:edu.cornell.med.icb.goby.util.SimulateBisulfiteReads.java
protected void writeTrueRatesMutations(DoubleList methylationRates, CharSequence segmentBases, int from, Writer writer) throws IOException { PrintWriter trueRateWriter = new PrintWriter(writer); writeTrueRatesBisulfite(methylationRates, segmentBases, from, new StringWriter()); trueRateWriter.printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s%n", "index", "methylationRate", "strand", "chromosome", "position", "fromBase", "toBase", "context"); DoubleIterator it = methylationRates.iterator(); for (int i = 0; i < segmentBases.length(); i++) { char fromBaseForward = segmentBases.charAt(i); if (fromBaseForward == 'C') { final int genomicPosition = i + from; if (!it.hasNext()) { it = methylationRates.iterator(); }//from w w w . ja v a 2s . co m char toBase = '.'; final double value = it.nextDouble(); if (value == 1) { toBase = 'C'; } else if (value == 0) { toBase = 'G'; } methylationForward.put(genomicPosition, value); final double getterValue = getMethylationRateAtPosition(false, genomicPosition); assert getterValue == value; trueRateWriter.printf("%d\t%g\t+1\t%s\t%d\t%c\t%c\t%s%n", i, value, refChoice, genomicPosition + 1, fromBaseForward, toBase, context(i, segmentBases)); } } trueRateWriter.close(); }
From source file:com.simiacryptus.mindseye.models.Hdf5Archive.java
private static void printTree(@Nonnull Hdf5Archive hdf5, CharSequence prefix, boolean printData, @Nonnull Logger log, @Nonnull String... path) { for (CharSequence datasetName : hdf5.getDataSets(path)) { @Nullable//from w w w . jav a 2 s. c o m Tensor tensor = hdf5.readDataSet(datasetName.toString(), path); log.info(String.format("%sDataset %s: %s", prefix, datasetName, Arrays.toString(tensor.getDimensions()))); if (printData) log.info(String.format("%s%s", prefix, tensor.prettyPrint().replaceAll("\n", "\n" + prefix))); tensor.freeRef(); } hdf5.getAttributes(path).forEach((k, v) -> { log.info((String.format("%sAttribute: %s => %s", prefix, k, v))); }); for (String t : hdf5.getGroups(path).stream().map(CharSequence::toString).sorted(new Comparator<String>() { @Override public int compare(@Nonnull String o1, @Nonnull String o2) { @Nonnull String prefix = "layer_"; @Nonnull Pattern digit = Pattern.compile("^\\d+$"); if (digit.matcher(o1).matches() && digit.matcher(o2).matches()) return Integer.compare(Integer.parseInt(o1), Integer.parseInt(o2)); if (o1.startsWith(prefix) && o2.startsWith(prefix)) return compare(o1.substring(prefix.length()), o2.substring(prefix.length())); else return o1.compareTo(o2); } }).collect(Collectors.toList())) { log.info(prefix + t); printTree(hdf5, prefix + "\t", printData, log, concat(path, t)); } }
From source file:com.ibuildapp.romanblack.MultiContactsPlugin.MultiContactsPlugin.java
/** * Prepares page UI or starts ContactDetailsActivity if there is only one * person.// ww w .j a v a 2 s. co m * * @return true if there is only one person, false othrwise */ private boolean prepareUI() { if (persons.size() == 1) { try { Intent details = new Intent(this, ContactDetailsActivity.class); details.putExtra("Widget", widget); details.putExtra("person", persons.get(0)); details.putExtra("single", true); details.putExtra("isdark", Statics.isLight); details.putExtra("hasschema", PluginData.getInstance().isHasColorSchema()); details.putExtra("homebtn", true); finish(); startActivity(details); overridePendingTransition(R.anim.activity_open_translate, R.anim.activity_close_scale); return true; } catch (Exception e) { Log.e(TAG, e.getMessage()); e.printStackTrace(); } } setContentView(R.layout.grouped_contacts_main); setTopBarTitle(TextUtils.isEmpty(widget.getTitle()) ? "" : widget.getTitle()); setTopBarLeftButtonTextAndColor(getResources().getString(R.string.common_home_upper), getResources().getColor(android.R.color.black), true, new View.OnClickListener() { @Override public void onClick(View view) { finish(); overridePendingTransition(R.anim.activity_open_scale, R.anim.activity_close_translate); } }); setTopBarTitleColor(ContextCompat.getColor(this, android.R.color.black)); clearSearch = (ImageView) findViewById(R.id.grouped_contacts_delete_search); separator = findViewById(R.id.gc_head_separator); backSeparator = findViewById(R.id.gc_back_separator); clearSearch.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { searchContactsEditText.setText(""); noFoundText.setVisibility(View.GONE); } }); clearSearch.setVisibility(View.INVISIBLE); resources = getResources(); inputSearchLayout = (RelativeLayout) findViewById(R.id.grouped_contacts_input_search_layout); multicontactsSearchLayout = (LinearLayout) findViewById(R.id.grouped_contacts_search_layout); moveLayout = (LinearLayout) findViewById(R.id.grouped_contacts_move_layout); backSeparator.setBackgroundColor(Statics.color1); if (Statics.isLight) separator.setBackgroundColor(Color.parseColor("#4d000000")); else separator.setBackgroundColor(Color.parseColor("#4dFFFFFF")); ViewUtils.setBackgroundLikeHeader(multicontactsSearchLayout, Statics.color1); multicontactsSearchLayout.setVisibility(View.GONE); searchContactsEditText = (EditText) findViewById(R.id.grouped_contacts_input_search); if (getPackageName().endsWith("p638839")) { searchContactsEditText.setHint("Search by Location"); } searchContactsEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { } }); searchContactsEditText.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) { if (charSequence.length() == 0) { List<String> cats = PluginData.getInstance().getCategories(); clearSearch.setVisibility(View.INVISIBLE); noFoundText.setVisibility(View.GONE); if (cats.size() > 1) { GroupContactsAdapter adapter = new GroupContactsAdapter(MultiContactsPlugin.this, cats, Statics.isLight); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { showCategoryPersons(arg2); } }); } else { multicontactsSearchLayout.setVisibility(View.GONE); neededPersons = new ArrayList<>(); neededPersons.addAll(persons); MultiContactsAdapter adapter = new MultiContactsAdapter(MultiContactsPlugin.this, neededPersons, Statics.isLight); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { showPersonDetails(arg2); } }); listView.setVisibility(View.VISIBLE); } listView.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.VISIBLE); if (!isLeftPostition) { moveToLeft(); isLeftPostition = true; } List<Person> persons = PluginData.getInstance().searchByString(charSequence.toString()); neededPersons = new ArrayList<>(); neededPersons.addAll(persons); if (neededPersons.size() == 0) { noFoundText.setVisibility(View.VISIBLE); listView.setVisibility(View.GONE); } else { MultiContactsAdapter adapter = new MultiContactsAdapter(MultiContactsPlugin.this, neededPersons, Statics.isLight); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { showPersonDetails(arg2); } }); listView.setDivider(null); listView.setVisibility(View.VISIBLE); noFoundText.setVisibility(View.GONE); } } } @Override public void afterTextChanged(Editable editable) { } }); searchContactsEditText.clearFocus(); cachePath = widget.getCachePath() + "/contacts-" + widget.getOrder(); root = (LinearLayout) findViewById(R.id.grouped_contacts_main_root); listView = (ListView) findViewById(R.id.grouped_contacts_list); listView.setCacheColorHint(Color.TRANSPARENT); listView.setDivider(null); noFoundText = (TextView) findViewById(R.id.no_found_text); noFoundText.setTextColor(Statics.color3); progressDialog = ProgressDialog.show(this, null, getString(R.string.common_loading_upper), true); progressDialog.setCancelable(true); progressDialog.setOnCancelListener(new OnCancelListener() { public void onCancel(DialogInterface di) { handler.sendEmptyMessage(LOADING_ABORTED); } }); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); return false; }
From source file:com.cyberway.issue.crawler.extractor.ExtractorHTML.java
/** * Process style text./* ww w. j av a 2 s .c o m*/ * @param curi CrawlURI we're processing. * @param sequence Sequence from underlying ReplayCharSequence. This * is TRANSIENT data. Make a copy if you want the data to live outside * of this extractors' lifetime. * @param endOfOpenTag */ protected void processStyle(CrawlURI curi, CharSequence sequence, int endOfOpenTag) { // First, get attributes of script-open tag as per any other tag. processGeneralTag(curi, sequence.subSequence(0, 6), sequence.subSequence(0, endOfOpenTag)); // then, parse for URIs this.numberOfLinksExtracted += ExtractorCSS.processStyleCode(curi, sequence.subSequence(endOfOpenTag, sequence.length()), getController()); }
From source file:edu.cornell.med.icb.goby.util.SimulateBisulfiteReads.java
protected void writeTrueRatesBisulfite(DoubleList methylationRates, CharSequence segmentBases, int from, Writer writer) throws IOException { PrintWriter trueRateWriter = new PrintWriter(writer); // System.out.printf("segmentBases.length: %d %n", segmentBases.length()); methylationForward = new Int2DoubleOpenHashMap(); methylationReverse = new Int2DoubleOpenHashMap(); trueRateWriter.printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s%n", "index", "methylationRate", "strand", "chromosome", "position", "fromBase", "toBase", "context"); final int segmentLength = segmentBases.length(); DoubleIterator it = methylationRates.iterator(); if (doForwardStrand) { // prepare methylation rates for each C position of the segment, forward strand: for (int i = 0; i < segmentBases.length(); i++) { char fromBase = segmentBases.charAt(i); if (fromBase == 'C') { char toBase = '.'; if (!it.hasNext()) { it = methylationRates.iterator(); }/* w ww . j a v a 2 s. co m*/ final double value = it.nextDouble(); if (value == 1) { toBase = 'C'; } else if (value == 0) { toBase = 'T'; } // zero-based final int genomicPosition = i + from; methylationForward.put(genomicPosition, value); final double getterValue = getMethylationRateAtPosition(false, genomicPosition); assert getterValue == value; // write 1-based position trueRateWriter.printf("%d\t%g\t+1\t%s\t%d\t%c\t%c\t%s%n", i, getterValue, refChoice, genomicPosition + 1, fromBase, toBase, context(i, segmentBases)); } } } if (doReverseStrand) { it = methylationRates.iterator(); CharSequence reverseStrandSegment = reverseComplement(segmentBases); // same for reverse strand: for (int i = 0; i < segmentLength; i++) { char fromBase = reverseStrandSegment.charAt(i); if (fromBase == 'C') { char toBase = '.'; if (!it.hasNext()) { it = methylationRates.iterator(); } final double value = it.nextDouble(); if (value == 1) { toBase = 'C'; } else if (value == 0) { toBase = 'T'; } // zero-based final int genomicPosition = segmentLength - (i + 1) + from; methylationReverse.put(genomicPosition, value); final double getterValue = getMethylationRateAtPosition(true, genomicPosition); assert getterValue == value : "getter must work for reverse strand"; trueRateWriter.printf("%d\t%g\t-1\t%s\t%d\t%c\t%c\t%s%n", i, getterValue, refChoice, genomicPosition + 1, fromBase, toBase, reverseComplement(context(i, reverseStrandSegment))); // write 1-based position } } } trueRateWriter.close(); }
From source file:com.appolis.receiving.AcReceiveOptionMove.java
/** * function to initial layout// w w w . j a v a 2 s. c om */ private void initLayout() { linBack = (ImageView) findViewById(R.id.imgHome); linBack.setVisibility(View.GONE); linScan = (ImageView) findViewById(R.id.img_main_menu_scan_barcode); linScan.setOnClickListener(this); linScan.setVisibility(View.GONE); tvHeader = (TextView) findViewById(R.id.tvHeader); tvHeader.setText( languagePrefs.getPreferencesString(GlobalParams.RID_LBL_MOVE_KEY, GlobalParams.RID_LBL_MOVE_VALUE)); tvMoveFunctionTitle = (TextView) findViewById(R.id.textView_move); tvMoveFunctionTitle.setText(languagePrefs.getPreferencesString(GlobalParams.MV_MSG_SELECTORSCAN_KEY, GlobalParams.MV_MSG_SELECTORSCAN_VALUE)); tvTitleTransfer = (TextView) findViewById(R.id.tvTitleTransfer); tvTitleTransfer.setText(languagePrefs.getPreferencesString(GlobalParams.TRANSFER, GlobalParams.TRANSFER) + GlobalParams.VERTICAL_TWO_DOT); tvTitleMaxQty = (TextView) findViewById(R.id.tvTitleMaxQty); tvTitleMaxQty.setText( languagePrefs.getPreferencesString(GlobalParams.MV_LBL_MAXQTY, GlobalParams.DMG_LBL_MAXQTY_VALUE) + ": "); tvUOM = (TextView) findViewById(R.id.tvUOM); tvUOM.setText( languagePrefs.getPreferencesString(GlobalParams.MV_LBL_UOM, GlobalParams.UNIT_OF_MEASURE_VALUE) + GlobalParams.VERTICAL_TWO_DOT); tvLot = (TextView) findViewById(R.id.tvLot); tvLot.setText(languagePrefs.getPreferencesString(GlobalParams.REST_GRD_LOT_KEY, GlobalParams.LOT) + GlobalParams.VERTICAL_TWO_DOT); tvFrom = (TextView) findViewById(R.id.tvFrom); tvFrom.setText(languagePrefs.getPreferencesString(GlobalParams.MV_LBL_FROM, GlobalParams.FROM) + GlobalParams.VERTICAL_TWO_DOT); tvQtyView = (TextView) findViewById(R.id.tvQtyView); tvQtyView.setText(languagePrefs.getPreferencesString(GlobalParams.RID_GRD_QTY_KEY, GlobalParams.QTY)); tvTo = (TextView) findViewById(R.id.tvTo); tvTo.setText(languagePrefs.getPreferencesString(GlobalParams.MV_LBL_TO, GlobalParams.TO) + GlobalParams.VERTICAL_TWO_DOT); tvmaxQty = (TextView) findViewById(R.id.tvmaxQty); tvItemDescription = (TextView) findViewById(R.id.tvItemDescription); tvTransfer = (TextView) findViewById(R.id.tvTransfer); spnMoveUOM = (Spinner) findViewById(R.id.spn_Move_UOM); edtLotValue = (EditText) findViewById(R.id.edtLotValue); edtMoveFrom = (EditText) findViewById(R.id.edt_move_from); edtMoveQty = (EditText) findViewById(R.id.et_move_qty); edtMoveQty.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (null != s && s.length() == 1 && s.toString().equalsIgnoreCase(".")) { edtMoveQty.setText(""); s = ""; } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); edtMoveQty.setFilters( new InputFilter[] { new DecimalDigitsInputFilter(enPurchaseOrderItemInfo.get_significantDigits()), new InputFilter.LengthFilter(14) }); edtMoveTo = (EditText) findViewById(R.id.et_move_to); btMoveOk = (Button) findViewById(R.id.btnOK); btMoveOk.setText(languagePrefs.getPreferencesString(GlobalParams.OK, GlobalParams.OK)); btMoveOk.setOnClickListener(this); btMoveOk.setEnabled(true); btMoveCancel = (Button) findViewById(R.id.btnCancel); btMoveCancel.setText(languagePrefs.getPreferencesString(GlobalParams.CANCEL, GlobalParams.CANCEL)); btMoveCancel.setOnClickListener(this); edtMoveTo.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { linScan.setVisibility(View.VISIBLE); scanFlag = GlobalParams.FLAG_ACTIVE; } else { linScan.setVisibility(View.GONE); scanFlag = GlobalParams.FLAG_INACTIVE; } } }); if (null != enPurchaseOrderItemInfo) { tvTransfer.setText(enPurchaseOrderItemInfo.get_itemNumber()); tvItemDescription.setText(enPurchaseOrderItemInfo.get_itemDesc()); } if (null != enPurchaseOrderInfo) { if (StringUtils.isNotBlank(enPurchaseOrderInfo.get_receivingBinNumber())) { edtMoveFrom.setText(enPurchaseOrderInfo.get_receivingBinNumber()); } else { edtMoveFrom.setText(""); } edtMoveFrom.setEnabled(false); } if (null != listReceiptInfos) { if (listReceiptInfos.size() == 1) { Log.e("Appolis", "single record was selected from the previous screen"); EnPurchaseOrderReceiptInfo recipt = listReceiptInfos.get(0); maxQty = recipt.get_quantityReceived(); tvmaxQty.setText(BuManagement.formatDecimal(recipt.get_quantityReceived()).trim()); edtLotValue.setText(recipt.get_lotNumber()); edtLotValue.setEnabled(false); edtMoveQty.setText(BuManagement.formatDecimal(recipt.get_quantityReceived()).trim()); edtMoveQty.setEnabled(true); spnMoveUOM.setEnabled(true); edtMoveTo.requestFocus(); GetDataAsyncTask getDataAsyncTask = new GetDataAsyncTask(this, enPurchaseOrderItemInfo.get_itemNumber()); getDataAsyncTask.execute(); } else { Logger.error("Appolis: multiple records have been selected on the previous screen"); String strlot = ""; int index = 0; for (EnPurchaseOrderReceiptInfo item : listReceiptInfos) { maxQty += item.get_quantityReceived(); if (StringUtils.isNotBlank(item.get_lotNumber())) { if (index == 0) { strlot = strlot + item.get_lotNumber(); } else { strlot = strlot + ", " + item.get_lotNumber(); } index++; } } tvmaxQty.setText(BuManagement.formatDecimal(maxQty).trim()); edtMoveTo.requestFocus(); edtLotValue.setText(strlot); edtLotValue.setEnabled(false); edtMoveQty.setText(BuManagement.formatDecimal(maxQty).trim()); edtMoveQty.setEnabled(false); spnMoveUOM.setEnabled(false); uom = enPurchaseOrderItemInfo.get_uomDesc(); ArrayList<String> listUom = new ArrayList<String>(); listUom.add(uom); ArrayAdapter<String> uomAdapter = new ArrayAdapter<String>(this, R.layout.custom_spinner_item, listUom); spnMoveUOM.setAdapter(uomAdapter); } } }
From source file:mp.paschalis.BookSearchActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); resultsShowing = false;//from w w w .java2 s . c om app = (App) getApplication(); setContentView(R.layout.activity_book_search); app.selectedBook = null; linearLayoutSearchLayout = (LinearLayout) findViewById(R.id.linearLayoutSearchLayout); editTextSearchKeyword = (EditText) findViewById(R.id.editTextSearchKeyword); spinnerColumnSelect = (Spinner) findViewById(R.id.spinnerSearchSelectColumn); buttonSearch = (Button) findViewById(R.id.buttonSearchBookSearch); progressBarSearchButton = (ProgressBar) findViewById(R.id.progressBarSearchSearchButton); listViewBookResults = (ListView) findViewById(R.id.listViewBookResults); textViewSearchResults = (TextView) findViewById(R.id.textViewSearchSearchResults); arrayListSearchResultBooks = new ArrayList<Book>(); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Create adapter for the Spinner adapterSearchColumns = ArrayAdapter.createFromResource(this, R.array.ArraySearchColumns, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapterSearchColumns.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner spinnerColumnSelect.setAdapter(adapterSearchColumns); isItemChecked = false; editTextSearchKeyword.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { if (s.length() == 0) { buttonSearch.setEnabled(false); } else { buttonSearch.setEnabled(true); } } }); // When button is pressed buttonSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dataClassSearch = new DataClassSearch(); dataClassSearch.column = getResources().getStringArray( R.array.ArraySearchColumnValues)[spinnerColumnSelect.getSelectedItemPosition()]; dataClassSearch.keyword = editTextSearchKeyword.getText().toString(); // Re-init results arrayListSearchResultBooks = new ArrayList<Book>(); new AsyncTaskSearchBooks().execute(dataClassSearch); } }); listViewBookResults.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) { app.selectedBook = (Book) (listViewBookResults.getItemAtPosition(pos)); listViewBookResults.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); listViewBookResults.setItemChecked(pos, true); isItemChecked = true; // Recreate the menu invalidateOptionsMenu(); } }); listViewBookResults.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int pos, long arg3) { app.selectedBook = (Book) (listViewBookResults.getItemAtPosition(pos)); // Open Book { // If user owns that book, open edit book if (app.selectedBook.status != App.BOOK_STATE_USER_DONT_OWNS) { // Workaround - Change the status of // book, to users // specific status for (Book.DataClassUser u : app.selectedBook.owners) { // Find real status for that book if (u.username.equalsIgnoreCase(app.user.username)) { app.selectedBook.status = u.status; break; } } Intent intent = new Intent(BookSearchActivity.this, EditBookActivity.class); intent.putExtra(App.ExtrasForEditBookActivityFromBookSearch, true); openedEditBook = true; startActivity(intent); } else { Boolean isAvail = false; // Find all users who lent this book for (Book.DataClassUser u : app.selectedBook.owners) { if (u.status == App.BOOK_STATE_USER_AVAILABLE) { isAvail = true; } } Intent intent = new Intent(BookSearchActivity.this, WatchBookActivity.class); intent.putExtra(App.ExtrasForWatchBookActivityFromBookSearch, isAvail); startActivity(intent); } } return true; } }); }
From source file:org.archive.modules.extractor.ExtractorHTML.java
/** * Handle generic HREF cases.//from w w w . j a v a 2s .c om * * @param curi * @param value * @param context */ protected void processLink(CrawlURI curi, final CharSequence value, CharSequence context) { if (TextUtils.matches(JAVASCRIPT, value)) { processScriptCode(curi, value.subSequence(11, value.length())); } else { if (logger.isLoggable(Level.FINEST)) { logger.finest("link: " + value.toString() + " from " + curi); } addLinkFromString(curi, value, context, Hop.NAVLINK); numberOfLinksExtracted.incrementAndGet(); } }