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 isSubmitEnabled: Flow<Boolean> = combine(_firstName, _password, _userID) { firstName, password, userId -> | |
val regexString = "[a-zA-Z]+" | |
val isNameCorrect = firstName.matches(regexString.toRegex()) | |
val isPasswordCorrect = password.length > 8 | |
val isUserIdCorrect = userId.contains("_") | |
return@combine isNameCorrect and isPasswordCorrect and isUserIdCorrect | |
} |
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 setFirstName(name: String) { | |
_firstName.value = name | |
} | |
fun setPassword(password: String) { | |
_password.value = password | |
} | |
fun setUserId(id: String) { | |
_userID.value = id |
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
override fun itemClickedClicked(view: View, dog: Dog) { | |
exitTransition = Hold().apply { | |
duration = resources.getInteger(R.integer.motion_duration_large).toLong() | |
} | |
reenterTransition = MaterialElevationScale(true).apply { | |
duration = resources.getInteger(R.integer.motion_duration_small).toLong() | |
} | |
val toDogDetailsFragment = DogListFragmentDirections.actionDogListFragmentToDogDetailFragment(dog.imageUrl.toString(), dog.breed) |
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
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
postponeEnterTransition() | |
view.doOnPreDraw { startPostponedEnterTransition() } | |
... | |
} |
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
override fun onCreate(savedInstanceState: Bundle?) { | |
sharedElementEnterTransition = MaterialContainerTransform().apply { | |
duration = 300L | |
isElevationShadowEnabled = true | |
setAllContainerColors(requireContext().themeColor(R.attr.colorSurface)) | |
} | |
super.onCreate(savedInstanceState) | |
} |
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 DogDetailFragment : Fragment(R.layout.dog_detail_fragment) { | |
private val args: DogDetailFragmentArgs by navArgs() | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
val (imageUrl, breed) = args | |
ImageLoader.loadImage(requireContext(), imageUrl, image_dog_detail) | |
textview_dog_breed.text = breed | |
//Set the unique transition name to the "end" view |
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
<?xml version="1.0" encoding="utf-8"?> | |
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
//End view of the Transition | |
android:id="@+id/detail_container" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:fitsSystemWindows="false"> |
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 DogListFragment : Fragment(R.layout.dog_list_fragment), RecyclerAdapter.RecyclerViewClickListener { | |
private val adapter by lazy(NONE) { RecyclerAdapter(this) } | |
override fun onItemClicked(view: View, dog: Dog) { | |
val toDogDetailsFragment = DogListFragmentDirections.actionDogListFragmentToDogDetailFragment(dog.imageUrl.toString(), dog.breed) | |
val extras = FragmentNavigatorExtras(view to dog.imageUrl.toString()) | |
navigate(toDogDetailsFragment, extras) | |
} | |
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 RecyclerAdapter(val callback: RecyclerViewClickListener) : ListAdapter<Dog, RecyclerAdapter.DogViewHolder>(UserDataAdapterListDiff()) { | |
interface RecyclerViewClickListener { | |
fun onItemClicked(view: View, dog: Dog) | |
} | |
....inner class DogViewHolder(override val containerView: View) : RecyclerView.ViewHolder(containerView), LayoutContainer { | |
fun bind(dog: Dog) { | |
with(containerView) { | |
breed_name.text = dog.breed?.capitalize() | |
dog.imageUrl?.let { it1 -> ImageLoader.loadImage(containerView.context, it1, image_thumbnail) } |
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
<?xml version="1.0" encoding="utf-8"?> | |
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:id="@+id/item_container" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_margin="4dp" | |
android:src="?attr/selectableItemBackground" | |
app:cardCornerRadius="8dp" |