This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package dev.gawluk | |
| import android.os.SystemClock | |
| import java.time.Clock | |
| import java.time.Instant | |
| import java.time.ZoneId | |
| import java.time.temporal.ChronoUnit | |
| fun monotonicClock(zone: ZoneId): Clock = MonotonicClock(zone) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @SuppressLint("PrivateApi") | |
| fun getSystemProperty(propertyName: String) : String? = runCatching { | |
| val clazz = Class.forName("android.os.SystemProperties") | |
| val method = clazz.getMethod("get", String::class.java, String::class.java) | |
| val value = method.invoke(clazz, propertyName, null) as String? | |
| value | |
| }.onFailure { Log.e("getSystemProperty", "failed to get: $propertyName", it) } | |
| .getOrNull() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.junit.Assert.assertEquals | |
| import org.junit.Test | |
| import java.time.LocalTime | |
| import java.time.format.DateTimeFormatter | |
| import java.util.Locale | |
| class TimeSuffixesTest { | |
| @Test | |
| fun getAmPm() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.app.role.RoleManager | |
| import android.content.Intent | |
| import androidx.activity.ComponentActivity | |
| import androidx.activity.result.ActivityResultLauncher | |
| import androidx.activity.result.ActivityResultRegistry | |
| import androidx.activity.result.contract.ActivityResultContracts | |
| import androidx.lifecycle.DefaultLifecycleObserver | |
| import androidx.lifecycle.Lifecycle | |
| import androidx.lifecycle.LifecycleOwner | |
| import java.util.UUID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // JUnit5 test extension | |
| // | |
| // usage: | |
| // | |
| // @ExtendWith(MockkAndroidLog::class) | |
| // class TestClass { | |
| // ... | |
| // } | |
| import android.util.Log | |
| import io.mockk.clearStaticMockk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.orderbird.testing | |
| import android.app.Activity | |
| import androidx.test.ext.junit.rules.ActivityScenarioRule | |
| import androidx.test.platform.app.InstrumentationRegistry | |
| import androidx.test.uiautomator.UiDevice | |
| import com.orderbird.testing.AnimationScaleSettings.disableAnimations | |
| import com.orderbird.testing.AnimationScaleSettings.restoreAnimations | |
| import org.junit.rules.RuleChain | |
| import org.junit.rules.TestRule |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cask_args appdir: "/Applications" | |
| # Apps | |
| cask "google-chrome" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.android.testing.blueprint | |
| import android.content.res.AssetManager | |
| import okhttp3.Interceptor | |
| import okhttp3.MediaType.Companion.toMediaType | |
| import okhttp3.OkHttpClient | |
| import okhttp3.Protocol | |
| import okhttp3.Request | |
| import okhttp3.Response | |
| import okhttp3.ResponseBody.Companion.toResponseBody |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.app.Activity | |
| import android.view.View | |
| import androidx.annotation.IdRes | |
| import androidx.fragment.app.Fragment | |
| fun <T : View> Activity.findView(@IdRes res : Int) : Lazy<T> { | |
| @Suppress("UNCHECKED_CAST") | |
| return lazy(LazyThreadSafetyMode.NONE){ findViewById<T>(res) } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import androidx.recyclerview.widget.DiffUtil | |
| import kotlin.reflect.KProperty1 | |
| @Suppress("NOTHING_TO_INLINE") | |
| inline fun <T : Any, R: Any> byProperty(kProperty: KProperty1<T, R>): (T, T) -> Boolean = | |
| { old, new -> kProperty.get(old) == kProperty.get(new) } | |
| @Suppress("FunctionName") | |
| inline fun <T : Any> DiffItemCallback( | |
| crossinline areItemsTheSame: (T, T) -> Boolean, |
NewerOlder