-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from TheXtremeLabs/develop
Develop
- Loading branch information
Showing
10 changed files
with
254 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
111 changes: 111 additions & 0 deletions
111
app/src/main/java/com/riders/thelab/ui/lottie/LottieActivity.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package com.riders.thelab.ui.lottie | ||
|
||
import android.animation.Animator | ||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.core.view.doOnPreDraw | ||
import com.riders.thelab.databinding.ActivityLottieBinding | ||
import timber.log.Timber | ||
import kotlin.random.Random | ||
|
||
class LottieActivity : AppCompatActivity() { | ||
|
||
private var _viewBinding: ActivityLottieBinding? = null | ||
|
||
// This property is only valid between onCreateView and | ||
// onDestroyView. | ||
private val binding get() = _viewBinding!! | ||
|
||
private var isConnected: Boolean = false | ||
|
||
companion object { | ||
val lottieUrls = mutableListOf( | ||
// Android | ||
"https://assets1.lottiefiles.com/datafiles/8rza4J0CdJeJ8Pb3v9INOKI0vcekEpVccKVF2lNQ/android.json", | ||
// Search | ||
"https://assets4.lottiefiles.com/packages/lf20_83et0zjc.json", | ||
// Loading | ||
"https://assets1.lottiefiles.com/private_files/lf30_bn5winlb.json", | ||
"https://assets5.lottiefiles.com/private_files/lf30_qsg7wqkv.json", | ||
// Fluid loader | ||
"https://assets2.lottiefiles.com/packages/lf20_kk62um5v.json", | ||
// Swinging | ||
"https://assets6.lottiefiles.com/packages/lf20_97iupqly.json", | ||
// Scanning files | ||
"https://assets5.lottiefiles.com/private_files/lf30_jasmilgh.json", | ||
|
||
// Backgrounds | ||
// IT | ||
"https://assets10.lottiefiles.com/packages/lf20_k5dcqzxm.json", | ||
// Abstract | ||
"https://assets7.lottiefiles.com/packages/lf20_ym8w5cx4.json", | ||
) | ||
} | ||
|
||
///////////////////////////////////// | ||
// | ||
// OVERRIDE | ||
// | ||
///////////////////////////////////// | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
_viewBinding = ActivityLottieBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
postponeEnterTransition() | ||
binding.root.doOnPreDraw { startPostponedEnterTransition() } | ||
|
||
binding.lottieAnimationView.enableMergePathsForKitKatAndAbove(true) | ||
binding.lottieAnimationView.setOutlineMasksAndMattes(true) | ||
|
||
binding.lottieAnimationView.setAnimationFromUrl(lottieUrls[6]) | ||
} | ||
|
||
override fun onPause() { | ||
super.onPause() | ||
Timber.e("onPause()") | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
Timber.d("onResume()") | ||
} | ||
|
||
|
||
override fun onDestroy() { | ||
Timber.e("onDestroy()") | ||
_viewBinding = null | ||
super.onDestroy() | ||
} | ||
|
||
private fun startRandomPlay() { | ||
|
||
binding.lottieAnimationView.setAnimationFromUrl(lottieUrls[3]) | ||
binding.lottieAnimationView.addAnimatorListener(object : Animator.AnimatorListener { | ||
override fun onAnimationStart(animation: Animator?) { | ||
Timber.d("onAnimationStart()") | ||
} | ||
|
||
override fun onAnimationEnd(animation: Animator?) { | ||
Timber.e("onAnimationEnd()") | ||
} | ||
|
||
override fun onAnimationCancel(animation: Animator?) { | ||
Timber.e("onAnimationCancel()") | ||
} | ||
|
||
override fun onAnimationRepeat(animation: Animator?) { | ||
Timber.d("onAnimationRepeat()") | ||
binding.lottieAnimationView.setAnimationFromUrl( | ||
lottieUrls[Random.nextInt( | ||
0, | ||
lottieUrls.size | ||
)] | ||
) | ||
binding.lottieAnimationView.playAnimation() | ||
} | ||
|
||
}) | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:aapt="http://schemas.android.com/aapt" | ||
android:width="64dp" | ||
android:height="64.35165dp" | ||
android:viewportWidth="182" | ||
android:viewportHeight="183"> | ||
<path android:pathData="M90.996,91.459m-90.957,0a90.957,90.957 0,1 1,181.914 0a90.957,90.957 0,1 1,-181.914 0"> | ||
<aapt:attr name="android:fillColor"> | ||
<gradient | ||
android:endX="143.671" | ||
android:endY="117.323" | ||
android:startX="47.0462" | ||
android:startY="42.7324" | ||
android:type="linear"> | ||
<item | ||
android:color="#FF2AEAEC" | ||
android:offset="0" /> | ||
<item | ||
android:color="#FF0FCECF" | ||
android:offset="1" /> | ||
</gradient> | ||
</aapt:attr> | ||
</path> | ||
<path | ||
android:fillColor="#ffffff" | ||
android:pathData="M124.233,52.425C127.924,52.972 130.471,56.413 129.927,60.108C129.382,63.805 125.949,66.362 122.256,65.814C116.19,64.915 106.901,74.575 96.481,94.477C83.053,120.124 70.526,132.371 57.257,131.388C53.535,131.112 50.744,127.866 51.019,124.141C51.293,120.414 54.531,117.614 58.253,117.89C64.557,118.357 74.001,108.278 84.518,88.19C98.035,62.374 110.739,50.425 124.233,52.425Z" /> | ||
</vector> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
app:cardBackgroundColor="@color/default_dark" | ||
app:cardCornerRadius="0dp"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<com.airbnb.lottie.LottieAnimationView | ||
android:id="@+id/lottieAnimationView" | ||
android:layout_width="match_parent" | ||
android:layout_height="0dp" | ||
android:scaleType="centerCrop" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:lottie_autoPlay="true" | ||
app:lottie_loop="true" | ||
app:lottie_scale="0.6" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</com.google.android.material.card.MaterialCardView> |
This file contains 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
Oops, something went wrong.