mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-26 18:45:49 +01:00
Avoid creating lots of SimpleDateFormat instances
This commit is contained in:
parent
dea4ee82a1
commit
1e89b12b15
@ -114,6 +114,8 @@ public class SleepMonitorActivity extends Activity implements SurfaceHolder.Call
|
|||||||
|
|
||||||
byte last_type = GBActivitySample.TYPE_UNKNOWN;
|
byte last_type = GBActivitySample.TYPE_UNKNOWN;
|
||||||
|
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
|
||||||
|
SimpleDateFormat annotationDateFormat = new SimpleDateFormat("HH:mm");
|
||||||
for (int i = 0; i < samples.size(); i++) {
|
for (int i = 0; i < samples.size(); i++) {
|
||||||
GBActivitySample sample = samples.get(i);
|
GBActivitySample sample = samples.get(i);
|
||||||
byte type = sample.getType();
|
byte type = sample.getType();
|
||||||
@ -121,11 +123,11 @@ public class SleepMonitorActivity extends Activity implements SurfaceHolder.Call
|
|||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
cal.setTimeInMillis((long) sample.getTimestamp() * 1000L);
|
cal.setTimeInMillis((long) sample.getTimestamp() * 1000L);
|
||||||
date = cal.getTime();
|
date = cal.getTime();
|
||||||
dateStringFrom = new SimpleDateFormat("dd.MM.yyyy HH:mm").format(date);
|
dateStringFrom = dateFormat.format(date);
|
||||||
} else if (i == samples.size() - 1) {
|
} else if (i == samples.size() - 1) {
|
||||||
cal.setTimeInMillis((long) sample.getTimestamp() * 1000L);
|
cal.setTimeInMillis((long) sample.getTimestamp() * 1000L);
|
||||||
date = cal.getTime();
|
date = cal.getTime();
|
||||||
dateStringTo = new SimpleDateFormat("dd.MM.yyyy HH:mm").format(date);
|
dateStringTo = dateFormat.format(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
short movement = sample.getIntensity();
|
short movement = sample.getIntensity();
|
||||||
@ -157,7 +159,7 @@ public class SleepMonitorActivity extends Activity implements SurfaceHolder.Call
|
|||||||
if (annotate_this) {
|
if (annotate_this) {
|
||||||
cal.setTimeInMillis((long) (sample.getTimestamp()) * 1000L);
|
cal.setTimeInMillis((long) (sample.getTimestamp()) * 1000L);
|
||||||
date = cal.getTime();
|
date = cal.getTime();
|
||||||
String dateString = new SimpleDateFormat("HH:mm").format(date);
|
String dateString = annotationDateFormat.format(date);
|
||||||
paint.setColor(Color.WHITE);
|
paint.setColor(Color.WHITE);
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.rotate(-90.0f, r.left, r.top);
|
canvas.rotate(-90.0f, r.left, r.top);
|
||||||
|
Loading…
Reference in New Issue
Block a user