Skip to content

Instantly share code, notes, and snippets.

View ivan200's full-sized avatar

John ivan200

  • Moscow
View GitHub Profile
@ivan200
ivan200 / AppLocalTime.kt
Created April 22, 2021 10:21
Managing correct time in android app
object AppLocalTime : AppLocalTimeBase() {
override fun saveServerDateTimeMls(millis: Long) = Prefs::serverDateTimeMls.set(millis)
override fun savePhoneDateTimeMls(millis: Long) = Prefs::phoneDateTimeMls.set(millis)
override fun savePhoneBootMillis(millis: Long) = Prefs::phonePhoneBootMls.set(millis)
override fun loadServerDateTimeMls(): Long = Prefs.serverDateTimeMls
override fun loadPhoneDateTimeMls(): Long = Prefs.phoneDateTimeMls
override fun loadPhoneBootMillis(): Long = Prefs.phonePhoneBootMls
override fun getServerDateFormat(): String = "yyyy-MM-dd HH:mm:ss ZZZZ" // sample 2017-04-24 15:14:39 +0000
override fun getServerDateString(ondate: (String?) -> Unit, onError: (Throwable?) -> Unit) {
//ClientServer.Requests.getServerTime()
@SuppressWarnings("unchecked")
@SafeVarargs
public static <T> List<T> sortBy(List<T> list, Function<? super T, ? super Comparable>... function) {
Comparator<T> comparator = (o1, o2) -> {
for (int i = 0; i < function.length; i++) {
Object obj1 = function[i].apply(o1);
Object obj2 = function[i].apply(o2);
int result;
if (obj1 == null || obj2 == null) {