use of com.google.firebase.example.fireeats.java.adapter.RatingAdapter in project quickstart-android by firebase.
the class RestaurantDetailFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mBinding.restaurantButtonBack.setOnClickListener(this);
mBinding.fabShowRatingDialog.setOnClickListener(this);
String restaurantId = RestaurantDetailFragmentArgs.fromBundle(getArguments()).getKeyRestaurantId();
// Initialize Firestore
mFirestore = FirebaseFirestore.getInstance();
// Get reference to the restaurant
mRestaurantRef = mFirestore.collection("restaurants").document(restaurantId);
// Get ratings
Query ratingsQuery = mRestaurantRef.collection("ratings").orderBy("timestamp", Query.Direction.DESCENDING).limit(50);
// RecyclerView
mRatingAdapter = new RatingAdapter(ratingsQuery) {
@Override
protected void onDataChanged() {
if (getItemCount() == 0) {
mBinding.recyclerRatings.setVisibility(View.GONE);
mBinding.viewEmptyRatings.setVisibility(View.VISIBLE);
} else {
mBinding.recyclerRatings.setVisibility(View.VISIBLE);
mBinding.viewEmptyRatings.setVisibility(View.GONE);
}
}
};
mBinding.recyclerRatings.setLayoutManager(new LinearLayoutManager(requireContext()));
mBinding.recyclerRatings.setAdapter(mRatingAdapter);
mRatingDialog = new RatingDialogFragment();
}
Aggregations