当前位置: 首页>>代码示例>>Java>>正文


Java PebbleVibrationPattern类代码示例

本文整理汇总了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"));
}
 
开发者ID:matejdro,项目名称:PebbleAndroidCommons,代码行数:11,代码来源:PebbleVibrationPatternTest.java

示例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]));
}
 
开发者ID:matejdro,项目名称:PebbleAndroidCommons,代码行数:11,代码来源:PebbleVibrationPatternTest.java

示例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;
    }
}
 
开发者ID:matejdro,项目名称:PebbleNotificationCenter-Android,代码行数:35,代码来源:NotificationSendingModule.java

示例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;
}
 
开发者ID:matejdro,项目名称:PebbleDialer-Android,代码行数:79,代码来源:CallModule.java


注:本文中的com.matejdro.pebblecommons.vibration.PebbleVibrationPattern类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。