refactor: let the periodic work run more frequently and never fail from excessive retries preventing from re-running.

remove resume pending jobs from ApplicationContext onCreate and handle in home activity's onCreate instead.

prevent some illegal argument exceptions from Random.kt by returning null if empty
This commit is contained in:
jubb
2021-05-10 17:07:10 +10:00
parent 11a89c0a76
commit 8439d57115
5 changed files with 11 additions and 27 deletions

View File

@@ -6,6 +6,7 @@ import java.security.SecureRandom
* Uses `SecureRandom` to pick an element from this collection.
*/
fun <T> Collection<T>.getRandomElementOrNull(): T? {
if (isEmpty()) return null
val index = SecureRandom().nextInt(size) // SecureRandom() should be cryptographically secure
return elementAtOrNull(index)
}