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
// Here counter can show 1 after incrementCounter is called | |
class ExampleViewModel : ViewModel() { | |
private val _counter = MutableLiveData(0) | |
init { | |
viewModelScope.launch(Dispatchers.IO) { | |
// Thread 1 | |
delay(500) | |
_counter.postValue(_counter.value?.plus(1)) | |
} |
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
<?xml version="1.0" encoding="utf-8"?> | |
<androidx.constraintlayout.motion.widget.MotionLayout | |
android:layout_height="match_parent" | |
android:layout_width="match_parent" | |
app:layoutDescription="@xml/motion_scene" | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto"> | |
<View | |
android:id="@+id/header" |
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
public class YRestriction : MonoBehaviour{ | |
public float padding = 1f; | |
private float ymin; | |
private float ymax; | |
//here we set our top and bottom barriers | |
void Start(){ | |
float distance = transform.position.z - Camera.main.transform.position.z; //not really necessary in 2D, but good habbit | |
//take the bottom-middle, to-middle point of our camera and get it's world coordinates |