Skip to content

Instantly share code, notes, and snippets.

View catalinghita8's full-sized avatar

Catalin Ghita catalinghita8

View GitHub Profile
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MyComposeApplication {
// A surface container using the 'background' color from the theme
Surface(color = MaterialTheme.colors.background) {
Greeting("Android")
}
}
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent { MainActivityComposable() }
}
}
@Composable
fun MainActivityComposable() { }
buildscript {
...
dependencies {
...
classpath "com.google.dagger:hilt-android-gradle-plugin:2.28-alpha"
}
}
class SharedStorage @Inject constructor(@ApplicationContext context: Context)
: ISharedStorage {
}
@InstallIn(ApplicationComponent::class)
@Module
abstract class SharedStorageModule {
@Binds
@Singleton
abstract fun provideStorage(storage: SharedStorage): ISharedStorage
}
@InstallIn(ApplicationComponent::class)
@Module
class NetworkingModule {
@Provides
@Singleton
fun provideAuthInterceptorOkHttpClient(): OkHttpClient {
return OkHttpClient.Builder()
.build()
}
@Singleton
class MessageRepository @Inject constructor(private val storage: ISharedStorage,
private val networkProvider: Retrofit) {
}
@ActivityScoped
class MessageViewModel @ViewModelInject constructor
(@ApplicationContext context: Context,
private val repository: MessageRepository) : ViewModel() {
}
@AndroidEntryPoint
class MessageFragment @Inject constructor()
: Fragment(R.layout.fragment_message), BaseView {
}
@AndroidEntryPoint
class MessageFragment @Inject constructor() : Fragment(R.layout.fragment_message), BaseView {
private val viewModel: MessageViewModel by viewModels()
}