use of fcu.app.unknownfooddelivery.item.MealItem in project Unknown-food-delivery by a47894785.
the class MenuAdapter method getView.
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(this.context);
LinearLayout itemLayout = null;
if (convertView == null) {
itemLayout = (LinearLayout) inflater.inflate(R.layout.listitem_shop_page, null);
} else {
itemLayout = (LinearLayout) convertView;
}
MealItem item = mealItems.get(position);
TextView tvMealName = itemLayout.findViewById(R.id.tv_menu_meal_name);
tvMealName.setText(item.getMealName());
TextView tvMealPrice = itemLayout.findViewById(R.id.tv_menu_meal_price);
tvMealPrice.setText("$ " + item.getMealPrice());
ImageView imMealImg = itemLayout.findViewById(R.id.im_menu_meal_img);
Picasso.get().load(item.getMealImg()).into(imMealImg);
return itemLayout;
}
use of fcu.app.unknownfooddelivery.item.MealItem in project Unknown-food-delivery by a47894785.
the class ShopInfoFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_shop_info, container, false);
if (getArguments() != null) {
shopId = this.getArguments().getString("shopId");
}
db = FirebaseFirestore.getInstance();
imShopImage = view.findViewById(R.id.im_shop_image);
tvShopName = view.findViewById(R.id.tv_shop_info_name);
tvShopPhone = view.findViewById(R.id.tv_shop_info_phone);
lvMenu = view.findViewById(R.id.lv_show_menu);
DocumentReference documentReference = db.collection("shops").document(shopId);
documentReference.get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
@Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
if (documentSnapshot.exists()) {
shopName = documentSnapshot.getString("shopName");
shopPhone = documentSnapshot.getString("shopPhone");
shopImgUrl = documentSnapshot.getString("shopImage");
Picasso.get().load(shopImgUrl).into(imShopImage);
tvShopName.setText(shopName);
tvShopPhone.setText(shopPhone);
}
}
});
db.collection("shops").document(shopId).collection("menu").get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
ArrayList<MealItem> mealList = new ArrayList<>();
for (QueryDocumentSnapshot document : task.getResult()) {
Log.d("menuInfo", document.getId());
String mealName = String.valueOf(document.getData().get("mealName"));
String mealPrice = String.valueOf(document.getData().get("mealPrice"));
String photoName = String.valueOf(document.getData().get("photoName"));
mealList.add(new MealItem(mealName, mealPrice, photoName));
}
MenuAdapter adapter = new MenuAdapter(getContext(), R.layout.listitem_shop_page, mealList);
lvMenu.setAdapter(adapter);
}
});
return view;
}
Aggregations