mirror of
https://github.com/imcarlost/Friendlists.git
synced 2026-04-10 02:46:54 -04:00
integrate lottie and create view for users
This commit is contained in:
@@ -52,6 +52,7 @@ dependencies {
|
||||
api deps.rx.android
|
||||
api deps.okhttp_logging_interceptor
|
||||
api deps.timber
|
||||
api deps.lottie
|
||||
//Testing
|
||||
api deps.testing.junit
|
||||
api deps.testing.koin
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.hako.base.extensions
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.LayoutRes
|
||||
|
||||
fun ViewGroup.inflate(@LayoutRes layout: Int, attachToRoot: Boolean = false) =
|
||||
LayoutInflater
|
||||
.from(context)
|
||||
.inflate(layout, this, attachToRoot)
|
||||
46
base/src/main/java/com/hako/base/widgets/LikeButton.kt
Normal file
46
base/src/main/java/com/hako/base/widgets/LikeButton.kt
Normal file
@@ -0,0 +1,46 @@
|
||||
package com.hako.base.widgets
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.widget.FrameLayout
|
||||
import com.hako.base.R
|
||||
import com.hako.base.extensions.inflate
|
||||
import kotlinx.android.synthetic.main.like_button.view.*
|
||||
|
||||
private const val LIKE_MIN_FRAME = 0
|
||||
private const val LIKE_MAX_FRAME = 28
|
||||
private const val LIKE_ANIM_SPEED = 1f
|
||||
private const val DISLIKE_MIN_FRAME = 28
|
||||
private const val DISLIKE_MAX_FRAME = 70
|
||||
private const val DISLIKE_ANIM_SPEED = 2f
|
||||
|
||||
class LikeButton @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : FrameLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
init {
|
||||
inflate(R.layout.like_button, true)
|
||||
}
|
||||
|
||||
fun like() {
|
||||
like_button_animation_view.frame = LIKE_MAX_FRAME
|
||||
}
|
||||
|
||||
fun dislike() {
|
||||
like_button_animation_view.frame = LIKE_MIN_FRAME
|
||||
}
|
||||
|
||||
fun playLike() {
|
||||
like_button_animation_view.setMinAndMaxFrame(LIKE_MIN_FRAME, LIKE_MAX_FRAME)
|
||||
like_button_animation_view.speed = LIKE_ANIM_SPEED
|
||||
like_button_animation_view.playAnimation()
|
||||
}
|
||||
|
||||
fun playDislike() {
|
||||
like_button_animation_view.setMinAndMaxFrame(DISLIKE_MIN_FRAME, DISLIKE_MAX_FRAME)
|
||||
like_button_animation_view.speed = DISLIKE_ANIM_SPEED
|
||||
like_button_animation_view.playAnimation()
|
||||
}
|
||||
}
|
||||
9
base/src/main/res/drawable/bg_card.xml
Normal file
9
base/src/main/res/drawable/bg_card.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape >
|
||||
<solid android:color="@color/card_background" />
|
||||
<corners android:radius="4dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
19
base/src/main/res/layout/like_button.xml
Normal file
19
base/src/main/res/layout/like_button.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:parentTag="android.widget.FrameLayout">
|
||||
|
||||
<com.airbnb.lottie.LottieAnimationView
|
||||
android:id="@+id/like_button_animation_view"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:scaleType="centerInside"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:lottie_rawRes="@raw/like_animation" />
|
||||
|
||||
</merge>
|
||||
1
base/src/main/res/raw/like_animation.json
Normal file
1
base/src/main/res/raw/like_animation.json
Normal file
File diff suppressed because one or more lines are too long
8
base/src/main/res/values/colors.xml
Normal file
8
base/src/main/res/values/colors.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="soft_background">#EEEEEE</color>
|
||||
|
||||
<color name="transparent">#00000000</color>
|
||||
|
||||
<color name="card_background">#FFFFFF</color>
|
||||
</resources>
|
||||
@@ -19,6 +19,7 @@ versions.junit = "4.13"
|
||||
versions.test = "1.2.0"
|
||||
versions.test_ext = "1.1.1"
|
||||
versions.espresso = "3.2.0"
|
||||
versions.lottie = "3.3.1"
|
||||
|
||||
def deps = [:]
|
||||
|
||||
@@ -75,5 +76,6 @@ deps.testing = testing
|
||||
|
||||
deps.okhttp_logging_interceptor = "com.squareup.okhttp3:logging-interceptor:$versions.okhttp_logging_interceptor"
|
||||
deps.timber = "com.jakewharton.timber:timber:$versions.timber"
|
||||
deps.lottie = "com.airbnb.android:lottie:$versions.lottie"
|
||||
|
||||
ext.deps = deps
|
||||
|
||||
Reference in New Issue
Block a user