-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathMainActivity.kt
More file actions
60 lines (50 loc) · 1.83 KB
/
Copy pathMainActivity.kt
File metadata and controls
60 lines (50 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package org.matrix.demo
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.View
import android.widget.TextView
import android.widget.Toast
import org.matrix.demo.databinding.ActivityMainBinding
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
private var doubleClick = false
private val handler = Handler(Looper.getMainLooper())
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
// Example of a call to a native method
binding.sampleText.text = stringFromJNI()
binding.root.setOnClickListener {
if (doubleClick) {
// Double click
binding.sampleText.text = stringFromJNI()
Toast.makeText(this, "result updated", Toast.LENGTH_SHORT).show()
doubleClick = false
} else {
// Single click
doubleClick = true
handler.postDelayed({
if (doubleClick) {
Toast.makeText(this, "double click to refresh result", Toast.LENGTH_SHORT).show()
doubleClick = false
}
}, 200) // Double click time window
}
}
KeyStoreTestRunner().runAllTests()
}
/**
* A native method that is implemented by the 'demo' native library,
* which is packaged with this application.
*/
external fun stringFromJNI(): String
companion object {
// Used to load the 'demo' library on application startup.
init {
System.loadLibrary("demo")
}
}
}