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