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
adb shell settings put global window_animation_scale 1 | |
adb shell settings put global transition_animation_scale 1 | |
adb shell settings put global animator_duration_scale 1 |
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
adb shell settings put global window_animation_scale 10 | |
adb shell settings put global transition_animation_scale 10 | |
adb shell settings put global animator_duration_scale 10 |
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
private fun subscribeObservers() { | |
viewModel.liveDateFetch.observe(this, Observer { | |
when (it) { | |
is ResultWrapper.Loading -> showLoading(it.isLoading) | |
is ResultWrapper.NetworkError -> showError() | |
is ResultWrapper.Success<*> -> { | |
animation_loading.visibility = View.INVISIBLE | |
scroll_root.fullScroll(View.FOCUS_DOWN) | |
} | |
} |
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
<androidx.core.widget.NestedScrollView | |
android:id="@+id/scroll_root" | |
android:layout_width="match_parent" | |
android:layout_height="0dp" | |
app:layout_constraintBottom_toTopOf="@id/loadMore" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toBottomOf="@id/search"> | |
<LinearLayout | |
android:layout_width="match_parent" |
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
<com.airbnb.lottie.LottieAnimationView | |
android:id="@+id/animationView" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginTop="200dp" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" | |
app:lottie_autoPlay="true" | |
app:lottie_loop="true" | |
app:lottie_rawRes="@raw/splash_animation" |
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
@Query("SELECT * FROM dog WHERE breed LIKE '%' || :search || '%'") | |
fun getSearchedDogs(search: String?): Flow<List<Dog>> | |
@Insert(onConflict = OnConflictStrategy.REPLACE) | |
suspend fun save(dog: Dog) |
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 getSearchedDogs(search: String): Flow<List<Dog>> { | |
return dogDao.getSearchedDogs(search) //Get searched dogs from Room Database | |
//Combine the result with another flow | |
.combine(topBreedsFlow) { dogs, topDogs -> | |
dogs.applyToDog(topDogs) | |
} | |
.flowOn(Dispatchers.Default) | |
//Return the latest values | |
.conflate() | |
} |
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
private val searchChanel = ConflatedBroadcastChannel<String>() | |
//We will use a ConflatedBroadcastChannel as this will only broadcast | |
//the most recent sent element to all the subscribers | |
fun setSearchQuery(search: String) { | |
//We use .offer() to send the element to all the subscribers. | |
searchChanel.offer(search) | |
} | |
//Observe this live Data from view and submit the list in adapter. |
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
search.setOnQueryTextListener(object : SearchView.OnQueryTextListener, androidx.appcompat.widget.SearchView.OnQueryTextListener { | |
override fun onQueryTextSubmit(query: String?): Boolean { | |
return true | |
} | |
override fun onQueryTextChange(newText: String?): Boolean { | |
newText?.let { | |
//Pass Search Query to this function in viewmodel | |
viewModel.setSearchQuery(it) | |
} |
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
livedata { | |
while(true){ | |
emit(service.getLikes()) | |
delay(10000) | |
} | |
} |