Android Open Source - SDCardTrac Delta Compute






From Project

Back to project page SDCardTrac.

License

The source code is released under:

GNU General Public License

If you think the Android project SDCardTrac 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

/*
 * SDCardTrac application - keeps track of the /sdcard usage
 * Copyright (C) 2012 Narendra M.A.// w w  w  .j a  va2s  .co m
*/

package com.nma.util.sdcardtrac;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;

// Class which wakes up based on alarms and triggers database update
// Also wakes up on boot up

public class DeltaCompute extends BroadcastReceiver {
  // Alarm
  AlarmHelper alarmHelp;

  @Override
  public void onReceive(Context ctx, Intent intent) {
    Log.d(getClass().getName(), "Triggered by <" + intent.getAction() + ">...");
    String intentName;
    
    if (intent.getAction() != null) {
      intentName = intent.getAction();
    } else {
      intentName = "NO_INTENT";
    }
    
    if (intentName.equals(Intent.ACTION_BOOT_COMPLETED)) {
      // Setup the alarms if triggered on boot
      // Get preferences first to determine the alarm parameters
      SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
      // Get configuration
      int startOffset = prefs.getInt("AlarmStartOffset", // UNUSED
                    SettingsActivity.DEFAULT_START_OFFSET_SEC);
            String trigPref = prefs.getString(SettingsActivity.STORE_TRIGGER_KEY, null);
      long triggerInterval;

            if (trigPref != null)
                triggerInterval = Long.parseLong(trigPref);
            else
                triggerInterval = SettingsActivity.DEFAULT_UPDATE_INTERVAL_MSEC;

      boolean alarmEnb = prefs.getBoolean(SettingsActivity.ALARM_RUNNING_KEY, false);

      if (alarmEnb) {
        alarmHelp = new AlarmHelper(ctx);
        alarmHelp.manageAlarm(true, false, startOffset, triggerInterval);

        /*SharedPreferences.Editor prefEdit = prefs.edit();
        prefEdit.putBoolean(, true);
        prefEdit.apply();*/

        Log.d(getClass().getName(), "Enabled alarms after boot!");
      }
    } else {
      // Trigger data collection if normal alarm
      Intent triggerCollect = new Intent(ctx, FileObserverService.class);
      if (intentName.equals(Intent.ACTION_MEDIA_MOUNTED)) {
        triggerCollect.setAction(Intent.ACTION_SYNC);
      } else {
        triggerCollect.setAction(Intent.ACTION_VIEW);
      }
      ctx.startService(triggerCollect); // TODO: Wake lock to be managed by service!
    }
  }
}




Java Source Code List

com.jjoe64.graphview.BarGraphView.java
com.jjoe64.graphview.CustomLabelFormatter.java
com.jjoe64.graphview.GraphViewDataInterface.java
com.jjoe64.graphview.GraphViewSeries.java
com.jjoe64.graphview.GraphViewStyle.java
com.jjoe64.graphview.GraphView.java
com.jjoe64.graphview.LineGraphView.java
com.jjoe64.graphview.ValueDependentColor.java
com.jjoe64.graphview.compatible.RealScaleGestureDetector.java
com.jjoe64.graphview.compatible.ScaleGestureDetector.java
com.nma.util.sdcardtrac.AlarmHelper.java
com.nma.util.sdcardtrac.BitcoinIntegration.java
com.nma.util.sdcardtrac.ChangeLogFragment.java
com.nma.util.sdcardtrac.DatabaseLoader.java
com.nma.util.sdcardtrac.DatabaseManager.java
com.nma.util.sdcardtrac.DeleteDataPreference.java
com.nma.util.sdcardtrac.DeltaCompute.java
com.nma.util.sdcardtrac.FileObserverService.java
com.nma.util.sdcardtrac.GraphActivity.java
com.nma.util.sdcardtrac.GraphFragment.java
com.nma.util.sdcardtrac.GraphTabListener.java
com.nma.util.sdcardtrac.HelpFragment.java
com.nma.util.sdcardtrac.MyExpandableListAdapter.java
com.nma.util.sdcardtrac.SQLiteHelper.java
com.nma.util.sdcardtrac.SearchableActivity.java
com.nma.util.sdcardtrac.SettingsActivity.java
com.nma.util.sdcardtrac.StorageHelper.java
com.nma.util.sdcardtrac.UsageFileObserver.java