This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DisplayTimer (context: Context) : LinearLayout(context) { | |
fun igniteTimer(){ | |
Timer("ring the bell") | |
.schedule(object : TimerTask() { | |
override fun run() { | |
Tick() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DisplayTimer (context: Context) : LinearLayout(context) | |
, LifecycleObserver { //LifecycleObserver is implemented here. | |
// Code removed for brevity | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyFragment:Fragment(){ | |
val displayTimer = DisplayTimer(requireContext()) | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
// assign the observability to timer view. | |
viewLifecycleOwner.lifecycle.addObserver(displayTimer) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DisplayTimer (context: Context) : LinearLayout(context) | |
, LifecycleObserver { | |
private var timer:Timer? =null | |
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME) | |
fun igniteTimer(){ | |
timer = Timer("ring the bell").apply{ | |
schedule(object : TimerTask() { | |
override fun run() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assuming necessary OpenGL ES context is already created | |
// Define vertex data for the square | |
const float vertices[] = { | |
-0.5f, -0.5f, 0.0f, // bottom-left | |
0.5f, -0.5f, 0.0f, // bottom-right | |
0.5f, 0.5f, 0.0f, // top-right | |
-0.5f, 0.5f, 0.0f, // top-left | |
}; |