Android Open Source - VirginMobileMinutesChecker Reference Scraper






From Project

Back to project page VirginMobileMinutesChecker.

License

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.

Java Source Code

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>", "");
    }

}




Java Source Code List

.MinutesBarGraph.java
com.baker.vm.PreferencesUtil.java
com.baker.vm.ScraperUtil.java
com.baker.vm.UsernamePassword.java
com.baker.vm.VMAccount.java
com.baker.vm.service.NotifyRemainingMinutes.java
com.baker.vm.ui.AboutActivity.java
com.baker.vm.ui.FetchAccountTask.java
com.baker.vm.ui.MinutesGraphDrawable.java
com.baker.vm.ui.MinutesPieGraphDrawable.java
com.baker.vm.ui.MultipleAccountsActivity.java
com.baker.vm.widget.PieGraphWidget.java
com.baker.vm.widget.Simple2x1Widget.java
com.baker.vm.widget.WidgetUtil.java
com.drfloob.VirginMobileMinutesChecker.call_trigger.CallEventReceiver.java
com.drfloob.VirginMobileMinutesChecker.call_trigger.MinutesService.java
com.jaygoel.virginminuteschecker.IVMCScraper.java
com.jaygoel.virginminuteschecker.MinutesChecker.java
com.jaygoel.virginminuteschecker.Preferences.java
com.jaygoel.virginminuteschecker.ReferenceScraper.java
com.jaygoel.virginminuteschecker.UpdateService.java
com.jaygoel.virginminuteschecker.ViewMinutes.java
com.jaygoel.virginminuteschecker.WebsiteScraper.java
com.jaygoel.virginminuteschecker.Widget.java