Skip to content

Instantly share code, notes, and snippets.

View Changelog.kt
package com.livepenalty.android
import com.livepenalty.android.CommitRange.BiDirectional
import com.livepenalty.android.CommitRange.UniDirectional
import com.livepenalty.android.ConventionalCommit.chore
import com.livepenalty.android.ConventionalCommit.docs
import com.livepenalty.android.ConventionalCommit.feat
import com.livepenalty.android.ConventionalCommit.fix
import com.livepenalty.android.ConventionalCommit.other
import com.livepenalty.android.ConventionalCommit.refactor
@ywett02
ywett02 / debounce.kt
Created Jan 28, 2019 — forked from lupajz/debounce.kt
Simple debounce extension for LiveData
View debounce.kt
import android.arch.lifecycle.LiveData
import android.arch.lifecycle.MediatorLiveData
import android.os.Handler
import android.os.Looper
fun <T> LiveData<T>.debounce(duration: Long = 1000L) = MediatorLiveData<T>().also { mld ->
val source = this
val handler = Handler(Looper.getMainLooper())
val runnable = Runnable {
@ywett02
ywett02 / progress_request_body.kt
Last active Feb 2, 2019
File upload with progress
View progress_request_body.kt
import okhttp3.MediaType
import okhttp3.RequestBody
import okio.BufferedSink
import okio.Okio
import java.io.File
import kotlin.math.roundToInt
class ProgressByteArrayRequestBody(
private val contentType: MediaType,
private val array: ByteArray,
View my_profile_view_model.kt
class MyProfileViewModel {
val progress = MutableLiveData()
val myProfile = MutableLiveData()
override fun loadProfile() {
progress.value = true
subscriptions.add(
myProfileInteractor.getLoggedUser().subscribe(
View country_list_view_state.kt
data class CountryListViewState(
val isLoading = false,
val countries = emptyList(),
val isRefreshing = true,
val error = `UnknownHostException…`)
View reducer.kt
val reducer = BiFunction { previousState: CountryListViewState, result: CountryListResult ->
when (result) {
is LoadCountriesResult ->
when (result) {
is LoadCountriesResult.Success -> {
previousState.copy(
isLoading = false,
isRefreshing = false,
countries = result.countries
)
View L.I.F.T. privacy policy
<html>
<body>
<h2>Privacy Policy</h2>
<p>Iveta Jurčíková and Benjamín Varga built the L.I.F.T. app as a free app. This SERVICE is provided by Iveta Jurčíková and Benjamín Varga at no cost and is intended
for use as is.</p>
<p>This page is used to inform website visitors regarding our policies with the collection, use, and
disclosure of Personal Information if anyone decided to use our Service.</p>
<p>If you choose to use our Service, then you agree to the collection and use of information in
relation with this policy. The Personal Information that we collect are used for providing and
improving the Service. We will not use or share your information with anyone except as described