Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

private val speech: SpeechRecognizer by lazy { SpeechRecognizer.createSpeechRecognizer(context) }
if (SpeechRecognizer.isRecognitionAvailable(context)) {
speechRecognizer.setRecognitionListener(this)
} else {
// Handle error
}
@OptIn(ExperimentalAnimationApi::class)
@Composable
fun CountDown(
count: Int?,
modifier: Modifier = Modifier,
) {
val transitionDuration = 500
val enterTransition = scaleIn(initialScale = 1.5f, animationSpec = tween(transitionDuration))
val exitTransition = scaleOut(targetScale = 4f, animationSpec = tween(transitionDuration)) + fadeOut(animationSpec = tween(transitionDuration))
AnimatedVisibility(
@HiltAndroidApp
class UpdateDetectorApplication : Application() {
@Inject
lateinit var updateDetector: UpdateDetector
override fun onCreate() {
super.onCreate()
// Update app version for next session
class UpdatePreferences @Inject constructor(context: Context) {
companion object {
private const val UPDATE_DETECTOR_SHARED_PREFERENCES = "updateDetector"
private const val VERSION = "updateDetector:version"
}
private val sharedPreferences: SharedPreferences by lazy { context.getSharedPreferences(UPDATE_DETECTOR_SHARED_PREFERENCES, Activity.MODE_PRIVATE) }
@Singleton
class UpdateDetector @Inject constructor(private val updatePreferences: UpdatePreferences) {
/**
* Store in RAM version so that we can directly save new version in preferences while using previous version in same session (Singleton)
*/
private var version = updatePreferences.version
/**
* Save current version into preferences. Must be called at app launch
#!/bin/bash
MESSAGE=$(cat $1)
TICKET=$(git rev-parse --abbrev-ref HEAD | grep -Eo '(\w+[-])?[0-9]+' | tr "[:lower:]" "[:upper:]")
if [[ "$MESSAGE" == *"$TICKET"* ]]; then
echo "Ticket found in commit message. Skipping..."
exit 0
fi
#!/bin/sh
BRANCH=$(git rev-parse --abbrev-ref HEAD)
REGEX="^(develop|master|release|((feature|bigfeature|task|bugfix|hotfix)\/[A-Z]+-[0-9]+_[A-Z]+_.+))$"
if ! [[ $BRANCH =~ $REGEX ]]; then
echo "Your commit was rejected due to branching name"
echo "Please rename your branch with $REGEX syntax"
exit 1
fi
fun Context.isDontKeepActivitiesEnabled(): Boolean =
Settings.Global.getInt(contentResolver, Settings.Global.ALWAYS_FINISH_ACTIVITIES, 0) == 1
private fun poll() {
pollable.startPolling()
.subscribe({
refreshView()
}, Timber::e)
}
class PollableViewModel {
fun startPolling(): Observable<Long> =
Observable.interval(1, TimeUnit.SECONDS)
.map { it / 0 } // throws ArithmeticException: / by zero
}
class PollableView(private val pollable: PollableViewModel) {
private fun poll() {