Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- val current = sm.amplitude
- sm.start()
- if (current > maxLaugh) {
- maxLaugh = current
- }
- if (current > 300) {
- // change the responses
- when {
- current > 6 * maxLaugh / 7 -> {
- //Only the original thread that created a view hierarchy can touch its views.
- runOnUiThread {
- im.setBackgroundColor(Color.RED)
- }
- startService(intentFor<TorchService>().setAction("on"))
- startService(intentFor<TorchService>().setAction("off"))
- }
- current > 5 * maxLaugh / 7 -> {
- runOnUiThread {
- im.setBackgroundColor(Color.BLUE)
- }
- startService(intentFor<TorchService>().setAction("on"))
- startService(intentFor<TorchService>().setAction("off"))
- }
- current > 4 * maxLaugh / 7 -> {
- runOnUiThread {
- im.setBackgroundColor(Color.GREEN)
- }
- }
- current > 3 * maxLaugh / 7 -> {
- runOnUiThread {
- im.setBackgroundColor(Color.YELLOW)
- }}
- current > 2 * maxLaugh / 7 -> {
- runOnUiThread {
- im.setBackgroundColor(Color.WHITE)
- }
- }
- else -> {
- runOnUiThread {
- im.setBackgroundResource(R.drawable.asd)
- }
- }
- }
- }
- count++
- if (count == 20) {
- count = 0
- maxLaugh = 5 * maxLaugh / 6
- }
- h.postDelayed(this, delay.toLong())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement