This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** normal function **/ | |
fun methodName(data: String) { | |
println(data) | |
} | |
/** lambda expression **/ | |
val test = {data:String-> println(data) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Higher Order Function **/ | |
fun funName(a: Int, func: (Int) -> Int) { | |
val s = func(a) | |
println(s) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val floatingLoaderButton: FloatingLoaderButton = findViewById<FloatingLoaderButton>(R.id.floatingLoaderBtn) | |
floatingLoaderButton.setOnClickListener { | |
// to start circular animation when api calling starts | |
floatingLoaderButton.setLoadingStatus(FloatingLoaderButton.LoaderStatus.LOADING) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
OlderNewer