Java Code Examples for com.getpebble.android.kit.util.PebbleDictionary#addUint32()

The following examples show how to use com.getpebble.android.kit.util.PebbleDictionary#addUint32() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PebbleDisplayStandard.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
private PebbleDictionary buildDictionary() {
    PebbleDictionary dictionary = new PebbleDictionary();
    TimeZone tz = TimeZone.getDefault();
    Date now = new Date();
    int offsetFromUTC = tz.getOffset(now.getTime());

    final String bgDelta = getBgDelta();
    final String bgReadingS = getBgReading();
    final String slopeOrdinal = getSlopeOrdinal();
    //boolean no_signal;

    if (use_best_glucose) {
        Log.v(TAG, "buildDictionary: slopeOrdinal-" + slopeOrdinal + " bgReading-" + bgReadingS + //
                " now-" + (int) now.getTime() / 1000 + " bgTime-" + (int) (dg.timestamp / 1000) + //
                " phoneTime-" + (int) (new Date().getTime() / 1000) + " getBgDelta-" + getBgDelta());
        //   no_signal = (dg.mssince > Home.stale_data_millis());
    } else {
        Log.v(TAG, "buildDictionary: slopeOrdinal-" + slopeOrdinal + " bgReading-" + bgReadingS + //
                " now-" + (int) now.getTime() / 1000 + " bgTime-" + (int) (this.bgReading.timestamp / 1000) + //
                " phoneTime-" + (int) (new Date().getTime() / 1000) + " getBgDelta-" + getBgDelta());
        //   no_signal = ((new Date().getTime()) - Home.stale_data_millis() - this.bgReading.timestamp > 0);
    }

    dictionary.addString(ICON_KEY, slopeOrdinal);
    dictionary.addString(BG_KEY, bgReadingS);

    if (use_best_glucose) {
        dictionary.addUint32(RECORD_TIME_KEY, (int) (((dg.timestamp + offsetFromUTC) / 1000)));
    } else {
        dictionary.addUint32(RECORD_TIME_KEY, (int) (((this.bgReading.timestamp + offsetFromUTC) / 1000)));
    }

    dictionary.addUint32(PHONE_TIME_KEY, (int) ((new Date().getTime() + offsetFromUTC) / 1000));
    dictionary.addString(BG_DELTA_KEY, bgDelta);

    addBatteryStatusToDictionary(dictionary);

    return dictionary;
}
 
Example 2
Source File: PebbleDisplayStandard.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private PebbleDictionary buildDictionary() {
    PebbleDictionary dictionary = new PebbleDictionary();
    TimeZone tz = TimeZone.getDefault();
    Date now = new Date();
    int offsetFromUTC = tz.getOffset(now.getTime());

    final String bgDelta = getBgDelta();
    final String bgReadingS = getBgReading();
    final String slopeOrdinal = getSlopeOrdinal();
    //boolean no_signal;

    if (use_best_glucose) {
        Log.v(TAG, "buildDictionary: slopeOrdinal-" + slopeOrdinal + " bgReading-" + bgReadingS + //
                " now-" + (int) now.getTime() / 1000 + " bgTime-" + (int) (dg.timestamp / 1000) + //
                " phoneTime-" + (int) (new Date().getTime() / 1000) + " getBgDelta-" + getBgDelta());
        //   no_signal = (dg.mssince > Home.stale_data_millis());
    } else {
        Log.v(TAG, "buildDictionary: slopeOrdinal-" + slopeOrdinal + " bgReading-" + bgReadingS + //
                " now-" + (int) now.getTime() / 1000 + " bgTime-" + (int) (this.bgReading.timestamp / 1000) + //
                " phoneTime-" + (int) (new Date().getTime() / 1000) + " getBgDelta-" + getBgDelta());
        //   no_signal = ((new Date().getTime()) - Home.stale_data_millis() - this.bgReading.timestamp > 0);
    }

    dictionary.addString(ICON_KEY, slopeOrdinal);
    dictionary.addString(BG_KEY, bgReadingS);

    if (use_best_glucose) {
        dictionary.addUint32(RECORD_TIME_KEY, (int) (((dg.timestamp + offsetFromUTC) / 1000)));
    } else {
        dictionary.addUint32(RECORD_TIME_KEY, (int) (((this.bgReading.timestamp + offsetFromUTC) / 1000)));
    }

    dictionary.addUint32(PHONE_TIME_KEY, (int) ((new Date().getTime() + offsetFromUTC) / 1000));
    dictionary.addString(BG_DELTA_KEY, bgDelta);

    addBatteryStatusToDictionary(dictionary);

    return dictionary;
}
 
Example 3
Source File: PebbleSync.java    From NightWatch with GNU General Public License v3.0 5 votes vote down vote up
public PebbleDictionary buildDictionary() {
    PebbleDictionary dictionary = new PebbleDictionary();
    TimeZone tz = TimeZone.getDefault();
    Date now = new Date();
    int offsetFromUTC = tz.getOffset(now.getTime());
    Log.v(TAG, "buildDictionary: slopeOrdinal-" + slopeOrdinal() + " bgReading-" + bgReading() + " now-"+ (int) now.getTime()/1000 + " bgTime-" + (int) (mBgReading.datetime / 1000) + " phoneTime-" + (int) (new Date().getTime() / 1000) + " bgDelta-" + bgDelta());
    dictionary.addString(ICON_KEY, slopeOrdinal());
    dictionary.addString(BG_KEY, bgReading());
    dictionary.addUint32(RECORD_TIME_KEY, (int) (((mBgReading.datetime + offsetFromUTC) / 1000)));
    dictionary.addUint32(PHONE_TIME_KEY, (int) ((new Date().getTime() + offsetFromUTC) / 1000));
    dictionary.addString(BG_DELTA_KEY, bgDelta());
    dictionary.addString(UPLOADER_BATTERY_KEY, phoneBattery());
    dictionary.addString(NAME_KEY, "Phone");
    return dictionary;
}
 
Example 4
Source File: PebbleSync.java    From NightWatch with GNU General Public License v3.0 5 votes vote down vote up
public PebbleDictionary buildDictionary() {
    PebbleDictionary dictionary = new PebbleDictionary();
    TimeZone tz = TimeZone.getDefault();
    Date now = new Date();
    int offsetFromUTC = tz.getOffset(now.getTime());
    Log.v(TAG, "buildDictionary: slopeOrdinal-" + slopeOrdinal() + " bgReading-" + bgReading() + " now-"+ (int) now.getTime()/1000 + " bgTime-" + (int) (mBgReading.datetime / 1000) + " phoneTime-" + (int) (new Date().getTime() / 1000) + " bgDelta-" + bgDelta());
    dictionary.addString(ICON_KEY, slopeOrdinal());
    dictionary.addString(BG_KEY, bgReading());
    dictionary.addUint32(RECORD_TIME_KEY, (int) (((mBgReading.datetime + offsetFromUTC) / 1000)));
    dictionary.addUint32(PHONE_TIME_KEY, (int) ((new Date().getTime() + offsetFromUTC) / 1000));
    dictionary.addString(BG_DELTA_KEY, bgDelta());
    dictionary.addString(UPLOADER_BATTERY_KEY, phoneBattery());
    dictionary.addString(NAME_KEY, "Phone");
    return dictionary;
}
 
Example 5
Source File: PebbleSync.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public PebbleDictionary buildDictionary() {
    PebbleDictionary dictionary = new PebbleDictionary();
    dictionary.addString(ICON_KEY, slopeOrdinal());
    dictionary.addString(BG_KEY, bgReading());
    dictionary.addUint32(RECORD_TIME_KEY, (int) (mBgReading.timestamp / 1000));
    dictionary.addUint32(PHONE_TIME_KEY, (int) (new Date().getTime() / 1000));
    dictionary.addString(BG_DELTA_KEY, bgDelta());
    dictionary.addString(UPLOADER_BATTERY_KEY, phoneBattery());
    dictionary.addString(NAME_KEY, "xDrip");
    return dictionary;
}
 
Example 6
Source File: PebbleDataReceiverTest.java    From JayPS-AndroidApp with MIT License 5 votes vote down vote up
@SmallTest
public void testReceiveDataWithORUXMAPS_START_RECORD_CONTINUE_PRESSStartsRecord() {
    PebbleDictionary dic = new PebbleDictionary();
    dic.addUint32(Constants.CMD_BUTTON_PRESS, Constants.ORUXMAPS_START_RECORD_CONTINUE_PRESS);

    _pebbleDataReceiver.receiveData(_mockContext,12345,dic);

    verify(_mockOruxMaps,times(1)).startRecordNewSegment();
}
 
Example 7
Source File: PebbleDataReceiverTest.java    From JayPS-AndroidApp with MIT License 5 votes vote down vote up
@SmallTest
public void testReceiveDataWithORUXMAPS_STOP_RECORD_PRESSStartsRecord() {
    PebbleDictionary dic = new PebbleDictionary();
    dic.addUint32(Constants.CMD_BUTTON_PRESS, Constants.ORUXMAPS_STOP_RECORD_PRESS);

    _pebbleDataReceiver.receiveData(_mockContext,12345,dic);

    verify(_mockOruxMaps,times(1)).stopRecord();
}
 
Example 8
Source File: PebbleDataReceiverTest.java    From JayPS-AndroidApp with MIT License 5 votes vote down vote up
@SmallTest
public void testReceiveDataWithORUXMAPS_NEW_WAYPOINT_PRESSAddsNewWaypoint() {
    PebbleDictionary dic = new PebbleDictionary();
    dic.addUint32(Constants.CMD_BUTTON_PRESS, Constants.ORUXMAPS_NEW_WAYPOINT_PRESS);

    _pebbleDataReceiver.receiveData(_mockContext,12345,dic);

    verify(_mockOruxMaps,times(1)).newWaypoint();
}
 
Example 9
Source File: PebbleDataReceiverTest.java    From JayPS-AndroidApp with MIT License 5 votes vote down vote up
@SmallTest
public void testReceiveDataWithSTOP_PRESSStopsLocationServices() {
    PebbleDictionary dic = new PebbleDictionary();
    dic.addUint32(Constants.CMD_BUTTON_PRESS, Constants.STOP_PRESS);

    _pebbleDataReceiver.receiveData(_mockContext,12345,dic);

    verify(_mockServiceStarter,times(1)).stopLocationServices();
}
 
Example 10
Source File: PebbleDataReceiverTest.java    From JayPS-AndroidApp with MIT License 5 votes vote down vote up
@SmallTest
public void testReceiveDataWithPLAY_PRESSStartsLocationServices() {
    PebbleDictionary dic = new PebbleDictionary();
    dic.addUint32(Constants.CMD_BUTTON_PRESS, Constants.PLAY_PRESS);

    _pebbleDataReceiver.receiveData(_mockContext,12345,dic);

    verify(_mockServiceStarter,times(1)).startLocationServices();
}
 
Example 11
Source File: PebbleDataReceiverTest.java    From JayPS-AndroidApp with MIT License 5 votes vote down vote up
@SmallTest
public void testReceiveDataWithREFRESH_PRESSRefreshLocationServices() throws InterruptedException {
    PebbleDictionary dic = new PebbleDictionary();
    dic.addUint32(Constants.CMD_BUTTON_PRESS, Constants.REFRESH_PRESS);

    _pebbleDataReceiver.receiveData(_mockContext,12345,dic);

    _stateLatch.await(1000, TimeUnit.MILLISECONDS);
    assertNotNull(_refreshEvent);
}
 
Example 12
Source File: PebbleDataReceiverTest.java    From JayPS-AndroidApp with MIT License 5 votes vote down vote up
@SmallTest
public void testReceiveDataWithREFRESH_PRESSResetsSavedData() throws InterruptedException {
    PebbleDictionary dic = new PebbleDictionary();
    dic.addUint32(Constants.CMD_BUTTON_PRESS, Constants.REFRESH_PRESS);

    _pebbleDataReceiver.receiveData(_mockContext,12345,dic);

    _stateLatch.await(1000, TimeUnit.MILLISECONDS);
    verify(_mockDataStore,times(1)).resetAllValues();
    verify(_mockDataStore,times(1)).commit();
}