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
class AnimatorExtension { | |
// Skipping the initialization | |
private val animator: Animator? = null | |
// Normal Usage | |
fun normalAnimationListener() { | |
animator?.addListener( | |
onStart = { |
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
class HomeActivity : DaggerAppCompatActivity() { | |
@Inject | |
lateinit var apiService: ApiService | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
// init UI | |
// Your apiService instance is ready to use. |
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
@Module | |
abstract class ActivityModule { | |
@ContributesAndroidInjector | |
internal abstract fun contributeHomeActivity(): HomeActivity | |
} |
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
class MyApplication : DaggerApplication() { | |
override fun onCreate() { | |
super.onCreate() | |
initializeTimber() | |
} | |
private fun initializeTimber() { | |
if (BuildConfig.DEBUG) { |
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
@Component(modules = [AndroidSupportInjectionModule::class, AppModule::class, ActivityModule::class]) | |
interface AppComponent : AndroidInjector<DaggerApplication> { | |
@Component.Builder | |
interface Builder { | |
@BindsInstance | |
fun application(application: Application): Builder | |
fun build(): AppComponent | |
} |
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
interface ApiService { | |
@GET("api") | |
fun getUsers(@Query("result") result: Int): Observable<RandomUserResponse> | |
} |
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
apply plugin: 'com.android.application' | |
apply plugin: 'kotlin-android' | |
apply plugin: 'kotlin-android-extensions' | |
apply plugin: 'kotlin-kapt' | |
android { | |
compileSdkVersion 27 | |
defaultConfig { | |
applicationId "com.simform.android.dagger2advanced" | |
minSdkVersion 16 |
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
public class BaseRecyclerAdapter<T, MVH extends BaseViewHolder<T>, EVH extends BaseViewHolder<T>> extends RecyclerView.Adapter<BaseViewHolder<T>> { | |
private static final int VIEW_TYPE_EMPTY = 0; | |
private static final int VIEW_TYPE_DATA = 1; | |
private List<T> list = new ArrayList<>(); | |
@LayoutRes | |
private int emptyViewLayoutResource; | |
private Class<EVH> emptyViewHolder; | |
@LayoutRes | |
private int dataLayoutResource; |
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
public class BaseRecyclerAdapter<T, MVH extends BaseViewHolder<T>, EVH extends BaseViewHolder<T>> extends RecyclerView.Adapter<BaseViewHolder<T>> { | |
private static final int VIEW_TYPE_EMPTY = 0; | |
private static final int VIEW_TYPE_DATA = 1; | |
private List<T> list = new ArrayList<>(); | |
@LayoutRes | |
private int emptyViewLayoutResource; | |
private Class<EVH> emptyViewHolder; | |
@LayoutRes | |
private int dataLayoutResource; |
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
public class ScrollingActivity extends AppCompatActivity { | |
private SectionsPagerAdapter mSectionsPagerAdapter; | |
private ViewPager mViewPager; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_scrolling); |
NewerOlder