package com.ablsolutions.wificonnect.connector import android.os.Build import com.facebook.react.bridge.ReactApplicationContext object WifiConnectorFactory { private var connector: WifiConnector? = null fun getWifiConnector(reactApplicationContext: ReactApplicationContext): WifiConnector { if (connector == null) { when { Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { // android 12 and later connector = Android12AndLaterWifiConnector(reactApplicationContext) } Build.VERSION.SDK_INT == Build.VERSION_CODES.R -> { // android 11 connector = Android11WifiConnector(reactApplicationContext) } Build.VERSION.SDK_INT == Build.VERSION_CODES.Q -> { // android 10 connector = Android10WifiConnector(reactApplicationContext) } Build.VERSION.SDK_INT <= Build.VERSION_CODES.P -> { // android 9 and before connector = Android9AndBeforeWifiConnector(reactApplicationContext) } } } return connector!! } }