Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<activity android:name=".LayoutActivity" />
<activity android:name=".RiveFragmentActivity" />
<activity android:name=".LowLevelActivity" />
<activity android:name=".SimpleStateMachineActivity" />
<activity android:name=".HttpActivity"></activity>
</application>

Expand Down
23 changes: 10 additions & 13 deletions app/src/main/java/app/rive/runtime/example/AndroidPlayerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.AppCompatButton
import app.rive.runtime.kotlin.RiveAnimationView
import app.rive.runtime.kotlin.RiveDrawable.Listener
import app.rive.runtime.kotlin.core.Direction
import app.rive.runtime.kotlin.core.LinearAnimationInstance
import app.rive.runtime.kotlin.core.Loop
import app.rive.runtime.kotlin.core.Rive
import app.rive.runtime.kotlin.core.*

class AndroidPlayerActivity : AppCompatActivity() {
var loop: Loop = Loop.NONE
Expand Down Expand Up @@ -160,7 +157,7 @@ class AndroidPlayerActivity : AppCompatActivity() {


fun setResourceSpinner() {
animationResources.let { resourceId ->
animationResources.let { _ ->
var dropdown = findViewById<Spinner>(R.id.resources)
var adapter = ArrayAdapter<String>(
this,
Expand Down Expand Up @@ -193,27 +190,27 @@ class AndroidPlayerActivity : AppCompatActivity() {
val that = this
val events = findViewById<LinearLayout>(R.id.events)
val listener = object : Listener {
override fun notifyPlay(animation: LinearAnimationInstance) {
override fun notifyPlay(animation: PlayableInstance) {
val text = TextView(that)
text.setText("Play ${animation.animation.name}")
text.setText("Play ${(animation as LinearAnimationInstance).animation.name}")
events.addView(text, 0)
}

override fun notifyPause(animation: LinearAnimationInstance) {
override fun notifyPause(animation: PlayableInstance) {
val text = TextView(that)
text.setText("Pause ${animation.animation.name}")
text.setText("Pause ${(animation as LinearAnimationInstance).animation.name}")
events.addView(text, 0)
}

override fun notifyStop(animation: LinearAnimationInstance) {
override fun notifyStop(animation: PlayableInstance) {
val text = TextView(that)
text.setText("Stop ${animation.animation.name}")
text.setText("Stop ${(animation as LinearAnimationInstance).animation.name}")
events.addView(text, 0)
}

override fun notifyLoop(animation: LinearAnimationInstance) {
override fun notifyLoop(animation: PlayableInstance) {
val text = TextView(that)
text.setText("Loop ${animation.animation.name}")
text.setText("Loop ${(animation as LinearAnimationInstance).animation.name}")
events.addView(text, 0)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class LowLevelRiveView: View {
private val artboard: Artboard
private val instance: LinearAnimationInstance
private var lastTime: Long = 0
private lateinit var bounds: AABB
private var bounds: AABB

constructor(renderer: Renderer, artboard: Artboard, context: Context) : super(context) {
this.renderer = renderer
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/app/rive/runtime/example/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,11 @@ class MainActivity : AppCompatActivity() {
Intent(this, HttpActivity::class.java)
)
}

findViewById<Button>(R.id.go_simple_state_machine).setOnClickListener {
startActivity(
Intent(this, SimpleStateMachineActivity::class.java)
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package app.rive.runtime.example

import android.os.Bundle
import android.view.View
import android.widget.RadioButton
import androidx.appcompat.app.AppCompatActivity
import app.rive.runtime.kotlin.RiveAnimationView
import app.rive.runtime.kotlin.core.Loop
import app.rive.runtime.kotlin.core.Rive
import app.rive.runtime.kotlin.core.SMINumber

class SimpleStateMachineActivity : AppCompatActivity() {

private val animationView by lazy(LazyThreadSafetyMode.NONE) {
findViewById<RiveAnimationView>(R.id.simple_state_machine)
}

val levelInput: SMINumber
get() = animationView.playingStateMachines.first().input("Level") as SMINumber

fun onLevelSelect(view: View) {
if (view is RadioButton && view.isChecked) {
// Check which radio button was clicked
when (view.getId()) {
R.id.level_beginner ->
levelInput.value = 0f
R.id.level_intermediate ->
levelInput.value = 1f
R.id.level_advanced ->
levelInput.value = 2f
}
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Rive.init()
setContentView(R.layout.simple_state_machine)
}

override fun onDestroy() {
super.onDestroy()
animationView.destroy()
}
}
7 changes: 7 additions & 0 deletions app/src/main/res/layout/example_selection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@
android:layout_height="wrap_content"
android:text="HTTP" />


<Button
android:id="@+id/go_simple_state_machine"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="State Machine" />

</LinearLayout>

</ScrollView>
Expand Down
15 changes: 10 additions & 5 deletions app/src/main/res/layout/layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<app.rive.runtime.kotlin.RiveAnimationView
android:id="@+id/layout_view"
Expand All @@ -25,12 +27,13 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fit:"
/>
android:text="Fit:" />

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<Button
android:id="@+id/fit_fill"
android:layout_width="wrap_content"
Expand Down Expand Up @@ -86,11 +89,12 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Alignment:"
/>
android:text="Alignment:" />

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -138,6 +142,7 @@
android:layout_height="wrap_content"
android:text="Center Right" />
</LinearLayout>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
Expand Down
23 changes: 10 additions & 13 deletions app/src/main/res/layout/loop_mode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,20 @@
tools:context=".MainActivity">


<app.rive.runtime.kotlin.RiveAnimationView
android:id="@+id/loop_mode_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:riveAutoPlay="false"
app:riveResource="@raw/loopy" />


<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintTop_toBottomOf="@+id/loop_mode_view">
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<app.rive.runtime.kotlin.RiveAnimationView
android:id="@+id/loop_mode_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
app:riveAutoPlay="false"
app:riveResource="@raw/loopy" />

<LinearLayout
android:layout_width="fill_parent"
Expand Down
54 changes: 54 additions & 0 deletions app/src/main/res/layout/simple_state_machine.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?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="match_parent"
tools:context=".MainActivity">

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<app.rive.runtime.kotlin.RiveAnimationView
android:id="@+id/simple_state_machine"
android:layout_width="match_parent"
android:layout_height="400dp"
app:riveResource="@raw/skills"
app:riveStateMachine="Designer's Test" />

<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"

android:orientation="horizontal">

<RadioButton
android:id="@+id/level_beginner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onLevelSelect"
android:text="Beginner" />

<RadioButton
android:id="@+id/level_intermediate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onLevelSelect"
android:text="Intermediate" />

<RadioButton
android:id="@+id/level_advanced"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:onClick="onLevelSelect"
android:text="Advanced" />

</RadioGroup>
</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
Binary file added app/src/main/res/raw/skills.riv
Binary file not shown.
2 changes: 1 addition & 1 deletion kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ task buildJNI(type: Exec) {

ext {
PUBLISH_GROUP_ID = 'app.rive'
PUBLISH_VERSION = '0.0.2'
PUBLISH_VERSION = '0.0.3'
PUBLISH_ARTIFACT_ID = 'rive-android'
}

Expand Down