Skip to content

Instantly share code, notes, and snippets.

@LuigiPapino
LuigiPapino / FontAwareTabLayout.java
Last active July 4, 2017 07:13
Android - Calligraphy and TabLayout
/**
* Simple helper class which extends a TabLayout to allow us to customize the font of the tab.
* https://gist.github.com/tmtrademarked/09926077a406959be15fc8a824a52751
* https://github.com/chrisjenx/Calligraphy/issues/180
*/
public final class FontAwareTabLayout extends TabLayout {
private String fontPath;
public FontAwareTabLayout(Context context, AttributeSet attrs) {
@LuigiPapino
LuigiPapino / ApplicationComponent.kt
Created January 31, 2018 08:22
Modular Architecture - Dagger2 - Application Component
@Singleton
@Component(modules = arrayOf(NetworkModule::class, RepositoryModule::class, SubcomponentModule::class))
interface ApplicationComponent : AndroidInjector<MyApplication> {
val userRepository: UserRepository
val apiService: ApiService
fun browserBuilder(): BrowserSubComponent.Builder
}
@Module
object NetworkModule {
@LuigiPapino
LuigiPapino / ApplicationComponent.kt
Last active January 31, 2018 08:57
Modular Architecture - Dagger2 - Browser SubComponent
@Singleton
@Component(modules = arrayOf(NetworkModule::class, RepositoryModule::class, SubcomponentModule::class))
interface ApplicationComponent : AndroidInjector<MyApplication> {
//here we declare that BrowserSubComponent is a subcomponent for ApplicationComponent,
//exposing an instance of the builder
fun browserBuilder(): BrowserSubComponent.Builder
}
@LuigiPapino
LuigiPapino / ApplicationComponent.kt
Last active February 2, 2018 08:26
Modular Architecture - Dagger2 - Browser Component
@Singleton
@Component(modules = arrayOf(NetworkModule::class, RepositoryModule::class))
interface ApplicationComponent : AndroidInjector<MyApplication> {
val userRepository: UserRepository
val apiService: ApiService
/**
* explicitly declare okHttp
**/
val okHttp: OkHttp
}
@LuigiPapino
LuigiPapino / ApplicationComponent.kt
Created February 2, 2018 08:59
Modular Architecture - Dagger2 - BaseInjector
@Singleton
@Component(modules = arrayOf(NetworkModule::class, RepositoryModule::class))
interface ApplicationComponent : AndroidInjector<MyApplication> {
fun networkSubComponentBuilder(): NetworkSubComponent.Builder;
fun repositorySubComponentBuilder(): RepositorySubComponent.Builder;
}