-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dagger #10
Open
ManojMadanmohan
wants to merge
10
commits into
master
Choose a base branch
from
dagger
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Dagger #10
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
deee7bd
version updates
manoj-madanmohan-toppr 369ef78
dagger dependencies
manoj-madanmohan-toppr 3ef6328
basic dagger, basic build
manoj-madanmohan-toppr 9d655dc
annotation provessor enabling for dagger
manoj-madanmohan-toppr 5ad0777
basic working dagger
manoj-madanmohan-toppr f903eac
basic dagger implementation - old style dagger, using dagger as a sim…
manoj-madanmohan-toppr fc71f3b
inject anothre dependency through dagger
manoj-madanmohan-toppr f55172d
more dependencies taken out
manoj-madanmohan-toppr c496d10
dagger impl
manoj-madanmohan-toppr b4b20b9
dagger refactor
manoj-madanmohan-toppr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
34 changes: 27 additions & 7 deletions
34
app/src/main/java/com/manoj/dlt/DeepLinkTestApplication.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,54 @@ | ||
package com.manoj.dlt | ||
|
||
import android.app.Activity | ||
import android.app.Application | ||
import android.widget.Toast | ||
import com.crashlytics.android.Crashlytics | ||
import com.google.firebase.database.FirebaseDatabase | ||
import com.manoj.dlt.di.AppComponent | ||
import com.manoj.dlt.di.ContextModule | ||
import com.manoj.dlt.di.DaggerAppComponent | ||
import com.manoj.dlt.features.DeepLinkHistoryFeature | ||
import com.manoj.dlt.features.LinkQueueHandler | ||
import com.manoj.dlt.features.ProfileFeature | ||
import com.manoj.dlt.utils.Utilities | ||
import dagger.android.AndroidInjector | ||
import dagger.android.DispatchingAndroidInjector | ||
import dagger.android.HasActivityInjector | ||
import dagger.android.support.DaggerApplication | ||
import dagger.internal.DaggerCollections | ||
import io.fabric.sdk.android.Fabric | ||
import javax.inject.Inject | ||
|
||
class DeepLinkTestApplication: Application { | ||
constructor() | ||
class DeepLinkTestApplication: DaggerApplication() { | ||
|
||
@Inject | ||
lateinit var _profileFeature: ProfileFeature | ||
@Inject | ||
lateinit var _linkQueueHandler: LinkQueueHandler | ||
|
||
override fun applicationInjector(): AndroidInjector<out DaggerApplication> { | ||
return DaggerAppComponent.builder() | ||
.contextModule(ContextModule(this)) | ||
.build() | ||
} | ||
|
||
override fun onCreate() { | ||
FirebaseDatabase.getInstance().setPersistenceEnabled(true) | ||
super.onCreate() | ||
|
||
if(Constants.ENVIRONMENT.equals(Constants.CONFIG.PRODUCTION)) { | ||
Fabric.with(this, Crashlytics()) | ||
Crashlytics.setUserIdentifier(ProfileFeature.getInstance(this).getUserId()) | ||
Crashlytics.setString("user id", ProfileFeature.getInstance(this).getUserId()) | ||
Crashlytics.setUserIdentifier(_profileFeature.getUserId()) | ||
Crashlytics.setString("user id", _profileFeature.getUserId()) | ||
} else | ||
{ | ||
Toast.makeText(applicationContext, "In Testing mode", Toast.LENGTH_LONG).show() | ||
} | ||
if(Constants.isFirebaseAvailable(this)) | ||
{ | ||
FirebaseDatabase.getInstance().setPersistenceEnabled(true); | ||
LinkQueueHandler.getInstance(this).runQueueListener() | ||
_linkQueueHandler.runQueueListener() | ||
} | ||
DeepLinkHistoryFeature.getInstance(applicationContext) | ||
Utilities.initializeAppRateDialog(applicationContext) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.manoj.dlt.di | ||
|
||
import com.manoj.dlt.ui.activities.DeepLinkHistoryActivity | ||
import dagger.Module | ||
import dagger.android.ContributesAndroidInjector | ||
|
||
@Module | ||
abstract class ActivityModule { | ||
|
||
@ContributesAndroidInjector | ||
abstract fun annotateAndroidInjectionMappingForDeepLinkHistoryActivity(): DeepLinkHistoryActivity | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.manoj.dlt.di | ||
|
||
import android.app.Activity | ||
import android.app.Application | ||
import android.content.Context | ||
import com.manoj.dlt.DeepLinkTestApplication | ||
import com.manoj.dlt.features.ProfileFeature | ||
import com.manoj.dlt.interfaces.IDeepLinkHistory | ||
import com.manoj.dlt.interfaces.IProfileFeature | ||
import com.manoj.dlt.ui.activities.DeepLinkHistoryActivity | ||
import dagger.BindsInstance | ||
import dagger.Component | ||
import dagger.android.AndroidInjectionModule | ||
import dagger.android.AndroidInjector | ||
import dagger.android.support.AndroidSupportInjectionModule | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
@Component(modules = [FeaturesModule::class, | ||
AndroidInjectionModule::class, AndroidSupportInjectionModule::class, | ||
ActivityModule::class]) | ||
public interface AppComponent: AndroidInjector<DeepLinkTestApplication> { | ||
|
||
fun getContext(): Context | ||
|
||
fun getProfileFeature(): IProfileFeature | ||
|
||
fun getDeepLinkHistoryFeature(): IDeepLinkHistory | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove accessor functions |
||
|
||
// @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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.manoj.dlt.di | ||
|
||
import android.content.Context | ||
import dagger.Module | ||
import dagger.Provides | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
class ContextModule constructor(val context: Context) { | ||
|
||
@Provides | ||
@Singleton | ||
fun getAppContext(): Context { | ||
return context.applicationContext | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.manoj.dlt.di | ||
|
||
import com.manoj.dlt.features.DeepLinkHistoryFeature | ||
import com.manoj.dlt.features.ProfileFeature | ||
import com.manoj.dlt.interfaces.IDeepLinkHistory | ||
import com.manoj.dlt.interfaces.IProfileFeature | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.Provides | ||
import javax.inject.Singleton | ||
|
||
@Module(includes = [UtilsModule::class]) | ||
abstract class FeaturesModule { | ||
|
||
@Singleton | ||
@Binds | ||
abstract fun getHistoryFeature(feature: DeepLinkHistoryFeature): IDeepLinkHistory | ||
|
||
@Singleton | ||
@Binds | ||
abstract fun getProfileFeature(feature: ProfileFeature): IProfileFeature | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.manoj.dlt.di | ||
|
||
import android.content.Context | ||
import com.manoj.dlt.Constants | ||
import com.manoj.dlt.features.FileSystem | ||
import com.manoj.dlt.interfaces.IFileSystem | ||
import dagger.Module | ||
import dagger.Provides | ||
import javax.inject.Named | ||
|
||
@Module(includes = [ContextModule::class]) | ||
class UtilsModule { | ||
|
||
@Provides | ||
@Named(Constants.GLOBAL_PREF_KEY) | ||
fun getGlobalPrefStore(context: Context): IFileSystem { | ||
return FileSystem(context, Constants.GLOBAL_PREF_KEY) | ||
} | ||
|
||
|
||
@Provides | ||
@Named(Constants.DEEP_LINK_HISTORY_KEY) | ||
fun getHistoryPrefStore(context: Context): IFileSystem { | ||
return FileSystem(context, Constants.DEEP_LINK_HISTORY_KEY) | ||
} | ||
|
||
} |
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check this