Skip to content

Instantly share code, notes, and snippets.

View vvinogra's full-sized avatar

Veniamin Vynohradov vvinogra

  • Ukraine, Kyiv
View GitHub Profile
@vvinogra
vvinogra / crypto_news.json
Created November 24, 2023 13:29 — forked from stungeye/crypto_news.json
News Site RSS Feeds
[
{
"url": "http://money.cnn.com",
"rss": "http://rss.cnn.com/rss/money_topstories.rss"
},
{
"url": "http://thehill.com",
"rss": "http://thehill.com/rss/syndicator/19110"
},
{
// Project level "build.gradle"
buildscript {
repositories {
google()
}
dependencies {
classpath 'com.jaredsburrows:gradle-license-plugin:0.9.0'
}
}
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
...
// When the user selects an option to see the licenses:
startActivity(Intent(this, OssLicensesMenuActivity::class.java))
// Add plugin to the project level 'build.gradle' file
buildscript {
repositories {
google()
}
dependencies {
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.5'
}
}
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
id 'kotlin-parcelize'
}
android {
// ...
// Read values
val isSuperFastChargingEnabled = Settings.System.getInt(context.contentResolver, "super_fast_charging", 0) == 1
val isFastChargingEnabled = Settings.System.getInt(context.contentResolver, "adaptive_fast_charging", 0) == 1
val isFastWirelessChargingEnabled = Settings.System.getInt(context.contentResolver, "wireless_fast_charging", 0) == 1
// Navigate to "Fast Charging Settings" activity
val intent = Intent()
intent.component = ComponentName(
interface NetworkConnectionManager {
/**
* Emits [Boolean] value when the current network becomes available or unavailable.
*/
val isNetworkConnectedFlow: StateFlow<Boolean>
val isNetworkConnected: Boolean
fun startListenNetworkState()
private val networkCallback = ConnectivityManager.NetworkCallback() {
override fun onAvailable(network: Network) {
// Called when network is ready to use
}
override fun onLost(network: Network) {
// Called when network disconnects
}
override fun onUnavailable() {
private val connectivityManager: ConnectivityManager = context.getSystemService()!!
val isNetworkConnected: Boolean
get() = connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)
.isNetworkCapabilitiesValid()
private fun NetworkCapabilities?.isNetworkCapabilitiesValid(): Boolean = when {
this == null -> false
hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) &&
hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED) &&
private val connectivityManager: ConnectivityManager = context.getSystemService()!!
val isNetworkConnected: Boolean
get() = connectivityManager.activeNetworkInfo?.isConnected ?: false