This file contains 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 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 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 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 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 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 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 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, |
This file contains 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.databinding.ObservableList | |
import androidx.recyclerview.widget.DiffUtil | |
import me.tatarka.bindingcollectionadapter2.collections.AsyncDiffObservableList | |
import me.tatarka.bindingcollectionadapter2.collections.DiffObservableList | |
@Suppress("NOTHING_TO_INLINE", "FunctionName") | |
inline fun <T : Any> DiffObservableList( | |
itemCallback: DiffUtil.ItemCallback<T>, | |
async: Boolean = true | |
): DiffList<T> = |
This file contains 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
@BindingAdapter("date") | |
fun setDate(datePicker: DatePicker, value: LocalDate) { | |
if (value != LocalDate.of(datePicker.year, datePicker.month + 1, datePicker.dayOfMonth)) { | |
datePicker.updateDate(value.year, value.monthValue - 1, value.dayOfMonth) | |
} | |
} | |
@BindingAdapter(value = ["dateAttrChanged", "onDateChanged"], requireAll = false) | |
fun setDateChangeListener( | |
datePicker: DatePicker, |
NewerOlder