Skip to content

Instantly share code, notes, and snippets.

View Unlimity's full-sized avatar
😴
repo sync -j5

Ilya Lim Unlimity

😴
repo sync -j5
  • Facebook
  • London
View GitHub Profile
class DeviceIdBootable(private val context: Context) : Bootable() {
override val key = Keys.DEVICE_ID
override val isCritical = true
override fun boot() {
val preferences = PreferenceManager.getDefaultSharedPreferences(context)
if (!preferences.contains("device_id")) {
preferences
.edit()
object Keys {
val DEVICE_ID = single("device_id")
}
abstract class Bootable {
abstract val key: Key.Single
open val dependencies: Key.Multiple = multiple()
open val isConcurrent: Boolean = true
open val isCritical: Boolean = false
@Throws(Throwable::class)
abstract fun boot()
}
@RunWith(AndroidJUnit4::class)
class TestActivityTest {
@Rule
@JvmField
val rule = ActivityTestRule(TestActivity::class.java)
val screen = TestActivityScreen()
@Test
fun test() {
class KTextView : KBaseView<KTextView>, TextViewAssertions {
constructor(function: ViewBuilder.() -> Unit): super(function)
constructor(parent: Matcher<View>, function: ViewBuilder.() -> Unit): super(parent, function)
constructor(parent: DataInteraction, function: ViewBuilder.() -> Unit): super(parent, function)
}
open class TestActivityScreen: Screen<TestActivityScreen>() {
val content: KView = KView { withId(R.id.content) }
val map: KView = KView { withId(R.id.map) }
val button: KButton = KButton { withId(R.id.button) }
val textViewLarge: KTextView = KTextView {
withId(R.id.text_view_large)
}
val textViewSmall: KTextView = KTextView {
@Test
fun espressoTest() {
screen { hotelName { isVisible() } }
}
@Test
public void espressoTest() {
onView(allOf(allOf(withId(R.id.label_bf_hotelname),
isDescendantOfA(withId(R.id.custom_view_trip_review))),
isDescendantOfA(withId(R.id.contentView))))
.check(matches(withEffectiveVisibility(View.VISIBLE)));
}
@Unlimity
Unlimity / SomeClass.kt
Created July 12, 2018 08:47
Extended companion object
class SomeClass {
companion object: Serializer() {
val TAG = "SomeClass"
fun create() = SomeClass()
}
fun doSomething() {
serialize(5)
}
}
@Unlimity
Unlimity / Example.kt
Created July 12, 2018 08:41
Private API companion object
open class Serializer {
protected fun serialize(obj: Any): String {
return obj.toString()
}
}
class SomeClassOne {
companion object: Serializer()
fun doSomething() {