List of usage examples for android.text Html fromHtml
@Deprecated public static Spanned fromHtml(String source)
From source file:com.liato.bankdroid.banking.banks.SEB.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;// w w w . j a v a 2 s .c om Matcher matcher; try { response = urlopen.open( "https://m.seb.se/cgi-bin/pts3/mps/1100/mps1102.aspx?M1=show&P2=1&P4=1&P1=" + account.getId()); matcher = reTransactions.matcher(response); ArrayList<Transaction> transactions = new ArrayList<Transaction>(); while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: Book. date 101214 * 2: Transaction St1 * 3: Trans. date 10-12-11 * 4: Amount -200,07 * */ String date; if (matcher.group(3) == null || matcher.group(3).length() == 0) { date = Html.fromHtml(matcher.group(1)).toString().trim(); date = String.format("%s-%s-%s", date.substring(0, 2), date.substring(2, 4), date.substring(4, 6)); } else { date = Html.fromHtml(matcher.group(3)).toString().trim(); } transactions.add(new Transaction("20" + date, Html.fromHtml(matcher.group(2)).toString().trim(), Helpers.parseBalance(matcher.group(4)))); } 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:net.olejon.mdapp.PoisoningsCardsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Connected? if (!mTools.isDeviceConnected()) { mTools.showToast(getString(R.string.device_not_connected), 1); finish();/*from w ww . j a v a2 s. co m*/ return; } // Intent final Intent intent = getIntent(); searchString = intent.getStringExtra("search"); // Layout setContentView(R.layout.activity_poisonings_cards); // Toolbar mToolbar = (Toolbar) findViewById(R.id.poisonings_cards_toolbar); mToolbar.setTitle(getString(R.string.poisonings_cards_search) + ": \"" + searchString + "\""); setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Progress bar mProgressBar = (ProgressBar) findViewById(R.id.poisonings_cards_toolbar_progressbar); mProgressBar.setVisibility(View.VISIBLE); // Refresh mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.poisonings_cards_swipe_refresh_layout); mSwipeRefreshLayout.setColorSchemeResources(R.color.accent_blue, R.color.accent_green, R.color.accent_purple, R.color.accent_orange); mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { search(searchString, false); } }); // Recycler view mRecyclerView = (RecyclerView) findViewById(R.id.poisonings_cards_cards); mRecyclerView.setHasFixedSize(true); mRecyclerView.setAdapter(new PoisoningsCardsAdapter(mContext, new JSONArray())); mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext)); // No poisonings mNoPoisoningsLayout = (LinearLayout) findViewById(R.id.poisonings_cards_no_poisonings); Button noPoisoningsHelsenorgeButton = (Button) findViewById(R.id.poisonings_cards_check_on_helsenorge); Button noPoisoningsHelsebiblioteketButton = (Button) findViewById( R.id.poisonings_cards_check_on_helsebiblioteket); noPoisoningsHelsenorgeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { Intent intent = new Intent(mContext, MainWebViewActivity.class); intent.putExtra("title", getString(R.string.poisonings_cards_search) + ": \"" + searchString + "\""); intent.putExtra("uri", "https://helsenorge.no/sok/giftinformasjon/?k=" + URLEncoder.encode(searchString.toLowerCase(), "utf-8")); mContext.startActivity(intent); } catch (Exception e) { Log.e("PoisoningsCardsActivity", Log.getStackTraceString(e)); } } }); noPoisoningsHelsebiblioteketButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { Intent intent = new Intent(mContext, MainWebViewActivity.class); intent.putExtra("title", getString(R.string.poisonings_cards_search) + ": \"" + searchString + "\""); intent.putExtra("uri", "http://www.helsebiblioteket.no/forgiftninger/alle-anbefalinger?cx=005475784484624053973%3A3bnj2dj_uei&ie=UTF-8&q=" + URLEncoder.encode(searchString.toLowerCase(), "utf-8") + "&sa=S%C3%B8k"); mContext.startActivity(intent); } catch (Exception e) { Log.e("PoisoningsCardsActivity", Log.getStackTraceString(e)); } } }); // Search search(searchString, true); // Correct RequestQueue requestQueue = Volley.newRequestQueue(mContext); try { JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, getString(R.string.project_website_uri) + "api/1/correct/?search=" + URLEncoder.encode(searchString, "utf-8"), new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { try { final String correctSearchString = response.getString("correct"); if (!correctSearchString.equals("")) { new MaterialDialog.Builder(mContext) .title(getString(R.string.correct_dialog_title)) .content(Html.fromHtml(getString(R.string.correct_dialog_message) + ":<br><br><b>" + correctSearchString + "</b>")) .positiveText(getString(R.string.correct_dialog_positive_button)) .negativeText(getString(R.string.correct_dialog_negative_button)) .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { ContentValues contentValues = new ContentValues(); contentValues.put(PoisoningsSQLiteHelper.COLUMN_STRING, correctSearchString); SQLiteDatabase sqLiteDatabase = new PoisoningsSQLiteHelper( mContext).getWritableDatabase(); sqLiteDatabase.delete(PoisoningsSQLiteHelper.TABLE, PoisoningsSQLiteHelper.COLUMN_STRING + " = " + mTools.sqe(searchString) + " COLLATE NOCASE", null); sqLiteDatabase.insert(PoisoningsSQLiteHelper.TABLE, null, contentValues); sqLiteDatabase.close(); mToolbar.setTitle(getString(R.string.poisonings_cards_search) + ": \"" + correctSearchString + "\""); mProgressBar.setVisibility(View.VISIBLE); mNoPoisoningsLayout.setVisibility(View.GONE); mSwipeRefreshLayout.setVisibility(View.VISIBLE); search(correctSearchString, true); } }).contentColorRes(R.color.black).positiveColorRes(R.color.dark_blue) .negativeColorRes(R.color.black).show(); } } catch (Exception e) { Log.e("PoisoningsCardsActivity", Log.getStackTraceString(e)); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e("PoisoningsCardsActivity", error.toString()); } }); jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(10000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); requestQueue.add(jsonObjectRequest); } catch (Exception e) { Log.e("PoisoningsCardsActivity", Log.getStackTraceString(e)); } }
From source file:com.eyekabob.EventInfo.java
protected void loadEvent(JSONObject response) { try {/*from w w w. j a v a2 s .c om*/ JSONObject jsonEvent = response.getJSONObject("event"); artists = new ArrayList<String>(); title = jsonEvent.getString("title"); JSONObject jsonAllArtists = jsonEvent.getJSONObject("artists"); headliner = jsonAllArtists.getString("headliner"); Object artistObj = jsonAllArtists.get("artist"); JSONArray jsonOpeners = new JSONArray(); if (artistObj instanceof JSONArray) { jsonOpeners = (JSONArray) artistObj; } for (int i = 0; i < jsonOpeners.length(); i++) { String artistName = jsonOpeners.getString(i); if (!headliner.equals(artistName)) { artists.add(artistName); } } JSONObject jsonVenue = jsonEvent.getJSONObject("venue"); venue = jsonVenue.optString("name"); venueCity = jsonVenue.optString("city"); venueStreet = jsonVenue.optString("street"); venueUrl = jsonVenue.optString("url"); startDate = EyekabobHelper.LastFM.toReadableDate(jsonEvent.getString("startDate")); JSONObject image = EyekabobHelper.LastFM.getLargestJSONImage(jsonEvent.getJSONArray("image")); imageUrl = image.getString("#text"); } catch (JSONException e) { Log.e(getClass().getName(), "", e); } try { new EventImageTask().execute(new URL(imageUrl)); } catch (MalformedURLException e) { Log.e(getClass().getName(), "Bad image URL [" + imageUrl + "]", e); } TextView titleView = (TextView) findViewById(R.id.infoMainHeader); titleView.setText(title); TextView headlinerView = (TextView) findViewById(R.id.infoSubHeaderOne); // TODO: I18N headlinerView.setText("Headlining: " + headliner); TextView dateTimeView = (TextView) findViewById(R.id.infoSubHeaderTwo); dateTimeView.setText(startDate); if (!startDate.equals("")) { Button tixButton = (Button) findViewById(R.id.infoTicketsButton); tixButton.setVisibility(View.VISIBLE); } LinearLayout artistsView = (LinearLayout) findViewById(R.id.infoFutureEventsContent); TextView alsoPerformingView = (TextView) findViewById(R.id.infoFutureEventsHeader); if (!artists.isEmpty()) { // TODO: I18N alsoPerformingView.setText("Also Performing:"); for (String artist : artists) { TextView row = new TextView(this); row.setTextColor(Color.WHITE); row.setText(artist); row.setPadding(20, 0, 0, 20); // Left and bottom padding artistsView.addView(row); } } String venueDesc = ""; TextView venueView = (TextView) findViewById(R.id.infoEventVenue); // TODO: Padding instead of whitespace venueDesc += " " + venue; if (!venueCity.equals("") && !venueStreet.equals("")) { // TODO: I18N venueDesc += "\n Address: " + venueStreet + "\n" + venueCity; } // TODO: Padding instead of whitespace venueDesc += "\n " + startDate; TextView venueTitleView = (TextView) findViewById(R.id.infoBioHeader); if (!venue.equals("") || !venueCity.equals("") || !venueStreet.equals("")) { // TODO: I18N venueTitleView.setText("Venue Details:"); View vView = findViewById(R.id.infoVenueDetails); vView.setVisibility(View.VISIBLE); } else { // TODO: I18N venueTitleView.setText("No Venue Details Available"); } venueView.setVisibility(View.VISIBLE); venueView.setText(venueDesc); TextView websiteView = (TextView) findViewById(R.id.infoVenueWebsite); if (!venueUrl.equals("")) { // TODO: I18N websiteView.setVisibility(View.VISIBLE); websiteView.setText(Html.fromHtml("<a href=\"" + venueUrl + "\">More Information</a>")); websiteView.setMovementMethod(LinkMovementMethod.getInstance()); } }
From source file:com.liato.bankdroid.banking.banks.TicketRikskortet.java
@Override public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException { super.updateTransactions(account, urlopen); String response = null;// w w w . j av a 2 s . com Matcher matcher; try { response = urlopen.open("https://www.edenred.se/sv/Apps/Employee/Start/Transaktioner/"); matcher = reTransactions.matcher(response); ArrayList<Transaction> transactions = new ArrayList<Transaction>(); while (matcher.find()) { /* * Capture groups: * GROUP EXAMPLE DATA * 1: Trans. date 2012-06-01 * 2: Specification DANMARKSG KISTA * 3: Amount - 85 kr * */ transactions.add(new Transaction(matcher.group(1), Html.fromHtml(matcher.group(2).trim()).toString(), 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(); } }
From source file:com.klinker.android.twitter.utils.NotificationUtils.java
public static void refreshNotification(Context context, boolean noTimeline) { AppSettings settings = AppSettings.getInstance(context); SharedPreferences sharedPrefs = context.getSharedPreferences( "com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); int currentAccount = sharedPrefs.getInt("current_account", 1); //int[] unreadCounts = new int[] {4, 1, 2}; // for testing int[] unreadCounts = getUnreads(context); int timeline = unreadCounts[0]; int realTimelineCount = timeline; // if they don't want that type of notification, simply set it to zero if (!settings.timelineNot || (settings.pushNotifications && settings.liveStreaming) || noTimeline) { unreadCounts[0] = 0;//from w w w .java 2 s . c o m } if (!settings.mentionsNot) { unreadCounts[1] = 0; } if (!settings.dmsNot) { unreadCounts[2] = 0; } if (unreadCounts[0] == 0 && unreadCounts[1] == 0 && unreadCounts[2] == 0) { } else { Intent markRead = new Intent(context, MarkReadService.class); PendingIntent readPending = PendingIntent.getService(context, 0, markRead, 0); String shortText = getShortText(unreadCounts, context, currentAccount); String longText = getLongText(unreadCounts, context, currentAccount); // [0] is the full title and [1] is the screenname String[] title = getTitle(unreadCounts, context, currentAccount); boolean useExpanded = useExp(context); boolean addButton = addBtn(unreadCounts); if (title == null) { return; } Intent resultIntent; if (unreadCounts[1] != 0 && unreadCounts[0] == 0) { // it is a mention notification (could also have a direct message) resultIntent = new Intent(context, RedirectToMentions.class); } else if (unreadCounts[2] != 0 && unreadCounts[0] == 0 && unreadCounts[1] == 0) { // it is a direct message resultIntent = new Intent(context, RedirectToDMs.class); } else { resultIntent = new Intent(context, MainActivity.class); } PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, 0); NotificationCompat.Builder mBuilder; Intent deleteIntent = new Intent(context, NotificationDeleteReceiverOne.class); mBuilder = new NotificationCompat.Builder(context).setContentTitle(title[0]) .setContentText(TweetLinkUtils.removeColorHtml(shortText, settings)) .setSmallIcon(R.drawable.ic_stat_icon).setLargeIcon(getIcon(context, unreadCounts, title[1])) .setContentIntent(resultPendingIntent).setAutoCancel(true) .setTicker(TweetLinkUtils.removeColorHtml(shortText, settings)) .setDeleteIntent(PendingIntent.getBroadcast(context, 0, deleteIntent, 0)) .setPriority(NotificationCompat.PRIORITY_HIGH); if (unreadCounts[1] > 1 && unreadCounts[0] == 0 && unreadCounts[2] == 0) { // inbox style notification for mentions mBuilder.setStyle(getMentionsInboxStyle(unreadCounts[1], currentAccount, context, TweetLinkUtils.removeColorHtml(shortText, settings))); } else if (unreadCounts[2] > 1 && unreadCounts[0] == 0 && unreadCounts[1] == 0) { // inbox style notification for direct messages mBuilder.setStyle(getDMInboxStyle(unreadCounts[1], currentAccount, context, TweetLinkUtils.removeColorHtml(shortText, settings))); } else { // big text style for an unread count on timeline, mentions, and direct messages mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(Html.fromHtml( settings.addonTheme ? longText.replaceAll("FF8800", settings.accentColor) : longText))); } // Pebble notification if (sharedPrefs.getBoolean("pebble_notification", false)) { sendAlertToPebble(context, title[0], shortText); } // Light Flow notification sendToLightFlow(context, title[0], shortText); int homeTweets = unreadCounts[0]; int mentionsTweets = unreadCounts[1]; int dmTweets = unreadCounts[2]; int newC = 0; if (homeTweets > 0) { newC++; } if (mentionsTweets > 0) { newC++; } if (dmTweets > 0) { newC++; } if (settings.notifications && newC > 0) { if (settings.vibrate) { mBuilder.setDefaults(Notification.DEFAULT_VIBRATE); } if (settings.sound) { try { mBuilder.setSound(Uri.parse(settings.ringtone)); } catch (Exception e) { mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); } } if (settings.led) mBuilder.setLights(0xFFFFFF, 1000, 1000); // Get an instance of the NotificationManager service NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); if (addButton) { // the reply and read button should be shown Intent reply; if (unreadCounts[1] == 1) { reply = new Intent(context, NotificationCompose.class); } else { reply = new Intent(context, NotificationDMCompose.class); } Log.v("username_for_noti", title[1]); sharedPrefs.edit().putString("from_notification", "@" + title[1] + " " + title[2]).commit(); MentionsDataSource data = MentionsDataSource.getInstance(context); long id = data.getLastIds(currentAccount)[0]; PendingIntent replyPending = PendingIntent.getActivity(context, 0, reply, 0); sharedPrefs.edit().putLong("from_notification_long", id).commit(); sharedPrefs.edit() .putString("from_notification_text", "@" + title[1] + ": " + TweetLinkUtils.removeColorHtml(shortText, settings)) .commit(); // Create the remote input RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY) .setLabel("@" + title[1] + " ").build(); // Create the notification action NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder( R.drawable.ic_action_reply_dark, context.getResources().getString(R.string.noti_reply), replyPending).addRemoteInput(remoteInput).build(); NotificationCompat.Action.Builder action = new NotificationCompat.Action.Builder( R.drawable.ic_action_read_dark, context.getResources().getString(R.string.mark_read), readPending); mBuilder.addAction(replyAction); mBuilder.addAction(action.build()); } else { // otherwise, if they can use the expanded notifications, the popup button will be shown Intent popup = new Intent(context, RedirectToPopup.class); popup.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); popup.putExtra("from_notification", true); PendingIntent popupPending = PendingIntent.getActivity(context, 0, popup, 0); NotificationCompat.Action.Builder action = new NotificationCompat.Action.Builder( R.drawable.ic_popup, context.getResources().getString(R.string.popup), popupPending); mBuilder.addAction(action.build()); } // Build the notification and issues it with notification manager. notificationManager.notify(1, mBuilder.build()); // if we want to wake the screen on a new message if (settings.wakeScreen) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); final PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG"); wakeLock.acquire(5000); } } // if there are unread tweets on the timeline, check them for favorite users if (settings.favoriteUserNotifications && realTimelineCount > 0) { favUsersNotification(currentAccount, context); } } try { ContentValues cv = new ContentValues(); cv.put("tag", "com.klinker.android.twitter/com.klinker.android.twitter.ui.MainActivity"); // add the direct messages and mentions cv.put("count", unreadCounts[1] + unreadCounts[2]); context.getContentResolver().insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv); } catch (IllegalArgumentException ex) { /* Fine, TeslaUnread is not installed. */ } catch (Exception ex) { /* Some other error, possibly because the format of the ContentValues are incorrect. Log but do not crash over this. */ ex.printStackTrace(); } }
From source file:com.akhbulatov.wordkeeper.ui.fragment.CategoryListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.fragment_category, menu); MenuItem searchItem = menu.findItem(R.id.menu_search_category); SearchView searchView = (SearchView) searchItem.getActionView(); SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); searchView.setSearchableInfo(//ww w . j a v a2 s . c o m searchManager.getSearchableInfo(new ComponentName(getActivity(), MainActivity.class))); searchView.setImeOptions(EditorInfo.IME_ACTION_SEARCH); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { final Cursor cursor = mCategoryDbAdapter.getAll(); final int column = cursor.getColumnIndex(CategoryEntry.COLUMN_NAME); if (newText.length() > 0) { mCategoryAdapter.swapCursor(new FilterCursorWrapper(cursor, newText, column)); if (mCategoryAdapter.getItemCount() == 0) { String escapedNewText = TextUtils.htmlEncode(newText); String formattedNoResults = String.format(getString(R.string.no_results_category), escapedNewText); CharSequence styledNoResults = Html.fromHtml(formattedNoResults); mTextNoResultsCategory.setText(styledNoResults); mTextNoResultsCategory.setVisibility(View.VISIBLE); } else { mTextNoResultsCategory.setVisibility(View.GONE); } } else { mCategoryAdapter.swapCursor(cursor); mTextNoResultsCategory.setVisibility(View.GONE); } return true; } @Override public boolean onQueryTextSubmit(String query) { return false; } }); }
From source file:com.liato.bankdroid.banking.banks.Swedbank.java
@Override public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException { super.updateTransactions(account, urlopen); if (account.getType() == Account.LOANS || account.getType() == Account.OTHER) return; //No transaction history for loans String response = null;/*from w w w .j a va2s. c om*/ Matcher matcher; try { Log.d(TAG, "Opening: https://mobilbank.swedbank.se/banking/swedbank/account.html?id=" + account.getId()); response = urlopen .open("https://mobilbank.swedbank.se/banking/swedbank/account.html?id=" + account.getId()); matcher = reTransactions.matcher(response); ArrayList<Transaction> transactions = new ArrayList<Transaction>(); while (matcher.find()) { transactions.add(new Transaction("20" + matcher.group(1).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(); } }
From source file:com.liato.bankdroid.banking.banks.Nordea.Nordea.java
@Override public void update() throws BankException, LoginException, BankChoiceException { super.update(); if (username == null || password == null || username.length() == 0 || password.length() == 0) { throw new LoginException(res.getText(R.string.invalid_username_password).toString()); }/* w w w. j a va 2 s . c om*/ urlopen = login(); String response = null; Matcher matcher; try { response = urlopen.open("https://mobil.nordea.se/banking-nordea/nordea-c3/accounts.html"); matcher = reAccounts.matcher(response); while (matcher.find()) { accounts.add(new Account(Html.fromHtml(matcher.group(2)).toString().trim(), Helpers.parseBalance(matcher.group(3)), matcher.group(1).trim())); } /* * Capture groups: * GROUP EXAMPLE DATA * 1: Currency SEK * 2: Amount 56,78 * */ matcher = reBalance.matcher(response); String currency = "SEK"; if (matcher.find()) { balance = Helpers.parseBalance(matcher.group(2)); currency = Html.fromHtml(matcher.group(1)).toString().trim(); } this.setCurrency(currency); response = urlopen.open("https://mobil.nordea.se/banking-nordea/nordea-c3/funds/portfolio/funds.html"); matcher = reFundsLoans.matcher(response); while (matcher.find()) { accounts.add(new Account(Html.fromHtml(matcher.group(2)).toString().trim(), Helpers.parseBalance(matcher.group(3)), "f:" + matcher.group(1).trim(), -1L, Account.FUNDS)); } response = urlopen.open("https://mobil.nordea.se/banking-nordea/nordea-c3/accounts.html?type=lan"); matcher = reFundsLoans.matcher(response); while (matcher.find()) { accounts.add(new Account(Html.fromHtml(matcher.group(2)).toString().trim(), Helpers.parseBalance(matcher.group(3)), "l:" + matcher.group(1).trim(), -1L, Account.LOANS)); } response = urlopen.open("https://mobil.nordea.se/banking-nordea/nordea-c3/card/list.html"); matcher = reCards.matcher(response); while (matcher.find()) { accounts.add(new Account(Html.fromHtml(matcher.group(2)).toString().trim(), Helpers.parseBalance(matcher.group(3)), "c:" + matcher.group(1).trim(), -1L, Account.CCARD)); } 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(); } // Demo account to use with screenshots //accounts.add(new Account("Personkonto", Helpers.parseBalance("7953.37"), "1")); //accounts.add(new Account("Kapitalkonto", Helpers.parseBalance("28936.08"), "0")); }
From source file:com.liato.bankdroid.banking.banks.payson.Payson.java
@Override public void update() throws BankException, LoginException, BankChoiceException { super.update(); if (username == null || password == null || username.length() == 0 || password.length() == 0) { throw new LoginException(res.getText(R.string.invalid_username_password).toString()); }/*from w w w. j a v a2 s.c o m*/ urlopen = login(); try { HttpResponse httpResponse = urlopen.openAsHttpResponse( String.format("https://www.payson.se/myaccount/User/GetUserInfo?DateTime=%s", System.currentTimeMillis()), new ArrayList<NameValuePair>(), false); User user = readJsonValue(httpResponse, User.class); httpResponse = urlopen.openAsHttpResponse(String.format( "https://www.payson.se/myaccount/History/List2?rows=40&page=1&sidx=&sord=asc&freeTextSearchString=&take=40¤cy=&timeSpanStartDate=&timeSpanEndDate=&minAmount=&maxAmount=&purchaseType=&purchasePart=&purchaseStatus=&_=%s", System.currentTimeMillis()), new ArrayList<NameValuePair>(), false); TransactionHistory thistory = readJsonValue(httpResponse, TransactionHistory.class); Account account = new Account("Saldo", Helpers.parseBalance(user.getBalance()), "1"); String currency = Helpers.parseCurrency(user.getBalance(), "SEK"); account.setCurrency(currency); setCurrency(currency); accounts.add(account); balance = balance.add(account.getBalance()); if (thistory != null && thistory.getRows() != null) { ArrayList<Transaction> transactions = new ArrayList<Transaction>(); for (com.liato.bankdroid.banking.banks.payson.model.Transaction transaction : thistory.getRows()) { String date = transaction.getCreatedDate().substring(0, 10); String description = !TextUtils.isEmpty(transaction.getMessage()) ? transaction.getMessage() : transaction.getSummary(); Transaction t = new Transaction(date, Html.fromHtml(description).toString(), Helpers.parseBalance(transaction.getAmount())); t.setCurrency(Helpers.parseCurrency(transaction.getCurrencySymbol(), account.getCurrency())); transactions.add(t); } account.setTransactions(transactions); } if (accounts.isEmpty()) { throw new BankException(res.getText(R.string.no_accounts_found).toString()); } } catch (JsonParseException e) { e.printStackTrace(); throw new BankException(e.getMessage()); } catch (ClientProtocolException e) { e.printStackTrace(); throw new BankException(e.getMessage()); } catch (IOException e) { e.printStackTrace(); throw new BankException(e.getMessage()); } super.updateComplete(); }
From source file:com.liato.bankdroid.banking.banks.ICABanken.java
@Override public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException { super.updateTransactions(account, urlopen); String response = null;/*w w w . j a va 2 s .co m*/ Matcher matcher; try { response = urlopen.open("https://mobil2.icabanken.se/account/account.aspx?id=" + account.getId()); matcher = reTransactions.matcher(response); ArrayList<Transaction> transactions = new ArrayList<Transaction>(); while (matcher.find()) { transactions.add(new Transaction(matcher.group(2).trim().substring(8), Html.fromHtml(matcher.group(1)).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(); } finally { super.updateComplete(); } }