content: package com.example.hp.myapplication;
  
  import android.support.design.widget.CollapsingToolbarLayout;
  import android.support.design.widget.FloatingActionButton;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.ImageView;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.bumptech.glide.Glide;
  import com.cepheuen.elegantnumberbutton.view.ElegantNumberButton;
  import com.example.hp.myapplication.Database.Database;
  import com.example.hp.myapplication.Model.Food;
  import com.example.hp.myapplication.Model.Order;
  import com.google.firebase.database.DataSnapshot;
  import com.google.firebase.database.DatabaseError;
  import com.google.firebase.database.DatabaseReference;
  import com.google.firebase.database.FirebaseDatabase;
  import com.google.firebase.database.ValueEventListener;
  
  public class FoodDetail extends AppCompatActivity {
  
      TextView food_name,food_price,food_description;
      ImageView food_image;
      CollapsingToolbarLayout collapsingToolbarLayout;
      FloatingActionButton btncart;
      ElegantNumberButton numberButton;
  
      String foodId="";
  
      FirebaseDatabase database;
      DatabaseReference foods;
      Food currentFood;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_food_detail);
  
          //Firebase
  
          database = FirebaseDatabase.getInstance();
          foods = database.getReference("Foods");
  
          //init view
          numberButton = (ElegantNumberButton)findViewById(R.id.number_button);
          btncart = (FloatingActionButton)findViewById(R.id.btncart);
  
          btncart.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  new Database(getBaseContext()).addToCart(new Order(foodId,
                          currentFood.getName(),
                          numberButton.getNumber(),
                          currentFood.getPrice(),
                          currentFood.getDiscount()));
                  Toast.makeText(FoodDetail.this, "Added to cart", Toast.LENGTH_SHORT).show();
              }
          });
  
          food_description = (TextView)findViewById(R.id.food_description);
          food_name = (TextView)findViewById(R.id.food_name);
          food_price = (TextView)findViewById(R.id.food_price);
  
          food_image = (ImageView)findViewById(R.id.img_food);
  
          collapsingToolbarLayout = (CollapsingToolbarLayout)findViewById(R.id.collapsing);
          collapsingToolbarLayout.setExpandedTitleTextAppearance(R.style.ExpandedAppbar);
          collapsingToolbarLayout.setCollapsedTitleTextAppearance(R.style.CollapsedAppbar);
          
          //get foodId
          
          if(getIntent() != null)
              foodId = getIntent().getStringExtra("FoodId");
          if(!foodId.isEmpty())
          {
              getDetailFood(foodId);
          }
      }
  
      private void getDetailFood(String foodId) {
          foods.child(foodId).addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot dataSnapshot) {
                  currentFood = dataSnapshot.getValue(Food.class);
                  //set Image
                  Glide.with(getBaseContext()).load(currentFood.getImage()).into(food_image);
  
                  collapsingToolbarLayout.setTitle(currentFood.getName());
                  food_price.setText(currentFood.getName());
                  food_description.setText(currentFood.getDescription());
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
  
              }
          });
      }
  }
  