diff --git a/app/src/main/java/com/nextcloud/client/di/ActivityInjector.java b/app/src/main/java/com/nextcloud/client/di/ActivityInjector.java deleted file mode 100644 index b3f1bed0565e..000000000000 --- a/app/src/main/java/com/nextcloud/client/di/ActivityInjector.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Nextcloud Android client application - * - * @author Chris Narkiewicz - * Copyright (C) 2019 Chris Narkiewicz - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package com.nextcloud.client.di; - -import android.app.Activity; -import android.app.Application; -import android.os.Bundle; -import androidx.fragment.app.FragmentActivity; -import androidx.fragment.app.FragmentManager; -import dagger.android.AndroidInjection; - -public class ActivityInjector implements Application.ActivityLifecycleCallbacks { - - @Override - public final void onActivityCreated(Activity activity, Bundle savedInstanceState) { - if (activity instanceof Injectable) { - AndroidInjection.inject(activity); - } - - if (activity instanceof FragmentActivity) { - final FragmentManager fm = ((FragmentActivity) activity).getSupportFragmentManager(); - fm.registerFragmentLifecycleCallbacks(new FragmentInjector(), true); - } - } - - @Override - public final void onActivityStarted(Activity activity) { - // not needed - } - - @Override - public final void onActivityResumed(Activity activity) { - // not needed - } - - @Override - public final void onActivityPaused(Activity activity) { - // not needed - } - - @Override - public final void onActivityStopped(Activity activity) { - // not needed - } - - @Override - public final void onActivitySaveInstanceState(Activity activity, Bundle outState) { - // not needed - } - - @Override - public final void onActivityDestroyed(Activity activity) { - // not needed - } -} diff --git a/app/src/main/java/com/nextcloud/client/di/ActivityInjector.kt b/app/src/main/java/com/nextcloud/client/di/ActivityInjector.kt new file mode 100644 index 000000000000..7828c9b82bf7 --- /dev/null +++ b/app/src/main/java/com/nextcloud/client/di/ActivityInjector.kt @@ -0,0 +1,62 @@ +/* + * Nextcloud Android client application + * + * @author Chris Narkiewicz + * Copyright (C) 2019 Chris Narkiewicz + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package com.nextcloud.client.di + +import android.app.Activity +import android.app.Application.ActivityLifecycleCallbacks +import android.os.Bundle +import androidx.fragment.app.FragmentActivity +import dagger.android.AndroidInjection + +class ActivityInjector : ActivityLifecycleCallbacks { + override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { + if (activity is Injectable) { + AndroidInjection.inject(activity) + } + if (activity is FragmentActivity) { + val fm = activity.supportFragmentManager + fm.registerFragmentLifecycleCallbacks(FragmentInjector(), true) + } + } + + override fun onActivityStarted(activity: Activity) { + // unused atm + } + + override fun onActivityResumed(activity: Activity) { + // unused atm + } + + override fun onActivityPaused(activity: Activity) { + // unused atm + } + + override fun onActivityStopped(activity: Activity) { + // unused atm + } + + override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) { + // unused atm + } + + override fun onActivityDestroyed(activity: Activity) { + // unused atm + } +}