Remove unused function
This commit is contained in:
parent
ef0f326073
commit
ad2dfcae1b
@ -1,51 +1,13 @@
|
|||||||
package bou.amine.apps.readerforselfossv2.android.utils.network
|
package bou.amine.apps.readerforselfossv2.android.utils.network
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Color
|
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
import android.net.NetworkCapabilities
|
import android.net.NetworkCapabilities
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.view.View
|
|
||||||
import android.widget.TextView
|
|
||||||
import bou.amine.apps.readerforselfossv2.android.R
|
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
|
||||||
var snackBarShown = false
|
|
||||||
var view: View? = null
|
|
||||||
lateinit var s: Snackbar
|
lateinit var s: Snackbar
|
||||||
|
|
||||||
fun Context.isNetworkAvailable(
|
|
||||||
v: View? = null,
|
|
||||||
overrideOffline: Boolean = false
|
|
||||||
): Boolean {
|
|
||||||
val networkIsAccessible = isNetworkAccessible(this)
|
|
||||||
|
|
||||||
if (v != null && (!networkIsAccessible || overrideOffline) && (!snackBarShown || v != view)) {
|
|
||||||
view = v
|
|
||||||
s = Snackbar
|
|
||||||
.make(
|
|
||||||
v,
|
|
||||||
R.string.no_network_connectivity,
|
|
||||||
Snackbar.LENGTH_INDEFINITE
|
|
||||||
)
|
|
||||||
|
|
||||||
s.setAction(android.R.string.ok) {
|
|
||||||
snackBarShown = false
|
|
||||||
s.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
val view = s.view
|
|
||||||
val tv: TextView = view.findViewById(com.google.android.material.R.id.snackbar_text)
|
|
||||||
tv.setTextColor(Color.WHITE)
|
|
||||||
s.show()
|
|
||||||
snackBarShown = true
|
|
||||||
}
|
|
||||||
if (snackBarShown && networkIsAccessible && !overrideOffline) {
|
|
||||||
s.dismiss()
|
|
||||||
}
|
|
||||||
return if(overrideOffline) overrideOffline else networkIsAccessible
|
|
||||||
}
|
|
||||||
|
|
||||||
fun isNetworkAccessible(context: Context): Boolean {
|
fun isNetworkAccessible(context: Context): Boolean {
|
||||||
val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user