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
********************************************************************************************************************************* | |
Image | |
********************************************************************************************************************************* | |
Usage: | |
painter = painterResource(id = OwlTheme.images.lockupLogo) | |
--------------------------------------------------------------------------------- | |
data class: | |
@Immutable | |
data class Images(@DrawableRes val lockupLogo: Int) |
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
********************************************************************************************************************************* | |
AnimatedVisibility - without params | |
********************************************************************************************************************************* | |
@Preview(showSystemUi = true) | |
@Composable | |
fun SimpleAnimatedVisibility() { | |
var visibility by remember { mutableStateOf(true) } | |
Column( | |
modifier = Modifier.fillMaxSize(), |
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
****************************************************************************************************************************************** | |
ex-1 | |
statement = here, we want to test that, from 3 tabs, whatever value is set for current screen so according that same tab should selected. | |
****************************************************************************************************************************************** | |
passed case) | |
@get:Rule | |
val composeTestRule = createComposeRule() | |
@Test | |
fun rallyTopAppBarTest() { |
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
object NursingApiClient { | |
lateinit var retrofit: Retrofit | |
val service: ApiInterface by lazy { | |
val builder = Retrofit.Builder() | |
.baseUrl(BASE_URL) //e.g., "https://api.github.com/" | |
//(we can change it at runtime to deal with multiple API versions) | |
//like, Production, staging, developments etc. | |
.addConverterFactory(GsonConverterFactory.create()) |
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
Abbreviation: fun0 | |
Description: Function with no parameters | |
Template text: | |
fun $NAME$() : $RETURN$ { | |
return $RETURN$ | |
} | |
******************************************************************************************************************************************* | |
Abbreviation: key | |
Description: Key for a bundle | |
Template text: |
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 sharedApplicationContext: Context get() = sharedApplicationContextBackingProperty | |
?: throw IllegalStateException( | |
"Application context not initialized yet." | |
) | |
private var sharedApplicationContextBackingProperty: Context? = null | |
class App : Application() { | |
override fun onCreate() { | |
super.onCreate() |
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
//implement custom column | |
@Composable | |
fun MyOwnColumn( | |
modifier: Modifier = Modifier, | |
content: @Composable () -> Unit | |
) { | |
Layout( | |
modifier = modifier, | |
content = content | |
) { measurables, constraints -> |
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
//WindowStateUtils.kt | |
/** | |
* Information about the posture of the device | |
*/ | |
sealed interface DevicePosture { | |
object NormalPosture : DevicePosture | |
data class BookPosture( | |
val hingePosition: Rect | |
) : DevicePosture |
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
Gzip interceptors = for data compression | |
public class GzipRequestInterceptor implements Interceptor { | |
@Override | |
public Response intercept(Chain chain) throws IOException { | |
Request originalRequest = chain.request(); | |
if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) { | |
return chain.proceed(originalRequest); | |
} | |
Request compressedRequest = originalRequest.newBuilder() |
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
*********************************************************StateFlow Demo************************************************************** | |
Step-1) build.gradle | |
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.6" | |
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.6" | |
Step-2) data class | |
data class Resource<out T>(val status: Status, val data: T?, val message: String?) { | |
companion object { |