Skip to content

Instantly share code, notes, and snippets.

View n-belokopytov's full-sized avatar

Nikita Belokopytov n-belokopytov

View GitHub Profile
@n-belokopytov
n-belokopytov / copyDeps.gradle
Last active December 6, 2023 08:35
Gradle script that generates a task to copy all build variant's dependencies to a certain directory for use with Nexus IQ Server. It copies exploded AARs too, renaming the classes.jar file into "<aar_dependency_name>.jar".
apply plugin: 'com.android.application'
android.applicationVariants.all { variant ->
task "copyDependencies${variant.name.capitalize()}"() {
outputs.upToDateWhen { false }
doLast {
println "Executing copyDependencies${variant.name.capitalize()}"
variant.getCompileClasspath().each { fileDependency ->
def sourcePath = fileDependency.absolutePath
def destinationPath = project.projectDir.path + "/build/dependencies/${variant.name}/"
@n-belokopytov
n-belokopytov / TabbedListState.kt
Created April 16, 2018 15:41
A state object implemented with Kotlin's sealed classes
sealed class TabbedListState
class InProgressState : TabbedListState()
class FinishedState : TabbedListState()
data class ErrorState(val errorMessage: String,
val errorColor: Int) : TabbedListState()
data class ListState(val listElements: List<Element>,
val totalItems: Int,
val currentTabId: Int,
val tabs: List<TabElement>) : TabbedListState()
data class OfflineState(val listElements: List<Element>) : TabbedListState()
@n-belokopytov
n-belokopytov / TabbedListActivity.kt
Created April 16, 2018 15:39
State Machine in View with a Sealed Class from Kotlin
override fun onStart() {
viewModel.tabbedListLiveData.observe(this, Observer {
when (it) {
is ErrorState -> {
showProgress(false)
showErrorView(it.errorMessage, it.errorColor)
}
is InProgressState -> showProgress(true)
is OfflineState -> {