Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

Hilt #1053

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Hilt #1053

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions GithubBrowserSample/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

apply plugin: 'dagger.hilt.android.plugin'
apply plugin: 'kotlin-allopen'
apply plugin: 'androidx.navigation.safeargs.kotlin'

Expand Down Expand Up @@ -81,16 +81,13 @@ dependencies {
implementation deps.retrofit.gson
implementation deps.glide.runtime

implementation deps.dagger.runtime
implementation deps.dagger.android
implementation deps.dagger.android_support
implementation deps.dagger.hilt_android
implementation deps.constraint_layout
implementation deps.kotlin.stdlib

implementation deps.timber

kapt deps.dagger.android_support_compiler
kapt deps.dagger.compiler
kapt deps.dagger.hilt_compiler
kapt deps.room.compiler
kapt deps.lifecycle.compiler

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,18 @@

package com.android.example.github

import android.app.Activity
import android.app.Application
import com.android.example.github.di.AppInjector
import dagger.android.DispatchingAndroidInjector
import dagger.android.HasActivityInjector
import dagger.hilt.android.HiltAndroidApp
import timber.log.Timber
import javax.inject.Inject


class GithubApp : Application(), HasActivityInjector {
@Inject
lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector<Activity>
@HiltAndroidApp
class GithubApp : Application() {

override fun onCreate() {
super.onCreate()
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
}
AppInjector.init(this)
}

override fun activityInjector() = dispatchingAndroidInjector
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,15 @@
package com.android.example.github

import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.appcompat.app.AppCompatActivity
import dagger.android.DispatchingAndroidInjector
import dagger.android.support.HasSupportFragmentInjector
import javax.inject.Inject
import dagger.hilt.android.AndroidEntryPoint

class MainActivity : AppCompatActivity(), HasSupportFragmentInjector {
@Inject
lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector<Fragment>
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.main_activity)
}

override fun supportFragmentInjector() = dispatchingAndroidInjector
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ import com.android.example.github.db.UserDao
import com.android.example.github.util.LiveDataCallAdapterFactory
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import javax.inject.Singleton

@Module(includes = [ViewModelModule::class])
@Module
@InstallIn(SingletonComponent::class)
class AppModule {
@Singleton
@Provides
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading