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 snapShot = CaptureBitmap { | |
//.. wite composable you want to capture | |
// it would be visible on view as well | |
} | |
// Caution : needs to be done on click action | |
// ui must be visible/laid out before calling this | |
val bitmap = snapShot.invoke() |
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
@Composable | |
fun CaptureBitmap( | |
content: @Composable () -> Unit, | |
): () -> Bitmap { | |
val context = LocalContext.current | |
/** | |
* ComposeView that would take composable as its content | |
* Kept in remember so recomposition doesn't re-initialize 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
package com.proptiger.ui.components.edittext | |
import androidx.compose.animation.ExperimentalAnimationApi | |
import androidx.compose.foundation.layout.* | |
import androidx.compose.foundation.text.BasicTextField | |
import androidx.compose.material.Divider | |
import androidx.compose.material.Icon | |
import androidx.compose.material.MaterialTheme | |
import androidx.compose.material.Text | |
import androidx.compose.material.icons.Icons |
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
/** | |
* Represent ViewTypes which user provides | |
*/ | |
sealed class ViewType { | |
object ListItemHeader : ViewType() | |
object ListItemContent : ViewType() | |
} | |
/** | |
* Test View Holders |
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 LayoutManager(private val recycler: Recycler) { | |
fun getViewForPosition(pos: Int): View { | |
return recycler.getView(pos) | |
} | |
} | |
class Recycler( | |
private val adapter: Adapter, | |
private val recyclerPool: RecyclerPool, | |
private val viewCache: ViewCache |
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 LayoutManager(private val recycler: Recycler) { | |
fun getViewForPosition(pos: Int): View { | |
return recycler.getView(pos) | |
} | |
} | |
class RecyclerView( | |
private val adapter: Adapter, | |
private val recyclerPool: RecyclerPool, | |
private val viewCache: ViewCache |
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
// layout manager calls function getViewForPosition over recycler | |
// thus has a recycler. | |
class LayoutManager(private val recycler: Recycler) { | |
fun getViewForPosition(pos: Int): View { | |
return recycler.getView(pos) | |
} | |
} | |
class RecyclerView( | |
private val viewCache: ViewCache |
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
/** | |
* Layout Manager : | |
* - Position the Views | |
* - Scrolling Views | |
*/ | |
class LayoutManager | |
/** | |
* Recycler View : | |
* - Coordinator of all component | |
* - Interaction with Elements |
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 SingletonThreadSafe private constructor() { | |
companion object { | |
private var _instance: SingletonThreadSafe? = null | |
fun getInstance(): SingletonThreadSafe { | |
val cachedInstance = _instance | |
return cachedInstance ?: synchronized(this) { | |
cachedInstance ?: SingletonThreadSafe().also { | |
_instance = 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
... | |
// it looks ugly 😵 IMO | |
fun setup(binding:MainLayoutBinding?) = binding?.run { | |
textName.text = "ch8n" | |
textTwitter.text = "twitter@ch8n2" | |
} |