DownloadProgressNotification extends KujakuNotification { protected static String formatDecimal(double no) { DecimalFormat twoDForm = new DecimalFormat("0.##"); return twoDForm.format(no); } DownloadProgressNotification(Context context); void createInitialNotification(String mapName, String mapBoxAccessToken, int requestCode, boolean showAction); void updateNotification(double percentageProgress, String mapName, int requestCode, boolean showAction); void displayForegroundNotification(NotificationCompat.Builder notificationBuilder, int notificationId); void displayForegroundNotification(int notificationId); void updateNotificationWithNewMapDownload(String mapName, int requestCode); void displayNotification(int notificationId); void updateNotificationWithDownloadProgress(double percentageProgress); void clearActions(); Intent createStopDownloadIntent(String mapName, String mapBoxAccessToken); static final String CHANNEL_ID; }
@Test public void formatDecimal() { String[] formatedDecimals = new String[]{"4", "78.1", "56.34", "56.34", "78.1"}; double[] decimals = new double[]{4, 78.1, 56.34, 56.3409, 78.10}; for (int i = 0; i < formatedDecimals.length; i++) { assertEquals(formatedDecimals[i], DownloadProgressNotification.formatDecimal(decimals[i])); } }