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
| private fun resolveParentCompositionContext() = parentContext | |
| ?: findViewTreeCompositionContext()?.also { cachedViewTreeCompositionContext = it } | |
| ?: cachedViewTreeCompositionContext | |
| ?: windowRecomposer.also { cachedViewTreeCompositionContext = it } |
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 DemoFragment: Fragment(){ | |
| override fun onCreateView( | |
| inflater: LayoutInflater, | |
| container: ViewGroup?, | |
| savedInstanceState: Bundle? | |
| ): View { | |
| return ComposeView(requireActivity()).apply { | |
| setContent { | |
| SampleTheme { | |
| Greeting(name = "Hello Android") |
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 MainActivity : AppCompatActivity() { | |
| lateinit var binding: SampleBinding | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| binding = SampleBinding.inflate(layoutInflater, findViewById(android.R.id.content), true) | |
| supportFragmentManager.beginTransaction() | |
| .add(binding.frame.id, DemoFragment(), "Sample").commit() | |
| } | |
| } |
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
| @ExperimentalCoroutinesApi | |
| object EventBus { | |
| val bus: BroadcastChannel<Any> = BroadcastChannel(Channel.CONFLATED) | |
| suspend fun send(o: Any) = bus.send(o) | |
| inline fun <reified T> asChannel(): ReceiveChannel<T> { | |
| return bus.openSubscription().filter { it is T }.map { it as T } | |
| } | |
| } |
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
| public static String getPath(final Uri uri) { | |
| try { | |
| final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; | |
| if (isKitKat && DocumentsContract.isDocumentUri(ApplicationLoader.applicationContext, uri)) { | |
| if (isExternalStorageDocument(uri)) { | |
| final String docId = DocumentsContract.getDocumentId(uri); | |
| final String[] split = docId.split(":"); | |
| final String type = split[0]; | |
| if ("primary".equalsIgnoreCase(type)) { | |
| return Environment.getExternalStorageDirectory() + "/" + split[1]; |
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 com.death.demo | |
| import android.os.Bundle | |
| import androidx.appcompat.app.AppCompatActivity | |
| import androidx.compose.Composable | |
| import androidx.compose.state | |
| import androidx.compose.unaryPlus | |
| import androidx.ui.core.Text | |
| import androidx.ui.core.setContent | |
| import androidx.ui.layout.Column |
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 com.death.demo | |
| import android.os.Bundle | |
| import androidx.appcompat.app.AppCompatActivity | |
| import androidx.compose.Composable | |
| import androidx.compose.State | |
| import androidx.compose.state | |
| import androidx.compose.unaryPlus | |
| import androidx.ui.core.Text | |
| import androidx.ui.core.setContent |
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 com.death.demo | |
| import android.os.Bundle | |
| import androidx.appcompat.app.AppCompatActivity | |
| import androidx.compose.Composable | |
| import androidx.compose.State | |
| import androidx.compose.state | |
| import androidx.compose.unaryPlus | |
| import androidx.ui.core.Text | |
| import androidx.ui.core.setContent |
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 com.death.demo | |
| import android.os.Bundle | |
| import androidx.appcompat.app.AppCompatActivity | |
| import androidx.compose.Composable | |
| import androidx.ui.core.Text | |
| import androidx.ui.core.setContent | |
| import androidx.ui.material.MaterialTheme | |
| import androidx.ui.tooling.preview.Preview |
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
| import android.app.Application | |
| import androidx.databinding.Observable | |
| import androidx.databinding.PropertyChangeRegistry | |
| import androidx.lifecycle.AndroidViewModel | |
| abstract class ObservableViewModel(app: Application): AndroidViewModel(app), Observable { | |
| @delegate:Transient | |
| private val mCallBacks: PropertyChangeRegistry by lazy { PropertyChangeRegistry() } |
NewerOlder