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
@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( |
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
@HiltAndroidApp | |
class UpdateDetectorApplication : Application() { | |
@Inject | |
lateinit var updateDetector: UpdateDetector | |
override fun onCreate() { | |
super.onCreate() | |
// Update app version for next session |
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 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) } |
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
@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 |
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
#!/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 |
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
#!/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 |
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
fun Context.isDontKeepActivitiesEnabled(): Boolean = | |
Settings.Global.getInt(contentResolver, Settings.Global.ALWAYS_FINISH_ACTIVITIES, 0) == 1 |
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 poll() { | |
pollable.startPolling() | |
.subscribe({ | |
refreshView() | |
}, Timber::e) | |
} |
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 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() { |
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 poll() { | |
Observable.interval(1, TimeUnit.SECONDS) | |
.subscribe { | |
refreshView() | |
} | |
} |
NewerOlder