Skip to content

Commit

Permalink
🔀 resolve conflicts from android dev branch
Browse files Browse the repository at this point in the history
  • Loading branch information
kmkim2689 committed Jul 26, 2024
1 parent ca9dcfc commit 32789b5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import net.pengcook.android.R
import net.pengcook.android.databinding.FragmentCategoryBinding
import net.pengcook.android.presentation.core.style.GridSpacingItemDecoration
Expand Down Expand Up @@ -46,7 +47,11 @@ class CategoryFragment : Fragment() {
val uiEvent = event.getContentIfNotHandled() ?: return@observe
when (uiEvent) {
is CategoryUiEvent.NavigateToList -> {
// TODO Navigation
val action =
CategoryFragmentDirections.actionCategoryFragmentToCategoryFeedListFragment(
uiEvent.categoryCode,
)
findNavController().navigate(action)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,24 @@ import androidx.recyclerview.widget.DiffUtil
import net.pengcook.android.databinding.ItemFeedBinding
import net.pengcook.android.presentation.core.model.Recipe
import net.pengcook.android.presentation.home.FeedRecyclerViewAdapter
import net.pengcook.android.presentation.home.holder.FeedViewHolder
import net.pengcook.android.presentation.home.listener.FeedItemEventListener

class CategoryFeedListAdapter :
PagingDataAdapter<Recipe, FeedRecyclerViewAdapter.ViewHolder>(diffCallback) {
class CategoryFeedListAdapter(
private val eventListener: FeedItemEventListener,
) :
PagingDataAdapter<Recipe, FeedViewHolder>(diffCallback) {
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int,
): FeedRecyclerViewAdapter.ViewHolder {
): FeedViewHolder {
val layoutInflater = LayoutInflater.from(parent.context)
val binding = ItemFeedBinding.inflate(layoutInflater, parent, false)
return FeedRecyclerViewAdapter.ViewHolder(binding)
return FeedViewHolder(binding, eventListener)
}

override fun onBindViewHolder(
holder: FeedRecyclerViewAdapter.ViewHolder,
holder: FeedViewHolder,
position: Int,
) {
val item = getItem(position) ?: return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
Expand All @@ -20,14 +22,15 @@ class CategoryFeedListFragment : Fragment() {
private var _binding: FragmentCategoryFeedListBinding? = null
private val binding: FragmentCategoryFeedListBinding
get() = _binding!!
private val args: CategoryFeedListFragmentArgs by navArgs()
private val viewModel: CategoryFeedListViewModel by viewModels {
CategoryFeedListViewModelFactory(
DefaultFeedRepository(DefaultFeedRemoteDataSource(RetrofitClient.service(FeedService::class.java))),
"Dessert",
args.category,
)
}
private val adapter: CategoryFeedListAdapter by lazy {
CategoryFeedListAdapter()
CategoryFeedListAdapter(viewModel)
}

override fun onCreateView(
Expand Down Expand Up @@ -56,7 +59,7 @@ class CategoryFeedListFragment : Fragment() {

private fun setUpBindingVariables() {
binding.viewModel = viewModel
binding.categoryName = "Dessert"
binding.categoryName = args.category
binding.adapter = adapter
}

Expand All @@ -75,10 +78,15 @@ class CategoryFeedListFragment : Fragment() {
val newEvent = event.getContentIfNotHandled() ?: return@observe
when (newEvent) {
is CategoryFeedListUiEvent.NavigateBack -> {
// TODO implement navigation
findNavController().navigateUp()
}

is CategoryFeedListUiEvent.NavigateToDetail -> {
// TODO implement navigation
val action =
CategoryFeedListFragmentDirections.actionCategoryFeedListFragmentToDetailRecipeFragment(
newEvent.recipe,
)
findNavController().navigate(action)
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions android/app/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
<action
android:id="@+id/action_categoryFragment_to_recipeMakingFragment"
app:destination="@id/recipeMakingFragment" />
<action
android:id="@+id/action_categoryFragment_to_categoryFeedListFragment"
app:destination="@id/categoryFeedListFragment" />
</fragment>

<fragment
Expand Down Expand Up @@ -127,6 +130,9 @@
android:name="category"
app:argType="string"
android:defaultValue="" />
<action
android:id="@+id/action_categoryFeedListFragment_to_detailRecipeFragment"
app:destination="@id/detailRecipeFragment" />
</fragment>

</navigation>

0 comments on commit 32789b5

Please sign in to comment.