Skip to content

Commit 298bf39

Browse files
committed
Refresh test result via double-clicking
1 parent 3de7f15 commit 298bf39

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

app/src/main/java/org/matrix/demo/MainActivity.kt

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ package org.matrix.demo
22

33
import androidx.appcompat.app.AppCompatActivity
44
import android.os.Bundle
5+
import android.os.Handler
6+
import android.os.Looper
7+
import android.view.View
58
import android.widget.TextView
9+
import android.widget.Toast
610
import org.matrix.demo.databinding.ActivityMainBinding
711

812
class MainActivity : AppCompatActivity() {
913

1014
private lateinit var binding: ActivityMainBinding
15+
private var doubleClick = false
16+
private val handler = Handler(Looper.getMainLooper())
1117

1218
override fun onCreate(savedInstanceState: Bundle?) {
1319
super.onCreate(savedInstanceState)
@@ -17,6 +23,24 @@ class MainActivity : AppCompatActivity() {
1723

1824
// Example of a call to a native method
1925
binding.sampleText.text = stringFromJNI()
26+
27+
binding.root.setOnClickListener {
28+
if (doubleClick) {
29+
// Double click
30+
binding.sampleText.text = stringFromJNI()
31+
Toast.makeText(this, "result updated", Toast.LENGTH_SHORT).show()
32+
doubleClick = false
33+
} else {
34+
// Single click
35+
doubleClick = true
36+
handler.postDelayed({
37+
if (doubleClick) {
38+
Toast.makeText(this, "double click to refresh result", Toast.LENGTH_SHORT).show()
39+
doubleClick = false
40+
}
41+
}, 200) // Double click time window
42+
}
43+
}
2044
}
2145

2246
/**
@@ -31,4 +55,4 @@ class MainActivity : AppCompatActivity() {
3155
System.loadLibrary("demo")
3256
}
3357
}
34-
}
58+
}

0 commit comments

Comments
 (0)