mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-11-01 23:33:54 +01:00
Convert CommonsDaggerService to kotlin
This commit is contained in:
parent
6ae4333183
commit
1f4f5764bc
2 changed files with 20 additions and 31 deletions
|
|
@ -1,31 +0,0 @@
|
|||
package fr.free.nrw.commons.di;
|
||||
|
||||
import android.app.Service;
|
||||
|
||||
import dagger.android.AndroidInjector;
|
||||
|
||||
public abstract class CommonsDaggerService extends Service {
|
||||
|
||||
public CommonsDaggerService() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
inject();
|
||||
super.onCreate();
|
||||
}
|
||||
|
||||
private void inject() {
|
||||
ApplicationlessInjection injection = ApplicationlessInjection.getInstance(getApplicationContext());
|
||||
|
||||
AndroidInjector<Service> serviceInjector = injection.serviceInjector();
|
||||
|
||||
if (serviceInjector == null) {
|
||||
throw new NullPointerException("ApplicationlessInjection.serviceInjector() returned null");
|
||||
}
|
||||
|
||||
serviceInjector.inject(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package fr.free.nrw.commons.di
|
||||
|
||||
import android.app.Service
|
||||
import fr.free.nrw.commons.di.ApplicationlessInjection.Companion.getInstance
|
||||
|
||||
abstract class CommonsDaggerService : Service() {
|
||||
override fun onCreate() {
|
||||
inject()
|
||||
super.onCreate()
|
||||
}
|
||||
|
||||
private fun inject() {
|
||||
val injection = getInstance(applicationContext)
|
||||
|
||||
val serviceInjector = injection.serviceInjector()
|
||||
?: throw NullPointerException("ApplicationlessInjection.serviceInjector() returned null")
|
||||
|
||||
serviceInjector.inject(this)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue