From c66400a91f99a37ccded68ab3fb412f17d25bf68 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Fri, 27 Oct 2023 16:32:13 +0200 Subject: [PATCH] Convert to kt Signed-off-by: alperozturk --- .../nextcloud/client/di/ActivityInjector.kt | 65 ++++++------------- 1 file changed, 21 insertions(+), 44 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/di/ActivityInjector.kt b/app/src/main/java/com/nextcloud/client/di/ActivityInjector.kt index b3f1bed0565e..d99b57cde20a 100644 --- a/app/src/main/java/com/nextcloud/client/di/ActivityInjector.kt +++ b/app/src/main/java/com/nextcloud/client/di/ActivityInjector.kt @@ -17,57 +17,34 @@ * 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); +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 instanceof FragmentActivity) { - final FragmentManager fm = ((FragmentActivity) activity).getSupportFragmentManager(); - fm.registerFragmentLifecycleCallbacks(new FragmentInjector(), true); + if (activity is FragmentActivity) { + val fm = activity.supportFragmentManager + fm.registerFragmentLifecycleCallbacks(FragmentInjector(), true) } } - @Override - public final void onActivityStarted(Activity activity) { - // not needed - } + override fun onActivityStarted(activity: Activity) {} - @Override - public final void onActivityResumed(Activity activity) { - // not needed - } + override fun onActivityResumed(activity: Activity) {} - @Override - public final void onActivityPaused(Activity activity) { - // not needed - } + override fun onActivityPaused(activity: Activity) {} - @Override - public final void onActivityStopped(Activity activity) { - // not needed - } + override fun onActivityStopped(activity: Activity) {} - @Override - public final void onActivitySaveInstanceState(Activity activity, Bundle outState) { - // not needed - } + override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {} - @Override - public final void onActivityDestroyed(Activity activity) { - // not needed - } + override fun onActivityDestroyed(activity: Activity) {} }