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
cardView.setOnClickListener { | |
val intent = Intent(this, DetailActivity::class.java) | |
val pairImage = Pair<View, String>(imageView, resources.getString(R.string.transition_image)) | |
val pairTitle = Pair<View, String>(tv_title, resources.getString(R.string.transition_title)) | |
val pairDesc = Pair<View, String>(tv_desc, resources.getString(R.string.transition_body)) | |
val pairBack = Pair<View, String>(cardView, resources.getString(R.string.transition_container)) | |
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(this, pairImage, pairTitle, pairDesc, pairBack) | |
startActivity(intent, activityOptions.toBundle()) |
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
<resources> | |
<!-- Base application theme. --> | |
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight"> | |
<!-- Customize your theme here. --> | |
... | |
<item name="android:windowActivityTransitions">true</item> | |
... | |
<!-- Optional enter/exit transitions --> | |
<item name="android:windowEnterTransition">@transition/explode</item> | |
<item name="android:windowExitTransition">@transition/explode</item> |
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
fun Route.customer(customerRepo: CustomerRepo) { | |
route("/customer") { | |
// http://127.0.0.1:8080/customer | |
get { | |
call.respond(HttpStatusCode.OK, customerRepo.customerList) | |
} | |
// http://127.0.0.1:8080/customer/1 | |
get("/{customerId}") { |
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
fun Route.customer(customerRepo: CustomerRepo) { | |
route("/customer") { | |
get("/{customerId}") { | |
val customerId = call.parameters["customerId"]?.toInt() | |
} | |
} | |
} |
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
fun main() { | |
val server = embeddedServer(Netty, port = 8080) { | |
routing { | |
helloWorld() | |
} | |
} | |
server.start(wait = true) | |
} | |
fun Route.helloWorld() { |
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
fun main() { | |
val server = embeddedServer(Netty, port = 8080) { | |
routing { | |
get("/") { | |
call.respondText("Hello World!", ContentType.Text.Plain) | |
} | |
} | |
} | |
server.start(wait = true) | |
} |
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
vb.spinner.onItemSelectedListener = object : | |
AdapterView.OnItemSelectedListener { | |
override fun onItemSelected( | |
parent: AdapterView<*>, | |
view: View, position: Int, id: Long | |
) { | |
vm.selectedBreedLiveData.value = position | |
} | |
override fun onNothingSelected(parent: AdapterView<*>) { |
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 selectedBreedLiveData = MutableLiveData<Int>() | |
fun fetchBreedDetails(): LiveData<String> { | |
return Transformations.switchMap(selectedBreedLiveData) | |
{ | |
makeDetailsApiCall(it + 1) | |
} | |
} | |
private fun makeDetailsApiCall(id: Int): LiveData<String> { |
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
vm.fetchDogBreedList().observe(viewLifecycleOwner, Observer { | |
it?.let { | |
val aa = ArrayAdapter<Any>(requireContext(), android.R.layout.simple_spinner_item, it) | |
aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) | |
vb.spinner.adapter = aa | |
} | |
}) |
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
fun fetchDogBreedList(): LiveData<List<String>> { | |
val dogBreedLiveData = fetchDetailsRepo.fetchBreedList() | |
return Transformations.map(dogBreedLiveData) { | |
when (it.status) { | |
Resource.Status.SUCCESS -> { | |
// Returns a list of 'name' string | |
it.data?.map { it.name } | |
} | |
Resource.Status.ERROR -> { | |
// Handle Error |
NewerOlder