Skip to content

Instantly share code, notes, and snippets.

package com.olearis.notate.ui.screen.settinglist
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import com.nhaarman.mockitokotlin2.times
import com.olearis.notate.interactor.INoteInteractor
import com.olearis.notate.interactor.INoteListInteractor
import com.olearis.notate.model.SortCriteria
import com.olearis.notate.model.SortDirection
import com.olearis.notate.model.SortOrder
import com.olearis.notate.model.UniId
private sealed class State {
object KerberosAuthorization : State()
object EmailAuthorization : State()
object UsernameAuthorization : State()
object ExchangeUrlAuthorization : State()
}
private sealed class Event {
object OnKerberosAuthorizationFailed : Event()
object OnEmailAuthorizationFailed : Event()
class CompositeAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
var adapters: List<RecyclerView.Adapter<RecyclerView.ViewHolder>> by adapterProperty(emptyList())
fun addAdapter(adapter: RecyclerView.Adapter<out RecyclerView.ViewHolder>) {
@Suppress("UNCHECKED_CAST")
adapters = adapters.plus(adapter as RecyclerView.Adapter<RecyclerView.ViewHolder>)
adapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
override fun onChanged() {
notifyDataSetChanged()
@featzima
featzima / main.kt
Created October 14, 2018 14:47
The cleaner for all gradle projects on a disc.
import java.io.File
interface IProjectDetector {
fun isProjectRootFolder(folder: File): Boolean
}
interface IProjectCleaner {
fun clean(folder: File)
}
data class MyViewModel(
private val myEndpoint: MyEndpoint): DisposableViewModel() {
private val searchText = ChannelLiveData("")
private val inProgress = ChannelLiveData(false)
private val result = ChannelLiveData("")
init {
disposableLaunch {
searchText.consumeEach { searchText ->
data class MyViewModel(
private val myEndpoint: MyEndpoint): DisposableViewModel() {
private val searchText = ChannelLiveData("")
private val inProgress = ChannelLiveData(false)
private val result = ChannelLiveData("")
init {
disposableLaunch {
searchText
@featzima
featzima / MainViewModel.kt
Last active March 27, 2019 17:15
LiveData implementation that is based on Kotlin coroutines
class MainViewModel : DisposableViewModel() {
val title = ChannelLiveData("New Title 0")
val isReady = ChannelLiveData(false)
init {
disposableLaunch {
(1..Int.MAX_VALUE).forEach { time ->
delay(1, TimeUnit.SECONDS)
title.send("New Title $time")
}
// добавить файлы в индекс (изменившиеся или новые)
git add <filename>
// сделать локальный коммит
git commit -m "<commit comment>"
// отправить все локальные коммиты на сервер
git push
{
"name": "gulp-test",
"version": "0.0.0",
"authors": [
"featZima <featzima@gmail.com>"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",