This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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) | |
| } |
This file contains hidden or 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 WebView @JvmOverloads constructor( | |
| context: Context, | |
| attrs: AttributeSet? = null, | |
| defStyleAttr: Int = 0, | |
| defStyleRes: Int = 0 | |
| ) : WebView(context, attrs, defStyleAttr, defStyleRes) { | |
| init { | |
| this.isScrollContainer = false | |
| this.isNestedScrollingEnabled = false |
This file contains hidden or 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
| fun startVideoRecord(fragment: MainFragment) { | |
| verifyPermission(activity = fragment.activity, | |
| permissions = listOf( | |
| Manifest.permission.RECORD_AUDIO | |
| ), | |
| fallBack = { | |
| fragment.isRecording = false | |
| }, | |
| success = { | |
| fragment.isRecording = true |
This file contains hidden or 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
| package io.github.sceneview.components | |
| import android.animation.ObjectAnimator | |
| import com.google.android.filament.* | |
| import com.google.ar.sceneform.rendering.* | |
| import dev.romainguy.kotlin.math.* | |
| import io.github.sceneview.* | |
| import io.github.sceneview.animation.TransformAnimator | |
| import io.github.sceneview.gesture.* | |
| import io.github.sceneview.math.* |
This file contains hidden or 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
| package io.github.sceneview.components | |
| import com.google.android.filament.EntityInstance | |
| import com.google.android.filament.LightManager | |
| import dev.romainguy.kotlin.math.Quaternion | |
| import io.github.sceneview.light.* | |
| import io.github.sceneview.math.Direction | |
| import io.github.sceneview.math.Position | |
| import io.github.sceneview.utils.Color | |
| import io.github.sceneview.utils.toColor |
This file contains hidden or 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
| package io.github.sceneview | |
| import android.annotation.SuppressLint | |
| import android.content.Context | |
| import android.content.res.AssetManager | |
| import android.graphics.PixelFormat | |
| import android.graphics.drawable.ColorDrawable | |
| import android.media.MediaRecorder | |
| import android.os.Handler | |
| import android.os.Looper |