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
// some setup | |
interface IDisposable { | |
fun dispose() | |
} | |
data class Handle(val resource: String) : IDisposable { | |
override fun dispose() { | |
println("Disposing of $this") | |
} |
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 raiseMoveMade() = moveMade.forEach { it.invoke() } | |
val moveMade = mutableListOf<() -> Unit>() | |
// invoking | |
raiseMoveMade() | |
// assigning a listener (in the outside world) | |
moveMade += { uiSounds.playMove() } |
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 HelpDialogFragment : androidx.fragment.app.DialogFragment() { | |
override fun onCreateView( | |
inflater: LayoutInflater, | |
container: ViewGroup?, | |
savedInstanceState: Bundle? | |
): View? { | |
return inflater.inflate(R.layout.fragment_help, null) | |
} |
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
import com.github.pksokolowski.posty.di.PerApp | |
import kotlinx.coroutines.Dispatchers | |
import kotlinx.coroutines.GlobalScope | |
import kotlinx.coroutines.launch | |
import kotlinx.coroutines.withContext | |
import javax.inject.Inject | |
@PerApp | |
class RequestRunner @Inject constructor(private val ongoingTasksTracker: OngoingTasksTracker) { |
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
import android.content.Context | |
import android.util.AttributeSet | |
import android.widget.LinearLayout | |
import kotlinx.android.synthetic.main.icon_view.view.* | |
class IconView @JvmOverloads constructor( | |
context: Context, | |
attrs: AttributeSet? = null | |
) : LinearLayout(context, attrs) { |
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
/** | |
* Utilizes TextToSpeech engine on the device to speak out loud what you want it to say. | |
*/ | |
@PerApp | |
class Voice @Inject constructor( | |
private val context: Application | |
) { | |
private var isTtsReady = false | |
private var tts: TextToSpeech? = null | |
private var postponedTextToSay: String? = null |
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
import android.app.Activity | |
import android.content.pm.PackageManager | |
import androidx.core.app.ActivityCompat | |
import androidx.core.content.ContextCompat | |
import com.github.pksokolowski.trainingplanner.di.PerApp | |
import javax.inject.Inject | |
/** | |
* A universal permissions helper. It should be injected both where you need to ask for a | |
* given permission and in the underlying activity. Within the activity, in |
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 const val reset = "\u001b[0m" | |
fun printc(content: String, r: Int, g: Int, b: Int) = print("\u001b[38;2;$r;$g;${b}m" + content + reset) | |
fun printlnc(content: String, r: Int, g: Int, b: Int) = println("\u001b[38;2;$r;$g;${b}m" + content + reset) |
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
import androidx.compose.foundation.clickable | |
import androidx.compose.foundation.layout.Arrangement | |
import androidx.compose.foundation.layout.Box | |
import androidx.compose.foundation.layout.Row | |
import androidx.compose.foundation.layout.padding | |
import androidx.compose.material.DropdownMenu | |
import androidx.compose.material.DropdownMenuItem | |
import androidx.compose.material.Icon | |
import androidx.compose.material.icons.Icons | |
import androidx.compose.material.icons.filled.ArrowDropDown |