Skip to content

Instantly share code, notes, and snippets.

View AradiPatrik's full-sized avatar

Aradi Patrik AradiPatrik

  • Taipei
  • 16:24 (UTC +08:00)
View GitHub Profile
// 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))
}
@AradiPatrik
AradiPatrik / activity_main.xml
Created December 27, 2020 09:27
The View gets pushed up by the RecyclerView but never out of screen
<?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"
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