Android Open Source - ccardstats Notification Reader






From Project

Back to project page ccardstats.

License

The source code is released under:

GNU General Public License

If you think the Android project ccardstats 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.github.marwinxxii.ccardstats.notifications;
// w  ww.j  a v  a 2 s. co  m
import java.util.HashMap;

import com.github.marwinxxii.ccardstats.db.DBHelper;

import android.content.Context;
import android.database.Cursor;
import android.util.Log;

public class NotificationReader extends SmsReader {

    private DBHelper helper;
    private static String[] addresses;

    public NotificationReader(Context context, DBHelper helper) {
        super(context);
        this.helper = helper;
        if (addresses == null) {
            addresses = new String[NotificationService.SERVICES.length];
            for (int i = 0; i < NotificationService.SERVICES.length; i++) {
                addresses[i] = NotificationService.SERVICES[i].getAddress();
            }
        }
    }

    public void readNotificationsToDB() {
        Cursor cursor = query(new String[] { BODY }, ADDRESS + " in (?)",
                addresses, DATE + " asc");
        HashMap<String, Double> cards = new HashMap<String, Double>();
        while (cursor.moveToNext()) {
            SmsNotification notif = SmsParser.parse(cursor.getString(0));
            if (notif == null)
                continue;
            helper.addNotification(notif);
            cards.put(notif.card, notif.balance);
            Log.d("nr", notif.diff + "/" + notif.balance);
        }
        for (String name : cards.keySet()) {
            helper.saveCard(name, name, cards.get(name));
        }
        cursor.close();
    }

}




Java Source Code List

com.github.marwinxxii.ccardstats.Application.java
com.github.marwinxxii.ccardstats.SmsReceiver.java
com.github.marwinxxii.ccardstats.db.Card.java
com.github.marwinxxii.ccardstats.db.DBHelper.java
com.github.marwinxxii.ccardstats.gui.CardListActivity.java
com.github.marwinxxii.ccardstats.gui.GetStatsTask.java
com.github.marwinxxii.ccardstats.gui.ListActivity.java
com.github.marwinxxii.ccardstats.gui.MonthStatsActivity.java
com.github.marwinxxii.ccardstats.gui.PreferencesActivity.java
com.github.marwinxxii.ccardstats.gui.SimpleListActivity.java
com.github.marwinxxii.ccardstats.gui.TextMappingAdapter.java
com.github.marwinxxii.ccardstats.gui.YearStatsActivity.java
com.github.marwinxxii.ccardstats.helpers.DateHelper.java
com.github.marwinxxii.ccardstats.helpers.MoneyHelper.java
com.github.marwinxxii.ccardstats.notifications.NotificationReader.java
com.github.marwinxxii.ccardstats.notifications.NotificationService.java
com.github.marwinxxii.ccardstats.notifications.SberbankService.java
com.github.marwinxxii.ccardstats.notifications.SmsNotification.java
com.github.marwinxxii.ccardstats.notifications.SmsParser.java
com.github.marwinxxii.ccardstats.notifications.SmsReader.java