All Downloads are FREE. Search and download functionalities are using the official Maven repository.

androidMain.tech.skot.core.components.SKFragment.kt Maven / Gradle / Ivy

There is a newer version: 1.2.9
Show newest version
package tech.skot.core.components

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import tech.skot.core.SKLog

open class SKFragment : Fragment() {

    private var screenKey: Long? = null
    var screen: SKScreenView<*>? = null

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return arguments?.getLong(ScreensManager.SK_ARGUMENT_VIEW_KEY)?.let { viewKey ->
            ScreensManager.getInstance(viewKey)?.bindTo(activity as SKActivity, this, inflater)
                ?.also {
                    screenKey = viewKey
                    screen = it
                }?.view
                ?: View(context).also { screenKey = null }

        }
    }

    override fun onPause() {
        if (isAdded || isRemoving) {
            screen?.onPause()
        }
        super.onPause()

    }

    override fun onResume() {
        super.onResume()
        if (isAdded) {
            screen?.onResume()
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy