Back to project page VirginMobileMinutesChecker.
The source code is released under:
Copyright 2011 Jay Goel. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Red...
If you think the Android project VirginMobileMinutesChecker listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.jaygoel.virginminuteschecker; //from w w w .j av a2 s. c om public class ReferenceScraper implements IVMCScraper { /* usage note: don't call any other method if the page data is invalid */ @Override public boolean isValid(final String str) { if (str.indexOf("<p class=\"tel\">") < 0) { return false; } return true; } @Override public String getPhoneNumber(final String str) { String srch = "<p class=\"tel\">"; int start = str.indexOf(srch); int end = str.indexOf("</p>", start); return str.substring(start + srch.length(), end); } @Override public String getMonthlyCharge(final String str) { String srch = "<h3>Next Month's Charge</h3><p>"; int start = str.indexOf(srch); int end = str.indexOf("</p>", start); return str.substring(start + srch.length(), end); } @Override public String getCurrentBalance(final String str) { String srch = "<h3>Current Balance</h3><p>"; int start = str.indexOf(srch); int end = str.indexOf("</p>", start); return str.substring(start + srch.length(), end); } @Override public String getMinAmountDue(final String str) { String srch = "<h3>Min. Amount Due</h3><p>"; int start = str.indexOf(srch); int end = str.indexOf("</p>", start); if ((start > 0) && (end > 0)) { return str.substring(start + srch.length(), end); } else { // throw error? return null; } } @Override public String getDateDue(final String str) { String srch = "<h3>Date Due</h3><p>"; int start = str.indexOf(srch); int end = str.indexOf("</p>", start); if ((start > 0) && (end > 0)) { return str.substring(start + srch.length(), end); } else { // throw error? return null; } } @Override public String getChargedOn(final String str) { // VM seems to waffle between "Date Due" and "Charged On" return getDateDue(str); } @Override public String getMinutesUsed(final String str) { String srch = "<p id=\"remaining_minutes\"><strong>"; int start = str.indexOf(srch); int end = str.indexOf("</p>", start); return str.substring(start + srch.length(), end).replaceFirst( "</strong>", ""); } }