Loading src/com/android/bluetooth/opp/BluetoothOppUtility.java +8 −7 Original line number Original line Diff line number Diff line Loading @@ -51,6 +51,8 @@ import android.util.Log; import java.io.File; import java.io.File; import java.io.IOException; import java.io.IOException; import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.ArrayList; import java.util.List; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap; Loading Loading @@ -271,14 +273,13 @@ public class BluetoothOppUtility { * Helper function to build the progress text. * Helper function to build the progress text. */ */ public static String formatProgressText(long totalBytes, long currentBytes) { public static String formatProgressText(long totalBytes, long currentBytes) { if (totalBytes <= 0) { DecimalFormat df = new DecimalFormat("0%"); return "0%"; df.setRoundingMode(RoundingMode.DOWN); } double percent = 0.0; long progress = currentBytes * 100 / totalBytes; if (totalBytes > 0) { StringBuilder sb = new StringBuilder(); percent = currentBytes / (double) totalBytes; sb.append(progress); } sb.append('%'); return df.format(percent); return sb.toString(); } } /** /** Loading Loading
src/com/android/bluetooth/opp/BluetoothOppUtility.java +8 −7 Original line number Original line Diff line number Diff line Loading @@ -51,6 +51,8 @@ import android.util.Log; import java.io.File; import java.io.File; import java.io.IOException; import java.io.IOException; import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.ArrayList; import java.util.List; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap; Loading Loading @@ -271,14 +273,13 @@ public class BluetoothOppUtility { * Helper function to build the progress text. * Helper function to build the progress text. */ */ public static String formatProgressText(long totalBytes, long currentBytes) { public static String formatProgressText(long totalBytes, long currentBytes) { if (totalBytes <= 0) { DecimalFormat df = new DecimalFormat("0%"); return "0%"; df.setRoundingMode(RoundingMode.DOWN); } double percent = 0.0; long progress = currentBytes * 100 / totalBytes; if (totalBytes > 0) { StringBuilder sb = new StringBuilder(); percent = currentBytes / (double) totalBytes; sb.append(progress); } sb.append('%'); return df.format(percent); return sb.toString(); } } /** /** Loading