This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
coroutineScope.launch { | |
val job = coroutineScope.launch { | |
var counter = 0 | |
while (true) { | |
counter++ | |
println("Current Counter is $counter") | |
} | |
} | |
delay(1000) | |
println("Cancelling Job") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class IConfigProvider { | |
abstract fun getString(key: String): String | |
abstract fun getBoolean(key: String): Boolean | |
abstract fun getDouble(key: String): Double | |
abstract fun getLong(key: String): Long | |
abstract fun getInt(key: String): Int | |
inline fun <reified T> dataFromJson(data: String?): T? { | |
var configData: T? = null | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ConfigProviderImpl(private val remoteConfig: FirebaseRemoteConfig) : | |
IConfigProvider() { | |
override fun getString(key: String): String { | |
return remoteConfig.getString(key) | |
} | |
override fun getBoolean(key: String): Boolean { | |
return remoteConfig.getBoolean(key) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* common remote config data source for configs used in more than 1 module | |
*/ | |
class CommonRemoteConfigData(private val config: IConfigProvider) { | |
fun getListOfEnabledCities(): List<String>? { | |
return config.dataFromJson( | |
config.getString( | |
"SOMEKEY" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun observeDataChange() { | |
holidayViewModel.holidays.observe(viewLifecycleOwner, { | |
when (it) { | |
is Resource.Error -> {} | |
is Resource.Loading -> {} | |
is Resource.Success -> {} | |
} | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Naming Activities | |
class HomeActivity | |
class HomeScreen | |
class Home | |
//Interface naming conventions | |
interface IHolidaysRepository |
OlderNewer