Add more verbose logging
This commit is contained in:
@@ -4,6 +4,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import gq.kirmanak.mealient.R
|
||||
import gq.kirmanak.mealient.data.recipes.db.entity.RecipeSummaryEntity
|
||||
import gq.kirmanak.mealient.databinding.ViewHolderRecipeBinding
|
||||
import timber.log.Timber
|
||||
|
||||
class RecipeViewHolder(
|
||||
private val binding: ViewHolderRecipeBinding,
|
||||
@@ -15,8 +16,14 @@ class RecipeViewHolder(
|
||||
}
|
||||
|
||||
fun bind(item: RecipeSummaryEntity?) {
|
||||
Timber.v("bind() called with: item = $item")
|
||||
binding.name.text = item?.name ?: loadingPlaceholder
|
||||
recipeViewModel.loadRecipeImage(binding.image, item)
|
||||
item?.let { entity -> binding.root.setOnClickListener { clickListener(entity) } }
|
||||
item?.let { entity ->
|
||||
binding.root.setOnClickListener {
|
||||
Timber.d("bind: item clicked $entity")
|
||||
clickListener(entity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import gq.kirmanak.mealient.data.recipes.RecipeImageLoader
|
||||
import gq.kirmanak.mealient.data.recipes.RecipeRepo
|
||||
import gq.kirmanak.mealient.data.recipes.db.entity.RecipeSummaryEntity
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
@@ -18,6 +19,7 @@ class RecipeViewModel @Inject constructor(
|
||||
val recipeFlow = recipeRepo.createPager().flow
|
||||
|
||||
fun loadRecipeImage(view: ImageView, recipeSummary: RecipeSummaryEntity?) {
|
||||
Timber.v("loadRecipeImage() called with: view = $view, recipeSummary = $recipeSummary")
|
||||
viewModelScope.launch {
|
||||
recipeImageLoader.loadRecipeImage(view, recipeSummary?.slug)
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ class RecipesFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun navigateToRecipeInfo(recipeSummaryEntity: RecipeSummaryEntity) {
|
||||
Timber.v("navigateToRecipeInfo() called with: recipeSummaryEntity = $recipeSummaryEntity")
|
||||
findNavController().navigate(
|
||||
RecipesFragmentDirections.actionRecipesFragmentToRecipeInfoFragment(
|
||||
recipeSlug = recipeSummaryEntity.slug,
|
||||
|
||||
@@ -28,15 +28,11 @@ class RecipesPagingAdapter(
|
||||
override fun areItemsTheSame(
|
||||
oldItem: RecipeSummaryEntity,
|
||||
newItem: RecipeSummaryEntity
|
||||
): Boolean {
|
||||
return oldItem.remoteId == newItem.remoteId
|
||||
}
|
||||
): Boolean = oldItem.remoteId == newItem.remoteId
|
||||
|
||||
override fun areContentsTheSame(
|
||||
oldItem: RecipeSummaryEntity,
|
||||
newItem: RecipeSummaryEntity
|
||||
): Boolean {
|
||||
return oldItem.name == newItem.name && oldItem.slug == newItem.slug
|
||||
}
|
||||
): Boolean = oldItem.name == newItem.name && oldItem.slug == newItem.slug
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ class RecipeInfoFragment : Fragment() {
|
||||
viewModel.loadRecipeImage(binding.image, arguments.recipeSlug)
|
||||
viewModel.loadRecipeInfo(arguments.recipeId, arguments.recipeSlug)
|
||||
viewModel.recipeInfo.observe(viewLifecycleOwner) {
|
||||
Timber.d("onViewCreated: full info $it")
|
||||
binding.title.text = it.recipeSummaryEntity.name
|
||||
binding.description.text = it.recipeSummaryEntity.description
|
||||
|
||||
@@ -58,7 +59,7 @@ class RecipeInfoFragment : Fragment() {
|
||||
private fun listenToAuthStatuses() {
|
||||
Timber.v("listenToAuthStatuses() called")
|
||||
authViewModel.authenticationStatuses().observe(this) {
|
||||
Timber.v("listenToAuthStatuses: new auth status = $it")
|
||||
Timber.d("listenToAuthStatuses: new auth status = $it")
|
||||
if (!it) navigateToAuthFragment()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ class RecipeInfoViewModel @Inject constructor(
|
||||
val recipeInfo: LiveData<FullRecipeInfo> = _recipeInfo
|
||||
|
||||
fun loadRecipeImage(view: ImageView, recipeSlug: String) {
|
||||
Timber.v("loadRecipeImage() called with: view = $view, recipeSlug = $recipeSlug")
|
||||
viewModelScope.launch {
|
||||
recipeImageLoader.loadRecipeImage(view, recipeSlug)
|
||||
}
|
||||
|
||||
@@ -8,14 +8,16 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import gq.kirmanak.mealient.data.recipes.db.entity.RecipeIngredientEntity
|
||||
import gq.kirmanak.mealient.databinding.ViewHolderIngredientBinding
|
||||
import gq.kirmanak.mealient.ui.recipes.info.RecipeIngredientsAdapter.RecipeIngredientViewHolder
|
||||
import timber.log.Timber
|
||||
|
||||
class RecipeIngredientsAdapter() :
|
||||
class RecipeIngredientsAdapter :
|
||||
ListAdapter<RecipeIngredientEntity, RecipeIngredientViewHolder>(RecipeIngredientDiffCallback) {
|
||||
|
||||
class RecipeIngredientViewHolder(
|
||||
private val binding: ViewHolderIngredientBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(item: RecipeIngredientEntity) {
|
||||
Timber.v("bind() called with: item = $item")
|
||||
binding.checkBox.text = item.note
|
||||
}
|
||||
}
|
||||
@@ -33,6 +35,7 @@ class RecipeIngredientsAdapter() :
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecipeIngredientViewHolder {
|
||||
Timber.v("onCreateViewHolder() called with: parent = $parent, viewType = $viewType")
|
||||
val inflater = LayoutInflater.from(parent.context)
|
||||
return RecipeIngredientViewHolder(
|
||||
ViewHolderIngredientBinding.inflate(inflater, parent, false)
|
||||
@@ -40,6 +43,9 @@ class RecipeIngredientsAdapter() :
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: RecipeIngredientViewHolder, position: Int) {
|
||||
holder.bind(getItem(position))
|
||||
Timber.v("onBindViewHolder() called with: holder = $holder, position = $position")
|
||||
val item = getItem(position)
|
||||
Timber.d("onBindViewHolder: item is $item")
|
||||
holder.bind(item)
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,11 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import gq.kirmanak.mealient.R
|
||||
import gq.kirmanak.mealient.data.recipes.db.entity.RecipeInstructionEntity
|
||||
import gq.kirmanak.mealient.databinding.ViewHolderInstructionBinding
|
||||
import gq.kirmanak.mealient.ui.recipes.info.RecipeInstructionsAdapter.RecipeInstructionViewHolder
|
||||
import timber.log.Timber
|
||||
|
||||
class RecipeInstructionsAdapter :
|
||||
ListAdapter<RecipeInstructionEntity, RecipeInstructionsAdapter.RecipeInstructionViewHolder>(
|
||||
RecipeInstructionDiffCallback
|
||||
) {
|
||||
ListAdapter<RecipeInstructionEntity, RecipeInstructionViewHolder>(RecipeInstructionDiffCallback) {
|
||||
|
||||
private object RecipeInstructionDiffCallback :
|
||||
DiffUtil.ItemCallback<RecipeInstructionEntity>() {
|
||||
@@ -27,9 +27,11 @@ class RecipeInstructionsAdapter :
|
||||
): Boolean = oldItem == newItem
|
||||
}
|
||||
|
||||
class RecipeInstructionViewHolder(private val binding: ViewHolderInstructionBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
class RecipeInstructionViewHolder(
|
||||
private val binding: ViewHolderInstructionBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(item: RecipeInstructionEntity, position: Int) {
|
||||
Timber.v("bind() called with: item = $item, position = $position")
|
||||
binding.step.text = binding.root.resources.getString(
|
||||
R.string.view_holder_recipe_instructions_step, position + 1
|
||||
)
|
||||
@@ -38,6 +40,7 @@ class RecipeInstructionsAdapter :
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecipeInstructionViewHolder {
|
||||
Timber.v("onCreateViewHolder() called with: parent = $parent, viewType = $viewType")
|
||||
val inflater = LayoutInflater.from(parent.context)
|
||||
return RecipeInstructionViewHolder(
|
||||
ViewHolderInstructionBinding.inflate(inflater, parent, false)
|
||||
@@ -45,6 +48,9 @@ class RecipeInstructionsAdapter :
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: RecipeInstructionViewHolder, position: Int) {
|
||||
holder.bind(getItem(position), position)
|
||||
Timber.v("onBindViewHolder() called with: holder = $holder, position = $position")
|
||||
val item = getItem(position)
|
||||
Timber.d("onBindViewHolder: item is $item")
|
||||
holder.bind(item, position)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user