Update dependencies
This commit is contained in:
@@ -24,7 +24,6 @@ import be.mygod.vpnhotspot.DebugHelper
|
||||
import be.mygod.vpnhotspot.LocalOnlyHotspotService
|
||||
import be.mygod.vpnhotspot.R
|
||||
import be.mygod.vpnhotspot.databinding.ListitemInterfaceBinding
|
||||
import be.mygod.vpnhotspot.net.TetherType
|
||||
import be.mygod.vpnhotspot.util.ServiceForegroundConnector
|
||||
import be.mygod.vpnhotspot.util.formatAddresses
|
||||
import be.mygod.vpnhotspot.widget.SmartSnackbar
|
||||
|
||||
@@ -9,9 +9,8 @@ import androidx.annotation.RequiresApi
|
||||
import androidx.core.net.toUri
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.updatePaddingRelative
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleObserver
|
||||
import androidx.lifecycle.OnLifecycleEvent
|
||||
import androidx.lifecycle.DefaultLifecycleObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import be.mygod.vpnhotspot.App.Companion.app
|
||||
import be.mygod.vpnhotspot.DebugHelper
|
||||
@@ -147,15 +146,14 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(),
|
||||
override fun stop() = TetheringManager.stop(TetheringManager.TETHERING_USB)
|
||||
}
|
||||
@RequiresApi(24)
|
||||
class Bluetooth(parent: TetheringFragment) : TetherManager(parent), LifecycleObserver {
|
||||
class Bluetooth(parent: TetheringFragment) : TetherManager(parent), DefaultLifecycleObserver {
|
||||
private val tethering = BluetoothTethering(parent.requireContext()) { onTetheringStarted() }
|
||||
|
||||
init {
|
||||
parent.lifecycle.addObserver(this)
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
||||
fun onDestroy() = tethering.close()
|
||||
override fun onDestroy(owner: LifecycleOwner) = tethering.close()
|
||||
|
||||
override val title get() = parent.getString(R.string.tethering_manage_bluetooth)
|
||||
override val tetherType get() = TetherType.BLUETOOTH
|
||||
|
||||
@@ -5,17 +5,15 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.ServiceConnection
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleObserver
|
||||
import androidx.lifecycle.DefaultLifecycleObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.OnLifecycleEvent
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
/**
|
||||
* owner also needs to be Context/Fragment.
|
||||
*/
|
||||
class ServiceForegroundConnector(private val owner: LifecycleOwner, private val connection: ServiceConnection,
|
||||
private val clazz: KClass<out Service>) : LifecycleObserver {
|
||||
private val clazz: KClass<out Service>) : DefaultLifecycleObserver {
|
||||
init {
|
||||
owner.lifecycle.addObserver(this)
|
||||
}
|
||||
@@ -26,12 +24,10 @@ class ServiceForegroundConnector(private val owner: LifecycleOwner, private val
|
||||
else -> throw UnsupportedOperationException("Unsupported owner")
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_START)
|
||||
fun onStart() {
|
||||
override fun onStart(owner: LifecycleOwner) {
|
||||
val context = context
|
||||
context.bindService(Intent(context, clazz.java), connection, Context.BIND_AUTO_CREATE)
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
|
||||
fun onStop() = context.stopAndUnbind(connection)
|
||||
override fun onStop(owner: LifecycleOwner) = context.stopAndUnbind(connection)
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ import android.os.Looper
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.lifecycle.DefaultLifecycleObserver
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleObserver
|
||||
import androidx.lifecycle.OnLifecycleEvent
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import be.mygod.vpnhotspot.App.Companion.app
|
||||
import be.mygod.vpnhotspot.util.readableMessage
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
@@ -32,17 +32,15 @@ sealed class SmartSnackbar {
|
||||
}.readableMessage)
|
||||
}
|
||||
|
||||
class Register(lifecycle: Lifecycle, private val view: View) : LifecycleObserver {
|
||||
class Register(lifecycle: Lifecycle, private val view: View) : DefaultLifecycleObserver {
|
||||
init {
|
||||
lifecycle.addObserver(this)
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
||||
fun onResume() {
|
||||
override fun onResume(owner: LifecycleOwner) {
|
||||
holder = view
|
||||
}
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
||||
fun onPause() {
|
||||
override fun onPause(owner: LifecycleOwner) {
|
||||
if (holder === view) holder = null
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user