Skip to content

Instantly share code, notes, and snippets.

registerReceiver(object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if ((intent.extras["networkInfo"] as NetworkInfo).state != NetworkInfo.State.CONNECTED) {
Toast.makeText(context, R.string.networkErr, Toast.LENGTH_LONG).show()
unregisterReceiver(this)
finish()
return
}
}
}, IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION))
@EugW
EugW / SimpleMap.kt
Created March 3, 2018 15:39
Kotlin simple map
class SimpleMap<in K, V> {
private var keys = ArrayList<K>()
private var values = ArrayList<V>()
operator fun get(key: K): V {
return values[keys.indexOf(key)]
}
operator fun set(key: K, value: V) {