[Sample App] Added PreviewFragment
diff --git a/LottieSample/build.gradle b/LottieSample/build.gradle
index 00fe7fa..278801a 100644
--- a/LottieSample/build.gradle
+++ b/LottieSample/build.gradle
@@ -64,7 +64,6 @@
implementation 'com.matthew-tamlin:sliding-intro-screen:3.2.0'
implementation 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.2'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.2'
- debugImplementation 'com.github.brianPlummer:tinydancer:0.0.9'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.airbnb.android:happo:0.0.15@aar'
// TODO: figure out why transitive deps of happo are needed
diff --git a/LottieSample/src/debug/java/com/airbnb/lottie/samples/LottieApplication.java b/LottieSample/src/debug/java/com/airbnb/lottie/samples/LottieApplication.java
deleted file mode 100644
index 81ae149..0000000
--- a/LottieSample/src/debug/java/com/airbnb/lottie/samples/LottieApplication.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.airbnb.lottie.samples;
-
-import android.app.Application;
-import android.support.v4.util.Pair;
-import android.support.v7.app.AppCompatDelegate;
-import android.view.Gravity;
-
-import com.airbnb.lottie.L;
-import com.codemonkeylabs.fpslibrary.FrameDataCallback;
-import com.codemonkeylabs.fpslibrary.TinyDancer;
-
-public class LottieApplication extends Application implements ILottieApplication {
- private int droppedFrames;
- private long droppedFramesStartingNs;
- private long currentFrameNs;
- @Override public void onCreate() {
- super.onCreate();
- AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
- if (L.DBG) {
- TinyDancer.create()
- .startingGravity(Gravity.TOP | Gravity.END)
- .startingXPosition(0)
- .startingYPosition(0)
- .addFrameDataCallback(new FrameDataCallback() {
- @Override
- public void doFrame(long previousFrameNs, long currentFrameNs, int droppedFrames) {
- LottieApplication.this.droppedFrames += droppedFrames;
- LottieApplication.this.currentFrameNs = currentFrameNs;
- }
- })
- .show(this);
- }
- }
-
- @Override public void startRecordingDroppedFrames() {
- droppedFrames = 0;
- droppedFramesStartingNs = currentFrameNs;
- }
-
- @Override public Pair<Integer, Long> stopRecordingDroppedFrames() {
- long duration = currentFrameNs - droppedFramesStartingNs;
- Pair<Integer, Long> ret = new Pair<>(droppedFrames, duration);
- droppedFrames = 0;
- return ret;
- }
-}
diff --git a/LottieSample/src/main/AndroidManifest.xml b/LottieSample/src/main/AndroidManifest.xml
index e97c567..f3ff772 100644
--- a/LottieSample/src/main/AndroidManifest.xml
+++ b/LottieSample/src/main/AndroidManifest.xml
@@ -22,6 +22,7 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
+
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts"/>
@@ -36,10 +37,13 @@
<activity
android:name=".QRScanActivity"
android:screenOrientation="portrait"/>
- <activity android:name=".FullScreenActivity" />
+ <activity android:name=".FullScreenActivity"/>
<activity
android:name=".TestColorFilterActivity"
android:screenOrientation="portrait"/>
+ <activity
+ android:name=".PlayerActivity"
+ android:screenOrientation="portrait"/>
</application>
</manifest>
\ No newline at end of file
diff --git a/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/AnimationFragment.kt b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/AnimationFragment.kt
index 9e9cbb5..60d8a1a 100644
--- a/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/AnimationFragment.kt
+++ b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/AnimationFragment.kt
@@ -16,7 +16,6 @@
import android.support.v4.app.Fragment
import android.support.v7.app.AppCompatActivity
import android.text.TextUtils
-import android.util.Log
import android.view.*
import android.widget.EditText
import android.widget.Toast
@@ -60,8 +59,6 @@
private val handler = Handler()
private val client: OkHttpClient by lazy { OkHttpClient() }
private lateinit var myActivity: AppCompatActivity
- private val application: ILottieApplication
- get() = activity!!.application as ILottieApplication
private var renderTimeGraphRange = 4f
private val lineDataSet by lazy {
val entries = ArrayList<Entry>(101)
@@ -101,9 +98,7 @@
view.overflowMenu.setDrawableLeft(R.drawable.ic_more_vert_selector, myActivity)
view.animationView.addAnimatorListener(AnimatorListenerAdapter(
- onStart = { startRecordingDroppedFrames() },
onEnd = {
- recordDroppedFrames()
postUpdatePlayButtonText()
animationView.performanceTracker?.logRenderTimes()
},
@@ -111,8 +106,6 @@
onRepeat = {
animationView.performanceTracker?.logRenderTimes()
animationView.performanceTracker?.clearRenderTimes()
- recordDroppedFrames()
- startRecordingDroppedFrames()
}
))
@@ -437,12 +430,6 @@
private fun onLoadError() = view!!.showSnackbarLong("Failed to load animation")
- private fun startRecordingDroppedFrames() = application.startRecordingDroppedFrames()
-
- private fun recordDroppedFrames() {
- val droppedFrames = application.stopRecordingDroppedFrames()
- Log.d(TAG, "Dropped frames: " + droppedFrames.first)
- }
private fun getAnimationScale(context: Context): Float {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
diff --git a/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/CompositionLoader.kt b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/CompositionLoader.kt
new file mode 100644
index 0000000..8cc04eb
--- /dev/null
+++ b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/CompositionLoader.kt
@@ -0,0 +1,93 @@
+package com.airbnb.lottie.samples
+
+import android.annotation.SuppressLint
+import android.content.Context
+import android.net.Uri
+import android.os.Parcelable
+import com.airbnb.lottie.LottieComposition
+import com.airbnb.lottie.OnCompositionLoadedListener
+import kotlinx.android.parcel.Parcelize
+import okhttp3.Request
+import java.io.FileInputStream
+import java.io.FileNotFoundException
+
+@SuppressLint("ParcelCreator")
+@Parcelize
+class CompositionArgs(
+ val assetName: String? = null,
+ val url: String? = null,
+ val fileUri: Uri? = null
+) : Parcelable
+class CompositionLoader(
+ private val context: Context,
+ args: CompositionArgs,
+ private val listener: OnCompositionLoadedListener
+) {
+ private val okHttpClient by lazy { (context.applicationContext as LottieApplication).okHttpClient }
+
+ init {
+ if (args.assetName != null) {
+ LottieComposition.Factory.fromAssetFileName(context, args.assetName, listener)
+ } else if (args.url != null) {
+ loadUrl(args.url)
+ } else if (args.fileUri != null) {
+ loadFile(args.fileUri)
+ }
+ }
+
+ private fun loadUrl(url: String) {
+ val request: Request
+ try {
+ request = Request.Builder()
+ .url(url)
+ .build()
+ } catch (e: IllegalArgumentException) {
+ onLoadError()
+ return
+ }
+ okHttpClient.newCall(request)?.enqueue(OkHttpCallback(
+ onFailure = { _, _ -> onLoadError() },
+ onResponse = { _, response ->
+ if (!response.isSuccessful) {
+ onLoadError()
+ } else {
+ val string = response.body()?.string()
+ if (string == null) {
+ onLoadError()
+ return@OkHttpCallback
+ }
+ try {
+ LottieComposition.Factory.fromJsonString(string, listener)
+ } catch (e: RuntimeException) {
+ onLoadError()
+ }
+ }
+ }))
+ }
+
+ private fun loadFile(uri: Uri) {
+ val fis = try {
+ when (uri.scheme) {
+ "file" -> FileInputStream(uri.path)
+ "content" -> context.contentResolver.openInputStream(uri)
+ else -> {
+ onLoadError()
+ return
+ }
+ }
+ } catch (e: FileNotFoundException) {
+ onLoadError()
+ return
+ }
+
+ LottieComposition.Factory.fromInputStream(fis, { composition ->
+ if (composition == null) {
+ onLoadError()
+ } else {
+ listener.onCompositionLoaded(composition)
+ }
+ })
+ }
+
+ private fun onLoadError() = listener.onCompositionLoaded(null)
+}
\ No newline at end of file
diff --git a/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/ILottieApplication.kt b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/ILottieApplication.kt
deleted file mode 100644
index 1f6f86e..0000000
--- a/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/ILottieApplication.kt
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.airbnb.lottie.samples
-
-import android.support.v4.util.Pair
-
-internal interface ILottieApplication {
- fun startRecordingDroppedFrames()
-
- /**
- * Returns the number of frames dropped since starting
- */
- fun stopRecordingDroppedFrames(): Pair<Int, Long>
-}
diff --git a/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/LottieApplication.kt b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/LottieApplication.kt
new file mode 100644
index 0000000..e5a3278
--- /dev/null
+++ b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/LottieApplication.kt
@@ -0,0 +1,8 @@
+package com.airbnb.lottie.samples
+
+import android.app.Application
+import okhttp3.OkHttpClient
+
+class LottieApplication : Application() {
+ val okHttpClient by lazy { OkHttpClient.Builder().build() }
+}
\ No newline at end of file
diff --git a/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/PlayerActivity.kt b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/PlayerActivity.kt
new file mode 100644
index 0000000..9769efd
--- /dev/null
+++ b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/PlayerActivity.kt
@@ -0,0 +1,29 @@
+package com.airbnb.lottie.samples
+
+import android.content.Context
+import android.content.Intent
+import android.os.Bundle
+import android.support.v7.app.AppCompatActivity
+
+class PlayerActivity : AppCompatActivity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_player)
+
+ if (savedInstanceState == null) {
+ val args = intent.getParcelableExtra<CompositionArgs>(PlayerFragment.EXTRA_ANIMATION_ARGS)
+ supportFragmentManager.beginTransaction()
+ .add(R.id.content, PlayerFragment.forAsset(args))
+ .commit()
+ }
+ }
+
+ companion object {
+ fun intent(context: Context, args: CompositionArgs): Intent {
+ return Intent(context, PlayerActivity::class.java).apply {
+ putExtra(PlayerFragment.EXTRA_ANIMATION_ARGS, args)
+ }
+ }
+ }
+}
diff --git a/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/AnimationFragment2.kt b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/PlayerFragment.kt
similarity index 84%
rename from LottieSample/src/main/kotlin/com/airbnb/lottie/samples/AnimationFragment2.kt
rename to LottieSample/src/main/kotlin/com/airbnb/lottie/samples/PlayerFragment.kt
index 1e8aadb..1600228 100644
--- a/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/AnimationFragment2.kt
+++ b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/PlayerFragment.kt
@@ -4,6 +4,7 @@
import android.annotation.SuppressLint
import android.graphics.Color
import android.os.Bundle
+import android.support.design.widget.Snackbar
import android.support.transition.AutoTransition
import android.support.transition.TransitionManager
import android.support.v4.app.Fragment
@@ -11,17 +12,20 @@
import android.util.Log
import android.view.*
import android.widget.RelativeLayout
+import androidx.view.isInvisible
+import androidx.view.isVisible
import com.airbnb.lottie.L
import com.airbnb.lottie.LottieComposition
+import com.airbnb.lottie.OnCompositionLoadedListener
import com.airbnb.lottie.samples.views.BackgroundColorView
import com.github.mikephil.charting.components.LimitLine
import com.github.mikephil.charting.components.YAxis
import com.github.mikephil.charting.data.Entry
import com.github.mikephil.charting.data.LineData
import com.github.mikephil.charting.data.LineDataSet
-import kotlinx.android.synthetic.main.fragment_animation2.*
+import kotlinx.android.synthetic.main.fragment_player.*
-class AnimationFragment2 : Fragment() {
+class PlayerFragment : Fragment(), OnCompositionLoadedListener {
private val transition = AutoTransition().apply {
duration = 250
@@ -41,8 +45,8 @@
}
}
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) =
- inflater.inflate(R.layout.fragment_animation2, container, false)
+ override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View =
+ inflater.inflate(R.layout.fragment_player, container, false)
private val animatorListener = AnimatorListenerAdapter(
onStart = { playButton.isActivated = true },
@@ -64,7 +68,8 @@
setHasOptionsMenu(true)
toolbar.title = ""
- LottieComposition.Factory.fromAssetFileName(context, "HamburgerArrow.json", this::setComposition)
+ val compositionArgs = arguments?.getParcelable<CompositionArgs>(EXTRA_ANIMATION_ARGS) ?: throw IllegalArgumentException("No composition args specified")
+ CompositionLoader(requireContext(), compositionArgs, this)
backgroundButton.setOnClickListener { showContainer(backgroundColorContainer) }
scaleButton.setOnClickListener { showContainer(scaleContainer) }
@@ -148,7 +153,7 @@
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
- inflater.inflate(R.menu.fragment_animation2, menu)
+ inflater.inflate(R.menu.fragment_player, menu)
super.onCreateOptionsMenu(menu, inflater)
}
@@ -161,7 +166,7 @@
R.id.merge_paths -> animationView.enableMergePathsForKitKatAndAbove(item.isChecked)
R.id.performance_graph -> {
beginDelayedTransition()
- renderTimesGraphContainer.visibility = if (item.isChecked) View.VISIBLE else View.INVISIBLE
+ renderTimesGraphContainer.isInvisible = !item.isChecked
val lp = renderTimesGraphContainer.layoutParams as RelativeLayout.LayoutParams
if (item.isChecked) {
lp.addRule(RelativeLayout.ABOVE, R.id.controlsContainer)
@@ -176,8 +181,11 @@
return true
}
- private fun setComposition(composition: LottieComposition?) {
- if (composition == null) return
+ override fun onCompositionLoaded(composition: LottieComposition?) {
+ if (composition == null) {
+ Snackbar.make(coordinatorLayout, R.string.composition_load_error, Snackbar.LENGTH_LONG)
+ return
+ }
animationView.setComposition(composition)
animationView.setPerformanceTrackingEnabled(true)
animationView.performanceTracker?.addFrameListener { ms ->
@@ -190,10 +198,20 @@
private fun showContainer(container: View) {
beginDelayedTransition()
- arrayOf(toolbarContainer, backgroundColorContainer, scaleContainer).forEach {
- it.visibility = if (it == container) View.VISIBLE else View.GONE
- }
+ arrayOf(toolbarContainer, backgroundColorContainer, scaleContainer).forEach { it.isVisible = it == container }
}
private fun beginDelayedTransition() = TransitionManager.beginDelayedTransition(container, transition)
+
+ companion object {
+ const val EXTRA_ANIMATION_ARGS = "animation_args"
+
+ fun forAsset(args: CompositionArgs): Fragment {
+ return PlayerFragment().apply {
+ arguments = Bundle().apply {
+ putParcelable(EXTRA_ANIMATION_ARGS, args)
+ }
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/PreviewFragment.kt b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/PreviewFragment.kt
index 532c453..4b5d256 100644
--- a/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/PreviewFragment.kt
+++ b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/PreviewFragment.kt
@@ -1,12 +1,16 @@
package com.airbnb.lottie.samples
+import android.app.Activity
+import android.content.Intent
import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.Toast
import kotlinx.android.synthetic.main.fragment_preview.*
+private val RC_FILE = 1000
class PreviewFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =
@@ -16,22 +20,38 @@
qr.apply {
addIcon(R.drawable.ic_device)
setOnClickListener {
-
+ startActivity(QRScanActivity.intent(context))
}
}
file.apply {
addIcon(R.drawable.ic_device)
setOnClickListener {
-
+ try {
+ val intent = Intent(Intent.ACTION_GET_CONTENT).apply {
+ type = "*/*"
+ addCategory(Intent.CATEGORY_OPENABLE)
+ }
+ startActivityForResult(Intent.createChooser(intent, "Select a JSON file"), RC_FILE)
+ } catch (ex: android.content.ActivityNotFoundException) {
+ // Potentially direct the user to the Market with a Dialog
+ Toast.makeText(context, "Please install a File Manager.", Toast.LENGTH_SHORT).show()
+ }
}
}
url.apply {
addIcon(R.drawable.ic_device)
setOnClickListener {
-
+ startActivity(PlayerActivity.intent(context, CompositionArgs(assetName = "HamburgerArrow.json")))
}
}
}
+
+ override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
+ if (resultCode != Activity.RESULT_OK) return
+ when (requestCode) {
+ RC_FILE-> startActivity(PlayerActivity.intent(requireContext(), CompositionArgs(fileUri = data?.data)))
+ }
+ }
}
\ No newline at end of file
diff --git a/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/QRScanActivity.kt b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/QRScanActivity.kt
index 1cebae4..b7b952b 100644
--- a/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/QRScanActivity.kt
+++ b/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/QRScanActivity.kt
@@ -1,6 +1,5 @@
package com.airbnb.lottie.samples
-import android.app.Activity
import android.content.Context
import android.content.Intent
import android.graphics.PointF
@@ -35,10 +34,12 @@
}
override fun onQRCodeRead(url: String, pointFS: Array<PointF>) {
+ @Suppress("DEPRECATION")
vibrator.vibrate(100)
- val resultIntent = Intent()
- resultIntent.putExtra(AnimationFragment.EXTRA_URL, url)
- setResult(Activity.RESULT_OK, resultIntent)
- finish()
+ startActivity(PlayerActivity.intent(this, CompositionArgs(url = url)))
+ }
+
+ companion object {
+ fun intent(context: Context) = Intent(context, QRScanActivity::class.java)
}
}
diff --git a/LottieSample/src/main/res/layout/activity_player.xml b/LottieSample/src/main/res/layout/activity_player.xml
new file mode 100644
index 0000000..134f33b
--- /dev/null
+++ b/LottieSample/src/main/res/layout/activity_player.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout
+ 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:id="@+id/content"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".PlayerActivity"/>
\ No newline at end of file
diff --git a/LottieSample/src/main/res/layout/fragment_animation2.xml b/LottieSample/src/main/res/layout/fragment_animation2.xml
deleted file mode 100644
index 266a3c0..0000000
--- a/LottieSample/src/main/res/layout/fragment_animation2.xml
+++ /dev/null
@@ -1,232 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:id="@+id/container"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@android:color/white">
-
- <FrameLayout
- android:id="@+id/animationContainer"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_above="@+id/toolbarsContainer">
-
- <com.airbnb.lottie.LottieAnimationView
- android:id="@+id/animationView"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:background="@drawable/outline"/>
- </FrameLayout>
-
- <android.support.v7.widget.Toolbar
- android:id="@+id/toolbar"
- android:layout_width="match_parent"
- android:layout_height="?attr/actionBarSize"
- android:layout_alignParentTop="true"
- app:navigationIcon="@drawable/ic_back_black"
- app:title=""/>
-
- <FrameLayout
- android:id="@id/toolbarsContainer"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_above="@+id/renderTimesGraphContainer">
-
- <LinearLayout
- android:id="@+id/toolbarContainer"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal">
-
- <Button
- android:id="@+id/scaleButton"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:background="@null"
- android:paddingBottom="16dp"
- android:paddingTop="16dp"
- android:text="@string/scale"/>
-
- <Button
- android:id="@+id/backgroundButton"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:background="@null"
- android:paddingBottom="16dp"
- android:paddingTop="16dp"
- android:text="@string/background"/>
-
- </LinearLayout>
-
- <LinearLayout
- android:id="@+id/scaleContainer"
- android:layout_width="match_parent"
- android:layout_height="64dp"
- android:layout_gravity="center_vertical"
- android:background="@android:color/white"
- android:gravity="center_vertical"
- android:orientation="horizontal"
- android:visibility="gone">
-
- <TextView
- android:id="@+id/scaleText"
- android:layout_width="64dp"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:textColor="#222222"
- android:textSize="14sp"/>
-
- <android.support.v7.widget.AppCompatSeekBar
- android:id="@+id/scaleSeekBar"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_marginRight="8dp"
- android:layout_weight="1"/>
-
- <ImageButton
- android:id="@+id/closeScaleButton"
- android:layout_width="32dp"
- android:layout_height="32dp"
- android:layout_marginRight="24dp"
- android:background="?attr/selectableItemBackgroundBorderless"
- app:srcCompat="@drawable/ic_close"/>
- </LinearLayout>
-
- <LinearLayout
- android:id="@+id/backgroundColorContainer"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:background="@android:color/white"
- android:gravity="center_vertical"
- android:orientation="horizontal"
- android:paddingBottom="16dp"
- android:paddingTop="16dp"
- android:visibility="gone">
-
- <com.airbnb.lottie.samples.views.BackgroundColorView
- android:id="@+id/backgroundButton1"
- android:layout_width="0dp"
- android:layout_height="24dp"
- android:layout_marginLeft="24dp"
- android:layout_weight="1"
- android:background="@color/background_color1"/>
-
- <com.airbnb.lottie.samples.views.BackgroundColorView
- android:id="@+id/backgroundButton2"
- android:layout_width="0dp"
- android:layout_height="24dp"
- android:layout_weight="1"
- android:background="@color/background_color2"/>
-
- <com.airbnb.lottie.samples.views.BackgroundColorView
- android:id="@+id/backgroundButton3"
- android:layout_width="0dp"
- android:layout_height="24dp"
- android:layout_weight="1"
- android:background="@color/background_color3"/>
-
- <com.airbnb.lottie.samples.views.BackgroundColorView
- android:id="@+id/backgroundButton4"
- android:layout_width="0dp"
- android:layout_height="24dp"
- android:layout_weight="1"
- android:background="@color/background_color4"/>
-
- <com.airbnb.lottie.samples.views.BackgroundColorView
- android:id="@+id/backgroundButton5"
- android:layout_width="0dp"
- android:layout_height="24dp"
- android:layout_weight="1"
- android:background="@color/background_color5"/>
-
- <com.airbnb.lottie.samples.views.BackgroundColorView
- android:id="@+id/backgroundButton6"
- android:layout_width="0dp"
- android:layout_height="24dp"
- android:layout_weight="1"
- android:background="@color/background_color6"/>
-
- <ImageButton
- android:id="@+id/closeBackgroundColorButton"
- android:layout_width="32dp"
- android:layout_height="32dp"
- android:layout_marginRight="24dp"
- android:background="?attr/selectableItemBackgroundBorderless"
- app:srcCompat="@drawable/ic_close"/>
- </LinearLayout>
-
- <View
- android:layout_width="match_parent"
- android:layout_height="@dimen/divider_height"
- android:layout_gravity="top"
- android:background="@color/divider"/>
-
- <View
- android:layout_width="match_parent"
- android:layout_height="@dimen/divider_height"
- android:layout_gravity="bottom"
- android:background="@color/divider"/>
- </FrameLayout>
-
- <LinearLayout
- android:id="@+id/renderTimesGraphContainer"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignTop="@+id/controlsContainer"
- android:gravity="center_vertical"
- android:orientation="horizontal"
- android:visibility="invisible">
-
- <TextView
- android:layout_width="48dp"
- android:layout_height="wrap_content"
- android:gravity="right"
- android:layout_marginRight="16dp"
- android:text="@string/ms"/>
-
- <com.github.mikephil.charting.charts.LineChart
- android:id="@+id/renderTimesGraph"
- android:layout_width="0dp"
- android:layout_height="128dp"
- android:layout_marginRight="64dp"
- android:layout_weight="1"/>
- </LinearLayout>
-
- <LinearLayout
- android:id="@id/controlsContainer"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:orientation="horizontal"
- android:paddingBottom="16dp"
- android:paddingTop="16dp">
-
- <ImageButton
- android:id="@+id/playButton"
- android:layout_width="64dp"
- android:layout_height="32dp"
- android:background="?attr/selectableItemBackgroundBorderless"
- app:srcCompat="@drawable/ic_play_pause"/>
-
- <android.support.v7.widget.AppCompatSeekBar
- android:id="@+id/seekBar"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:layout_weight="1"/>
-
- <ImageButton
- android:id="@+id/loopButton"
- android:layout_width="64dp"
- android:layout_height="32dp"
- android:background="?attr/selectableItemBackgroundBorderless"
- app:srcCompat="@drawable/ic_loop"/>
- </LinearLayout>
-
-</RelativeLayout>
\ No newline at end of file
diff --git a/LottieSample/src/main/res/layout/fragment_player.xml b/LottieSample/src/main/res/layout/fragment_player.xml
new file mode 100644
index 0000000..53d8c91
--- /dev/null
+++ b/LottieSample/src/main/res/layout/fragment_player.xml
@@ -0,0 +1,235 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.design.widget.CoordinatorLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/coordinatorLayout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@android:color/white">
+ <RelativeLayout
+ android:id="@+id/container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <FrameLayout
+ android:id="@+id/animationContainer"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_above="@+id/toolbarsContainer">
+
+ <com.airbnb.lottie.LottieAnimationView
+ android:id="@+id/animationView"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:background="@drawable/outline"/>
+ </FrameLayout>
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/actionBarSize"
+ android:layout_alignParentTop="true"
+ app:navigationIcon="@drawable/ic_back_black"
+ app:title=""/>
+
+ <FrameLayout
+ android:id="@id/toolbarsContainer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_above="@+id/renderTimesGraphContainer">
+
+ <LinearLayout
+ android:id="@+id/toolbarContainer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/scaleButton"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:background="@null"
+ android:paddingBottom="16dp"
+ android:paddingTop="16dp"
+ android:text="@string/scale"/>
+
+ <Button
+ android:id="@+id/backgroundButton"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:background="@null"
+ android:paddingBottom="16dp"
+ android:paddingTop="16dp"
+ android:text="@string/background"/>
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/scaleContainer"
+ android:layout_width="match_parent"
+ android:layout_height="64dp"
+ android:layout_gravity="center_vertical"
+ android:background="@android:color/white"
+ android:gravity="center_vertical"
+ android:orientation="horizontal"
+ android:visibility="gone">
+
+ <TextView
+ android:id="@+id/scaleText"
+ android:layout_width="64dp"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:textColor="#222222"
+ android:textSize="14sp"/>
+
+ <android.support.v7.widget.AppCompatSeekBar
+ android:id="@+id/scaleSeekBar"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginRight="8dp"
+ android:layout_weight="1"/>
+
+ <ImageButton
+ android:id="@+id/closeScaleButton"
+ android:layout_width="32dp"
+ android:layout_height="32dp"
+ android:layout_marginRight="24dp"
+ android:background="?attr/selectableItemBackgroundBorderless"
+ app:srcCompat="@drawable/ic_close"/>
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/backgroundColorContainer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:background="@android:color/white"
+ android:gravity="center_vertical"
+ android:orientation="horizontal"
+ android:paddingBottom="16dp"
+ android:paddingTop="16dp"
+ android:visibility="gone">
+
+ <com.airbnb.lottie.samples.views.BackgroundColorView
+ android:id="@+id/backgroundButton1"
+ android:layout_width="0dp"
+ android:layout_height="24dp"
+ android:layout_marginLeft="24dp"
+ android:layout_weight="1"
+ android:background="@color/background_color1"/>
+
+ <com.airbnb.lottie.samples.views.BackgroundColorView
+ android:id="@+id/backgroundButton2"
+ android:layout_width="0dp"
+ android:layout_height="24dp"
+ android:layout_weight="1"
+ android:background="@color/background_color2"/>
+
+ <com.airbnb.lottie.samples.views.BackgroundColorView
+ android:id="@+id/backgroundButton3"
+ android:layout_width="0dp"
+ android:layout_height="24dp"
+ android:layout_weight="1"
+ android:background="@color/background_color3"/>
+
+ <com.airbnb.lottie.samples.views.BackgroundColorView
+ android:id="@+id/backgroundButton4"
+ android:layout_width="0dp"
+ android:layout_height="24dp"
+ android:layout_weight="1"
+ android:background="@color/background_color4"/>
+
+ <com.airbnb.lottie.samples.views.BackgroundColorView
+ android:id="@+id/backgroundButton5"
+ android:layout_width="0dp"
+ android:layout_height="24dp"
+ android:layout_weight="1"
+ android:background="@color/background_color5"/>
+
+ <com.airbnb.lottie.samples.views.BackgroundColorView
+ android:id="@+id/backgroundButton6"
+ android:layout_width="0dp"
+ android:layout_height="24dp"
+ android:layout_weight="1"
+ android:background="@color/background_color6"/>
+
+ <ImageButton
+ android:id="@+id/closeBackgroundColorButton"
+ android:layout_width="32dp"
+ android:layout_height="32dp"
+ android:layout_marginRight="24dp"
+ android:background="?attr/selectableItemBackgroundBorderless"
+ app:srcCompat="@drawable/ic_close"/>
+ </LinearLayout>
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/divider_height"
+ android:layout_gravity="top"
+ android:background="@color/divider"/>
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/divider_height"
+ android:layout_gravity="bottom"
+ android:background="@color/divider"/>
+ </FrameLayout>
+
+ <LinearLayout
+ android:id="@+id/renderTimesGraphContainer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignTop="@+id/controlsContainer"
+ android:gravity="center_vertical"
+ android:orientation="horizontal"
+ android:visibility="invisible">
+
+ <TextView
+ android:layout_width="48dp"
+ android:layout_height="wrap_content"
+ android:gravity="right"
+ android:layout_marginRight="16dp"
+ android:text="@string/ms"/>
+
+ <com.github.mikephil.charting.charts.LineChart
+ android:id="@+id/renderTimesGraph"
+ android:layout_width="0dp"
+ android:layout_height="128dp"
+ android:layout_marginRight="64dp"
+ android:layout_weight="1"/>
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@id/controlsContainer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:orientation="horizontal"
+ android:paddingBottom="16dp"
+ android:paddingTop="16dp">
+
+ <ImageButton
+ android:id="@+id/playButton"
+ android:layout_width="64dp"
+ android:layout_height="32dp"
+ android:background="?attr/selectableItemBackgroundBorderless"
+ app:srcCompat="@drawable/ic_play_pause"/>
+
+ <android.support.v7.widget.AppCompatSeekBar
+ android:id="@+id/seekBar"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:layout_weight="1"/>
+
+ <ImageButton
+ android:id="@+id/loopButton"
+ android:layout_width="64dp"
+ android:layout_height="32dp"
+ android:background="?attr/selectableItemBackgroundBorderless"
+ app:srcCompat="@drawable/ic_loop"/>
+ </LinearLayout>
+ </RelativeLayout>
+</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
diff --git a/LottieSample/src/main/res/menu/fragment_animation2.xml b/LottieSample/src/main/res/menu/fragment_player.xml
similarity index 100%
rename from LottieSample/src/main/res/menu/fragment_animation2.xml
rename to LottieSample/src/main/res/menu/fragment_player.xml
diff --git a/LottieSample/src/main/res/values/strings.xml b/LottieSample/src/main/res/values/strings.xml
index 1c140d2..6de55f0 100644
--- a/LottieSample/src/main/res/values/strings.xml
+++ b/LottieSample/src/main/res/values/strings.xml
@@ -22,7 +22,7 @@
<string name="shortcut_disabled">Shortcut Disabled</string>
<string name="start_typing">Start typing!</string>
<string name="qr_code_overlay">QR code overlay</string>
-
+
<string name="scale">Scale</string>
<string name="background">Background</string>
<string name="ms">ms</string>
@@ -39,4 +39,6 @@
<string name="preview_file_action">Open</string>
<string name="preview_url">Enter a URL</string>
<string name="preview_url_action">Enter</string>
+
+ <string name="composition_load_error">There was an error loading the composition</string>
</resources>
diff --git a/lottie/src/main/res/values/ids.xml b/lottie/src/main/res/values/ids.xml
index 5ba70a6..541869b 100644
--- a/lottie/src/main/res/values/ids.xml
+++ b/lottie/src/main/res/values/ids.xml
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="lottie_layer_name" type="id" />
+ <item name="rc_file" type="id" />
</resources>
\ No newline at end of file