List of usage examples for android.text Html fromHtml
@Deprecated public static Spanned fromHtml(String source)
From source file:au.com.wallaceit.reddinator.Rservice.java
@Override public RemoteViews getViewAt(int position) { RemoteViews row;//ww w.jav a 2 s. com if (position > data.length()) { return null; // prevent errornous views } // check if its the last view and return loading view instead of normal row if (position == data.length()) { // build load more item //System.out.println("load more getViewAt("+position+") firing"); RemoteViews loadmorerow = new RemoteViews(mContext.getPackageName(), R.layout.listrowloadmore); if (endOfFeed) { loadmorerow.setTextViewText(R.id.loadmoretxt, "There's nothing more here"); } else { loadmorerow.setTextViewText(R.id.loadmoretxt, "Load more..."); } loadmorerow.setTextColor(R.id.loadmoretxt, themeColors[0]); Intent i = new Intent(); Bundle extras = new Bundle(); extras.putString(WidgetProvider.ITEM_ID, "0"); // zero will be an indicator in the onreceive function of widget provider if its not present it forces a reload i.putExtras(extras); loadmorerow.setOnClickFillInIntent(R.id.listrowloadmore, i); return loadmorerow; } else { // build normal item String title = ""; String url = ""; String permalink = ""; String thumbnail = ""; String domain = ""; String id = ""; int score = 0; int numcomments = 0; boolean nsfw = false; try { JSONObject tempobj = data.getJSONObject(position).getJSONObject("data"); title = tempobj.getString("title"); //userlikes = tempobj.getString("likes"); domain = tempobj.getString("domain"); id = tempobj.getString("name"); url = tempobj.getString("url"); permalink = tempobj.getString("permalink"); thumbnail = (String) tempobj.get("thumbnail"); // we have to call get and cast cause its not in quotes score = tempobj.getInt("score"); numcomments = tempobj.getInt("num_comments"); nsfw = tempobj.getBoolean("over_18"); } catch (JSONException e) { e.printStackTrace(); // return null; // The view is invalid; } // create remote view from specified layout if (bigThumbs) { row = new RemoteViews(mContext.getPackageName(), R.layout.listrowbigthumb); } else { row = new RemoteViews(mContext.getPackageName(), R.layout.listrow); } // build view row.setTextViewText(R.id.listheading, Html.fromHtml(title).toString()); row.setFloat(R.id.listheading, "setTextSize", Integer.valueOf(titleFontSize)); // use for compatibility setTextViewTextSize only introduced in API 16 row.setTextColor(R.id.listheading, themeColors[0]); row.setTextViewText(R.id.sourcetxt, domain); row.setTextColor(R.id.sourcetxt, themeColors[3]); row.setTextColor(R.id.votestxt, themeColors[4]); row.setTextColor(R.id.commentstxt, themeColors[4]); row.setTextViewText(R.id.votestxt, String.valueOf(score)); row.setTextViewText(R.id.commentstxt, String.valueOf(numcomments)); row.setInt(R.id.listdivider, "setBackgroundColor", themeColors[2]); row.setViewVisibility(R.id.nsfwflag, nsfw ? TextView.VISIBLE : TextView.GONE); // add extras and set click intent Intent i = new Intent(); Bundle extras = new Bundle(); extras.putString(WidgetProvider.ITEM_ID, id); extras.putInt("itemposition", position); extras.putString(WidgetProvider.ITEM_URL, url); extras.putString(WidgetProvider.ITEM_PERMALINK, permalink); i.putExtras(extras); row.setOnClickFillInIntent(R.id.listrow, i); // load thumbnail if they are enabled for this widget if (loadThumbnails) { // load big image if preference is set if (!thumbnail.equals("")) { // check for thumbnail; self is used to display the thinking logo on the reddit site, we'll just show nothing for now if (thumbnail.equals("nsfw") || thumbnail.equals("self") || thumbnail.equals("default")) { int resource = 0; switch (thumbnail) { case "nsfw": resource = R.drawable.nsfw; break; case "default": case "self": resource = R.drawable.self_default; break; } row.setImageViewResource(R.id.thumbnail, resource); row.setViewVisibility(R.id.thumbnail, View.VISIBLE); //System.out.println("Loading default image: "+thumbnail); } else { Bitmap bitmap; String fileurl = mContext.getCacheDir() + "/thumbcache-" + appWidgetId + "/" + id + ".png"; // check if the image is in cache if (new File(fileurl).exists()) { bitmap = BitmapFactory.decodeFile(fileurl); saveImageToStorage(bitmap, id); } else { // download the image bitmap = loadImage(thumbnail); } if (bitmap != null) { row.setImageViewBitmap(R.id.thumbnail, bitmap); row.setViewVisibility(R.id.thumbnail, View.VISIBLE); } else { // row.setImageViewResource(R.id.thumbnail, android.R.drawable.stat_notify_error); for later row.setViewVisibility(R.id.thumbnail, View.GONE); } } } else { row.setViewVisibility(R.id.thumbnail, View.GONE); } } else { row.setViewVisibility(R.id.thumbnail, View.GONE); } // hide info bar if options set if (hideInf) { row.setViewVisibility(R.id.infbox, View.GONE); } else { row.setViewVisibility(R.id.infbox, View.VISIBLE); } } //System.out.println("getViewAt("+position+");"); return row; }
From source file:at.jclehner.rxdroid.BackupFragment.java
private void showExceptionDialog(Exception e) { final AlertDialog.Builder ab = new AlertDialog.Builder(getActivity()); ab.setTitle(R.string._title_error);//w w w . ja va2s. c om ab.setIcon(android.R.drawable.ic_dialog_alert); ab.setPositiveButton(android.R.string.ok, null); ab.setCancelable(true); ab.setMessage(Html .fromHtml("<tt>" + e.getClass().getSimpleName() + "</tt><br/>" + Util.escapeHtml(e.getMessage()))); //ab.show(getFragmentManager(), "create_error"); ab.show(); }
From source file:com.aqnote.app.wifianalyzer.MainActivity.java
private CharSequence makeSubtitle() { NavigationMenu navigationMenu = navigationMenuView.getCurrentNavigationMenu(); Settings settings = MainContext.INSTANCE.getSettings(); CharSequence subtitle = StringUtils.EMPTY; if (navigationMenu.isWiFiBandSwitchable()) { int color = getResources().getColor(R.color.connected); WiFiBand currentWiFiBand = settings.getWiFiBand(); String subtitleText = makeSubtitleText("<font color='" + color + "'><strong>", "</strong></font>", "<small>", "</small>"); if (WiFiBand.GHZ5.equals(currentWiFiBand)) { subtitleText = makeSubtitleText("<small>", "</small>", "<font color='" + color + "'><strong>", "</strong></font>"); }// w ww. j ava 2 s . co m subtitle = Html.fromHtml(subtitleText); } return subtitle; }
From source file:org.liberty.android.fantastischmemopro.downloader.DownloaderFE.java
@Override 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(//w ww. j a va2s . c o m 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(DownloaderFE.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(DownloaderFE.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(DownloaderFE.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.Eurocard.java
@Override public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException { super.updateTransactions(account, urlopen); Matcher matcher;/*from w ww . j a v a2 s. c om*/ // If the account is of type "other" it's the fake "Ofakturerat" account. if (account.getType() == Account.OTHER) return; try { String accountWebId = accountIds.get(Integer.parseInt(account.getId())); Log.d(TAG, "Opening: https://e-saldo.eurocard.se/nis/ecse/getPendingTransactions.do?id=" + accountWebId); response = urlopen .open("https://e-saldo.eurocard.se/nis/ecse/getPendingTransactions.do?id=" + accountWebId); matcher = reTransactions.matcher(response); ArrayList<Transaction> transactions = new ArrayList<Transaction>(); String strDate = null; Calendar cal = Calendar.getInstance(); while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: trans. date 10-18 * 2: reg. date 10-19 * 3: specification ICA Kvantum * 4: location Stockholm * 5: currency SEK * 6: amount/tax 147,64 * 7: amount in sek 5791,18 * */ strDate = "" + cal.get(Calendar.YEAR) + "-" + Html.fromHtml(matcher.group(1)).toString().trim(); transactions.add(new Transaction(strDate, 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())); } 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:me.oriley.homage.Homage.java
public void addLicense(@NonNull String key, @StringRes int nameRes, @StringRes int urlRes, @StringRes int descRes) { String name = mContext.getString(nameRes); String url = mContext.getString(urlRes); Spanned description = Html.fromHtml(mContext.getString(descRes)); addLicense(key, name, url, description); }
From source file:com.liato.bankdroid.banking.banks.Lansforsakringar.java
@Override public void update() throws BankException, LoginException { super.update(); if (username == null || password == null || username.length() == 0 || password.length() == 0) { throw new LoginException(res.getText(R.string.invalid_username_password).toString()); }/* ww w . j a va 2 s .c om*/ urlopen = login(); String response = null; Matcher matcher; try { if (accountsUrl == null) { Log.d(TAG, "accountsUrl is null, unable to update."); return; } response = urlopen.open(accountsUrl); matcher = reAccountsReg.matcher(response); while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: Account number 125486547 * 2: Name Personkonto * 3: Amount 25 000 000 * */ accounts.add(new Account(Html.fromHtml(matcher.group(2)).toString().trim(), Helpers.parseBalance(matcher.group(3).trim()), matcher.group(1).trim())); balance = balance.add(Helpers.parseBalance(matcher.group(3))); } matcher = reAccountsFunds.matcher(response); while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: Name Fonder * 2: ID idJsp165 * 3: Amount 0,00 * */ accounts.add(new Account(Html.fromHtml(matcher.group(1)).toString().trim(), Helpers.parseBalance(matcher.group(3).trim()), matcher.group(2).trim(), Account.FUNDS)); } matcher = reAccountsLoans.matcher(response); while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: Name Privatlån * 2: ID idJsp207 * 3: Amount 25 000 000 * 4: Debt 1,00 * */ accounts.add(new Account(Html.fromHtml(matcher.group(1)).toString().trim(), Helpers.parseBalance(matcher.group(4).trim()), matcher.group(2).trim(), Account.LOANS)); } // Save token for next request matcher = reToken.matcher(response); if (!matcher.find()) { throw new BankException(res.getText(R.string.unable_to_find).toString() + " token."); } mRequestToken = matcher.group(1); if (accounts.isEmpty()) { throw new BankException(res.getText(R.string.no_accounts_found).toString()); } } catch (ClientProtocolException e) { throw new BankException(e.getMessage()); } catch (IOException e) { throw new BankException(e.getMessage()); } finally { super.updateComplete(); } }
From source file:com.amaze.filemanager.fragments.ProcessViewerFragment.java
public void processResults(final DatapointParcelable dataPackage, int serviceType) { if (dataPackage != null) { String name = dataPackage.name; long total = dataPackage.totalSize; long doneBytes = dataPackage.byteProgress; boolean move = dataPackage.move; if (!isInitialized) { // initializing views for the first time chartInit(total);//w w w . j ava 2s .co m // setting progress image setupDrawables(serviceType, move); isInitialized = true; } addEntry(FileUtils.readableFileSizeFloat(doneBytes), FileUtils.readableFileSizeFloat(dataPackage.speedRaw)); mProgressFileNameText.setText(name); Spanned bytesText = Html.fromHtml(getResources().getString(R.string.written) + " <font color='" + accentColor + "'><i>" + Formatter.formatFileSize(getContext(), doneBytes) + " </font></i>" + getResources().getString(R.string.out_of) + " <i>" + Formatter.formatFileSize(getContext(), total) + "</i>"); mProgressBytesText.setText(bytesText); Spanned fileProcessedSpan = Html.fromHtml(getResources().getString(R.string.processing_file) + " <font color='" + accentColor + "'><i>" + (dataPackage.sourceProgress) + " </font></i>" + getResources().getString(R.string.of) + " <i>" + dataPackage.sourceFiles + "</i>"); mProgressFileText.setText(fileProcessedSpan); Spanned speedSpan = Html.fromHtml( getResources().getString(R.string.current_speed) + ": <font color='" + accentColor + "'><i>" + Formatter.formatFileSize(getContext(), dataPackage.speedRaw) + "/s</font></i>"); mProgressSpeedText.setText(speedSpan); Spanned timerSpan = Html.fromHtml(getResources().getString(R.string.service_timer) + ": <font color='" + accentColor + "'><i>" + Utils.formatTimer(++looseTimeInSeconds) + "</font></i>"); mProgressTimer.setText(timerSpan); if (dataPackage.completed) mCancelButton.setVisibility(View.GONE); } }
From source file:com.liato.bankdroid.banking.banks.Statoil.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 w ww . java 2s. c om*/ } if (account.getType() != Account.CCARD) return; String response = null; Matcher matcher; try { Log.d(TAG, "Opening: https://applications.sebkort.com/nis/stse/getPendingTransactions.do"); response = urlopen.open("https://applications.sebkort.com/nis/stse/getPendingTransactions.do"); matcher = reTransactions.matcher(response); ArrayList<Transaction> transactions = new ArrayList<Transaction>(); Calendar cal = Calendar.getInstance(); 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 always empty? * 6: Amount always empty? * 7: Amount in sek 5791,18 * */ transactions.add(new Transaction("" + cal.get(Calendar.YEAR) + "-" + matcher.group(1).trim(), 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())); } 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.liato.bankdroid.banking.banks.AmericanExpress.java
@Override public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException { super.updateTransactions(account, urlopen); try {/*from w w w. j a v a2s .c o m*/ response = urlopen.open( "https://global.americanexpress.com/myca/intl/estatement/emea/statement.do?request_type=&Face=sv_SE&BPIndex=0&sorted_index=" + account.getId()); Matcher matcher = reTransactions.matcher(response); ArrayList<Transaction> transactions = new ArrayList<Transaction>(); SimpleDateFormat sdfFrom = new SimpleDateFormat("d MMM yyyy", new Locale("sv-SE")); SimpleDateFormat sdfTo = new SimpleDateFormat("yyyy-MM-dd"); Date transactionDate; while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: Date 17 jan 2011 * 2: Specification xx * 3: Amount 1.582,00 kr * */ try { transactionDate = sdfFrom.parse(matcher.group(1).trim()); String strDate = sdfTo.format(transactionDate); transactions.add(new Transaction(strDate, Html.fromHtml(matcher.group(2)).toString().trim(), Helpers.parseBalance(matcher.group(3).trim()).negate())); } catch (ParseException e) { Log.w(TAG, "Unable to parse date: " + matcher.group(1).trim()); } } account.setTransactions(transactions); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }