Skip to content

Instantly share code, notes, and snippets.

View remcomokveld's full-sized avatar

Remco Mokveld remcomokveld

View GitHub Profile
override fun onAttach(context: Context) {
AndroidSupportInjection.inject(this)
super.onAttach(context)
}
@RunWith(AndroidJUnit4::class)
class MyFragmentTest {
@Test
fun launchFragment() {
launchFragmentInContainer<MyFragment>()
}
}
import dagger.android.support.DaggerFragment
class MyFragment: DaggerFragment() {
@Inject lateinit var viewModel: MyViewModel
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
viewModel.liveData.observe(this) { button.isEnabled = it }
}
}
@remcomokveld
remcomokveld / JsonClassDetector.kt
Last active March 23, 2021 15:18
Moshi Lint Check
/*
* Copyright (C) 2021 Remco Mokveld
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package nl.remcomokveld.firebaseloaders;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.content.Loader;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.ValueEventListener;
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software