本文整理汇总了Java中com.getpebble.android.kit.util.PebbleDictionary.addInt32方法的典型用法代码示例。如果您正苦于以下问题:Java PebbleDictionary.addInt32方法的具体用法?Java PebbleDictionary.addInt32怎么用?Java PebbleDictionary.addInt32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.getpebble.android.kit.util.PebbleDictionary
的用法示例。
在下文中一共展示了PebbleDictionary.addInt32方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetBytesLeft
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
@Test
public void testGetBytesLeft() throws Exception
{
PebbleCapabilities testCapabilities = new PebbleCapabilities(false, false, false, false, false, 100);
PebbleDictionary testDictionary = new PebbleDictionary();
assertEquals(92, PebbleUtil.getBytesLeft(testDictionary, testCapabilities));
testDictionary.addInt8(1, (byte) 20);
assertEquals(84, PebbleUtil.getBytesLeft(testDictionary, testCapabilities));
testDictionary.addInt32(2, 20);
assertEquals(73, PebbleUtil.getBytesLeft(testDictionary, testCapabilities));
testDictionary.addBytes(3, new byte[]{1, 2, 3, 4});
assertEquals(62, PebbleUtil.getBytesLeft(testDictionary, testCapabilities));
testDictionary.addString(4, "abcde");
assertEquals(50, PebbleUtil.getBytesLeft(testDictionary, testCapabilities));
testDictionary.addUint32(1, 20);
assertEquals(47, PebbleUtil.getBytesLeft(testDictionary, testCapabilities));
}
示例2: sendWatchappIcon
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private boolean sendWatchappIcon()
{
Timber.d("Sending icon");
PebbleDictionary data = new PebbleDictionary();
data.addUint8(0, (byte) 1);
data.addUint8(1, (byte) 2);
data.addInt32(2, curSendingNotification.id);
curSendingNotification.needsIconSending = false;
// Only send icon if it can fit into one Appmessage
if (curSendingNotification.iconData.length <= PebbleUtil.getBytesLeft(data, getService().getPebbleCommunication().getConnectedWatchCapabilities()))
{
data.addBytes(3, curSendingNotification.iconData);
getService().getPebbleCommunication().sendToPebble(data);
return true;
}
else
{
Timber.d("Sending failed! Icon cannot fit into AppMessage.");
return sendNextMessage(); //Icon sending failed, send next message in a row.
}
}
示例3: updateLocation
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
public void updateLocation(double lat, double lon, String name, int distance) {
// Log.d(TAG, "updateLocation " + lat + " " + lon + " '" + name + "'");
if (name.isEmpty())
name = String.format("%.4f,%.4f", lat, lon);
PebbleDictionary out = new PebbleDictionary();
out.addInt32(KEY_LAT, (int)Math.round(lat * 1000));
out.addInt32(KEY_LON, (int)Math.round(lon * 1000));
out.addString(KEY_LOCATION_NAME, name);
PebbleKit.sendDataToPebble(m_weatherService, WATCHAPP_UUID, out);
}
示例4: sendItem
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
/**
* Sends a message with the item
*
* @param e the item to send
* @param index the index in this sync
*/
private void sendItem(AgendaItem e, int index) {
PebbleDictionary data = new PebbleDictionary();
data.addUint8(PEBBLE_KEY_COMMAND, PEBBLE_COMMAND_ITEM); // command
data.addUint8(PEBBLE_KEY_ITEM_INDEX, (byte) index);
data.addString(PEBBLE_KEY_ITEM_TEXT1, e.line1 == null ? "" : stringToSendableString(e.line1.text));
data.addString(PEBBLE_KEY_ITEM_TEXT2, e.line2 == null ? "" : stringToSendableString(e.line2.text));
data.addUint8(PEBBLE_KEY_ITEM_DESIGN1, e.line1 == null ? 0 : getPebbleDesign(e.line1, 1));
data.addUint8(PEBBLE_KEY_ITEM_DESIGN2, e.line2 == null ? 0 : getPebbleDesign(e.line2, 2));
data.addInt32(PEBBLE_KEY_ITEM_START_TIME, e.getStartTimeInPebbleFormat());
data.addInt32(PEBBLE_KEY_ITEM_END_TIME, e.getEndTimeInPebbleFormat());
sendMessage(data, false);
}
示例5: sendFirstItemHalf
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
/**
* Sends a message with the first half of an item
* @param e the item to send
* @param index the index in this sync
*/
private void sendFirstItemHalf(AgendaItem e, int index) {
PebbleDictionary data = new PebbleDictionary();
data.addUint8(PEBBLE_KEY_COMMAND, PEBBLE_COMMAND_ITEM_1); // command
data.addUint8(PEBBLE_KEY_ITEM_INDEX, (byte) index);
data.addString(PEBBLE_KEY_ITEM_TEXT1, e.line1 == null ? "" : stringToSendableString(e.line1.text));
data.addUint8(PEBBLE_KEY_ITEM_DESIGN1, e.line1 == null ? 0 : getPebbleDesign(e.line1, 1));
data.addInt32(PEBBLE_KEY_ITEM_START_TIME, e.getStartTimeInPebbleFormat());
sendMessage(data, false);
}
示例6: sendSecondItemHalf
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
/**
* Sends a message with the first half of an item
* @param e the item to send
* @param index the index in this sync
*/
private void sendSecondItemHalf(AgendaItem e, int index) {
PebbleDictionary data = new PebbleDictionary();
data.addUint8(PEBBLE_KEY_COMMAND, PEBBLE_COMMAND_ITEM_2); // command
data.addUint8(PEBBLE_KEY_ITEM_INDEX, (byte) index);
data.addString(PEBBLE_KEY_ITEM_TEXT2, e.line2 == null ? "" : stringToSendableString(e.line2.text));
data.addUint8(PEBBLE_KEY_ITEM_DESIGN2, e.line2 == null ? 0 : getPebbleDesign(e.line2, 2));
data.addInt32(PEBBLE_KEY_ITEM_END_TIME, e.getEndTimeInPebbleFormat());
sendMessage(data, false);
}
示例7: testReceiveDataWithMSG_VERSION_PEBBLEAndVersionGreaterOrEqualThanCurrentDoesNotSendMessage
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
@SmallTest
public void testReceiveDataWithMSG_VERSION_PEBBLEAndVersionGreaterOrEqualThanCurrentDoesNotSendMessage() throws InterruptedException {
PebbleDictionary dic = new PebbleDictionary();
dic.addInt32(Constants.MSG_VERSION_PEBBLE, Constants.LAST_VERSION_PEBBLE);
_pebbleDataReceiver.receiveData(_mockContext,12345,dic);
verify(_mockMessageManager, timeout(1000).times(0)).sendMessageToPebble(any(String.class), any(String.class)); }
示例8: sendMoreText
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private void sendMoreText()
{
Timber.d("Sending more text... %d %d", curSendingNotification.id, curSendingNotification.nextChunkToSend);
PebbleDictionary data = new PebbleDictionary();
data.addUint8(0, (byte) 1);
data.addUint8(1, (byte) 1);
data.addInt32(2, curSendingNotification.id);
data.addBytes(3, curSendingNotification.textChunks.get(curSendingNotification.nextChunkToSend));
getService().getPebbleCommunication().sendToPebble(data);
curSendingNotification.nextChunkToSend++;
}
示例9: sendDismiss
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private void sendDismiss(Integer id)
{
Timber.d("Dismissing upwards %d", id);
PebbleDictionary data = new PebbleDictionary();
data.addUint8(0, (byte) 3);
data.addUint8(1, (byte) 0);
data.addInt32(2, id);
data.addUint8(3, (byte) (NotificationSendingModule.get(getService()).isAnyNotificationWaiting() ? 1 : 0));
getService().getPebbleCommunication().sendToPebble(data);
}
示例10: sendDataToPebble
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private void sendDataToPebble(String formattedWorktime) {
PebbleDictionary data = new PebbleDictionary();
data.addString(2, formattedWorktime);
data.addInt32(3, getBatteryLevel());
PebbleKit.sendDataToPebble(mContext, PEBBLE_APP_UUID, data);
}
示例11: sendMessage
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
@Kroll.method
public void sendMessage(HashMap args)
{
Log.d(LCAT, "sendMessage");
if(!checkWatchConnected())
{
Log.w(LCAT, "sendMessage: No watch connected");
return;
}
final KrollFunction successCallback = (KrollFunction)args.get("success");
final KrollFunction errorCallback = (KrollFunction)args.get("error");
final Object message = args.get("message");
Map<Integer, Object> messageHash = (HashMap<Integer, Object>) message;
Iterator<Map.Entry<Integer, Object>> entries = messageHash.entrySet().iterator();
HashMap<String,KrollFunction> callbackArray = new HashMap<String,KrollFunction>();
PebbleDictionary data = new PebbleDictionary();
if(successCallback != null)
{
callbackArray.put("success", successCallback);
}
if(errorCallback != null)
{
callbackArray.put("error", errorCallback);
}
callbacks.put(transactionCounter, callbackArray);
while(entries.hasNext())
{
Map.Entry<Integer, Object> entry = entries.next();
if(entry.getValue() instanceof Integer)
{
data.addInt32((Integer) entry.getKey(), (Integer) entry.getValue());
} else if(entry.getValue() instanceof String) {
data.addString((Integer) entry.getKey(), (String) entry.getValue());
}
}
PebbleKit.sendDataToPebbleWithTransactionId(getApplicationContext(), uuid, data, transactionCounter);
transactionCounter++;
}
示例12: notifyPebbleGPSStarted
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private void notifyPebbleGPSStarted() {
//Log.i(TAG, "notifyPebbleGPSStarted");
PebbleDictionary dictionary = new PebbleDictionary();
dictionary.addInt32(Constants.STATE_CHANGED,Constants.STATE_START);
sendDataToPebble(dictionary);
}
示例13: notifyPebbleGPSStopped
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
private void notifyPebbleGPSStopped() {
//Log.i(TAG, "notifyPebbleGPSStopped");
PebbleDictionary dictionary = new PebbleDictionary();
dictionary.addInt32(Constants.STATE_CHANGED,Constants.STATE_STOP);
sendDataToPebble(dictionary);
}
示例14: sendSavedDataToPebble
import com.getpebble.android.kit.util.PebbleDictionary; //导入方法依赖的package包/类
@Override
public void sendSavedDataToPebble(boolean isLocationServicesRunning, int units, float distance, long elapsedTime, float ascent, float maxSpeed) {
// use AdvancedLocation and than NewLocation to use units conversion in AdvancedLocationToNewLocation
AdvancedLocation advancedLocation = new AdvancedLocation();
advancedLocation.setDistance(distance);
advancedLocation.setElapsedTime(elapsedTime);
advancedLocation.setAscent(ascent);
advancedLocation.setMaxSpeed(maxSpeed);
NewLocation newLocation = new AdvancedLocationToNewLocation(advancedLocation, 0, 0, units);
newLocation.setBatteryLevel(BatteryStatus.getBatteryLevel(_applicationContext));
newLocation.setSendNavigation(_navigator.getNbPoints() > 0);
// Get current version code
int versionCode = 0;
try {
PackageInfo packageInfo = _applicationContext.getPackageManager().getPackageInfo(_applicationContext.getPackageName(), 0);
versionCode = packageInfo.versionCode;
} catch (PackageManager.NameNotFoundException e) {
versionCode = 0;
}
PebbleDictionary dictionary = new NewLocationToPebbleDictionary(
newLocation,
_navigator,
isLocationServicesRunning,
_sharedPreferences.getBoolean("PREF_DEBUG", false),
_sharedPreferences.getBoolean("LIVE_TRACKING", false),
Integer.valueOf(_sharedPreferences.getString("REFRESH_INTERVAL", String.valueOf(Constants.REFRESH_INTERVAL_DEFAULT))),
_sharedPreferences.getInt("WATCHFACE_VERSION", 0),
_sharedPreferences.getBoolean("NAV_NOTIFICATION", false)
);
dictionary.addInt32(Constants.MSG_VERSION_ANDROID, versionCode);
try {
byte[] data_heartmax = new byte[2];
data_heartmax[0] = (byte) (Integer.valueOf(_sharedPreferences.getString("PREF_BLE_HRM_HRMAX", "0")) % 256);
data_heartmax[1] = (byte) (Integer.valueOf(_sharedPreferences.getString("PREF_BLE_HRM_ZONE_NOTIFICATION_MODE", "0")) % 256);
dictionary.addBytes(Constants.MSG_HR_MAX, data_heartmax);
} catch (NumberFormatException nfe) {}
offer(dictionary);
}