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:
@@ -1,11 +1,10 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<!-- Base application theme. -->
|
|
||||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||||
<!-- Customize your theme here. -->
|
|
||||||
<item name="colorPrimary">@color/colorPrimary</item>
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
<item name="colorAccent">@color/colorAccent</item>
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
|
<item name="android:windowBackground">@color/soft_background</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ dependencies {
|
|||||||
api deps.rx.android
|
api deps.rx.android
|
||||||
api deps.okhttp_logging_interceptor
|
api deps.okhttp_logging_interceptor
|
||||||
api deps.timber
|
api deps.timber
|
||||||
|
api deps.lottie
|
||||||
//Testing
|
//Testing
|
||||||
api deps.testing.junit
|
api deps.testing.junit
|
||||||
api deps.testing.koin
|
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 = "1.2.0"
|
||||||
versions.test_ext = "1.1.1"
|
versions.test_ext = "1.1.1"
|
||||||
versions.espresso = "3.2.0"
|
versions.espresso = "3.2.0"
|
||||||
|
versions.lottie = "3.3.1"
|
||||||
|
|
||||||
def deps = [:]
|
def deps = [:]
|
||||||
|
|
||||||
@@ -75,5 +76,6 @@ deps.testing = testing
|
|||||||
|
|
||||||
deps.okhttp_logging_interceptor = "com.squareup.okhttp3:logging-interceptor:$versions.okhttp_logging_interceptor"
|
deps.okhttp_logging_interceptor = "com.squareup.okhttp3:logging-interceptor:$versions.okhttp_logging_interceptor"
|
||||||
deps.timber = "com.jakewharton.timber:timber:$versions.timber"
|
deps.timber = "com.jakewharton.timber:timber:$versions.timber"
|
||||||
|
deps.lottie = "com.airbnb.android:lottie:$versions.lottie"
|
||||||
|
|
||||||
ext.deps = deps
|
ext.deps = deps
|
||||||
|
|||||||
@@ -39,7 +39,3 @@ detekt {
|
|||||||
task clean(type: Delete) {
|
task clean(type: Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.buildDir
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
|
||||||
google()
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,7 +8,13 @@ import androidx.fragment.app.Fragment
|
|||||||
import com.hako.friendlist_userlist.R
|
import com.hako.friendlist_userlist.R
|
||||||
|
|
||||||
class UserlistFragment : Fragment() {
|
class UserlistFragment : Fragment() {
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View {
|
||||||
return inflater.inflate(R.layout.fragment_userlist, container, false)
|
return inflater.inflate(R.layout.fragment_userlist, container, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<include
|
||||||
android:id="@+id/textView2"
|
layout="@layout/item_user_card"
|
||||||
android:layout_width="wrap_content"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:layout_height="wrap_content"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:text="Hello world"
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
tools:layout_editor_absoluteX="174dp"
|
|
||||||
tools:layout_editor_absoluteY="352dp" />
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
40
userlist/src/main/res/layout/item_user_card.xml
Normal file
40
userlist/src/main/res/layout/item_user_card.xml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout 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="match_parent"
|
||||||
|
android:layout_height="70dp"
|
||||||
|
android:background="@drawable/bg_card"
|
||||||
|
android:elevation="2dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/item_user_card_real_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="24dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:textSize="18sp"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:text="Real Name" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/item_user_card_user_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="12sp"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/item_user_card_real_name"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/item_user_card_real_name"
|
||||||
|
tools:text="User Name" />
|
||||||
|
|
||||||
|
<com.hako.base.widgets.LikeButton
|
||||||
|
android:id="@+id/item_user_card_like_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="24dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
Reference in New Issue
Block a user