content: package com.example.hp.myapplication;
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.support.design.widget.FloatingActionButton;
  import android.support.design.widget.Snackbar;
  import android.support.v7.widget.LinearLayoutManager;
  import android.support.v7.widget.RecyclerView;
  import android.view.View;
  import android.support.design.widget.NavigationView;
  import android.support.v4.view.GravityCompat;
  import android.support.v4.widget.DrawerLayout;
  import android.support.v7.app.ActionBarDrawerToggle;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.bumptech.glide.Glide;
  import com.example.hp.myapplication.Common.Common;
  import com.example.hp.myapplication.Interface.ItemClickListener;
  import com.example.hp.myapplication.Model.Category;
  import com.example.hp.myapplication.ViewHolder.MenuViewHolder;
  import com.firebase.ui.database.FirebaseRecyclerAdapter;
  import com.google.firebase.database.DatabaseReference;
  import com.google.firebase.database.FirebaseDatabase;
  import com.squareup.picasso.Picasso;
  
  
  
  public class Home extends AppCompatActivity
          implements NavigationView.OnNavigationItemSelectedListener {
  
      FirebaseDatabase database;
      DatabaseReference category;
      TextView txtFullName;
  
      RecyclerView recycle_menu;
      RecyclerView.LayoutManager layoutManager;
  
      FirebaseRecyclerAdapter<Category,MenuViewHolder> adapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_home);
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          toolbar.setTitle("Menu");
  
          setSupportActionBar(toolbar);
  
          //Firebase:
          database = FirebaseDatabase.getInstance();
          category = database.getReference("Category");
  
  
          FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
          fab.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Intent cart = new Intent(Home.this,Cart.class);
                  startActivity(cart);
              }
          });
  
          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
          ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                  this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
          drawer.addDrawerListener(toggle);
          toggle.syncState();
  
          NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
          navigationView.setNavigationItemSelectedListener(this);
  
          View headerview = navigationView.getHeaderView(0);
          txtFullName = (TextView)headerview.findViewById(R.id.txtFullName);
          txtFullName.setText(Common.currentUser.getName());
  
          //Menu
          recycle_menu  = (RecyclerView)findViewById(R.id.recycler_menu);
          recycle_menu.setHasFixedSize(true);
          layoutManager = new LinearLayoutManager(this);
          recycle_menu.setLayoutManager(layoutManager);
          loadMenu();
      }
  
      private void loadMenu() {
          adapter = new FirebaseRecyclerAdapter<Category, MenuViewHolder>(Category.class,R.layout.menu_list,MenuViewHolder.class,category) {
              @Override
              protected void populateViewHolder(MenuViewHolder viewHolder, Category model, int position) {
                  viewHolder.txtMenuName.setText(model.getName());
                  //Picasso.get(getApplicationContext()).load(model.getImage()).into(viewHolder.imageView);
                  Glide.with(getBaseContext()).load(model.getImage()).into(viewHolder.imageView);
  
                 final Category clickItem = model;
                  viewHolder.setItemClickListener(new ItemClickListener() {
                      @Override
                      public void onClick(View view, int position, boolean isLongClick) {
                          //Toast.makeText(Home.this, ""+clickItem.getName(), Toast.LENGTH_SHORT).show();
                          Intent foodlist = new Intent(Home.this,FoodList.class);
                          foodlist.putExtra("CategoryId",adapter.getRef(position).getKey());
                          startActivity(foodlist);
                      }
                  });
              }
          };
          recycle_menu.setAdapter(adapter);
      }
  
      @Override
      public void onBackPressed() {
          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
          if (drawer.isDrawerOpen(GravityCompat.START)) {
              drawer.closeDrawer(GravityCompat.START);
          } else {
              super.onBackPressed();
          }
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.home, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
  
          return super.onOptionsItemSelected(item);
      }
  
      @SuppressWarnings("StatementWithEmptyBody")
      @Override
      public boolean onNavigationItemSelected(MenuItem item) {
          // Handle navigation view item clicks here.
          int id = item.getItemId();
  
          if (id == R.id.nav_menu) {
              // Handle the camera action
          } else if (id == R.id.nav_cart) {
  
          } else if (id == R.id.nav_orders) {
  
          } else if (id == R.id.nav_log_out) {
  
          } else if (id == R.id.nav_share) {
  
          } else if (id == R.id.nav_send) {
  
          }
  
          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
          drawer.closeDrawer(GravityCompat.START);
          return true;
      }
  }
  