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
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 |
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
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."); | |
} |
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
<uses-permission android:name="android.permission.CAMERA" /> | |
<application> | |
… | |
<meta-data android:name="com.google.ar.core" android:value="optional" /> | |
</application> |
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
val View.lifecycle get() = lifecycleOwner.lifecycle | |
val View.lifecycleScope get() = lifecycleOwner.lifecycleScope |
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
view.lifecycle.addObserver(onResume = { | |
refreshData() | |
}) |
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
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 | |
} |
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
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 | |
} | |
} | |
} |
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
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) | |
} |
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
view.doOnResume { | |
startWelcomeAnimation(view) | |
} | |
view.doOnPause { | |
stopWelcomeAnimation(view) | |
} |
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
view.doOnDestroy { | |
removeListener(view) | |
} |
OlderNewer