@@ -23,6 +23,7 @@ class AndroidPlayerActivity : AppCompatActivity() {
23
23
val animationResources = listOf (
24
24
R .raw.artboard_animations,
25
25
R .raw.basketball,
26
+ R .raw.clipping,
26
27
R .raw.explorer,
27
28
R .raw.f22,
28
29
R .raw.flux_capacitor,
@@ -101,30 +102,30 @@ class AndroidPlayerActivity : AppCompatActivity() {
101
102
}
102
103
103
104
fun addAnimationControl (animationName : String ): View {
104
- var layout = LinearLayout (this )
105
+ val layout = LinearLayout (this )
105
106
layout.orientation = LinearLayout .HORIZONTAL
106
107
layout.gravity = Gravity .END
107
108
108
- var text = TextView (this )
109
+ val text = TextView (this )
109
110
text.text = animationName
110
111
111
- var playButton = AppCompatButton (this )
112
+ val playButton = AppCompatButton (this )
112
113
playButton.text = " >"
113
114
playButton.background.setTint(Color .WHITE )
114
115
playButton.setOnClickListener {
115
116
animationView.play(animationName, loop, direction)
116
117
}
117
118
playButtonMap[animationName] = playButton
118
119
119
- var pauseButton = AppCompatButton (this )
120
+ val pauseButton = AppCompatButton (this )
120
121
pauseButton.text = " ||"
121
122
pauseButton.background.setTint(Color .WHITE )
122
123
pauseButton.setOnClickListener {
123
124
animationView.pause(animationName)
124
125
}
125
126
pauseButtonMap[animationName] = pauseButton
126
127
127
- var stopButton = AppCompatButton (this )
128
+ val stopButton = AppCompatButton (this )
128
129
stopButton.text = " []"
129
130
stopButton.background.setTint(Color .RED )
130
131
stopButton.setOnClickListener {
@@ -184,13 +185,13 @@ class AndroidPlayerActivity : AppCompatActivity() {
184
185
185
186
186
187
stateMachine.inputs.forEach {
187
- val layout = LinearLayout (this )
188
- layout .orientation = LinearLayout .HORIZONTAL
189
- layout .gravity = Gravity .END
188
+ val innerLayout = LinearLayout (this )
189
+ innerLayout .orientation = LinearLayout .HORIZONTAL
190
+ innerLayout .gravity = Gravity .END
190
191
191
- val text = TextView (this )
192
- text .text = it.name
193
- layout .addView(text )
192
+ val innerText = TextView (this )
193
+ innerText .text = it.name
194
+ innerLayout .addView(innerText )
194
195
195
196
if (it.isTrigger) {
196
197
val triggerButton = AppCompatButton (this )
@@ -199,7 +200,7 @@ class AndroidPlayerActivity : AppCompatActivity() {
199
200
triggerButton.setOnClickListener { _ ->
200
201
animationView.fireState(stateMachineName, it.name)
201
202
}
202
- layout .addView(triggerButton)
203
+ innerLayout .addView(triggerButton)
203
204
}
204
205
205
206
if (it.isBoolean) {
@@ -210,7 +211,7 @@ class AndroidPlayerActivity : AppCompatActivity() {
210
211
boolBox.setOnCheckedChangeListener { _, b ->
211
212
animationView.setBooleanState(stateMachineName, it.name, b)
212
213
}
213
- layout .addView(boolBox)
214
+ innerLayout .addView(boolBox)
214
215
}
215
216
216
217
if (it.isNumber) {
@@ -221,25 +222,25 @@ class AndroidPlayerActivity : AppCompatActivity() {
221
222
editTriggerButton.background.setTint(Color .WHITE )
222
223
editTriggerButton.setOnClickListener { _ ->
223
224
try {
224
- var value = editText.text.toString().toFloat()
225
+ val value = editText.text.toString().toFloat()
225
226
animationView.setNumberState(stateMachineName, it.name, value)
226
227
} catch (e: Error ) {
227
228
228
229
}
229
230
}
230
231
231
- layout .addView(editText)
232
- layout .addView(editTriggerButton)
232
+ innerLayout .addView(editText)
233
+ innerLayout .addView(editTriggerButton)
233
234
}
234
235
235
- views.add(layout )
236
+ views.add(innerLayout )
236
237
}
237
238
238
239
return views
239
240
}
240
241
241
242
fun loadArtboard (artboardName : String ) {
242
- var controls = findViewById<LinearLayout >(R .id.controls)
243
+ val controls = findViewById<LinearLayout >(R .id.controls)
243
244
controls.removeAllViews()
244
245
animationView.drawable.file?.artboard(artboardName)?.let { artboard ->
245
246
if (artboard.stateMachineNames.size > 0 ) {
@@ -266,8 +267,8 @@ class AndroidPlayerActivity : AppCompatActivity() {
266
267
267
268
fun setSpinner () {
268
269
animationView.drawable.file?.artboardNames?.let { artboardNames ->
269
- var dropdown = findViewById<Spinner >(R .id.artboards)
270
- var adapter = ArrayAdapter <String >(
270
+ val dropdown = findViewById<Spinner >(R .id.artboards)
271
+ val adapter = ArrayAdapter <String >(
271
272
this ,
272
273
android.R .layout.simple_spinner_dropdown_item,
273
274
artboardNames
@@ -294,8 +295,8 @@ class AndroidPlayerActivity : AppCompatActivity() {
294
295
295
296
fun setResourceSpinner () {
296
297
animationResources.let { _ ->
297
- var dropdown = findViewById<Spinner >(R .id.resources)
298
- var adapter = ArrayAdapter <String >(
298
+ val dropdown = findViewById<Spinner >(R .id.resources)
299
+ val adapter = ArrayAdapter <String >(
299
300
this ,
300
301
android.R .layout.simple_spinner_dropdown_item,
301
302
resourceNames
@@ -332,19 +333,13 @@ class AndroidPlayerActivity : AppCompatActivity() {
332
333
} else if (animation is StateMachineInstance ) {
333
334
text = animation.stateMachine.name
334
335
}
335
- text?.let {
336
+ text?.let { theText ->
336
337
val textView = TextView (that)
337
- textView.text = " Play $text "
338
+ textView.text = " Play $theText "
338
339
events.addView(textView, 0 )
339
- playButtonMap.get(text)?.let {
340
- it.background.setTint(Color .GREEN )
341
- }
342
- pauseButtonMap.get(text)?.let {
343
- it.background.setTint(Color .WHITE )
344
- }
345
- stopButtonMap.get(text)?.let {
346
- it.background.setTint(Color .WHITE )
347
- }
340
+ playButtonMap[theText]?.background?.setTint(Color .GREEN )
341
+ pauseButtonMap[theText]?.background?.setTint(Color .WHITE )
342
+ stopButtonMap[theText]?.background?.setTint(Color .WHITE )
348
343
}
349
344
}
350
345
@@ -359,15 +354,9 @@ class AndroidPlayerActivity : AppCompatActivity() {
359
354
val textView = TextView (that)
360
355
textView.text = " Pause $text "
361
356
events.addView(textView, 0 )
362
- playButtonMap.get(text)?.let {
363
- it.background.setTint(Color .WHITE )
364
- }
365
- pauseButtonMap.get(text)?.let {
366
- it.background.setTint(Color .BLUE )
367
- }
368
- stopButtonMap.get(text)?.let {
369
- it.background.setTint(Color .WHITE )
370
- }
357
+ playButtonMap[text]?.background?.setTint(Color .WHITE )
358
+ pauseButtonMap[text]?.background?.setTint(Color .BLUE )
359
+ stopButtonMap[text]?.background?.setTint(Color .WHITE )
371
360
}
372
361
}
373
362
@@ -382,15 +371,9 @@ class AndroidPlayerActivity : AppCompatActivity() {
382
371
val textView = TextView (that)
383
372
textView.text = " Stop $text "
384
373
events.addView(textView, 0 )
385
- playButtonMap.get(text)?.let {
386
- it.background.setTint(Color .WHITE )
387
- }
388
- pauseButtonMap.get(text)?.let {
389
- it.background.setTint(Color .WHITE )
390
- }
391
- stopButtonMap.get(text)?.let {
392
- it.background.setTint(Color .RED )
393
- }
374
+ playButtonMap[text]?.background?.setTint(Color .WHITE )
375
+ pauseButtonMap[text]?.background?.setTint(Color .WHITE )
376
+ stopButtonMap[text]?.background?.setTint(Color .RED )
394
377
}
395
378
}
396
379
@@ -401,6 +384,13 @@ class AndroidPlayerActivity : AppCompatActivity() {
401
384
events.addView(text, 0 )
402
385
}
403
386
}
387
+
388
+ override fun notifyStateChanged (layerState : LayerState ) {
389
+
390
+ val text = TextView (that)
391
+ text.text = " State Changed $layerState "
392
+ events.addView(text, 0 )
393
+ }
404
394
}
405
395
406
396
animationView.registerListener(listener)
0 commit comments