diff --git a/app/src/main/java/fr/free/nrw/commons/di/CommonsDaggerIntentService.java b/app/src/main/java/fr/free/nrw/commons/di/CommonsDaggerIntentService.java deleted file mode 100644 index 41f661db4..000000000 --- a/app/src/main/java/fr/free/nrw/commons/di/CommonsDaggerIntentService.java +++ /dev/null @@ -1,32 +0,0 @@ -package fr.free.nrw.commons.di; - -import android.app.IntentService; -import android.app.Service; - -import dagger.android.AndroidInjector; - -public abstract class CommonsDaggerIntentService extends IntentService { - - public CommonsDaggerIntentService(String name) { - super(name); - } - - @Override - public void onCreate() { - inject(); - super.onCreate(); - } - - private void inject() { - ApplicationlessInjection injection = ApplicationlessInjection.getInstance(getApplicationContext()); - - AndroidInjector serviceInjector = injection.serviceInjector(); - - if (serviceInjector == null) { - throw new NullPointerException("ApplicationlessInjection.serviceInjector() returned null"); - } - - serviceInjector.inject(this); - } - -} diff --git a/app/src/main/java/fr/free/nrw/commons/di/CommonsDaggerIntentService.kt b/app/src/main/java/fr/free/nrw/commons/di/CommonsDaggerIntentService.kt new file mode 100644 index 000000000..4aae35f0b --- /dev/null +++ b/app/src/main/java/fr/free/nrw/commons/di/CommonsDaggerIntentService.kt @@ -0,0 +1,20 @@ +package fr.free.nrw.commons.di + +import android.app.IntentService +import fr.free.nrw.commons.di.ApplicationlessInjection.Companion.getInstance + +abstract class CommonsDaggerIntentService(name: String?) : IntentService(name) { + 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) + } +}