Skip to content

Instantly share code, notes, and snippets.

View NitinPraksash9911's full-sized avatar
🎯
Focusing

Nitin Prakash NitinPraksash9911

🎯
Focusing
View GitHub Profile
class BookStocks:Book {
val no_of_books: Int = 0;
}
class Book {
val name: String = ""
val price: Int = 0;
val author: String = ""
}
class TestViewModel @Inject constructor(private val dataRepo: DataRepository) : ViewModel() {
private var dataLiveData = MutableLiveData<Int>()
fun insertUser(user: User) {
dataRepo.insertUser(user)
}
fun deleteUser() {
class TestViewModel(application: Application) : AndroidViewModel(application) {
private var dataLiveData = MutableLiveData<Int>()
var data = dataLiveData as LiveData<Int>
private val roomDb = RoomDb.getInstance(application).getUserDao()
fun insertUser(user: User) {
roomDb.insertUser(user)
@NitinPraksash9911
NitinPraksash9911 / FloatingExample.kt
Last active May 1, 2020 19:16
FloatingExample kotlin
val floatingLoaderButton: FloatingLoaderButton = findViewById<FloatingLoaderButton>(R.id.floatingLoaderBtn)
floatingLoaderButton.setOnClickListener {
// to start circular animation when api calling starts
floatingLoaderButton.setLoadingStatus(FloatingLoaderButton.LoaderStatus.LOADING)
@NitinPraksash9911
NitinPraksash9911 / attrs.csv
Last active May 1, 2020 17:10
Attributes table for floating button
Name Values
app:loaderBackgroundColor to change the FloatingLoaderButton background color & by default background color is black
app:loaderFabSize to change the size of FloatingLoaderButton & it's available in three sizes `Medium` `Small` & `Large` choose one from these
app:loadingIconColor to change the arrow-icon color & by default arow-icon color is white
app:loadingStatus use to define the state of loader & it has three states 1. `None` for initial stage when doing nothing2. `Loading` to start circular loading 3. `Finish` to stop circular loading(recommended to use None in xml and set the loader state programmatically) and you can use these states to change the loader state in xml when using data binding
val flb : FloatingLoaderButton = findViewById<FloatingLoaderButton>(R.id.floatingLoaderBtn)
// to start circular animation
flb.setLoadingStatus(FloatingLoaderButton.LoaderStatus.LOADING)
// to stop circular animation
flb.setLoadingStatus(FloatingLoaderButton.LoaderStatus.FINISH)
<in.nitin.library.FloatingLoaderButton
android:id="@+id/floatingLoaderBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:loaderBackgroundColor="#50CCDF"
app:loaderFabSize="Medium"
app:loadingIconColor="#FFD600"
app:loadingStatus="None" />
/** Higher Order Function **/
fun funNameTwo(func:(Int)->Int):(Int)->Int{
val k = func(6)
return {x:Int->x*k}
}
/** calling above HOF **/
val test= funNameTwo({it*4})
/** Higher Order Function **/
fun returnAfunc(a:Int):(Int)->Int{
return {x:Int->x*a}
}
/** calling above HOF **/
val func = returnAfunc(3)
val value = func(2)