Skip to content

Commit

Permalink
[TIMOB-25045] Fix vibratePattern property
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Mathews committed Nov 15, 2017
1 parent fecc689 commit 444f444
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void handleCreationDict(KrollDict d)
setShowBadge(d.getBoolean(TiC.PROPERTY_SHOW_BADGE));
}
if (d.containsKey(TiC.PROPERTY_VIBRATE_PATTERN)) {
setVibrationPattern((long[]) d.get(TiC.PROPERTY_VIBRATE_PATTERN));
setVibrationPattern(d.get(TiC.PROPERTY_VIBRATE_PATTERN));
}
} else {
Log.e(TAG, "could not create notification channel");
Expand Down Expand Up @@ -161,10 +161,22 @@ public void setShowBadge(boolean showBadge)
}

@Kroll.method @Kroll.setProperty
public void setVibrationPattern(long[] vibrationPattern)
{
channel.setVibrationPattern(vibrationPattern);
setProperty(TiC.PROPERTY_VIBRATE_PATTERN, vibrationPattern);
public void setVibrationPattern(Object patternObj)
{
if (patternObj instanceof Object[]) {
Object[] patternArray = (Object[]) patternObj;
long[] pattern = new long[patternArray.length];

for (int i = 0; i < patternArray.length; i++) {
if (!(patternArray[i] instanceof Integer)) {
Log.e(TAG, "invalid vibratePattern array element");
return;
}
pattern[i] = ((Integer) patternArray[i]).intValue();
}
channel.setVibrationPattern(pattern);
setProperty(TiC.PROPERTY_VIBRATE_PATTERN, patternArray);
}
}

public NotificationChannel getNotificationChannel()
Expand Down

0 comments on commit 444f444

Please sign in to comment.