This file contains hidden or 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.animation.* | |
import androidx.compose.foundation.gestures.FlingBehavior | |
import androidx.compose.foundation.gestures.ScrollableDefaults | |
import androidx.compose.foundation.layout.Arrangement | |
import androidx.compose.foundation.layout.PaddingValues | |
import androidx.compose.foundation.layout.Spacer | |
import androidx.compose.foundation.layout.fillMaxWidth | |
import androidx.compose.foundation.lazy.* | |
import androidx.compose.runtime.* |
This file contains hidden or 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
@Immutable | |
sealed class Item<T> { | |
class Unavailable<T>: Item<T>() | |
data class Available<T>( | |
val data: T, | |
private var onVisible: (() -> Unit)? | |
): Item<T>() { | |
fun notifyVisible() { | |
this.onVisible?.invoke() |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:bones="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools"> | |
<data> | |
<variable | |
name="viewModel" |
This file contains hidden or 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 val dummyData = arrayOfNulls<DemoData>(DUMMY_ENTRY_COUNT) | |
val items: LiveData<Resource<List<DemoData?>?>> = repository.getDemoData().map { | |
if (it.loading) { | |
Resource.Loading(dummyData.toList()) | |
} else it | |
} | |
val itemBinding: ItemBinding<DemoData> = { data, position -> | |
when (data) { |
This file contains hidden or 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 val demoData: MutableLiveData<Resource<List<DemoData?>?>> = MutableLiveData(Resource.Loading()) | |
// Start request and emit a loading state | |
demoData.postValue(Resource.Loading() | |
// Request was successfull. Emit the data | |
demoData.postValue(Resource.Success(data)) | |
This file contains hidden or 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
sealed class Resource<out T>( | |
open val data: T?, | |
open val loading: Boolean | |
) { | |
class Success<T>( | |
data: T | |
) : Resource<T>( | |
data = data, | |
loading = false | |
) |
This file contains hidden or 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
sealed class DemoData: DiffComparable { | |
abstract val id: String | |
override fun getIdentifier() = id | |
data class A( | |
override val id: String, | |
val text: String, | |
val imageUrl: String | |
) : DemoData() |
This file contains hidden or 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
dependencies { | |
implementation 'com.github.EudyContreras:Skeleton-Bones:v1.0' | |
} |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:bones="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools"> | |
<data> | |
<variable name="viewModel" type="com.eudycontreras.bones.SomeViewModel" /> | |
<import type="com.eudycontreras.boneslibrary.properties.ShapeType" /> |
This file contains hidden or 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
val choreographer = Choreographer(this) | |
choreographer | |
.allowChildInheritance(false) | |
.withDefaultPivot(0.5f, 0f) | |
.withDefaultInterpolator(interpolator) | |
.withDefaultDuration(800) | |
.animate(card){ | |
xRotateAdd(30f) |
NewerOlder