forked from upstream-mirrors/OpenTracks
Add recycler view adapter for marker list
This commit is contained in:
@@ -24,7 +24,9 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
@@ -180,4 +182,17 @@ public class ListItemUtils {
|
||||
textView.setShadowLayer(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setDateAndTime(Context context, TextView dateView, TextView timeView, Instant time, ZoneOffset timeZone) {
|
||||
OffsetDateTime offsetDateTime = OffsetDateTime.ofInstant(time, timeZone);
|
||||
String dateContent = StringUtils.formatDateTodayRelative(context, offsetDateTime);
|
||||
String pattern = "HH:mm";
|
||||
if (!offsetDateTime.getOffset().equals(OffsetDateTime.now().getOffset())) {
|
||||
pattern = "HH:mm x";
|
||||
}
|
||||
String timeContent = offsetDateTime.format(DateTimeFormatter.ofPattern(pattern));
|
||||
|
||||
dateView.setText(dateContent);
|
||||
timeView.setText(timeContent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,4 +52,15 @@ public class ThemeUtils {
|
||||
typedArray.recycle();
|
||||
return fontSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the photo height.
|
||||
*/
|
||||
public static int getPhotoHeight(Context context) {
|
||||
int[] attrs = new int[]{android.R.attr.listPreferredItemHeight};
|
||||
TypedArray typeArray = context.obtainStyledAttributes(attrs);
|
||||
int height = typeArray.getDimensionPixelSize(0, 128);
|
||||
typeArray.recycle();
|
||||
return 2 * height;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user