-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
174 additions
and
116 deletions.
There are no files selected for viewing
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
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
48 changes: 0 additions & 48 deletions
48
app/src/main/java/com/tip/lunchbox/view/activity/CollectionDetails.java
This file was deleted.
Oops, something went wrong.
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
57 changes: 57 additions & 0 deletions
57
app/src/main/java/com/tip/lunchbox/view/fragment/CollectionDetails.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.tip.lunchbox.view.fragment; | ||
|
||
import android.os.Bundle; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.fragment.app.Fragment; | ||
import androidx.lifecycle.ViewModelProvider; | ||
import androidx.navigation.fragment.NavHostFragment; | ||
import androidx.recyclerview.widget.LinearLayoutManager; | ||
|
||
import com.tip.lunchbox.databinding.FragmentCollectionDetailsBinding; | ||
import com.tip.lunchbox.view.adapter.RestaurantAdapter; | ||
import com.tip.lunchbox.view.listeners.RecyclerTouchListener; | ||
import com.tip.lunchbox.viewmodel.CollectionDetailsViewModel; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class CollectionDetails extends Fragment { | ||
private FragmentCollectionDetailsBinding binding; | ||
private CollectionDetailsViewModel viewModel; | ||
private RestaurantAdapter adapter; | ||
|
||
@Override | ||
public View onCreateView(@NotNull LayoutInflater inflater, | ||
ViewGroup container, | ||
Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
binding = FragmentCollectionDetailsBinding.inflate(inflater, container, false); | ||
setupRecyclerView(); | ||
|
||
viewModel = new ViewModelProvider(this).get(CollectionDetailsViewModel.class); | ||
assert getArguments() != null; | ||
int collectionId = CollectionDetailsArgs.fromBundle(getArguments()).getCollectionID(); | ||
String collectionName = CollectionDetailsArgs.fromBundle(getArguments()).getCollectionName(); | ||
binding.appBarTvLocation.setText(collectionName); | ||
viewModel.getSearchResponseLiveData(collectionId).observe(getViewLifecycleOwner(), searchResponse -> | ||
adapter.setData(searchResponse.getRestaurantContainers())); | ||
return binding.getRoot(); | ||
} | ||
|
||
private void setupRecyclerView() { | ||
adapter = new RestaurantAdapter(requireContext()); | ||
binding.rvCollectionsDetails.setAdapter(adapter); | ||
binding.rvCollectionsDetails.setLayoutManager(new LinearLayoutManager(requireContext())); | ||
|
||
new RecyclerTouchListener(requireContext(), binding.rvCollectionsDetails, (view, position) -> { | ||
CollectionDetailsDirections.ActionCollectionDetailsToRestaurantDetails action = | ||
CollectionDetailsDirections.actionCollectionDetailsToRestaurantDetails( | ||
Integer.parseInt(adapter.getData().get(position) | ||
.getRestaurant().getId())); | ||
|
||
NavHostFragment.findNavController(this).navigate(action); | ||
}); | ||
} | ||
} |
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
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
Oops, something went wrong.