Android Open Source - VirginMobileMinutesChecker Scraper Util






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

/**
 */*www.  java2  s .co m*/
 */
package com.baker.vm;

import android.util.Log;

import com.jaygoel.virginminuteschecker.IVMCScraper;
import com.jaygoel.virginminuteschecker.ReferenceScraper;
import com.jaygoel.virginminuteschecker.WebsiteScraper;

/**
 * @author baker
 *
 */
public final class ScraperUtil
{
    private static final String TAG = "ScraperUtil";

    private ScraperUtil()
    {

    }

    public static VMAccount scrape(final UsernamePassword a)
    {
        return scrape(a, new ReferenceScraper());
    }

    public static VMAccount scrape(final UsernamePassword a,
                                   final IVMCScraper scraper)
    {
        VMAccount acct = null;

        if (a.pass != null && a.pass.length() != 0)
        {
            try
            {
                final String html= WebsiteScraper.fetchScreen(a.user, a.pass);
                Log.d(TAG, html);

                if (scraper.isValid(html))
                {
                    Log.d(TAG, "valid");
                    acct = new VMAccount(a, html, scraper);
                }
                else
                {
                    Log.d(TAG, "invalid: " + a.user);
                    acct = VMAccount.createInvalid(a);
                }
            }
            catch (Exception ex)
            {
                Log.e(TAG, "Failed to fetch virgin mobile info: " + a.user);
            }
        }

        return acct;
    }
}




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