Skip to content

Instantly share code, notes, and snippets.

View vladimirpetrovski's full-sized avatar

Vladimir Petrovski vladimirpetrovski

View GitHub Profile
class WiFiConnectUseCase(context: Context) {
private var wifiManager =
context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
private val connectivityManager =
context.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
private val wifiSSID = "My Network"
private val wifiPassword = "password1234"
class WiFiConnectLegacyUseCase(private val context: Context) {
private var wifiManager =
context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
private val connectivityManager =
context.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
private val wifiSSID = "My Network"
private val wifiPassword = "password1234"
class WiFiDisconnectUseCase(context: Context) {
private var wifiManager =
context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
private val connectivityManager =
context.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
private val wifiSSID = "My Network"
class WiFiScanUseCase(private val context: Context) {
private val wifiManager =
context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
private val wifiSSID = "My Network"
operator fun invoke(): Completable {
return startScanning()
}
class WifiConnectionViewModel(
private val context: Context,
wifiScanUseCase: WiFiScanUseCase,
private val wifiConnectUseCase: WiFiConnectDockUseCase,
private val wifiConnectLegacyUseCase: WiFiConnectDockLegacyUseCase,
private val wifiDisconnectUseCase: WiFiDisconnectDockUseCase
) : ViewModel() {
private val disposables = CompositeDisposable();
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
kotlin("multiplatform")
id("com.android.library")
}
android {
compileSdkVersion(29)
defaultConfig {
minSdkVersion(21)
plugins {
id("com.android.application")
kotlin("android")
kotlin("android.extensions")
kotlin("kapt")
id("androidx.navigation.safeargs.kotlin")
}
android {
compileSdkVersion(Versions.compile_sdk)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.6.3")
classpath(kotlin("gradle-plugin", "1.3.71"))
include(":shared", ":androidApp")
rootProject.name = "xxx"
enableFeaturePreview("GRADLE_METADATA")
fun isWiFiEnabled(): Boolean {
val wifiManager = applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
return wifiManager.isWifiEnabled
}