Questions tagged [toothpick-di]

Toothpick is a scope tree based Dependency Injection (DI) library for Java with a special focus on Android. It performs as well as the daggers, but offers a simple approach to Di.

Toothpick Toothpick is a scope tree based Dependency Injection (DI) library for Java with a special focus on Android.

Toothpick (a.k.a TP) API is based on Guice/RoboGuice APIs, but it avoids runtime reflection by using annotation processing like Dagger 1 & Dagger 2 do. Hence, TP claims to be simpler to use, offer best testing support but have performances at least as good as the Daggers.

https://github.com/stephanenicolas/toothpick

User Snicolas is one of the authors.

22 questions
9
votes
2 answers

Is there a way to ignore binding override in Toothpick?

Say I have scope S1 which has the module with the binding: bind(Repository.class).to(RepositoryImpl.class).singletonInScope() Then S2 scope gets opened with S1 as a parent (S1 -> S2) and S2 defines the same binding (because it's independent and…
dimsuz
  • 8,969
  • 8
  • 54
  • 88
5
votes
1 answer

Toothpick bind modules that depends on each other

I am trying out the toothpick DI library and I seem to miss something crucial. I created the following test project on github where I tried to make a smallest possible use case for my understanding issue. There you will find the ApplicationModule…
WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
3
votes
1 answer

How inject Map<> or Set<> (dagger 2 multibindings) with Toothpick

Dagger 2 has the ability to injecting set or map with multibindings. How to do it in Toothpick for example i want @Inject constructor(val map: Map)
Jacob
  • 81
  • 1
  • 6
3
votes
1 answer

how to use proguard toothpick rule?

I am using TP in my project. And I am Injecting some objects using TP. But when I applied the proguard rule in my application. It is working fine with debug mode But give null objects in release mode all the Objects I have injected through the…
3
votes
1 answer

How to pass instance of the dependency from a same module in Toothpick?

Suppose I have a module in which one binding depends on another: class MyModule : Module(){ init { bind(SettingsStorage::class.java).to(PreferencesBasedSettingsStorage::class.java) // how to use createOkHttpClient here? // how to get…
dimsuz
  • 8,969
  • 8
  • 54
  • 88
2
votes
1 answer

Dagger code works, how to make that Toothpick code work the same way?

I am starting using Toothpick and I need to migrage from Dagger code to Toothpick. Well, I have next string at my project with Dagger. @Provides @Singleton @Named(ProjectsRepository.DB) ProjectsRepository…
TT_W
  • 78
  • 6
2
votes
1 answer

Using the Toothpick DI framework be used with a Java (only) project

I started a small proof of concept exercise to make us of the Toothpick DI framework with an existing Gradle based Java project. I have read quite a few claims that you can use Toothpick with Java (meaning the JRE, OpenJDK, JDK or JSE - No Android)…
will
  • 4,799
  • 8
  • 54
  • 90
2
votes
1 answer

Cannot use Toothpick.inject in Fragment

I'm getting strange error while trying to use Toothpick DI in a fragment: toothpick.registries.NoFactoryFoundException: No factory could be found for class android.app.Application. Check that the class has either a @Inject annotated constructor or…
dipcore
  • 190
  • 2
  • 8
1
vote
0 answers

Is it possible to use a registry look up in Toothpick 3.x?

Toothpick is working great for us on Android, but the required proguard / R8 rules mean that classes using injection cannot be obfuscated to the degree we need. It seems like the reason the rules are required is for the Class.forName calls in the…
fatfingers
  • 11
  • 1
1
vote
0 answers

How to achieve scope singleton with Toothpick annotations?

I have a non-Android app having many similar shards objects, and I want all objets inside each shard (DB client, DAOs...) to be singletons. For this purpose, I have created a ShardSingleton…
bfreuden
  • 65
  • 7
1
vote
0 answers

How to use constructor injection for android ViewModels with Toothpick

I want to use constructor injection for my view models @InjectConstructor class SomeViewModel(private val dependency: SomeDependency) : ViewModel() { ... } It seems possible with custom view model factory…
1
vote
0 answers

Obscure leak found with Leak Canary in app that uses ToothPick

I have an app that is implemented with single Activity and with Toothpick / Ktp. I create a scope for every fragment, that I close when the fragment is destroyed. This behavior is done in the BaseFragment Class. It does use ViewBinding. The adapter…
Anthony
  • 3,989
  • 2
  • 30
  • 52
1
vote
1 answer

Injecting viewmodels into fragment when multiple instances of fragment exist

I am using the Toothpick dependency injection framework for an Android application and I'm having problems injecting android viewmodels into fragments when multiple instances of the same fragment exists on the backstack. I would like each fragment…
Kjetil Eide
  • 1,404
  • 1
  • 15
  • 20
1
vote
2 answers

Injecting via a factory when constructor has parameters in toothpick

I have a class that I want to inject which has a constructor that receives one parameter (Context). I would normally bind it to an instance, but this class has JNI dependencies and I can not instantiate it using Robolectric, which is preventing me…
shalafi
  • 3,926
  • 2
  • 23
  • 27
1
vote
0 answers

Kotlin kapt argument several values for one key

I'm trying to integrate Toothpick library without reflection into my multi modules project. I follow this guide in order to connect all my modules with DI. For example I have three module: :app, :feature1, :feature2. :app module dependes both on…
Sergey
  • 140
  • 1
  • 10
1
2