Skip to content

Instantly share code, notes, and snippets.

View NitinPraksash9911's full-sized avatar
🎯
Focusing

Nitin Prakash NitinPraksash9911

🎯
Focusing
View GitHub Profile
/** normal function **/
fun methodName(data: String) {
println(data)
}
/** lambda expression **/
val test = {data:String-> println(data) }
/** Higher Order Function **/
fun funName(a: Int, func: (Int) -> Int) {
val s = func(a)
println(s)
}
/** Higher Order Function **/
fun funName(a: Int, func: (Int, Int) -> Int) {
val s = func(a,5)
println(s)
}
/** calling above HOF **/
val a: Int = 7
/** 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)
/** 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})
<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" />
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)
@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
@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)
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)