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
@Composable
Fun stateFullScreen(){
// lets say we done handle our viewmodels
Val uiState by viewmodel.uiState.collectWithLifeCycle()
LaunchedEffect() {
viewmodel.getAgentVisitDetailFullResponse()
}
stateLessScreen(
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
}
override fun onViewCreated() {
viewModel.getAgentVisitDetailFullResponseFlow()
observeVisitDetail()
}
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() {
observeVisitDetail()
}
private fun observeVisitDetail() {
viewLifecycleOwner.lifecycleScope.launch {
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.agentDetail?.collect { visitingUiState ->
when (visitingUiState) {
is VisitingDetailUiState.Success -> {
@virendersran01
virendersran01 / CounterButtonSample.kt
Created June 8, 2023 08:15 — forked from landomen/CounterButtonSample.kt
Animated counter button sample implemented in Jetpack Compose
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
CounterButtonTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
@virendersran01
virendersran01 / build.gradle
Created December 28, 2022 12:02 — forked from maxirosson/build.gradle
Versioning Android apps
apply plugin: 'com.android.application'
ext.versionMajor = 1
ext.versionMinor = 2
ext.versionPatch = 3
ext.versionClassifier = null
ext.isSnapshot = true
ext.minimumSdkVersion = 19
android {
apply plugin: 'com.android.application'
ext.versionMajor = 1
ext.versionMinor = 2
ext.versionPatch = 3
ext.versionClassifier = null
ext.isSnapshot = true
android {
defaultConfig {
@virendersran01
virendersran01 / FlowWithExtension.kt
Created November 24, 2022 13:10 — forked from Vaibhav2002/FlowWithExtension.kt
Collecting flows by using an extension function
/** Making this extension function cleans out the code a lot by removing the repetitive
flowWithLifecycle() or repeatOnLifecycle()
**/
fun <T> Flow<T>.safeCollect(
owner: LifecycleOwner,
block: (T.() -> Unit)? = null
) = owner.lifecycleScope.launch {
flowWithLifecycle(owner.lifecycle).collectLatest { block?.invoke(it) }
}
package com.ercnksgl.testapp.util
import android.view.MotionEvent
import androidx.recyclerview.widget.RecyclerView
import kotlin.math.abs
class DisallowParentSwipeOnItemTouchListener : RecyclerView.OnItemTouchListener {
var startPoint = 0f
override fun onInterceptTouchEvent(
rv: RecyclerView,