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
{ | |
// Get display metrics. | |
metrics = getWindowManager().getDefaultDisplay(); | |
// Get watcher text as String. | |
String text = s.toString(); | |
// Reverse text and add to TextView. | |
String inversedText = new StringBuilder(s).reverse().toString(); | |
reverseTextView.setText(inversedText); |
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
inline fun waitUntilLoaded(crossinline recyclerProvider: () -> RecyclerView) { | |
Espresso.onIdle() | |
lateinit var recycler: RecyclerView | |
InstrumentationRegistry.getInstrumentation().runOnMainSync { | |
recycler = recyclerProvider() | |
} | |
while (recycler.hasPendingAdapterUpdates()) { |
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
internal class RequiredFieldsTypeAdpaterFactory : TypeAdapterFactory { | |
override fun <T : Any> create(gson: Gson, type: TypeToken<T>): TypeAdapter<T>? { | |
val delegate = gson.getDelegateAdapter(this, type) | |
val objectValidator = type.rawType.getAnnotation(EmptyObjectValidator::class.java) ?: return null | |
return object: TypeAdapter<T>() { | |
override fun write(out: JsonWriter?, value: T) { | |
delegate.write(out, value) | |
} |
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 com.google.gson.* | |
import com.google.gson.reflect.TypeToken | |
import com.google.gson.stream.JsonReader | |
import com.google.gson.stream.JsonWriter | |
import kotlin.jvm.internal.Reflection | |
import kotlin.reflect.KClass | |
import kotlin.reflect.full.memberProperties | |
class NullableTypAdapterFactory : TypeAdapterFactory { | |
override fun <T : Any> create(gson: Gson, type: TypeToken<T>): TypeAdapter<T>? { |