Skip to content

Commit

Permalink
Add last_send_previous to PersistentStore to cache btw restarts
Browse files Browse the repository at this point in the history
  • Loading branch information
kskandis committed Oct 19, 2016
1 parent a5a72c6 commit adea4f1
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;

import com.eveningoutpost.dexdrip.UtilityModels.PersistentStore;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
Expand Down Expand Up @@ -75,6 +76,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp
public static boolean mLocationPermissionApproved;//KS
public static long last_send_previous = 0;//KS
public static long last_send_sucess = 0;//KS
public static String pref_last_send_previous = "last_send_previous";

GoogleApiClient googleApiClient;
private static long lastRequest = 0;
Expand Down Expand Up @@ -379,6 +381,8 @@ public void onPeerDisconnected(Node peer) {//KS
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(TAG, "onStartCommand entered");
Home.setAppContext(getApplicationContext());
xdrip.checkAppContext(getApplicationContext());
last_send_previous = PersistentStore.getLong(pref_last_send_previous); // 0 if undef
mPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());//KS
listenForChangeInSettings();//KS
//sendPrefSettings();
Expand Down Expand Up @@ -450,7 +454,8 @@ public void onDataChanged(DataEventBuffer dataEvents) {
getApplicationContext().startActivity(intent);
} else if (path.equals(SYNC_DB_PATH)) {//KS
Log.d(TAG, "onDataChanged SYNC_DB_PATH=" + path);
Sensor.DeleteAndInitDb(getApplicationContext());//KS TODO test
Sensor.DeleteAndInitDb(getApplicationContext());
PersistentStore.setLong(pref_last_send_previous, 0);
} else if (path.equals(WEARABLE_SENSOR_DATA_PATH)) {//KS
dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap();
Log.d(TAG, "onDataChanged path=" + path + " DataMap=" + dataMap);
Expand Down Expand Up @@ -479,6 +484,7 @@ public void onDataChanged(DataEventBuffer dataEvents) {
date.setTime(timeOfLastBG);
Log.d(TAG, "onDataChanged received from sendDataReceived timeOfLastBG=" + df.format(date) + " Path=" + path);
last_send_previous = timeOfLastBG;
PersistentStore.setLong(pref_last_send_previous, last_send_previous);
date.setTime(last_send_previous);
Log.d(TAG, "onDataChanged received from sendDataReceived update last_send_previous=" + df.format(date));
}
Expand Down

0 comments on commit adea4f1

Please sign in to comment.