List of usage examples for android.text Html fromHtml
@Deprecated public static Spanned fromHtml(String source)
From source file:com.liato.bankdroid.banking.banks.CSN.java
@Override public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException { super.updateTransactions(account, urlopen); if (account.getAliasfor() == null || account.getAliasfor().length() == 0) return;/*from w w w . j a v a2s . c om*/ Matcher matcher; try { response = urlopen.open("https://www.csn.se/studiemedel/utbetalningar/utbetalningar.do?javascript=off"); matcher = reTransactions.matcher(response); ArrayList<Transaction> transactions = new ArrayList<Transaction>(); while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: Date 2010-11-25 * 2: Specification Vecka 47-50 * 3: Status Utbetald * 4: Amount 8,140 * */ transactions.add(new Transaction(matcher.group(1).trim(), Html.fromHtml(matcher.group(2)).toString().trim() + " (" + Html.fromHtml(matcher.group(3)).toString().trim() + ")", Helpers.parseBalance(matcher.group(4).replace(",", "")))); } response = urlopen.open( "https://www.csn.se/aterbetalning/vadSkallJagBetalUnderAret/betalningstillfallen.do?javascript=off"); matcher = reTransactions.matcher(response); while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: Date 2010-11-25 * 2: Specification Bankgiro 5580-3084 * 3: OCR-number 4576225900 * 4: Amount 1,234 * */ transactions.add(new Transaction(matcher.group(1).trim(), Html.fromHtml(matcher.group(2)).toString().trim() + " (" + Html.fromHtml(matcher.group(3)).toString().trim() + ")", Helpers.parseBalance(matcher.group(4).replace(",", "")).negate())); } response = urlopen.open( "https://www.csn.se/aterbetalning/harMinaInbetalningarKommitIn/registreradeInbetalningar.do?javascript=off"); matcher = reCompletedPayments.matcher(response); while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: Date 2006-08-21 * 2: Specification terkrav frsta halvret 2006 ln 1 * 3: Amount 1,050 * */ transactions.add( new Transaction(matcher.group(1).trim(), Html.fromHtml(matcher.group(2)).toString().trim(), Helpers.parseBalance(matcher.group(3).replace(",", "")).negate())); } Collections.sort(transactions, Collections.reverseOrder()); account.setTransactions(transactions); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.cettco.buycar.activity.BargainActivity.java
private void updateUI() { getCarTimeTextView.setText(getcarTimeList.get(getcarTimeSelection)); loantTextView.setText(loanList.get(loanSelection)); locationTextView.setText(locationList.get(locationSelection)); plateTextView.setText(plateList.get(plateSelection)); shoptexTextView//w ww. ja va 2 s .c o m .setText(Html.fromHtml("<font color='#ff0033'>" + dealers.size() + "</font>4s")); colorTextView .setText(Html.fromHtml("<font color='#ff0033'>" + colors.size() + "</font>?")); }
From source file:it.feio.android.omninotes.async.DataBackupIntentService.java
/** * Imports notes and notebooks from Springpad exported archive *// w ww . j a v a2 s . c o m * @param intent */ synchronized private void importDataFromSpringpad(Intent intent) { String backupPath = intent.getStringExtra(EXTRA_SPRINGPAD_BACKUP); Importer importer = new Importer(); try { importer.setZipProgressesListener(percentage -> mNotificationsHelper .setMessage(getString(R.string.extracted) + " " + percentage + "%").show()); importer.doImport(backupPath); // Updating notification updateImportNotification(importer); } catch (ImportException e) { new NotificationsHelper(this).createNotification(R.drawable.ic_emoticon_sad_white_24dp, getString(R.string.import_fail) + ": " + e.getMessage(), null).setLedActive().show(); return; } List<SpringpadElement> elements = importer.getSpringpadNotes(); // If nothing is retrieved it will exit if (elements == null || elements.size() == 0) { return; } // These maps are used to associate with post processing notes to categories (notebooks) HashMap<String, Category> categoriesWithUuid = new HashMap<>(); // Adds all the notebooks (categories) for (SpringpadElement springpadElement : importer.getNotebooks()) { Category cat = new Category(); cat.setName(springpadElement.getName()); cat.setColor(String.valueOf(Color.parseColor("#F9EA1B"))); DbHelper.getInstance().updateCategory(cat); categoriesWithUuid.put(springpadElement.getUuid(), cat); // Updating notification importedSpringpadNotebooks++; updateImportNotification(importer); } // And creates a default one for notes without notebook Category defaulCategory = new Category(); defaulCategory.setName("Springpad"); defaulCategory.setColor(String.valueOf(Color.parseColor("#F9EA1B"))); DbHelper.getInstance().updateCategory(defaulCategory); // And then notes are created Note note; Attachment mAttachment = null; Uri uri; for (SpringpadElement springpadElement : importer.getNotes()) { note = new Note(); // Title note.setTitle(springpadElement.getName()); // Content dependent from type of Springpad note StringBuilder content = new StringBuilder(); content.append( TextUtils.isEmpty(springpadElement.getText()) ? "" : Html.fromHtml(springpadElement.getText())); content.append( TextUtils.isEmpty(springpadElement.getDescription()) ? "" : springpadElement.getDescription()); // Some notes could have been exported wrongly if (springpadElement.getType() == null) { Toast.makeText(this, getString(R.string.error), Toast.LENGTH_SHORT).show(); continue; } if (springpadElement.getType().equals(SpringpadElement.TYPE_VIDEO)) { try { content.append(System.getProperty("line.separator")) .append(springpadElement.getVideos().get(0)); } catch (IndexOutOfBoundsException e) { content.append(System.getProperty("line.separator")).append(springpadElement.getUrl()); } } if (springpadElement.getType().equals(SpringpadElement.TYPE_TVSHOW)) { content.append(System.getProperty("line.separator")) .append(TextUtils.join(", ", springpadElement.getCast())); } if (springpadElement.getType().equals(SpringpadElement.TYPE_BOOK)) { content.append(System.getProperty("line.separator")).append("Author: ") .append(springpadElement.getAuthor()).append(System.getProperty("line.separator")) .append("Publication date: ").append(springpadElement.getPublicationDate()); } if (springpadElement.getType().equals(SpringpadElement.TYPE_RECIPE)) { content.append(System.getProperty("line.separator")).append("Ingredients: ") .append(springpadElement.getIngredients()).append(System.getProperty("line.separator")) .append("Directions: ").append(springpadElement.getDirections()); } if (springpadElement.getType().equals(SpringpadElement.TYPE_BOOKMARK)) { content.append(System.getProperty("line.separator")).append(springpadElement.getUrl()); } if (springpadElement.getType().equals(SpringpadElement.TYPE_BUSINESS) && springpadElement.getPhoneNumbers() != null) { content.append(System.getProperty("line.separator")).append("Phone number: ") .append(springpadElement.getPhoneNumbers().getPhone()); } if (springpadElement.getType().equals(SpringpadElement.TYPE_PRODUCT)) { content.append(System.getProperty("line.separator")).append("Category: ") .append(springpadElement.getCategory()).append(System.getProperty("line.separator")) .append("Manufacturer: ").append(springpadElement.getManufacturer()) .append(System.getProperty("line.separator")).append("Price: ") .append(springpadElement.getPrice()); } if (springpadElement.getType().equals(SpringpadElement.TYPE_WINE)) { content.append(System.getProperty("line.separator")).append("Wine type: ") .append(springpadElement.getWine_type()).append(System.getProperty("line.separator")) .append("Varietal: ").append(springpadElement.getVarietal()) .append(System.getProperty("line.separator")).append("Price: ") .append(springpadElement.getPrice()); } if (springpadElement.getType().equals(SpringpadElement.TYPE_ALBUM)) { content.append(System.getProperty("line.separator")).append("Artist: ") .append(springpadElement.getArtist()); } for (SpringpadComment springpadComment : springpadElement.getComments()) { content.append(System.getProperty("line.separator")).append(springpadComment.getCommenter()) .append(" commented at 0").append(springpadComment.getDate()).append(": ") .append(springpadElement.getArtist()); } note.setContent(content.toString()); // Checklists if (springpadElement.getType().equals(SpringpadElement.TYPE_CHECKLIST)) { StringBuilder sb = new StringBuilder(); String checkmark; for (SpringpadItem mSpringpadItem : springpadElement.getItems()) { checkmark = mSpringpadItem.getComplete() ? it.feio.android.checklistview.interfaces.Constants.CHECKED_SYM : it.feio.android.checklistview.interfaces.Constants.UNCHECKED_SYM; sb.append(checkmark).append(mSpringpadItem.getName()) .append(System.getProperty("line.separator")); } note.setContent(sb.toString()); note.setChecklist(true); } // Tags String tags = springpadElement.getTags().size() > 0 ? "#" + TextUtils.join(" #", springpadElement.getTags()) : ""; if (note.isChecklist()) { note.setTitle(note.getTitle() + tags); } else { note.setContent(note.getContent() + System.getProperty("line.separator") + tags); } // Address String address = springpadElement.getAddresses() != null ? springpadElement.getAddresses().getAddress() : ""; if (!TextUtils.isEmpty(address)) { try { double[] coords = GeocodeHelper.getCoordinatesFromAddress(this, address); note.setLatitude(coords[0]); note.setLongitude(coords[1]); } catch (IOException e) { Log.e(Constants.TAG, "An error occurred trying to resolve address to coords during Springpad import"); } note.setAddress(address); } // Reminder if (springpadElement.getDate() != null) { note.setAlarm(springpadElement.getDate().getTime()); } // Creation, modification, category note.setCreation(springpadElement.getCreated().getTime()); note.setLastModification(springpadElement.getModified().getTime()); // Image String image = springpadElement.getImage(); if (!TextUtils.isEmpty(image)) { try { File file = StorageHelper.createNewAttachmentFileFromHttp(this, image); uri = Uri.fromFile(file); String mimeType = StorageHelper.getMimeType(uri.getPath()); mAttachment = new Attachment(uri, mimeType); } catch (MalformedURLException e) { uri = Uri.parse(importer.getWorkingPath() + image); mAttachment = StorageHelper.createAttachmentFromUri(this, uri, true); } catch (IOException e) { Log.e(Constants.TAG, "Error retrieving Springpad online image"); } if (mAttachment != null) { note.addAttachment(mAttachment); } mAttachment = null; } // Other attachments for (SpringpadAttachment springpadAttachment : springpadElement.getAttachments()) { // The attachment could be the image itself so it's jumped if (image != null && image.equals(springpadAttachment.getUrl())) continue; if (TextUtils.isEmpty(springpadAttachment.getUrl())) { continue; } // Tries first with online images try { File file = StorageHelper.createNewAttachmentFileFromHttp(this, springpadAttachment.getUrl()); uri = Uri.fromFile(file); String mimeType = StorageHelper.getMimeType(uri.getPath()); mAttachment = new Attachment(uri, mimeType); } catch (MalformedURLException e) { uri = Uri.parse(importer.getWorkingPath() + springpadAttachment.getUrl()); mAttachment = StorageHelper.createAttachmentFromUri(this, uri, true); } catch (IOException e) { Log.e(Constants.TAG, "Error retrieving Springpad online image"); } if (mAttachment != null) { note.addAttachment(mAttachment); } mAttachment = null; } // If the note has a category is added to the map to be post-processed if (springpadElement.getNotebooks().size() > 0) { note.setCategory(categoriesWithUuid.get(springpadElement.getNotebooks().get(0))); } else { note.setCategory(defaulCategory); } // The note is saved DbHelper.getInstance().updateNote(note, false); ReminderHelper.addReminder(OmniNotes.getAppContext(), note); // Updating notification importedSpringpadNotes++; updateImportNotification(importer); } // Delete temp data try { importer.clean(); } catch (IOException e) { Log.w(Constants.TAG, "Springpad import temp files not deleted"); } String title = getString(R.string.data_import_completed); String text = getString(R.string.click_to_refresh_application); createNotification(intent, this, title, text, null); }
From source file:info.xuluan.podcast.SearchActivity.java
@Override protected void onListItemClick(ListView l, View v, int position, long id) { final SearchItem item = mItems.get(position); String content = item.content; AlertDialog d = new AlertDialog.Builder(this).setIcon(R.drawable.alert_dialog_icon).setTitle(item.title) .setMessage(Html.fromHtml(content)) .setPositiveButton(R.string.subscribe, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Subscription sub = new Subscription(item.url); sub.link = item.link; String tags = SearchActivity.this.mEditText.getText().toString(); String content = "<tag>" + tags + "</tag>"; content += "<content>" + item.content + "</content>"; sub.comment = content; int rc = sub.subscribe(getContentResolver()); if (rc == Subscription.ADD_FAIL_DUP) { Toast.makeText(SearchActivity.this, getResources().getString(R.string.already_subscribed), Toast.LENGTH_SHORT) .show(); } else if (rc == Subscription.ADD_SUCCESS) { Toast.makeText(SearchActivity.this, getResources().getString(R.string.success), Toast.LENGTH_SHORT).show(); } else { Toast.makeText(SearchActivity.this, getResources().getString(R.string.fail), Toast.LENGTH_SHORT).show(); }// ww w. j a v a 2 s . c o m mServiceBinder.start_update(); } }).setNegativeButton(R.string.menu_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* User clicked Cancel so do some stuff */ } }).create(); d.show(); }
From source file:com.liato.bankdroid.banking.banks.SEBKortBase.java
@Override public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException { super.updateTransactions(account, urlopen); if (!urlopen.acceptsInvalidCertificates()) { //Should never happen, but we'll check it anyway. urlopen = login();//from www. ja va 2 s . c o m } if (account.getType() != Account.CCARD) return; String response = null; Matcher matcher; try { response = urlopen.open(String .format("https://application.sebkort.com/nis/%s/getPendingTransactions.do", provider_part)); matcher = reTransactions.matcher(response); ArrayList<Transaction> transactions = new ArrayList<Transaction>(); while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: Trans. date 10-18 * 2: Book. date 10-19 * 3: Specification ICA Kvantum * 4: Location Stockholm * 5: Currency currency code (e.g. EUR) for transactions in non-SEK * 6: Amount local currency amount (in $currency) for transactions in non-SEK * 7: Amount in sek 5791,18 * */ String[] monthday = matcher.group(1).trim().split("-"); transactions.add(new Transaction(Helpers.getTransactionDate(monthday[0], monthday[1]), Html.fromHtml(matcher.group(3)).toString().trim() + (matcher.group(4).trim().length() > 0 ? " (" + Html.fromHtml(matcher.group(4)).toString().trim() + ")" : ""), Helpers.parseBalance(matcher.group(7)).negate())); Collections.sort(transactions, Collections.reverseOrder()); } account.setTransactions(transactions); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.liberty.android.fantastischmemopro.downloader.DownloaderSS.java
protected void fetchDatabase(final DownloadItem di) { View alertView = View.inflate(this, R.layout.link_alert, null); TextView textView = (TextView) alertView.findViewById(R.id.link_alert_message); textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setText(/* www . j a v a2s .c om*/ Html.fromHtml(getString(R.string.downloader_download_alert_message) + di.getDescription())); new AlertDialog.Builder(this).setView(alertView) .setTitle(getString(R.string.downloader_download_alert) + di.getTitle()) .setPositiveButton(getString(R.string.yes_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { mProgressDialog = ProgressDialog.show(DownloaderSS.this, getString(R.string.loading_please_wait), getString(R.string.loading_downloading)); new Thread() { public void run() { try { downloadDatabase(di); mHandler.post(new Runnable() { public void run() { mProgressDialog.dismiss(); String dbpath = Environment.getExternalStorageDirectory() .getAbsolutePath() + getString(R.string.default_dir); new AlertDialog.Builder(DownloaderSS.this) .setTitle(R.string.downloader_download_success) .setMessage( getString(R.string.downloader_download_success_message) + dbpath + di.getTitle() + ".db") .setPositiveButton(R.string.ok_text, null).create().show(); } }); } catch (final Exception e) { Log.e(TAG, "Error downloading", e); mHandler.post(new Runnable() { public void run() { mProgressDialog.dismiss(); new AlertDialog.Builder(DownloaderSS.this) .setTitle(R.string.downloader_download_fail) .setMessage(getString(R.string.downloader_download_fail_message) + " " + e.toString()) .setPositiveButton(R.string.ok_text, null).create().show(); } }); } } }.start(); } }).setNegativeButton(getString(R.string.no_text), null).show(); }
From source file:com.liato.bankdroid.banking.banks.IkanoBank.java
@Override public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException { super.updateTransactions(account, urlopen); // Find viewstate and eventvalidation from last page. Matcher matcher;//from w ww . j a v a2s .com matcher = reViewState.matcher(response); if (!matcher.find()) { Log.e(TAG, "Unable to find ViewState. L156."); return; } String strViewState = matcher.group(1); matcher = reEventValidation.matcher(response); if (!matcher.find()) { Log.e(TAG, "Unable to find EventValidation. L161."); return; } String strEventValidation = matcher.group(1); try { List<NameValuePair> postData = new ArrayList<NameValuePair>(); postData.add(new BasicNameValuePair("__EVENTTARGET", account.getId().replace("_", "$"))); postData.add(new BasicNameValuePair("__EVENTARGUMENT", "")); postData.add(new BasicNameValuePair("__VIEWSTATE", strViewState)); postData.add(new BasicNameValuePair("__EVENTVALIDATION", strEventValidation)); response = urlopen.open("https://secure.ikanobank.se/engines/page.aspx?structid=1787", postData); matcher = reTransactions.matcher(response); ArrayList<Transaction> transactions = new ArrayList<Transaction>(); while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: Date 2010-10-27 * 2: Specification ?VERF?RING * 3: Amount 50 * */ transactions.add(new Transaction(matcher.group(1).trim(), Html.fromHtml(matcher.group(2)).toString().trim(), Helpers.parseBalance(matcher.group(3)))); } account.setTransactions(transactions); } catch (ClientProtocolException e) { Log.e(TAG, "CPE: " + e.getMessage()); } catch (IOException e) { Log.e(TAG, "IOE: " + e.getMessage()); } }
From source file:org.transdroid.search.ScambioEtico.ScambioEtico.java
private SearchResult parseHtmlItem(String htmlItem) throws UnsupportedEncodingException { String title = Html.fromHtml(extractData(MAIN_EXTRACTOR, htmlItem, 2)).toString(); String detailsUrl = Html.fromHtml(extractData(MAIN_EXTRACTOR, htmlItem, 1)).toString(); String torrentId = extractData(TORRENT_ID_EXTRACTOR, htmlItem); String size = extractData(SIZE_EXTRACTOR, htmlItem) + " GiB"; int seeds = Integer.parseInt(extractData(SEEDS_EXTRACTOR, htmlItem)); int leechers = Integer.parseInt(extractData(LEECHERS_EXTRACTOR, htmlItem)); return new SearchResult(title, String.format(TORRENT_URL, torrentId), detailsUrl, size, null, seeds, leechers);/*www . j ava2 s . c o m*/ }
From source file:com.example.main.ViewPagerActivity.java
private void getTalkDataArrays(String decode) { // TODO Auto-generated method stub try {// w w w . j a v a 2 s . c o m JSONArray jsonArray = new JSONArray(decode); if (jsonArray.length() == 0) { return; } else { for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); TalkEntity entity = new TalkEntity(Boolean.valueOf(jsonObject.optString("isMsg")), Boolean.valueOf(jsonObject.optString("isSend")) , Html.fromHtml(jsonObject.optString("detail")).toString(), jsonObject.optString("PostTime"), jsonObject.optString("ark_id"), jsonObject.optString("send_user_id"), jsonObject.optString("msg_id")); entity.setState(Integer.valueOf(jsonObject.optString("state"))); LogHelper.trace(jsonObject.optString("detail")); LogHelper.trace(Html.fromHtml(jsonObject.optString("detail")).toString()); if (jsonObject.optString("isMsg").equals("false")) { String pic = jsonObject.optString("detail"); GlobalID globalID = ((GlobalID) getApplication()); Bitmap bit = FuntionUtil .downloadPic("http://" + globalID.getDBurl() + "/user/images" + pic); if (bit != null) { entity.setImage_picture(bit); } else { Bitmap default_Img = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); entity.setImage_picture(default_Img); } } // TalkDataArrays.add(entity); Message msg = new Message(); msg.what = 1; msg.obj = entity; add_handler.sendMessage(msg); } } } catch (JSONException e) { e.printStackTrace(); return; } }
From source file:com.liato.bankdroid.banking.banks.Nordea.java
@Override public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException { super.updateTransactions(account, urlopen); //No transaction history for loans, funds and credit cards. int accType = account.getType(); if (accType == Account.LOANS || accType == Account.FUNDS || accType == Account.CCARD) return;//from w w w .ja va 2 s . c om String response = null; Matcher matcher; try { response = urlopen.open("https://mobil.nordea.se/banking-nordea/nordea-c3/accounts.html"); Log.d(TAG, "Opening: https://mobil.nordea.se/banking-nordea/nordea-c3/account.html?id=konton:" + account.getId()); response = urlopen.open( "https://mobil.nordea.se/banking-nordea/nordea-c3/account.html?id=konton:" + account.getId()); matcher = reTransactions.matcher(response); ArrayList<Transaction> transactions = new ArrayList<Transaction>(); while (matcher.find()) { transactions.add(new Transaction(Html.fromHtml(matcher.group(1)).toString().trim(), Html.fromHtml(matcher.group(2)).toString().trim(), Helpers.parseBalance(matcher.group(3)))); } account.setTransactions(transactions); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }