Skip to content

Instantly share code, notes, and snippets.

View virendersran01's full-sized avatar
💻
Working from home

Virender Srxn virendersran01

💻
Working from home
  • India
View GitHub Profile
@HasibPrince
HasibPrince / FileUtils.kt
Created September 24, 2023 20:41
Usage of MediaStore API
val contentResolver = this.contentResolver
val contentValues = ContentValues().apply {
put(MediaStore.MediaColumns.DISPLAY_NAME, "applounge")
put(MediaStore.MediaColumns.MIME_TYPE, "text/plain")
put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_DOCUMENTS)
}
val uri = contentResolver.insert(MediaStore.Files.getContentUri("external"), contentValues)
uri?.let {
contentResolver.openOutputStream(it)?.use { outputStream ->
@nirbhayph
nirbhayph / Circles.kt
Last active December 11, 2023 21:06
Google Maps and Jetpack Compose
@Composable
fun CircleMap() {
// Define the coordinates for circle centers and their associated information
val circleData = listOf(
CircleInfo("Park A", LatLng(37.7749, -122.4194), "This is Park A"),
CircleInfo("Park B", LatLng(36.7783, -119.4179), "This is Park B"),
CircleInfo("Park C", LatLng(34.0522, -118.2437), "This is Park C")
)
// Create a mutable state to track the selected circle
@stevdza-san
stevdza-san / AnimatedBorderCard.kt
Last active October 9, 2024 12:23
Card with Animated Border built with Jetpack Compose.
@Composable
fun AnimatedBorderCard(
modifier: Modifier = Modifier,
shape: Shape = RoundedCornerShape(size = 0.dp),
borderWidth: Dp = 2.dp,
gradient: Brush = Brush.sweepGradient(listOf(Color.Gray, Color.White)),
animationDuration: Int = 10000,
onCardClick: () -> Unit = {},
content: @Composable () -> Unit
) {
@ZaqueuLima3
ZaqueuLima3 / Fixture.kt
Last active September 25, 2023 12:51
Fixture
import kotlin.random.Random
import kotlin.reflect.KClass
import kotlin.reflect.KFunction
import kotlin.reflect.KType
/**
* You can find the method explanation here on this post:
* https://zaqueusantos.medium.com/an-easy-way-to-create-fixture-or-dummy-classes-for-your-android-tests-with-kotlin-9d6c619237d4
*/
override fun onViewCreated() {
observeVisitDetail()
}
private fun observeVisitDetail() {
viewLifecycleOwner.lifecycleScope.launch {
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.agentDetail?.collect { visitingUiState ->
when (visitingUiState) {
is VisitingDetailUiState.Success -> {
val visitId = savedStateHandle.get<Int>("visitId")
val agentDetail: StateFlow<VisitingDetailUiState>? =
visitId?.let {
useCase.getDetailAgentVisitFullResponseFlow(id = it).map { visitDetail ->
Log.d("MYTAG", ": got exec")
when (visitDetail) {
is SallyResponseResource.Loading -> {
VisitingDetailUiState.Loading
}
override fun onViewCreated() {
viewModel.getAgentVisitDetailFullResponseFlow()
observeVisitDetail()
}
fun getAgentVisitDetailFullResponseFlow() {
val visitId = savedStateHandle.get<Int>("visitId")
viewModelScope.launch {
if (visitId != null) {
useCase.getDetailAgentVisitFullResponseFlow(id = visitId)
.collectLatest { visitDetail ->
when (visitDetail) {
is SallyResponseResource.Loading -> {
_uiStateDetail.value = VisitingDetailUiState.Loading
}
@Composable
Fun stateFullScreen(){
// lets say we done handle our viewmodels
Val uiState by viewmodel.uiState.collectWithLifeCycle()
LaunchedEffect() {
viewmodel.getAgentVisitDetailFullResponse()
}
stateLessScreen(