本文整理汇总了Java中com.matejdro.pebblecommons.vibration.PebbleVibrationPattern类的典型用法代码示例。如果您正苦于以下问题:Java PebbleVibrationPattern类的具体用法?Java PebbleVibrationPattern怎么用?Java PebbleVibrationPattern使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PebbleVibrationPattern类属于com.matejdro.pebblecommons.vibration包,在下文中一共展示了PebbleVibrationPattern类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testValidation
import com.matejdro.pebblecommons.vibration.PebbleVibrationPattern; //导入依赖的package包/类
@Test
public void testValidation()
{
assertFalse(PebbleVibrationPattern.validateVibrationPattern(""));
assertFalse(PebbleVibrationPattern.validateVibrationPattern("a"));
assertFalse(PebbleVibrationPattern.validateVibrationPattern("1, b, 3"));
assertTrue(PebbleVibrationPattern.validateVibrationPattern("1, 2, 3"));
assertTrue(PebbleVibrationPattern.validateVibrationPattern("100, 50, 1000"));
assertFalse(PebbleVibrationPattern.validateVibrationPattern("-100, 50, 1000"));
}
示例2: testParsing
import com.matejdro.pebblecommons.vibration.PebbleVibrationPattern; //导入依赖的package包/类
@Test
public void testParsing()
{
assertArrayEquals(new Byte[] { 0, 0 }, PebbleVibrationPattern.parseVibrationPattern("").toArray(new Byte[0]));
assertArrayEquals(new Byte[] { 10, 0, 10, 0 }, PebbleVibrationPattern.parseVibrationPattern("10, 10").toArray(new Byte[0]));
assertArrayEquals(new Byte[] { 0x10, 0x27 }, PebbleVibrationPattern.parseVibrationPattern("20000, 5000, 100, 20").toArray(new Byte[0]));
assertArrayEquals(
new Byte[] { 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20, 0 },
PebbleVibrationPattern.parseVibrationPattern("1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24").toArray(new Byte[0]));
}
示例3: getVibrationPattern
import com.matejdro.pebblecommons.vibration.PebbleVibrationPattern; //导入依赖的package包/类
private List<Byte> getVibrationPattern(ProcessedNotification notification, AppSettingStorage settingStorage)
{
Long lastVibration = lastAppVibration.get(notification.source.getKey().getPackage());
int minInterval = 0;
try
{
minInterval = Integer.parseInt(settingStorage.getString(AppSetting.MINIMUM_VIBRATION_INTERVAL));
}
catch (NumberFormatException e)
{
}
Timber.d("MinInterval: %d", minInterval);
Timber.d("LastVib: %d", lastVibration);
if (minInterval == 0 || lastVibration == null ||
(System.currentTimeMillis() - lastVibration) > minInterval * 1000)
{
notification.vibrated = true;
long[] forcedVibrationPattern = notification.source.getForcedVibrationPattern();
if (forcedVibrationPattern == null)
return PebbleVibrationPattern.parseVibrationPattern(settingStorage.getString(AppSetting.VIBRATION_PATTERN));
return PebbleVibrationPattern.getFromAndroidVibrationPattern(forcedVibrationPattern);
}
else
{
ArrayList<Byte> list = new ArrayList<Byte>(2);
list.add((byte) 0);
list.add((byte) 0);
return list;
}
}
示例4: sendUpdatePacket
import com.matejdro.pebblecommons.vibration.PebbleVibrationPattern; //导入依赖的package包/类
private void sendUpdatePacket()
{
PebbleDictionary data = new PebbleDictionary();
data.addUint8(0, (byte) 1);
data.addUint8(1, (byte) 0);
boolean nameAtBottomWhenImageDisplayed = callerImage != null && getService().getGlobalSettings().getBoolean("bottomCallerName", true);
if (name != null && type != null)
{
data.addString(2, TextUtil.prepareString(type, 30));
data.addString(3, TextUtil.prepareString(number, 30));
}
else
{
data.addString(2, "");
data.addString(3, "");
}
List<Byte> vibrationPattern;
if (vibrating)
{
String vibrationPatternString = getService().getGlobalSettings().getString("vibrationPattern", "100, 100, 100, 1000");
vibrationPattern = PebbleVibrationPattern.parseVibrationPattern(vibrationPatternString);
}
else
{
vibrationPattern = PebbleVibrationPattern.EMPTY_VIBRATION_PATTERN;
}
byte[] parameters = new byte[8 + vibrationPattern.size()];
parameters[0] = (byte) (callState == CallState.ESTABLISHED ? 1 : 0);
parameters[1] = (byte) (nameAtBottomWhenImageDisplayed ? 1 : 0);
parameters[6] = (byte) (identityUpdateRequired ? 1 : 0);
parameters[2] = (byte) getCallAction(getUserSelectedAction(getExtendedButtonId("Up"))).getIcon();
parameters[3] = (byte) getCallAction(getUserSelectedAction(getExtendedButtonId("Select"))).getIcon();
parameters[4] = (byte) getCallAction(getUserSelectedAction(getExtendedButtonId("Down"))).getIcon();
parameters[7] = (byte) vibrationPattern.size();
for (int i = 0; i < vibrationPattern.size(); i++)
parameters[8 + i] = vibrationPattern.get(i);
data.addBytes(4, parameters);
if (callState == CallState.ESTABLISHED)
data.addUint16(5, (short) Math.min(65000, (System.currentTimeMillis() - callStartTime) / 1000));
data.addUint8(999, (byte) 1);
callerImageNextByte = -1;
if (identityUpdateRequired && getService().getPebbleCommunication().getConnectedWatchCapabilities().hasColorScreen())
{
int imageSize = 0;
if (callerImage != null)
{
processContactImage();
imageSize = callerImageBytes.length;
}
data.addUint16(7, (short) imageSize);
if (imageSize != 0)
callerImageNextByte = 0;
Timber.d("Image size: %d", imageSize);
}
getService().getPebbleCommunication().sendToPebble(data);
Timber.d("Sent Call update packet. New identity: %b", identityUpdateRequired);
callerNameUpdateRequired = identityUpdateRequired;
updateRequired = false;
identityUpdateRequired = false;
}