Android Open Source - trafficcop Log Data Usage Alert Listener






From Project

Back to project page trafficcop.

License

The source code is released under:

Apache License

If you think the Android project trafficcop 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.willowtreeapps.trafficcop;
//w w  w . ja v  a 2 s .  c om
import android.util.Log;

/**
 * A simple implementation of {@link DataUsageAlertListener} that just logs the alert as an error
 * when triggered.
 */
public class LogDataUsageAlertListener implements DataUsageAlertListener {
    private static final String TAG = "DataUsageWarning";

    private String tag;

    /**
     * Constructs a new listener that logs with the default tag "DataUsageWarning".
     */
    public LogDataUsageAlertListener() {
        this.tag = TAG;
    }

    /**
     * Constructs a new listener that logs with the given tag.
     *
     * @param tag the tag to log at.
     */
    public LogDataUsageAlertListener(String tag) {
        if (tag == null) {
            throw new IllegalArgumentException("tag cannot be null");
        }
        this.tag = tag;
    }

    @Override
    public void alertThreshold(Threshold threshold, DataUsage dataUsage) {
        Log.e(tag, dataUsage.getWarningMessage());
    }
}




Java Source Code List

com.willowtreeapps.trafficcop.DataUsageAlertListener.java
com.willowtreeapps.trafficcop.DataUsageStatsProvider.java
com.willowtreeapps.trafficcop.DataUsage.java
com.willowtreeapps.trafficcop.LogDataUsageAlertListener.java
com.willowtreeapps.trafficcop.SizeUnit.java
com.willowtreeapps.trafficcop.Threshold.java
com.willowtreeapps.trafficcop.TimeUnit.java
com.willowtreeapps.trafficcop.TrafficCop.java