Skip to content

Instantly share code, notes, and snippets.

View kolanse's full-sized avatar

Samuel Ochuba kolanse

View GitHub Profile
@kolanse
kolanse / ScoresAverageWorker
Created December 6, 2022 09:15
A simple Workmanager class to demonstrate how to create one.
class ScoresAverageWorker(
context: Context,
workerParams: WorkerParameters
) : Worker(context, workerParams) {
override suspend fun doWork(): Result {
val results = Results.List
val average = results.average()
var myEditText = findViewById<EditText>(R.id.myEditText)
myEditText.doOnTextChanged { text, start, before, count ->
run {
// run your code here.
// the text is the changed text
}
@kolanse
kolanse / IconView.kt
Created November 23, 2020 10:10 — forked from nickbutcher/IconView.kt
A prototype implementation of a shadow effect inspired by the Google Play Games app (https://play.google.com/store/apps/details?id=com.google.android.play.games).
/*
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
<style name="spinnerTheme" parent= "Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu">
<item name="strokeColor">@color/grey</item>
<item name="endIconDrawable">@drawable/vector__spinner_dropdown</item>
</style>
<style name="spinnerTheme" parent= "Widget.MaterialComponents.TextInputLayout.FilledBox.ExposedDropdownMenu">
<item name="strokeColor">@color/grey</item>
</style>
@kolanse
kolanse / MainActivity.kt
Created August 8, 2020 20:23
dark mode kotlin
package com.example.constrainttutorial
import android.content.SharedPreferences
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import androidx.appcompat.app.AppCompatDelegate
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
@kolanse
kolanse / colors.xml
Created August 8, 2020 20:17
color night
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#6200EE</color>
<color name="colorPrimaryDark">#3700B3</color>
<color name="colorAccent">#03DAC5</color>
<color name="background_lay">#00008B</color>
<color name="buttonbackground">#fff</color>
<color name="button_text">#00008B</color>
</resources>
<string name="mode">Enable Dark Mode</string>
@kolanse
kolanse / colors.xml
Created August 8, 2020 19:54
colors
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#6200EE</color>
<color name="colorPrimaryDark">#3700B3</color>
<color name="colorAccent">#03DAC5</color>
<color name="background_lay">#fff</color>
<color name="buttonbackground">#00008B</color>
<color name="button_text">#fff</color>
@kolanse
kolanse / button_design.xml
Created August 8, 2020 19:53
button design
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="@color/buttonbackground"/>
<corners android:radius="16dp"/>
</shape>
</item>
</selector>