- Using Room, use the
AndroidViewMode(application)
class YourModelViewModel(val database: YourModelDatabaseDao,
application: Application) : AndroidViewModel(application){
}
- Add the ViewModelFactory
import ( | |
"context" | |
//"database/sql" | |
"fmt" | |
"log" | |
"net" | |
"os" | |
"github.com/go-sql-driver/mysql" | |
"golang.org/x/crypto/ssh" |
private const val LAST_REQUEST_TIME_MILLISECONDS = "last_request_time_milliseconds" | |
private val getDateFormat = SimpleDateFormat("dd-hh-mm-ss") | |
private fun isRapidRequest(lastRequestDateTime: String): Boolean { | |
if (lastRequestDateTime.isBlank()) return false | |
val date = getDateFormat.format(Date()) | |
val dateTimeIntArrayList = date.split("-") | |
val lastDatetimeIntArrayList = lastRequestDateTime.split("-") |
inline fun <T> ArrayList<T>.filterAndUpdateList(predicate: (T) -> Boolean) : List<T> { | |
return filter(predicate = predicate).also { filteredList -> | |
this.clear() | |
this.addAll(filteredList) | |
} | |
} |
fun Modifier.velocityBouncePhysicsList( | |
scrollState: ScrollState): Modifier = composed { | |
if(scrollState.value == 0 || scrollState.value == scrollState.maxValue){ | |
val offsetY = remember { Animatable(0f) } | |
pointerInput(Unit) { | |
val decay = splineBasedDecay<Float>(this) | |
coroutineScope { | |
while (true) { | |
val pointerId = awaitPointerEventScope { awaitFirstDown().id } |
@ExperimentalAnimationApi | |
@Composable | |
fun EdufundBackConfirmationDialog( | |
componentParameter: ComponentParameter, | |
isDialogTypeBackConfirmation: Boolean, | |
title: String, | |
desc: String, | |
onYesClicked: () -> Unit, | |
onDismiss: () -> Unit, | |
testTag: String |
@ExperimentalAnimationApi | |
@ExperimentalPagerApi | |
@Composable | |
fun HorizontalPagerIndicator2( | |
pagerState: PagerState, | |
modifier: Modifier = Modifier, | |
activeColor: Color = LocalContentColor.current.copy(alpha = LocalContentAlpha.current), | |
inactiveColor: Color = activeColor.copy(ContentAlpha.disabled), | |
indicatorHeight: Dp = 8.dp, |
@Composable | |
fun SomePage(){ | |
val animatedVisibility = produceState(initialValue = false){ | |
delay(2000) | |
value = true | |
} | |
BoxWithConstraints{ |
val text = mutableListOf("") | |
fun onValueChanged(value: String) { | |
if (!value.isName()) return | |
val filteredValue = value.replace("\\s+".toRegex(), " ") | |
if (value.contains("\n")) return | |
text.value = value | |
} |
<manifest> | |
<uses-feature android:name="android.hardware.camera.any" /> | |
<uses-permission android:name="android.permission.CAMERA" /> | |
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | |
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | |
<application> |
AndroidViewMode(application)
class YourModelViewModel(val database: YourModelDatabaseDao,
application: Application) : AndroidViewModel(application){
}