Slf4j loggers in 3 ways
If you use SLF4J (and possibly Logback) for logging, you are probably familiar with the following code:
val logger = LoggerFactory.getLogger(MyClass::class.java)
About 2 min
If you use SLF4J (and possibly Logback) for logging, you are probably familiar with the following code:
val logger = LoggerFactory.getLogger(MyClass::class.java)
Selectable Component
String
import android.util.Patterns
/**
* [String.isValidEmail()]
* Check for a Valid Email address
*
* @return whether the input is valid for email address
*/
fun String.isValidEmail(): Boolean {
val pattern = Patterns.EMAIL_ADDRESS
val isEmail = pattern.matcher(this).matches()
return this.isNotEmpty() && isEmail
}
class GodActivity : AppCompatActivity {
override fun onStart() {
with(ProcessLifecycleOwner.get()) {
lifecycleScope.launch {
lifecycle.repeatOnLifecycle(Lifecycle.State.RESUMED) {
startService()
}
}
}
}
priavte suspend fun startService() {
try {
exponentialRetry {
context.startService(
Intent(
context,
WebSocketService::class.java,
)
)
}
} catch (e1: CancellationException) {
// user has gone to the background before service was suceessflly started
// the scope has beeen closed along with the process hence we cannot start a background service
} catch (e2: IllegalStateException) {
log(e2)
}
}
}