public static <T> ThreadLocal<T> threadLocalWithInitial(final Supplier<T> supplier) {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            return ThreadLocal.withInitial(supplier::get);
        }

        return new ThreadLocal<T>() {

            @Override
            protected T initialValue() {
                return supplier.get();
            }
        };
    }
Returns a ThreadLocal with initial value given by passed Supplier.
Use this method instead of ThreadLocal.withInitial() for SDK<26;
main/src/main/java/cgeo/geocaching/utils/CommonUtils.java