Skip to content

Instantly share code, notes, and snippets.

View ThomasGorisse's full-sized avatar

Thomas Gorisse ThomasGorisse

View GitHub Profile
private void updateRegionNodes() {
if (augmentedFace == null) {
return;
}
Pose centerPose = augmentedFace.getCenterPose();
faceRegionNode.setWorldPosition(new Vector3(centerPose.tx(), centerPose.ty(), centerPose.tz()));
// Rotate the bones by 180 degrees because the .fbx template's coordinate system is
IndirectLight buildIndirectLight() {
Preconditions.checkNotNull(irradianceData, "\"irradianceData\" was null.");
Preconditions.checkState(
irradianceData.length >= FLOATS_PER_VECTOR,
"\"irradianceData\" does not have enough components to store a vector");
if (reflectCubemap == null) {
throw new IllegalStateException("reflectCubemap is null.");
}
<uses-permission android:name="android.permission.CAMERA" />
<application>
<meta-data android:name="com.google.ar.core" android:value="optional" />
</application>
val View.lifecycle get() = lifecycleOwner.lifecycle
val View.lifecycleScope get() = lifecycleOwner.lifecycleScope
view.lifecycle.addObserver(onResume = {
refreshData()
})
texView.lifecycleScope.launchWhenCreated { // Launch on Dispatchers.Main
val data = withContext(Dispatchers.IO) { // Dispatchers.IO for background task
loadNetworkData() // Suspend function making http calls
}
texView.text = data // Dispatchers.Main for UI change
}
textView.lifecycleScope.launchWhenCreated {
while (isActive) {
view.text = "${System.currentTimeMillis()}" // Dispatchers.Main
withContext(Dispatchers.IO) { // Dispatchers.IO for waiting in background
delay(1000) // Wait 1 second
}
}
}
val lifecycle = findViewById(R.id.frameLayout).lifecycle
// Or
val imageView = ImageView(context)
imageView.lifecycleScope.launchWhenCreated {
(imageView.parent as View).isVisible = true
loadSlideShow(imageView.width, imageView.height)
}
view.doOnResume {
startWelcomeAnimation(view)
}
view.doOnPause {
stopWelcomeAnimation(view)
}
view.doOnDestroy {
removeListener(view)
}