<repo_name>omgitspradeep/TheSpiceLounge<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/CashierActivity.java
package com.sujan.info.thespicelounge;

import android.content.Intent;
import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import android.widget.Toolbar;

import com.sujan.info.thespicelounge.Adapters.OrderedListAdapterCashier;
import com.sujan.info.thespicelounge.Adapters.TableAdapter;
import com.sujan.info.thespicelounge.Utils.Constants;
import com.sujan.info.thespicelounge.Utils.MyPreferences;
import com.sujan.info.thespicelounge.Utils.Utils;
import com.sujan.info.thespicelounge.fragments.CashierOrderFragment;
import com.sujan.info.thespicelounge.fragments.CashierTableFragment;
import com.sujan.info.thespicelounge.interfaceT.orderListWithTableListener;
import com.sujan.info.thespicelounge.models.OrderDetail;
import com.sujan.info.thespicelounge.models.TableInformation;
import com.sujan.info.thespicelounge.webservices.GetOrderListWithTable;

import java.util.ArrayList;

public class CashierActivity extends BaseActivity implements TableAdapter.tableSelectionInterface,OrderedListAdapterCashier.onOrderedListInCashierUpdated,orderListWithTableListener {


    Toolbar tb;
    FrameLayout frameLayout;
    FloatingActionButton fabForBack,fabForRefresh;
    boolean doubleBackToExitPressedOnce = false;
    CashierOrderFragment cashierOrderFragment;
    ProgressBar progressBar;


    @Override
    public void onTableClick(int tableNum,ArrayList<OrderDetail> orderDetailArrayList) {
        cashierOrderFragment=new CashierOrderFragment(this,orderDetailArrayList,tableNum);
        getSupportFragmentManager().beginTransaction().replace(R.id.fragment_cashier_frame, cashierOrderFragment).commit();
        fabForBack.setVisibility(View.VISIBLE);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cashier);
        init();
    }

    private void init() {

        tb = (Toolbar) findViewById(R.id.toolbar_cashier);
        tb.setTitle(MyPreferences.getStringPrefrences(Constants.EMPLOYEE_NAME_TITLE,this));
        tb.inflateMenu(R.menu.toolbar);
        setActionBar(tb);
        progressBar=(ProgressBar)findViewById(R.id.progressBarRefresh);
        fabForBack=(FloatingActionButton)findViewById(R.id.fab_cashier_back_to_table);
        fabForRefresh=(FloatingActionButton)findViewById(R.id.fab_refresh_to_update);
        frameLayout=(FrameLayout)findViewById(R.id.fragment_cashier_frame);
        getSupportFragmentManager().beginTransaction().replace(R.id.fragment_cashier_frame, new CashierTableFragment(this)).commit();
        fabForBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                    onFabForBackPressed();
            }
        });
        fabForRefresh.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                progressBar.setVisibility(View.VISIBLE);
                new GetOrderListWithTable(CashierActivity.this,CashierActivity.this).execute();
            }
        });
    }

    public void onFabForBackPressed() {
        getSupportFragmentManager().beginTransaction().replace(R.id.fragment_cashier_frame, new CashierTableFragment(CashierActivity.this)).commit();
        fabForBack.setVisibility(View.INVISIBLE);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {


        tb.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                return onOptionsItemSelected(item);
            }
        });
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            // action with ID action_refresh was selected
            case R.id.action_logout:
                MyPreferences.resetAllPreferences(getApplicationContext());
                Utils.activityTransitionRemovingHistory(this,new Intent(this, MainActivity.class));
                break;

            default:
                break;
        }

        return true;
    }

    @Override
    public void onBackPressed() {
        if (doubleBackToExitPressedOnce) {
            super.onBackPressed();
            return;
        }

        this.doubleBackToExitPressedOnce = true;
        Utils.displayShortToastMessage(this, "Please click BACK again to exit");

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                doubleBackToExitPressedOnce=false;
            }
        }, 2000);

    }

    @Override
    public void onCashierListUpdated(int totalAmt, boolean canBeCheckout) {
        cashierOrderFragment.updateTotalPriceAndCheckout(totalAmt,canBeCheckout);
    }

    public void setFabForRefreshInvisible(){
        fabForRefresh.setVisibility(View.INVISIBLE);
    }

    public void progressBarVisibility(int id){
        // id: 0->invisible, 1:visible
        if(id==0){
            progressBar.setVisibility(View.INVISIBLE);
        }else{
            progressBar.setVisibility(View.VISIBLE);
        }
    }

    @Override
    public void onOrdersForTableReceived(boolean isSuccess) {
        progressBar.setVisibility(View.INVISIBLE);
        if(isSuccess){
            Utils.activityTransitionRemovingHistory(this,new Intent(this,CashierActivity.class));
            Utils.displayLongToastMessage(this,"All table orders are updated.");
        }

    }

    public void setFabForRefreshVisible() {
        fabForRefresh.setVisibility(View.VISIBLE);
    }

    @Override
    public void onCustomerCheckoutSuccessfully(boolean isSuccess) {
        Utils.activityTransitionRemovingHistory(this,new Intent(this,CashierActivity.class));
        Utils.displayShortToastMessage(this,"Successfully checkout");
    }
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/Adapters/OrderedListAdapterChef.java
package com.sujan.info.thespicelounge.Adapters;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.sujan.info.thespicelounge.ChefActivity;
import com.sujan.info.thespicelounge.R;
import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.Utils.Utils;
import com.sujan.info.thespicelounge.models.FoodDetails;
import com.sujan.info.thespicelounge.models.OrderDetail;
import com.sujan.info.thespicelounge.webservices.ChangeOrderStatus;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * Created by pradeep on 9/7/20.
 */

public class OrderedListAdapterChef extends RecyclerView.Adapter<OrderedListAdapterChef.ViewHolder> {

    ChefActivity context;
    private LayoutInflater mInflater;
    ArrayList<OrderDetail> orderDetailsList;



    public OrderedListAdapterChef(ChefActivity context,ArrayList<OrderDetail> orderDetailsList) {
        this.context = context;
        this.mInflater = LayoutInflater.from(context);
        this.orderDetailsList=orderDetailsList;
    }

    @Override
    public OrderedListAdapterChef.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = mInflater.inflate(R.layout.order_item_recycler_element_chef, parent, false);
        return new OrderedListAdapterChef.ViewHolder(view);
    }



   /* java.lang.NullPointerException:
    Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference*/


    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        init(holder,position);

    }

    @SuppressLint("SetTextI18n")
    private void init(ViewHolder holder, int position) {
        OrderDetail od=orderDetailsList.get(position);
        int foodId=od.getItemId();
        FoodDetails fd= ResourceManager.getFoodDetails(foodId);

        int orderStatus=od.getFoodStatus();
        String custRequest=od.getCustRequest();
        holder.sNoChef.setText(position+1+"");
        holder.quantity.setText(od.getQuantity()+" ");
        holder.chefOrderItem.setText(fd.getFullItemName());
        holder.chefOrderTime.setText(fd.getPrepareTimeinMins()+"");
        if(!custRequest.equals("")){
            holder.custRequest.setText("Request: "+custRequest);
        }

        changeColor(orderStatus,holder.chefFoodStatus);
        holder.chefFoodStatus.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // Chef can click on waiting and cooking only
                if(orderStatus==0 || orderStatus == 1){
                    context.getProgressBarChef().setVisibility(View.VISIBLE);
                    new ChangeOrderStatus(context,context,od.getOrderID(),orderStatus).execute();
                }
            }
        });
    }

    private void changeColor(int orderStatus, Button chefFoodStatus) {
        switch (orderStatus){
            case 0:
                chefFoodStatus.setText("waiting");
                chefFoodStatus.setTextColor(Color.parseColor("#4B0082"));
                chefFoodStatus.setClickable(true);
                break;

            case 1:
                chefFoodStatus.setText("cooking");
                chefFoodStatus.setTextColor(Color.parseColor("#0000FF"));
                chefFoodStatus.setClickable(true);
                break;

            case 2:
                chefFoodStatus.setText("cooked");
                chefFoodStatus.setTextColor(Color.parseColor("#FF7F00"));

                break;

            case 3:
                chefFoodStatus.setText("served");
                chefFoodStatus.setTextColor(Color.parseColor("#006400"));
                break;

        }
    }

    @Override
    public int getItemCount() {
        return orderDetailsList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        TextView sNoChef,quantity, chefOrderItem,chefOrderTime,custRequest;
        Button chefFoodStatus;

        public ViewHolder(View itemView) {
            super(itemView);
            sNoChef=(TextView)itemView.findViewById(R.id.sNo_chef);
            quantity=(TextView)itemView.findViewById(R.id.chef_order_qty);
            chefOrderItem=(TextView)itemView.findViewById(R.id.chef_ordered_item);
            chefOrderTime=(TextView)itemView.findViewById(R.id.chef_order_time);
            chefFoodStatus=(Button) itemView.findViewById(R.id.chef_status_button);
            custRequest=(TextView) itemView.findViewById(R.id.customer_request_message);

        }

    }
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/webservices/AddUpdateFoodItem.java
package com.sujan.info.thespicelounge.webservices;

import android.app.Activity;
import android.net.Uri;
import android.os.AsyncTask;
import android.util.Log;

import com.sujan.info.thespicelounge.Utils.AppConstants;
import com.sujan.info.thespicelounge.Utils.Constants;
import com.sujan.info.thespicelounge.Utils.JSONParser;
import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.Utils.Utils;
import com.sujan.info.thespicelounge.interfaceT.deleteItemListener;
import com.sujan.info.thespicelounge.interfaceT.menuItemAddUpdateListener;
import com.sujan.info.thespicelounge.models.FoodDetails;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.ParseException;
import java.util.ArrayList;

/**
 * Created by pradeep on 5/8/20.
 */

public class AddUpdateFoodItem extends AsyncTask<String,Integer,Boolean> {

    private ArrayList<FoodDetails> foodDetailsArrayList;
    menuItemAddUpdateListener listener;
    FoodDetails foodDetails;
    Activity context;

    public AddUpdateFoodItem(Activity activity,menuItemAddUpdateListener listener, FoodDetails fd) {
        this.listener = listener;
        this.foodDetails = fd;
        this.context=activity;
    }

    @Override
    protected Boolean doInBackground(String... strings) {

        try{

            URL url=new URL(AppConstants.BASE_ADMIN_URL+AppConstants.ADD_UPDATE_MENU_ITEM);
            HttpURLConnection conn = (HttpURLConnection)url.openConnection();
            conn.setRequestMethod("POST");
            conn.setRequestProperty("Content-Type", "application/json; utf-8");
            conn.setRequestProperty("Accept", "application/json");
            conn.setDoOutput(true);
            conn.setDoInput(true);

            String jsonString=foodDetails.toJSON();

            try(OutputStream os = conn.getOutputStream()) {
                byte[] input = jsonString.getBytes("utf-8");
                os.write(input, 0, input.length);
            }



            String line;
            StringBuilder sb = new StringBuilder();
            BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            while ((line = in.readLine()) != null) {
                sb.append(line);
            }

            String s = sb.toString();
            JSONArray jsonArray = new JSONArray(s);
            Log.e("Hoooooooo",s);
            ResourceManager.writeToFile(s, Constants.MENU_FILE, context); // For offline uses
            foodDetailsArrayList = JSONParser.ParseMenuItems(jsonArray);

            ResourceManager.setGlobalFoodMenu(foodDetailsArrayList);  // to store all foodMenu serially to inflate in foodMenu adapter
            ResourceManager.setFoodMenuHashMap(foodDetailsArrayList);  // to get item detail using "foodId"

            return true;
        }catch (IOException |JSONException |ParseException e){
            e.printStackTrace();
        }
        return false;
    }

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
    }

    @Override
    protected void onPostExecute(Boolean aBoolean) {
        super.onPostExecute(aBoolean);
        listener.onItemAddedOrUpdated(aBoolean);
    }
}<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/WaiterActivity.java
package com.sujan.info.thespicelounge;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import android.widget.Toolbar;

import com.sujan.info.thespicelounge.Adapters.FoodMenuAdapter;
import com.sujan.info.thespicelounge.Utils.Constants;
import com.sujan.info.thespicelounge.Utils.MyPreferences;
import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.Utils.Utils;
import com.sujan.info.thespicelounge.fragments.HomeFragment;
import com.sujan.info.thespicelounge.fragments.WaiterOrderListFragment;
import com.sujan.info.thespicelounge.interfaceT.orderStatusUpdateListener;
import com.sujan.info.thespicelounge.models.FoodDetails;
import com.sujan.info.thespicelounge.models.OrderDetail;

import java.util.ArrayList;

public class WaiterActivity extends BaseActivity implements FoodMenuAdapter.ItemClickListener,orderStatusUpdateListener {


    FrameLayout displayFoodItemsFrame;
    FloatingActionButton fab;
    Toolbar tb=null;
    boolean doubleBackToExitPressedOnce = false;
    ProgressBar progressBar;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_waiter);
        init();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {


        tb.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                return onOptionsItemSelected(item);
            }
        });
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            // action with ID action_refresh was selected
            case R.id.action_logout:
                MyPreferences.resetAllPreferences(getApplicationContext());
                Utils.activityTransitionRemovingHistory(this,new Intent(this, MainActivity.class));
                break;

            default:
                break;
        }

        return true;
    }

    public FloatingActionButton getFab() {
        return fab;
    }

    private void init() {
        tb = (Toolbar)findViewById(R.id.toolbar_waiter_activity);
        tb.setTitle(MyPreferences.getStringPrefrences(Constants.EMPLOYEE_NAME_TITLE,this));
        tb.inflateMenu(R.menu.toolbar);
        setActionBar(tb);
        displayFoodItemsFrame=(FrameLayout) findViewById(R.id.display_food_items_frame);
        progressBar=(ProgressBar)findViewById(R.id.waiter_activity_progressbar);
        fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                getSupportFragmentManager().beginTransaction().replace(R.id.display_food_items_frame, new HomeFragment(WaiterActivity.this)).commit();
                fab.setVisibility(View.GONE);
            }
        });
        getSupportFragmentManager().beginTransaction().replace(R.id.display_food_items_frame, new HomeFragment(WaiterActivity.this)).commit();
        fab.setVisibility(View.GONE);
    }


    public ProgressBar getWaiterProgressBar(){
        return progressBar;
    }
    @Override
    public void onBackPressed() {

        if (doubleBackToExitPressedOnce) {
            super.onBackPressed();
            return;
        }

        this.doubleBackToExitPressedOnce = true;
        Utils.displayShortToastMessage(this, "Please click BACK again to exit");

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                doubleBackToExitPressedOnce=false;
            }
        }, 2000);

    }

    @Override
    public void onItemClick(View view, int position) {

        Intent intent = new Intent(this, FoodOrderActivity.class);
        intent.putExtra("foodID",ResourceManager.getFoodDetailsInstance().getItemId());
        startActivity(intent);
//        finish();
    }

    public void inflateAdapter(){
        getSupportFragmentManager().beginTransaction().replace(R.id.display_food_items_frame, new WaiterOrderListFragment(this)).commit();
        ResourceManager.getWaiterActivityInstance().getFab().setVisibility(View.VISIBLE);
    }

    @Override
    public void onAllOrderedListReceiver(ArrayList<OrderDetail> orderDetailArrayList, boolean isSuccess) {
        progressBar.setVisibility(View.INVISIBLE);
        if (isSuccess){
            ResourceManager.setAllOrders(orderDetailArrayList);
            inflateAdapter();
        }else {
            Utils.displayShortToastMessage(this,"Try again");
        }
    }

    @Override
    public void onOrderStatusUpdated(boolean isSuccessful) {
        progressBar.setVisibility(View.INVISIBLE);
        if (isSuccessful){
            inflateAdapter();
        }
    }
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/webservices/DeleteMenuItem.java
package com.sujan.info.thespicelounge.webservices;

import android.app.Activity;
import android.net.Uri;
import android.os.AsyncTask;

import com.sujan.info.thespicelounge.Utils.AppConstants;
import com.sujan.info.thespicelounge.Utils.Constants;
import com.sujan.info.thespicelounge.Utils.JSONParser;
import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.interfaceT.deleteItemListener;
import com.sujan.info.thespicelounge.models.FoodDetails;

import org.json.JSONArray;
import org.json.JSONException;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.ParseException;
import java.util.ArrayList;

/**
 * Created by pradeep on 5/8/20.
 */

public class DeleteMenuItem extends AsyncTask<String,Integer,Boolean> {

    private ArrayList<FoodDetails> foodDetailsArrayList;
    deleteItemListener listener;
    int foodId;
    Activity context;

    public DeleteMenuItem(Activity activity,deleteItemListener listener, int foodId) {
        this.listener = listener;
        this.foodId = foodId;
        this.context=activity;
    }

    @Override
    protected Boolean doInBackground(String... strings) {
        try{

            Uri.Builder builder = new Uri.Builder().appendQueryParameter("foodID",foodId+"");

            URL url=new URL(AppConstants.BASE_ADMIN_URL+AppConstants.DELETE_MENU_ITEM);
            HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
            String query = builder.build().getEncodedQuery();

            urlConnection.setRequestMethod("POST");
            urlConnection.setDoInput(true);
            urlConnection.setDoOutput(true);
            urlConnection.connect();

            //Send request
            DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream ());
            wr.writeBytes (query);
            wr.flush ();
            wr.close ();

            //Get Response
            InputStream isNew = urlConnection.getInputStream();
            BufferedReader rd = new BufferedReader(new InputStreamReader(isNew));

            String line;
            StringBuilder sb = new StringBuilder();
            BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
            while ((line = in.readLine()) != null) {
                sb.append(line);
            }
            rd.close();

            String s = sb.toString();
            JSONArray jsonArray = new JSONArray(s);
            ResourceManager.writeToFile(s, Constants.MENU_FILE, context); // FOr offline uses
            foodDetailsArrayList = JSONParser.ParseMenuItems(jsonArray);

            ResourceManager.setGlobalFoodMenu(foodDetailsArrayList);  // to store all foodMenu serially to inflate in foodMenu adapter
            ResourceManager.setFoodMenuHashMap(foodDetailsArrayList);  // to get item detail using "foodId"

            return true;
        }catch (IOException |JSONException |ParseException e){
            e.printStackTrace();
        }
        return false;
    }

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
    }

    @Override
    protected void onPostExecute(Boolean aBoolean) {
        super.onPostExecute(aBoolean);
        listener.onMenuItemDeleted(aBoolean);
    }
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/interfaceT/feedbackAddedListener.java
package com.sujan.info.thespicelounge.interfaceT;

import android.widget.ProgressBar;

import com.sujan.info.thespicelounge.models.CustomerFeedback;

import java.util.ArrayList;

/**
 * Created by pradeep on 4/8/20.
 */

public interface feedbackAddedListener {
    public void onFBAddedMessage(boolean isSuccessful);

}

<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/Adapters/OrderedListAdapterWaiter.java
package com.sujan.info.thespicelounge.Adapters;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Color;
import android.support.annotation.ColorRes;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.sujan.info.thespicelounge.R;
import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.Utils.Utils;
import com.sujan.info.thespicelounge.WaiterActivity;
import com.sujan.info.thespicelounge.models.FoodDetails;
import com.sujan.info.thespicelounge.models.OrderDetail;
import com.sujan.info.thespicelounge.webservices.ChangeOrderStatus;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by pradeep on 8/7/20.
 */

public class OrderedListAdapterWaiter extends RecyclerView.Adapter<OrderedListAdapterWaiter.ViewHolder> {


    ArrayList<OrderDetail> orderDetailList;
    WaiterActivity context;
    private LayoutInflater mInflater;
    HashMap<Integer,FoodDetails> foodDetailsHashMap;

    public OrderedListAdapterWaiter(WaiterActivity mContext, ArrayList<OrderDetail> orderDetailsList) {
        this.mInflater = LayoutInflater.from(mContext);
        this.context=mContext;
        this.orderDetailList=orderDetailsList;
        this.foodDetailsHashMap=ResourceManager.getGlobalFoodMenuMap();
    }


    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = mInflater.inflate(R.layout.order_item_recycler_element_waiter, parent, false);
        return new OrderedListAdapterWaiter.ViewHolder(view);
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {

        final OrderDetail orderDetail=orderDetailList.get(position);

        int foodId=orderDetail.getItemId();
        FoodDetails foodDetails=foodDetailsHashMap.get(foodId);

        final int orderStatus=orderDetail.getFoodStatus();
        holder.sNo.setText(position+1+"");
        holder.qty.setText(orderDetail.getQuantity()+"");
        holder.waiterOrderItem.setText(foodDetails.getFullItemName());
        Log.e("HEHEHE",""+foodDetails.getFullItemName());
        holder.waiterorderPrice.setText(foodDetails.getPrice()+"");
        changeColor(orderStatus,holder.waiterFoodStatus);
        holder.waiterFoodStatus.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(orderStatus==2){
                  //  context.getWaiterProgressBar().setVisibility(View.VISIBLE);
                    new ChangeOrderStatus(context,context,orderDetail.getOrderID(),orderStatus).execute();
                }
            }
        });

    }

    @SuppressLint("SetTextI18n")
    private void changeColor(int orderStatus, Button waiterFoodStatus) {
        switch (orderStatus){
            case 0:
               waiterFoodStatus.setText("waiting");
               waiterFoodStatus.setTextColor(Color.parseColor("#4B0082"));
               break;

            case 1:
                waiterFoodStatus.setText("cooking");
                waiterFoodStatus.setTextColor(Color.parseColor("#0000FF"));
                break;

            case 2:
                waiterFoodStatus.setText("cooked");
                waiterFoodStatus.setTextColor(Color.parseColor("#FF7F00"));
                waiterFoodStatus.setClickable(true);

                break;

            case 3:
                waiterFoodStatus.setText("served");
                waiterFoodStatus.setTextColor(Color.parseColor("#006400"));
                break;

        }
    }

    @Override
    public int getItemCount() {
        return orderDetailList.size();
    }


    public class ViewHolder extends RecyclerView.ViewHolder{

        TextView sNo,qty, waiterOrderItem,waiterorderPrice;
        Button waiterFoodStatus;

        public ViewHolder(View itemView) {
            super(itemView);
            sNo=(TextView)itemView.findViewById(R.id.sNo_waiter);
            qty=(TextView)itemView.findViewById(R.id.waiter_order_qty);
            waiterOrderItem=(TextView)itemView.findViewById(R.id.waiter_ordered_item);
            waiterorderPrice=(TextView)itemView.findViewById(R.id.waiter_order_price);
            waiterFoodStatus=(Button) itemView.findViewById(R.id.waiter_status_button);
        }


    }
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/webservices/GetOrdersList.java
package com.sujan.info.thespicelounge.webservices;

import android.os.AsyncTask;

import com.sujan.info.thespicelounge.Utils.AppConstants;
import com.sujan.info.thespicelounge.Utils.Constants;
import com.sujan.info.thespicelounge.Utils.JSONParser;
import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.Utils.Utils;
import com.sujan.info.thespicelounge.interfaceT.allOrderedListListener;
import com.sujan.info.thespicelounge.models.OrderDetail;

import org.json.JSONArray;
import org.json.JSONException;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.ParseException;
import java.util.ArrayList;

/**
 * Created by pradeep on 3/8/20.
 */

public class GetOrdersList extends AsyncTask<String,Integer,Boolean>{
    ArrayList<OrderDetail> orderDetailArrayList;
    allOrderedListListener listener;

    public GetOrdersList( allOrderedListListener orderedListListener) {
        this.listener = orderedListListener;
    }


    @Override
    protected Boolean doInBackground(String... strings) {
        try{
            URL url=new URL(AppConstants.BASE_ADMIN_URL+AppConstants.GET_ALL_ORDERS);
            HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
            String line;
            StringBuilder sb = new StringBuilder();
            BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
            while ((line = in.readLine()) != null) {
                sb.append(line);
            }
            String s = sb.toString();
            JSONArray jsonArray = new JSONArray(s);

            orderDetailArrayList = JSONParser.ParseAllOrders(jsonArray);
            System.out.println("Final Orders===="+jsonArray);
            System.out.println("Final Orders===="+orderDetailArrayList.size());


            return true;

        }catch (JSONException | IOException e){
            e.printStackTrace();
        }
        return false;
    }

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
    }

    @Override
    protected void onPostExecute(Boolean aBoolean) {
        super.onPostExecute(aBoolean);
        if(aBoolean){
            listener.onAllOrderedListReceiver(orderDetailArrayList,true);
        }else{
            listener.onAllOrderedListReceiver(orderDetailArrayList,false);
        }
    }

    // SAMPLE OF RECEIVED JSON

/*    [
    {
        "orderID": "1",
            "foodID": "10",
            "tableNum": "1",
            "orderStatus": "2",
            "quantity": "2",
            "extraRequest": "Make it little spicy"
    },
    {
        "orderID": "2",
            "foodID": "7",
            "tableNum": "2",
            "orderStatus": "1",
            "quantity": "3",
            "extraRequest": "with coke"
    },
    {
        "orderID": "3",
            "foodID": "11",
            "tableNum": "1",
            "orderStatus": "3",
            "quantity": "3",
            "extraRequest": "Bring with tomato ketchup"
    },
    {
        "orderID": "4",
            "foodID": "15",
            "tableNum": "6",
            "orderStatus": "3",
            "quantity": "3",
            "extraRequest": "Make it little crispy"
    }
]*/
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/Adapters/FoodMenuAdapter.java
package com.sujan.info.thespicelounge.Adapters;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;
import com.sujan.info.thespicelounge.R;
import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.Utils.Utils;
import com.sujan.info.thespicelounge.models.FoodDetails;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by pradeep on 3/7/20.
 */

public class FoodMenuAdapter extends RecyclerView.Adapter<FoodMenuAdapter.ViewHolder>{



    private ArrayList<FoodDetails> mData;
    private LayoutInflater mInflater;
    Context mContext;
    public Drawable drawable;
    private ItemClickListener mClickListener;

    public FoodMenuAdapter(Context context) {
        this.mInflater = LayoutInflater.from(context);
        this.mContext=context;
        this.mData = ResourceManager.getGlobalFoodMenu();

    }
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = mInflater.inflate(R.layout.menu_item_adapter, parent, false);
        return new ViewHolder(view);
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {

        FoodDetails foodDetails = mData.get(position);
        holder.foodImage.setImageResource(foodDetails.getImage());
        holder.foodName.setText(ResourceManager.getFoodName(foodDetails));
        holder.foodPrice.setText(foodDetails.getPrice()+"");
        holder.foodTime.setText("Time : "+foodDetails.getPrepareTimeinMins()+" Mins");
        holder.foodRating.setNumStars(foodDetails.getRatingStar());

    }
    @Override
    public int getItemCount() {
        return mData.size();
    }

    public FoodDetails getItem(int id) {
        return mData.get(id);
    }

    public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{

        ImageView foodImage;
        TextView foodName,foodPrice,foodTime;
        RatingBar foodRating;


        public ViewHolder(View itemView) {
            super(itemView);
            foodImage = itemView.findViewById(R.id.food_image);
            foodName = itemView.findViewById(R.id.food_name);
            foodTime = itemView.findViewById(R.id.food_prepare_time);
            foodPrice=itemView.findViewById(R.id.food_price);
            foodRating = itemView.findViewById(R.id.food_rating);
            drawable = foodRating.getProgressDrawable();
            drawable.setColorFilter(Color.parseColor("#F2BA49"), PorterDuff.Mode.SRC_ATOP);
            itemView.setOnClickListener(this);

        }

        @Override
        public void onClick(View v) {
            if (Utils.isConnected(mContext)){
                ResourceManager.setFoodDetailsInstance(mData.get(getAdapterPosition())); // temporary setup to inflate data
                if (mClickListener != null) mClickListener.onItemClick(v, getAdapterPosition());
            }else{
                Utils.displayShortToastMessage(mContext,"No Internet");
            }
        }
    }

    // allows clicks events to be caught
    public void setClickListener(ItemClickListener itemClickListener) {
        this.mClickListener = itemClickListener;
    }



    // parent activity will implement this method to respond to click events
    public interface ItemClickListener {
        void onItemClick(View view, int position);
    }
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/Utils/MyPreferences.java
package com.sujan.info.thespicelounge.Utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by pradeep on 16/7/20.
 */

public class MyPreferences {
    private static String myPrefrences = "THESPICELOUNGE_APP_PREFERENCES";

    public  static void setStringPrefrences(String key,String value,Context context){
        SharedPreferences preferences = context.getSharedPreferences(myPrefrences, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = preferences.edit();
        editor.putString(key, value);
        editor.commit();

    }
    public static String getStringPrefrences(String key,Context context){
        SharedPreferences preferences = context.getSharedPreferences(myPrefrences, Context.MODE_PRIVATE);
        return preferences.getString(key, "");
    }
    public static  void setBooleanPrefrences(String key,boolean value,Context context){
        SharedPreferences preferences = context.getSharedPreferences(myPrefrences, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = preferences.edit();
        editor.putBoolean(key, value);
        editor.commit();
    }
    public static boolean getBooleanPrefrences(String key,Context context){
        SharedPreferences prefrences = context.getSharedPreferences(myPrefrences, Context.MODE_PRIVATE);
        return prefrences.getBoolean(key, false);
    }

    public static  void setIntPrefrences(String key,int value,Context context){
        SharedPreferences preferences = context.getSharedPreferences(myPrefrences, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = preferences.edit();
        editor.putInt(key, value);
        editor.commit();
    }
    public static int getIntPrefrences(String key,Context context){
        SharedPreferences prefrences = context.getSharedPreferences(myPrefrences, Context.MODE_PRIVATE);
        return prefrences.getInt(key, -1);
    }

    public static void resetAllPreferences(Context mContext) {
        SharedPreferences preferences = mContext.getSharedPreferences(myPrefrences, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = preferences.edit();
        editor.clear();
        editor.commit();
    }
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/fragments/Login.java
package com.sujan.info.thespicelounge.fragments;


import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;

import com.sujan.info.thespicelounge.MainActivity;
import com.sujan.info.thespicelounge.R;
import com.sujan.info.thespicelounge.Utils.Utils;
import com.sujan.info.thespicelounge.webservices.StaffLogin;

/**
 * A simple {@link Fragment} subclass.
 */
@SuppressLint("ValidFragment")
public class Login extends Fragment {


    EditText userText,passwordText;
    Button login;
    MainActivity context;
    String userName,userPass;

    public Login() {}

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_login, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        context= (MainActivity) getActivity();
        userText=(EditText)context.findViewById(R.id.input_email);
        passwordText=(EditText)context.findViewById(R.id.input_password);
        login=(Button)context.findViewById(R.id.btn_login);
        login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if(Utils.isConnected(context)){
                    userName = userText.getText().toString();
                    userPass= passwordText.getText().toString();
                    if(validate(userName,userPass)){
                        new StaffLogin(context,context,userName,userPass).execute();
                        context.getProgressBarMain().setVisibility(View.VISIBLE);
                    }

                }else {
                    Utils.displayShortToastMessage(context,"No Internet.");
                }
            }
        });


    }


    public boolean validate(String userName,String password) {
        boolean valid = true;
        if (userName.isEmpty()) {
            userText.setError("Username field is empty");
            valid = false;
        } else {
            userText.setError(null);
        }

        if (password.isEmpty()) {
            passwordText.setError("Password Field is empty");
            valid = false;
        } else {
            passwordText.setError(null);
        }

        return valid;
    }

}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/interfaceT/orderStatusUpdateListener.java
package com.sujan.info.thespicelounge.interfaceT;

/**
 * Created by pradeep on 5/8/20.
 */

public interface orderStatusUpdateListener {
    public void onOrderStatusUpdated(boolean isSuccessful);
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/models/MyTasks.java
package com.sujan.info.thespicelounge.models;

/**
 * Created by pradeep on 1/8/20.
 */

public class MyTasks {

    /*
    *
    * 1. make feedback for waiter activity (Done)
    * 2. Get and display all the food orders for waiter
    * 2. Get and display all the food orders for Chef except served ones
    * 2.
    * 3.
    * 4.
    *
    *
    *
    *
    *
    *
    *
    * ISSUES:
    * 1. When api is hit to bring feedbacks from orderedListAdapterCust , feedback icon can be click multiple times as progressbar is visible.
    *
    *
    *
    *
    *
    * */
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/ChefActivity.java
package com.sujan.info.thespicelounge;

import android.content.Intent;
import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.Toolbar;

import com.sujan.info.thespicelounge.Adapters.OrderedListAdapterChef;
import com.sujan.info.thespicelounge.Utils.Constants;
import com.sujan.info.thespicelounge.Utils.MyPreferences;
import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.Utils.Utils;
import com.sujan.info.thespicelounge.fragments.WaiterOrderListFragment;
import com.sujan.info.thespicelounge.interfaceT.orderStatusUpdateListener;
import com.sujan.info.thespicelounge.models.OrderDetail;
import com.sujan.info.thespicelounge.webservices.GetOrdersList;

import java.util.ArrayList;
import java.util.Collections;

import static junit.framework.Assert.assertTrue;

public class ChefActivity extends BaseActivity implements orderStatusUpdateListener {

    FloatingActionButton modifyFoodItemFab;
    RecyclerView chefRecyclerViewOrders;
    ArrayList<OrderDetail> orderDetailsListChef;
    OrderedListAdapterChef orderedListAdapterChef;
    Toolbar tb;
    ProgressBar progressBarChef;
    boolean doubleBackToExitPressedOnce = false;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chef);
        init();

    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        tb.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
                    @Override
                    public boolean onMenuItemClick(MenuItem item) {
                        return onOptionsItemSelected(item);
                    }
                });
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            // action with ID action_refresh was selected
            case R.id.action_logout:
                Utils.activityTransitionRemovingHistory(this,new Intent(this, MainActivity.class));
                MyPreferences.resetAllPreferences(getApplicationContext());
                break;

            default:
                break;
        }

        return true;
    }



    private void init() {


        tb = (Toolbar) findViewById(R.id.toolbar_chef_activity);
        tb.setTitle(MyPreferences.getStringPrefrences(Constants.EMPLOYEE_NAME_TITLE,this));
        tb.inflateMenu(R.menu.toolbar);
        setActionBar(tb);

        orderDetailsListChef=new ArrayList<OrderDetail>();


        progressBarChef=(ProgressBar)findViewById(R.id.progress_bar_chef);
        modifyFoodItemFab=(FloatingActionButton)findViewById(R.id.fab_chef_itemview);
        chefRecyclerViewOrders=(RecyclerView)findViewById(R.id.ordered_items_recycler_chef);
        chefRecyclerViewOrders.setLayoutManager(new LinearLayoutManager(this));

        modifyFoodItemFab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ChefActivity.this, ChefMenuModifyActivity.class);
                startActivity(intent);
                finish();
            }
        });

        if(ResourceManager.isAllFoodOrdersAvailable()){

            inflateAdapter();

        }else{
            new GetOrdersList(this).execute();
        }
    }

    public void inflateAdapter(){
        orderedListAdapterChef = new OrderedListAdapterChef(this,ResourceManager.getAllOrders());
        chefRecyclerViewOrders.setAdapter(orderedListAdapterChef);
    }

    @Override
    public void onBackPressed() {
        if (doubleBackToExitPressedOnce) {
            super.onBackPressed();
            return;
        }

        this.doubleBackToExitPressedOnce = true;
        Utils.displayShortToastMessage(this, "Please click BACK again to exit");

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                doubleBackToExitPressedOnce=false;
            }
        }, 2000);

    }


    public ProgressBar getProgressBarChef(){
        return progressBarChef;
    }

    @Override
    public void onAllOrderedListReceiver(ArrayList<OrderDetail> orderDetailArrayList, boolean isSuccess) {
        ResourceManager.setAllOrders(orderDetailArrayList);

        if (isSuccess){
            Collections.sort(ResourceManager.allOrders, OrderDetail.statusComparator);
        }else {
            Utils.displayShortToastMessage(this,"Something went wrong.Try again");
        }
     inflateAdapter();
    }

    @Override
    public void onOrderStatusUpdated(boolean isSuccessful) {
        progressBarChef.setVisibility(View.INVISIBLE);
        if (isSuccessful){
            inflateAdapter();
        }else{
            Utils.displayShortToastMessage(this,"Try again");
        }
    }
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/Adapters/MenuAdapter.java
package com.sujan.info.thespicelounge.Adapters;

import android.content.Context;
import android.support.annotation.NonNull;
import android.widget.ArrayAdapter;
import android.widget.ImageView;

import com.sujan.info.thespicelounge.interfaceT.MenuItemsListener;
import com.sujan.info.thespicelounge.models.FoodDetails;
import com.sujan.info.thespicelounge.webservices.GetMenuItems;

import java.util.ArrayList;

/**
 * Created by pradeep on 2/7/20.
 */

public class MenuAdapter extends ArrayAdapter<FoodDetails> implements MenuItemsListener {


    public MenuAdapter(@NonNull Context context, int resource) {
        super(context, resource);
    }


    @Override
    public void MenuItemsReceived(ArrayList<FoodDetails> foodDetails, boolean fileExists) {
        // place all the received data here
       /* if(fileExists){
            this.bookings = bookings;
            if (!showCanceled.isChecked()) {
                removeCanceled();
            }
            if (bookings.size()==0){
                placeHolder.setVisibility(View.VISIBLE);
                placeHolder.setText(Utils.getLanguageMessage("booking_err"));
            }else{
                placeHolder.setVisibility(View.INVISIBLE);
            }
            adapter = new BookingsAdapter(getActivity(), R.layout.booking_list_item, bookings);
            adapter.setListener(listener);
            listView.setAdapter(adapter);
            progressBar.setVisibility(View.INVISIBLE);
        }else {
            Utils.displayConnectivityStatus(getContext());
            progressBar.setVisibility(View.INVISIBLE);
        }*/
    }
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/BaseActivity.java
package com.sujan.info.thespicelounge;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.interfaceT.MenuItemsListener;
import com.sujan.info.thespicelounge.interfaceT.allOrderedListListener;
import com.sujan.info.thespicelounge.interfaceT.cashierCheckoutListener;
import com.sujan.info.thespicelounge.interfaceT.menuItemAddUpdateListener;
import com.sujan.info.thespicelounge.interfaceT.orderListWithTableListener;
import com.sujan.info.thespicelounge.models.FoodDetails;
import com.sujan.info.thespicelounge.models.OrderDetail;
import com.sujan.info.thespicelounge.models.TableInformation;
import com.sujan.info.thespicelounge.webservices.GetMenuItems;
import com.sujan.info.thespicelounge.webservices.GetOrderListWithTable;

import org.json.JSONArray;

import java.util.ArrayList;

public class BaseActivity extends AppCompatActivity implements MenuItemsListener,allOrderedListListener,orderListWithTableListener,menuItemAddUpdateListener,cashierCheckoutListener {

    JSONArray jsonArray;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        /*// Download menuitems from internet only when chef makes changes in menu or when there is no local file that have menu items.
        if(ResourceManager.isMenuFileExists("MenuItems.obj",this)){
            Utils.displayLongToastMessage(this,"This file does exists.");
            jsonArray=ResourceManager.getFileToJSON("MenuItems.obj",this);
        }else{
            getMenuItems();
        }*/
        ResourceManager.setBaseActivityInstance(this);

    }

    public void runApi(){

    }

    public void getMenuItems() {
        new GetMenuItems(this,this).execute("Url address here");
    }

    public void getOrderItems(){
        new GetOrderListWithTable(this,this).execute("get order items");
    }

    public void getTableInformation(){}

    @Override
    public void MenuItemsReceived(ArrayList<FoodDetails> foodDetails, boolean fileExists) {
    }





    @Override
    public void onOrdersForTableReceived( boolean fileExists) {

    }

    @Override
    public void onAllOrderedListReceiver(ArrayList<OrderDetail> orderDetailArrayList, boolean isSuccess) {

    }

    @Override
    public void onItemAddedOrUpdated(boolean isSuccessful) {

    }

    @Override
    public void onCustomerCheckoutSuccessfully(boolean isSuccess) {

    }
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/FoodOrderActivity.java
package com.sujan.info.thespicelounge;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.TextView;

import com.sujan.info.thespicelounge.Utils.Constants;
import com.sujan.info.thespicelounge.Utils.MyPreferences;
import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.Utils.Utils;
import com.sujan.info.thespicelounge.interfaceT.feedbackListener;
import com.sujan.info.thespicelounge.interfaceT.takeOrderListener;
import com.sujan.info.thespicelounge.models.CustomerFeedback;
import com.sujan.info.thespicelounge.models.FoodDetails;
import com.sujan.info.thespicelounge.models.OrderDetail;
import com.sujan.info.thespicelounge.webservices.GetCustomerFeedbacks;
import com.sujan.info.thespicelounge.webservices.PushFoodOrder;

import java.util.ArrayList;

public class FoodOrderActivity extends AppCompatActivity implements feedbackListener,takeOrderListener {

    Button placeOrder,feedbacks;
    FoodDetails foodDetails;
    ImageView foodImage;
    TextView  foodName, timePreparation, foodDesc, foodPrice;
    Spinner tableNumSpinner;
    CheckBox verifyEntries;
    int tableNumber;
    ArrayAdapter<Integer> adapter;
    boolean isItWaiter=false;
    ProgressBar receivingFeedbacksPB;
    boolean feedbackIsNotClickedOnce=true; // to stop user from clicking feedback option multiple times
    OrderDetail newOrder;
    int selectedFoodID;
    EditText foodQuantity,custumerRequest;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_food_order);

        Intent intent = getIntent();
        selectedFoodID= intent.getIntExtra("foodID",0);

        init();
        dataInflate();

    }

    @SuppressLint("SetTextI18n")
    private void dataInflate() {

     //   foodImage.setImageResource(foodDetails.getImage());
        foodImage.setImageResource(R.drawable.momos);
        foodName.setText(foodDetails.getItemName());
        timePreparation.setText(foodDetails.getPrepareTimeinMins()+"");
        foodDesc.setText(foodDetails.getDescription());
        foodPrice.setText(foodDetails.getPrice()+"");

        feedbacks.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(Utils.isConnected(FoodOrderActivity.this)){
                    if(feedbackIsNotClickedOnce){
                        feedbackIsNotClickedOnce=false;
                        receivingFeedbacksPB.setVisibility(View.VISIBLE);
                        new GetCustomerFeedbacks(FoodOrderActivity.this,foodDetails.getItemId(),receivingFeedbacksPB).execute();
                    }

                }else{
                    Utils.displayShortToastMessage(FoodOrderActivity.this,"No Internet.");
                }



            }
        });

        tableNumSpinner.setAdapter(adapter);

        placeOrder.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String orderQuant=foodQuantity.getText().toString();
                if(verifyEntries.isChecked() && !orderQuant.equals("")){

                    tableNumber=Integer.parseInt(tableNumSpinner.getSelectedItem().toString());
                    String customerRequestStr=custumerRequest.getText().toString();

                    Log.d("SIZEy","Quantity of orders are: "+orderQuant);
                    // Here orderId and foodStatus doesnot matter since we place "null" and "0" in php file
                    newOrder=new OrderDetail(0,selectedFoodID,tableNumber,Integer.parseInt(orderQuant),0,customerRequestStr);
                    new PushFoodOrder(newOrder,FoodOrderActivity.this).execute();

                    /*if(MyPreferences.getBooleanPrefrences(Constants.IS_USER_LOGGED_IN,getApplicationContext())){
                        // Waiter orders from here

                    }else {

                        //Customer orders from here
                    }*/
                }else{
                    Utils.displayLongToastMessage(FoodOrderActivity.this, "Please verify the details ");
                }
            }
        });
    }



    private void init() {


        isItWaiter=MyPreferences.getBooleanPrefrences(Constants.IS_USER_LOGGED_IN,this);
        foodDetails= ResourceManager.getFoodDetailsInstance();

        adapter = new ArrayAdapter<Integer>(this,R.layout.customized_spinner,ResourceManager.getListOfTableNumber());

        foodImage=(ImageView)findViewById(R.id.food_image);
        foodName=(TextView)findViewById(R.id.order_fullName);
        foodQuantity=(EditText) findViewById(R.id.order_quantity);
        timePreparation=(TextView)findViewById(R.id.prepare_time_order);
        foodDesc=(TextView)findViewById(R.id.desc_order);
        foodPrice=(TextView)findViewById(R.id.order_price);
        tableNumSpinner=(Spinner) findViewById(R.id.table_num_spinner_order);
        custumerRequest=(EditText) findViewById(R.id.customer_request_order);
        verifyEntries=(CheckBox)findViewById(R.id.verify_order_details);
        placeOrder=(Button)findViewById(R.id.place_order);
        feedbacks=(Button)findViewById(R.id.view_item_feedback_customer);
        receivingFeedbacksPB=(ProgressBar)findViewById(R.id.feedback_pb_placeorder);

    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        if(isItWaiter){
            Utils.activityTransitionRemovingHistory(this,new Intent(this,WaiterActivity.class));
        }else{
            Utils.activityTransitionRemovingHistory(this,new Intent(this,MainActivity.class));
        }
    }

    @Override
    public void onFeedbackReceived(ArrayList<CustomerFeedback> customerFeedbacks, int foodID, ProgressBar progressBar,boolean isSuccess) {
        progressBar.setVisibility(View.GONE);
        feedbackIsNotClickedOnce=true;
        if(isSuccess){
            ResourceManager.setCustomerFeedbackArrayList(customerFeedbacks);
            Intent intent=new Intent(FoodOrderActivity.this, CustomerFeedbackActivity.class);
            intent.putExtra("foodID",foodDetails.getItemId());
            intent.putExtra("toComment",false);
            startActivity(intent);
        }else {
            Utils.displayShortToastMessage(this,"Try again.");

        }

    }

    @Override
    public void onOrderReceived(boolean isSuccess) {
        if(isSuccess){
            Utils.displayLongToastMessage(getApplication(),"Your order has been successfully placed for table number "+tableNumber);

            // if user is logged in go to waiterActivity else go to Home page since it must be customer who placed order.
            if(isItWaiter){
                startActivity(new Intent(FoodOrderActivity.this, WaiterActivity.class));
            }else {
                startActivity(new Intent(FoodOrderActivity.this, MainActivity.class));
                ResourceManager.setActiveTableForCurrentCustomer(tableNumber+"");

            }
        }else {
            Utils.displayLongToastMessage(this,"Something went wrong.Please try again ");
        }

    }
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/webservices/GetCustomerFeedbacks.java
package com.sujan.info.thespicelounge.webservices;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import android.os.AsyncTask;
import android.view.View;
import android.widget.ProgressBar;

import com.sujan.info.thespicelounge.MainActivity;
import com.sujan.info.thespicelounge.Utils.AppConstants;
import com.sujan.info.thespicelounge.Utils.Constants;
import com.sujan.info.thespicelounge.Utils.JSONParser;
import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.interfaceT.feedbackListener;
import com.sujan.info.thespicelounge.models.CustomerFeedback;
import com.sujan.info.thespicelounge.models.FoodDetails;

import org.json.JSONArray;
import org.json.JSONException;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.ParseException;
import java.util.ArrayList;

/**
 * Created by pradeep on 2/8/20.
 */

public class GetCustomerFeedbacks extends AsyncTask<String,Integer,Boolean> {
    feedbackListener fbListener;
    private ArrayList<CustomerFeedback> customerFeedbacks;
    int foodID;
    @SuppressLint("StaticFieldLeak")
    ProgressBar pb;

    public GetCustomerFeedbacks(feedbackListener fbListener, int foodId, ProgressBar pb) {
        this.fbListener = fbListener;
        this.foodID=foodId;
        this.pb=pb;
    }


    @Override
    protected Boolean doInBackground(String... strings) {
        try{

            Uri.Builder builder = new Uri.Builder().appendQueryParameter("foodID",foodID+"");
            URL url=new URL(AppConstants.BASE_ADMIN_URL+AppConstants.GET_CUSTOMER_FEEDBACKS);
            HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
            String query = builder.build().getEncodedQuery();

            System.out.println("REQUEST PARAMETERS ARE===" + query);

            urlConnection.setRequestMethod("POST");
            urlConnection.setDoInput(true);
            urlConnection.setDoOutput(true);
            urlConnection.connect();

            //Send request
            DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream ());
            wr.writeBytes (query);
            wr.flush ();
            wr.close ();

            //Get Response
            InputStream isNew = urlConnection.getInputStream();
            BufferedReader rd = new BufferedReader(new InputStreamReader(isNew));

            String line;
            StringBuilder sb = new StringBuilder();
            BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
            while ((line = in.readLine()) != null) {
                sb.append(line);
            }
            rd.close();

            String s = sb.toString();
            JSONArray jsonArray = new JSONArray(s);

            customerFeedbacks=JSONParser.ParseFeedbackItems(jsonArray);
            System.out.println("Final response===="+jsonArray);

            return true;
        }catch (JSONException | IOException | ParseException e){
            e.printStackTrace();
            pb.setVisibility(View.GONE);
            fbListener.onFeedbackReceived(customerFeedbacks,foodID,pb,false);
        }
        return false;
    }

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
    }

    @Override
    protected void onPostExecute(Boolean aBoolean) {
        super.onPostExecute(aBoolean);
        fbListener.onFeedbackReceived(customerFeedbacks,foodID,pb,true);
    }
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/interfaceT/cashierCheckoutListener.java
package com.sujan.info.thespicelounge.interfaceT;

/**
 * Created by pradeep on 5/8/20.
 */

public interface cashierCheckoutListener {
    public void onCustomerCheckoutSuccessfully(boolean isSuccess);
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/ChefItemAddAndModifyActivity.java
package com.sujan.info.thespicelounge;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;

import com.sujan.info.thespicelounge.Utils.Constants;
import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.Utils.Utils;
import com.sujan.info.thespicelounge.models.FoodDetails;
import com.sujan.info.thespicelounge.webservices.AddUpdateFoodItem;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import static com.sujan.info.thespicelounge.Utils.Constants.PICK_IMAGE;

public class ChefItemAddAndModifyActivity extends BaseActivity {

    Button addModifyItem;
    ImageView foodImage;
    boolean isItForItemEdit=false;
    FoodDetails foodDetailsInstanceForEdit,foodDetailsForUpdate;
    EditText foodCategoryChef,foodNameChef,foodServeTypeChef,foodPriceChef,foodTimePrepChef,foodDescChef;
    CheckBox verifyDetails;


    String foodC,foodN,foodST,foodD,foodP,foodT;
    int foodImg,foodPri,foodTim;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chef_item_add_and_modify);
        isItForItemEdit= getIntent().getBooleanExtra("isItForItemEdit",false);
        init();

    }

    @SuppressLint("SetTextI18n")
    private void init() {

        addModifyItem=(Button)findViewById(R.id.push_button_chef_modify);
        foodImage=(ImageView)findViewById(R.id.food_image_chef_modify);
        foodImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                imageSelection();
            }
        });
        foodCategoryChef=(EditText)findViewById(R.id.food_catgory_chef_modify);
        foodNameChef=(EditText)findViewById(R.id.food_name_chef_modify);
        foodServeTypeChef=(EditText)findViewById(R.id.serve_type_chef_modify);
        foodPriceChef=(EditText)findViewById(R.id.food_price_chef_modify);
        foodTimePrepChef=(EditText)findViewById(R.id.food_time_chef_modify);
        foodDescChef=(EditText)findViewById(R.id.food_desc_chef_modify);
        verifyDetails=(CheckBox)findViewById(R.id.terms_conditions_chef_modify);

        verifyDetails.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(areFieldsEmpty()){
                    verifyDetails.setChecked(false);
                    Utils.displayLongToastMessage(ChefItemAddAndModifyActivity.this,"Please verify the details first.");

                }
            }
        });

        if(isItForItemEdit){
            foodDetailsInstanceForEdit=ResourceManager.getFoodDetailsInstance();
            Utils.displayShortToastMessage(ChefItemAddAndModifyActivity.this,"This item will be edited");

            addModifyItem.setText("Modify Item");
            foodImage.setImageResource(foodDetailsInstanceForEdit.getImage());
            foodCategoryChef.setText(foodDetailsInstanceForEdit.getItemCategory());
            foodNameChef.setText(foodDetailsInstanceForEdit.getItemName());
            foodServeTypeChef.setText(foodDetailsInstanceForEdit.getServeType());
            foodPriceChef.setText(foodDetailsInstanceForEdit.getPrice()+"");
            foodTimePrepChef.setText(foodDetailsInstanceForEdit.getPrepareTimeinMins()+"");
            foodDescChef.setText(foodDetailsInstanceForEdit.getDescription());
            addModifyItem.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) { // tO MODIFY THE MENU ITEM.
                    if (verifyDetails.isChecked()) {

                        ResourceManager.getBaseActivityInstance().getMenuItems();
                        foodDetailsForUpdate=getFoodObject(foodDetailsInstanceForEdit.getRatingStar(),foodDetailsInstanceForEdit.getItemId());
                        new AddUpdateFoodItem(ChefItemAddAndModifyActivity.this,ChefItemAddAndModifyActivity.this,foodDetailsForUpdate).execute();


                    }else{
                        Utils.displayLongToastMessage(ChefItemAddAndModifyActivity.this,"Please verify the details first.");
                    }
                }
            });

        }else{ // to ADD A NEW ITEM IN MENU
            Utils.displayShortToastMessage(ChefItemAddAndModifyActivity.this,"New item will be added here.");
            addModifyItem.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (verifyDetails.isChecked()) {
                        foodDetailsForUpdate=getFoodObject(5,0);
                        new AddUpdateFoodItem(ChefItemAddAndModifyActivity.this,ChefItemAddAndModifyActivity.this,foodDetailsForUpdate).execute();


                    }else{
                        Utils.displayLongToastMessage(ChefItemAddAndModifyActivity.this,"Please verify the details first.");
                    }
                }
            });
        }
    }

    private boolean areFieldsEmpty() {
        boolean flag;
        extractFieldsData();
        if (foodC.isEmpty() || foodN.isEmpty() || foodST.isEmpty() || foodD.isEmpty() || foodP.isEmpty()||foodT.isEmpty()){
            flag=true;
        }else{
            flag=false;
        }

        return flag;
    }

    private void extractFieldsData() {
        try {
            foodC = foodCategoryChef.getText().toString();
            foodN = foodNameChef.getText().toString();
            foodST = foodServeTypeChef.getText().toString();
            foodD = foodDescChef.getText().toString();
            foodT = foodTimePrepChef.getText().toString();
            foodP = foodPriceChef.getText().toString();


            foodPri = Integer.parseInt(foodP);
            foodTim = Integer.parseInt(foodT);
            foodImg = foodImage.getImageAlpha();
        }catch (Exception e){
            // Exception arises when INT fields doesnot parse empty string ""
            Utils.displayLongToastMessage(ChefItemAddAndModifyActivity.this,"Please verify the details first.");
        }
    }

    private FoodDetails getFoodObject(int rating,int foodID) {

        extractFieldsData();
        return new FoodDetails(foodC,foodN,foodST,foodD,foodPri,foodImg,foodTim,rating,foodID);
    }

    private void imageSelection() {
        final CharSequence[] options = {"Choose from Gallery","Cancel" };
        android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(ChefItemAddAndModifyActivity.this);
        builder.setTitle("Add Photo!");
        builder.setItems(options, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int item) {
                if(options[item].equals("Choose from Gallery"))
                {
                    Intent intent = new Intent();
                    intent.setType("image/*");
                    intent.setAction(Intent.ACTION_GET_CONTENT);
                    startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE);
                }
                else if (options[item].equals("Cancel")) {
                    dialog.dismiss();
                }
            }
        });
        builder.show();
    }


    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data)
    {
        if (resultCode == Activity.RESULT_OK && data!=null) {

            if(requestCode == PICK_IMAGE ){
                Uri uri = data.getData();
                try {
                    Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
                    Log.d(Constants.TAG, String.valueOf(bitmap));
                    foodImage.setImageBitmap(bitmap);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

        }else{
            Utils.displayShortToastMessage(this,"Some thing went wrong.");
        }
    }

    @Override
    public void onItemAddedOrUpdated(boolean isSuccessful) {
        if(isSuccessful){
            if(isItForItemEdit){

                Utils.displayShortToastMessage(ChefItemAddAndModifyActivity.this,"Food details are modified sucessfully.");
                Intent intent = new Intent(ChefItemAddAndModifyActivity.this,ChefActivity.class);
                startActivity(intent);

            }else{
                Utils.displayShortToastMessage(ChefItemAddAndModifyActivity.this,"New item is added in Menu sucessfully");
                Intent intent = new Intent(ChefItemAddAndModifyActivity.this,ChefActivity.class);
                startActivity(intent);
            }
        }
    }

}<file_sep>/README.md
# TheSpiceLoungeAndroid application

This is a android version of resturant app that was designed for college project.
SOurce code for backend / web version is located at [web application](https://github.com/omgitspradeep/TheSpiceLoungeWeb).

You are free to use this code for any purpose.
Before you implement it in your business make sure to fix backend.
Backend could be vunerable to lots of attacks. 

However, you can always visit the frontend of web app [hosted @ 000webhost](https://thespicelounge.000webhostapp.com/index.php )

[![Documentation Status](https://readthedocs.org/projects/thespiceloungeweb/badge/?version=latest)](https://thespiceloungeweb.readthedocs.io/en/latest/?badge=latest)

Also, [Documentation](https://thespiceloungeweb.rtfd.io) is provided for further information.

<file_sep>/app/src/androidTest/java/com/sujan/info/thespicelounge/TempTest.java
package com.sujan.info.thespicelounge;

import static org.junit.Assert.*;

/**
 * Created by pradeep on 19/7/20.
 */
public class TempTest {

}<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/webservices/PushCustomerFeedbacks.java
package com.sujan.info.thespicelounge.webservices;

import android.net.Uri;
import android.os.AsyncTask;
import android.view.View;
import android.widget.RelativeLayout;

import com.sujan.info.thespicelounge.CustomerFeedbackActivity;
import com.sujan.info.thespicelounge.Utils.AppConstants;
import com.sujan.info.thespicelounge.Utils.JSONParser;
import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.Utils.Utils;
import com.sujan.info.thespicelounge.interfaceT.feedbackAddedListener;
import com.sujan.info.thespicelounge.models.CustomerFeedback;

import org.json.JSONArray;
import org.json.JSONException;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.ParseException;
import java.util.ArrayList;

/**
 * Created by pradeep on 4/8/20.
 */

public class PushCustomerFeedbacks extends AsyncTask<String,Integer,Boolean> {
    CustomerFeedback customerFeedback;
    feedbackAddedListener mListener;

    public PushCustomerFeedbacks(feedbackAddedListener listener, CustomerFeedback customerFeedback) {
        this.customerFeedback = customerFeedback;
        this.mListener=listener;
    }

    @Override
    protected Boolean doInBackground(String... strings) {
        try{

            Uri.Builder builder = new Uri.Builder()
                    .appendQueryParameter("foodID",customerFeedback.getFoodId()+"")
                    .appendQueryParameter("custName",customerFeedback.getCustName()+"")
                    .appendQueryParameter("feedbackMessage",customerFeedback.getFeedback()+"")
                    .appendQueryParameter("ratingStarCust",customerFeedback.getRatingstar()+"");

            URL url=new URL(AppConstants.BASE_ADMIN_URL+AppConstants.PUSH_CUSTOMER_FEEDBACKS);
            HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
            String query = builder.build().getEncodedQuery();

            System.out.println("REQUEST PARAMETERS ARE===" + query);

            urlConnection.setRequestMethod("POST");
            urlConnection.setDoInput(true);
            urlConnection.setDoOutput(true);
            urlConnection.connect();

            //Send request
            DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream ());
            wr.writeBytes (query);
            wr.flush ();
            wr.close ();

            //Get Response
            InputStream isNew = urlConnection.getInputStream();
            BufferedReader rd = new BufferedReader(new InputStreamReader(isNew));

            String line;
            StringBuilder sb = new StringBuilder();
            BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
            while ((line = in.readLine()) != null) {
                sb.append(line);
            }
            rd.close();

            String s = sb.toString();
            System.out.println("FEEDBACK ADDED RESUTLT:"+s);

            return true;
        }catch ( IOException  e){
            e.printStackTrace();
        }
        return false;
    }

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
    }

    @Override
    protected void onPostExecute(Boolean aBoolean) {
        super.onPostExecute(aBoolean);
            mListener.onFBAddedMessage(aBoolean);
    }
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/webservices/ChangeOrderStatus.java
package com.sujan.info.thespicelounge.webservices;

import android.app.Activity;
import android.net.Uri;
import android.os.AsyncTask;
import android.util.Log;

import com.sujan.info.thespicelounge.Utils.AppConstants;
import com.sujan.info.thespicelounge.Utils.JSONParser;
import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.interfaceT.cashierCheckoutListener;
import com.sujan.info.thespicelounge.interfaceT.orderStatusUpdateListener;
import com.sujan.info.thespicelounge.models.OrderDetail;
import com.sujan.info.thespicelounge.models.TableInformation;

import org.json.JSONArray;
import org.json.JSONException;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.ParseException;
import java.util.ArrayList;

/**
 * Created by pradeep on 5/8/20.
 */

public class ChangeOrderStatus extends AsyncTask<String,Integer,Boolean> {

    orderStatusUpdateListener listener;
    int orderID;
    int orderStatus;
    private Activity context;

    public ChangeOrderStatus(Activity activity,orderStatusUpdateListener listener, int orderID,int orderStat) {
        this.listener = listener;
        this.orderID = orderID;
        // Since status must be incremented per click  (0: waiting,1:cooking, 2:cooked, 3:served)
        this.orderStatus=orderStat+1;
        this.context=activity;
    }

    @Override
    protected Boolean doInBackground(String... strings) {
        try{

            Log.e("QWERTY",orderID+":"+orderStatus);

            Uri.Builder builder = new Uri.Builder()
                    .appendQueryParameter("orderID",orderID+"")
                    .appendQueryParameter("orderStatus",orderStatus+"");

            URL url=new URL(AppConstants.BASE_ADMIN_URL+AppConstants.UPDATE_ORDER_STATUS);
            HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
            String query = builder.build().getEncodedQuery();

            urlConnection.setRequestMethod("POST");
            urlConnection.setDoInput(true);
            urlConnection.setDoOutput(true);
            urlConnection.connect();

            //Send request
            DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream ());
            wr.writeBytes (query);
            wr.flush ();
            wr.close ();

            //Get Response
            InputStream isNew = urlConnection.getInputStream();
            BufferedReader rd = new BufferedReader(new InputStreamReader(isNew));

            String line;
            StringBuilder sb = new StringBuilder();
            BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
            while ((line = in.readLine()) != null) {
                sb.append(line);
            }
            rd.close();

            String s = sb.toString();
            JSONArray jsonArray = new JSONArray(s);

            Log.e("QWERTY",s);
            ArrayList<OrderDetail> orderDetailArrayList = JSONParser.ParseAllOrders(jsonArray);
            ResourceManager.setAllOrders(orderDetailArrayList);

            return true;
        }catch (IOException |JSONException e){
            e.printStackTrace();
        }
        return false;
    }

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
    }

    @Override
    protected void onPostExecute(Boolean aBoolean) {
        super.onPostExecute(aBoolean);
        listener.onOrderStatusUpdated(aBoolean);
    }
}<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/interfaceT/orderListWithTableListener.java
package com.sujan.info.thespicelounge.interfaceT;

import com.sujan.info.thespicelounge.models.TableInformation;

import java.util.ArrayList;

/**
 * Created by pradeep on 3/8/20.
 */

public interface orderListWithTableListener {
    void onOrdersForTableReceived( boolean fileExists);
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/Adapters/OrderedListAdapterCust.java
package com.sujan.info.thespicelounge.Adapters;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;

import com.sujan.info.thespicelounge.R;
import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.Utils.Utils;
import com.sujan.info.thespicelounge.models.FoodDetails;
import com.sujan.info.thespicelounge.models.OrderDetail;
import com.sujan.info.thespicelounge.models.TableInformation;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by pradeep on 3/7/20.
 */

public class OrderedListAdapterCust extends RecyclerView.Adapter<OrderedListAdapterCust.ViewHolder> {

    Activity context;
    private LayoutInflater mInflater;
    FeedbackClickListener mFeedbackClickListener;

    HashMap<Integer,TableInformation> tableInformationHashMap;   // To get TableInformation with the help of "tableNum" as key
    TableInformation tableInformation;                           // TableInformation received from "tableInformationHashMap"
    ArrayList<OrderDetail> orderDetailArrayList;             // List of ordered foods received from "tableInformation"
    HashMap<Integer,FoodDetails> foodDetailsHashMap;         // To get FoodDetails with the help of "foodID "

    public interface FeedbackClickListener {
        void onFeedbackClick(View view, int position);
    }


    public OrderedListAdapterCust(Activity mContext) {
        this.mInflater = LayoutInflater.from(mContext);
        this.context=mContext;


        tableInformationHashMap=ResourceManager.getGlobalTableInformationMap();
        tableInformation=tableInformationHashMap.get(ResourceManager.getSelectedTable());
        orderDetailArrayList=tableInformation.getOrderedFoods();
        foodDetailsHashMap=ResourceManager.getGlobalFoodMenuMap();

    }

    @Override
    public OrderedListAdapterCust.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = mInflater.inflate(R.layout.order_item_recycler_element_cust, parent, false);
        return new OrderedListAdapterCust.ViewHolder(view);
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void onBindViewHolder(OrderedListAdapterCust.ViewHolder holder, int position) {

        OrderDetail orderDetail=orderDetailArrayList.get(position);
        int foodID=orderDetail.getItemId();


        FoodDetails foodDetails= (FoodDetails) foodDetailsHashMap.get(foodID);

        holder.custOrderItem.setText(foodDetails.getFullItemName());
        holder.orderPrice.setText(foodDetails.getPrice()+"");

        holder.orderStatus.setText(ResourceManager.getOrderStatus(orderDetail.getFoodStatus()));
        int orderStatus=orderDetail.getFoodStatus();
        holder.qty.setText(orderDetail.getQuantity()+"");
        if (displayFeedbackButton(orderStatus)){
            holder.feedback.setVisibility(View.VISIBLE);
            holder.feedback.setClickable(true);
        }else {
            holder.feedback.setVisibility(View.INVISIBLE);

            // If food is still waiting user can cancel the order.
            if(orderStatus==0){
                holder.feedback.setVisibility(View.VISIBLE);
                holder.feedback.setClickable(true);
                holder.feedback.setImageResource(R.drawable.delete);
            }
        }
    }

    private boolean displayFeedbackButton(int status) {
        boolean isServed=false;
        switch (status){
            case 0:
                isServed= false;
                break;
            case 1:
                isServed= false;
                break;
            case 2:
                isServed= false;
                break;
            case 3:
                isServed= true;
                break;
        }
        return isServed;
    }



    @Override
    public int getItemCount() {
        return orderDetailArrayList.size();
    }


    public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{

        TextView qty, custOrderItem,orderStatus,orderPrice;
        ImageButton feedback;
        public ViewHolder(View itemView) {
            super(itemView);

            qty=(TextView)itemView.findViewById(R.id.qty);
            custOrderItem=(TextView)itemView.findViewById(R.id.cust_ordered_item);
            orderStatus=(TextView)itemView.findViewById(R.id.cust_order_status);
            orderPrice=(TextView)itemView.findViewById(R.id.cust_order_price);
            feedback=(ImageButton) itemView.findViewById(R.id.customer_feedback_button);
            feedback.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if(Utils.isConnected(context)){
                        if (mFeedbackClickListener != null) mFeedbackClickListener.onFeedbackClick(v, getAdapterPosition());

                    }
                }
            });
        }


        @Override
        public void onClick(View v) {
        }
    }

    public void setFeedbackClickListener(FeedbackClickListener feedbackClickListener) {
        this.mFeedbackClickListener = feedbackClickListener;
    }

    public OrderDetail getItem(int id) {
        return orderDetailArrayList.get(id);
    }

}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/interfaceT/deleteItemListener.java
package com.sujan.info.thespicelounge.interfaceT;

/**
 * Created by pradeep on 5/8/20.
 */

public interface deleteItemListener {
    public void onMenuItemDeleted(boolean isSuccessful);
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/webservices/PushFoodOrder.java
package com.sujan.info.thespicelounge.webservices;

import android.net.Uri;
import android.os.AsyncTask;
import android.view.View;

import com.sujan.info.thespicelounge.Utils.AppConstants;
import com.sujan.info.thespicelounge.Utils.JSONParser;
import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.interfaceT.takeOrderListener;
import com.sujan.info.thespicelounge.models.OrderDetail;
import com.sujan.info.thespicelounge.models.TableInformation;

import org.json.JSONArray;
import org.json.JSONException;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.ParseException;
import java.util.ArrayList;

/**
 * Created by pradeep on 4/8/20.
 */

public class PushFoodOrder extends AsyncTask<String,Integer,Boolean> {

    private ArrayList<TableInformation> tableInformationArrayList;
    OrderDetail orderDetail;
    takeOrderListener listener;

    public PushFoodOrder(OrderDetail orderDetail,takeOrderListener mListener) {
        this.orderDetail = orderDetail;
        this.listener=mListener;
    }


    @Override
    protected Boolean doInBackground(String... strings) {
        try{

            String foodID=orderDetail.getItemId()+"";
            String tableNum=orderDetail.getTableNum()+"";
            String quantity=orderDetail.getQuantity()+"";
            String custRequest=orderDetail.getCustRequest()+"";


            System.out.println("REQUEST PARAMETERS ARE===" + foodID+"  "+tableNum+"   "+quantity+"   "+custRequest);

            Uri.Builder builder = new Uri.Builder().appendQueryParameter("foodID",foodID)
                    .appendQueryParameter("tableNum",tableNum)
                    .appendQueryParameter("quantity",quantity)
                    .appendQueryParameter("extraRequest",custRequest);

            URL url=new URL(AppConstants.BASE_ADMIN_URL+AppConstants.PUSH_CUSTOMER_ORDER);
            HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
            String query = builder.build().getEncodedQuery();

            System.out.println("REQUEST PARAMETERS ARE===" + query);

            urlConnection.setRequestMethod("POST");
            urlConnection.setDoInput(true);
            urlConnection.setDoOutput(true);
            urlConnection.connect();

            //Send request
            DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream ());
            wr.writeBytes (query);
            wr.flush ();
            wr.close ();

            //Get Response
            InputStream isNew = urlConnection.getInputStream();
            BufferedReader rd = new BufferedReader(new InputStreamReader(isNew));

            String line;
            StringBuilder sb = new StringBuilder();
            BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
            while ((line = in.readLine()) != null) {
                sb.append(line);
            }
            rd.close();

            String s = sb.toString();
            System.out.println("FEEDBACK ADDED RESUTLT:"+s);

            JSONArray jsonArray = new JSONArray(s);
            System.out.println("TESTING 2:"+jsonArray);

            // List of orders for each table is received here.
            tableInformationArrayList=JSONParser.ParseOrderItemsForTable(jsonArray);

            // It is set as global since customer have to see updated orders for his table.
            ResourceManager.setGlobalTableInfoArraylist(tableInformationArrayList);


            return true;
        }catch (IOException |JSONException |ParseException e){
            e.printStackTrace();
        }

        return false;
    }


    @Override
    protected void onPostExecute(Boolean aBoolean) {
        super.onPostExecute(aBoolean);
        listener.onOrderReceived(aBoolean);
    }
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/fragments/HomeFragment.java
package com.sujan.info.thespicelounge.fragments;


import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.media.Image;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.sujan.info.thespicelounge.Adapters.FoodMenuAdapter;
import com.sujan.info.thespicelounge.Adapters.TableSelectionDialogAdapter;
import com.sujan.info.thespicelounge.FoodOrderActivity;
import com.sujan.info.thespicelounge.MainActivity;
import com.sujan.info.thespicelounge.R;
import com.sujan.info.thespicelounge.Utils.Constants;
import com.sujan.info.thespicelounge.Utils.MyPreferences;
import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.Utils.Utils;
import com.sujan.info.thespicelounge.WaiterActivity;
import com.sujan.info.thespicelounge.models.FoodDetails;
import com.sujan.info.thespicelounge.webservices.GetOrdersList;

import java.util.ArrayList;

/**
 * A simple {@link Fragment} subclass.
 */
@SuppressLint("ValidFragment")
public class HomeFragment extends Fragment {

    MainActivity mainActivityInstance;
    WaiterActivity waiterActivityInstance;

    Activity activity;
    RecyclerView recyclerView;
    FloatingActionButton fab;
    FoodMenuAdapter menuFoodAdapter;

    boolean isItWaiter=false;

    @SuppressLint("ValidFragment")
    public HomeFragment(MainActivity mContext) {
        // Required empty public constructor
        mainActivityInstance=mContext;
        activity=mContext;
    }

    public HomeFragment(WaiterActivity waiterActivityInstance) {
        this.waiterActivityInstance = waiterActivityInstance;
        activity=waiterActivityInstance;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_home, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        init();
    }



    private void init() {
        isItWaiter=MyPreferences.getBooleanPrefrences(Constants.IS_USER_LOGGED_IN,activity);

        //This fragment is used in both waiter and customer menu list.
        if(isItWaiter){
            fab = (FloatingActionButton)waiterActivityInstance.findViewById(R.id.fab_order_view);
            recyclerView=(RecyclerView)waiterActivityInstance.findViewById(R.id.food_menu_recycler);
            recyclerView.setLayoutManager(new LinearLayoutManager(waiterActivityInstance));
            menuFoodAdapter = new FoodMenuAdapter(waiterActivityInstance);
            recyclerView.setAdapter(menuFoodAdapter);
            menuFoodAdapter.setClickListener(waiterActivityInstance);

            fab.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    // GET ORDERS LIST
                    if(Utils.isConnected(activity)){
                        waiterActivityInstance.getWaiterProgressBar().setVisibility(View.VISIBLE);
                        new GetOrdersList(waiterActivityInstance).execute();
                        ResourceManager.setWaiterActivityInstance(waiterActivityInstance);
                    }else{
                        Utils.displayShortToastMessage(activity,"No Internet.");
                    }
                }
            });


        }else {
            fab = (FloatingActionButton)mainActivityInstance.findViewById(R.id.fab_order_view);
            recyclerView=(RecyclerView)mainActivityInstance.findViewById(R.id.food_menu_recycler);
            recyclerView.setLayoutManager(new LinearLayoutManager(mainActivityInstance));
            menuFoodAdapter = new FoodMenuAdapter(mainActivityInstance);
            recyclerView.setAdapter(menuFoodAdapter);
            menuFoodAdapter.setClickListener(mainActivityInstance);
            fab.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                        if(Utils.isConnected(mainActivityInstance)){
                            if(ResourceManager.listOfBusyTables!=null){
                                Utils.buildAskTableDialog(mainActivityInstance);
                            }else {
                                Utils.displayShortToastMessage(mainActivityInstance,"You have not order your food yet.");
                            }
                        }
                         else{
                            Utils.displayShortToastMessage(mainActivityInstance,"No Internet");

                        }
                }
            });
        }

    }



}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/interfaceT/loginListener.java
package com.sujan.info.thespicelounge.interfaceT;

public interface loginListener {
    public void onLoginResponse(boolean isSuccess);
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/Adapters/FeedbackListAdapter.java
package com.sujan.info.thespicelounge.Adapters;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RatingBar;
import android.widget.TextView;

import com.sujan.info.thespicelounge.CustomerFeedbackActivity;
import com.sujan.info.thespicelounge.R;
import com.sujan.info.thespicelounge.models.CustomerFeedback;

import java.util.ArrayList;

/**
 * Created by pradeep on 6/7/20.
 */

public class FeedbackListAdapter extends RecyclerView.Adapter<FeedbackListAdapter.ViewHolder> {

    private LayoutInflater mInflater;
    ArrayList<CustomerFeedback> mCustomerFeedbackList;
    CustomerFeedbackActivity mContext;

    public FeedbackListAdapter(ArrayList<CustomerFeedback> customerFeedbackList, CustomerFeedbackActivity context) {
        this.mContext=context;
        this.mInflater = LayoutInflater.from(context);
        this.mCustomerFeedbackList=customerFeedbackList;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = mInflater.inflate(R.layout.adapter_feedback_recycler, parent, false);
        return new FeedbackListAdapter.ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.feedback.setText(mCustomerFeedbackList.get(position).getFeedback());
        holder.name.setText(mCustomerFeedbackList.get(position).getCustName());
        holder.rating.setNumStars(mCustomerFeedbackList.get(position).getRatingstar());
    }

    @Override
    public int getItemCount() {
        return mCustomerFeedbackList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{

        TextView feedback,name;
        RatingBar rating;
        public ViewHolder(View itemView) {
            super(itemView);
            feedback=(TextView)itemView.findViewById(R.id.feedback_desc);
            name=(TextView)itemView.findViewById(R.id.customer_name);
            rating=(RatingBar) itemView.findViewById(R.id.customer_rating_bar_);
        }

        @Override
        public void onClick(View v) {

        }
    }
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/fragments/WaiterOrderListFragment.java
package com.sujan.info.thespicelounge.fragments;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.sujan.info.thespicelounge.Adapters.OrderedListAdapterWaiter;
import com.sujan.info.thespicelounge.R;
import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.WaiterActivity;

/**
 * Created by pradeep on 8/7/20.
 */

@SuppressLint("ValidFragment")
public class WaiterOrderListFragment extends android.support.v4.app.Fragment {
    WaiterActivity mContext;
    OrderedListAdapterWaiter orderedListAdapter;
    RecyclerView customerOrderRecyclerView;

    public WaiterOrderListFragment(WaiterActivity waiterActivity) {
        this.mContext=waiterActivity;
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.waiter_frag_order_list, container, false);

    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        init();
    }

    private void init() {

        customerOrderRecyclerView= (RecyclerView)mContext.findViewById(R.id.waiter_orders_list_recycler);
        customerOrderRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        orderedListAdapter = new OrderedListAdapterWaiter(mContext,ResourceManager.getAllOrders());
        customerOrderRecyclerView.setAdapter(orderedListAdapter);
    }



}

<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/MainActivity.java
package com.sujan.info.thespicelounge;


import android.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ProgressBar;

import com.sujan.info.thespicelounge.Adapters.FoodMenuAdapter;
import com.sujan.info.thespicelounge.Utils.Constants;
import com.sujan.info.thespicelounge.Utils.JSONParser;
import com.sujan.info.thespicelounge.Utils.MyPreferences;
import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.Utils.Utils;
import com.sujan.info.thespicelounge.fragments.AboutUs;
import com.sujan.info.thespicelounge.fragments.CustomerOrderdListFragment;
import com.sujan.info.thespicelounge.fragments.Entertainment;
import com.sujan.info.thespicelounge.fragments.HomeFragment;
import com.sujan.info.thespicelounge.fragments.Login;
import com.sujan.info.thespicelounge.interfaceT.cancelFoodListener;
import com.sujan.info.thespicelounge.interfaceT.feedbackListener;
import com.sujan.info.thespicelounge.interfaceT.loginListener;
import com.sujan.info.thespicelounge.models.CustomerFeedback;
import com.sujan.info.thespicelounge.models.FoodDetails;
import com.sujan.info.thespicelounge.webservices.GetMenuItems;

import org.json.JSONArray;
import org.json.JSONException;

import java.text.ParseException;
import java.util.ArrayList;


public class MainActivity extends AppCompatActivity implements FoodMenuAdapter.ItemClickListener,feedbackListener,cancelFoodListener, loginListener {

    BottomNavigationView navigation;
    FrameLayout frameLayout;
    boolean doubleBackToExitPressedOnce = false;
    ProgressBar progressBarMain;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();
    }

    private void init() {

        frameLayout=(FrameLayout)findViewById(R.id.fl_fragment);
        progressBarMain=(ProgressBar)findViewById(R.id.main_activity_progressbar);
        navigation = (BottomNavigationView) findViewById(R.id.navigation);
        navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
        getSupportFragmentManager().beginTransaction().replace(R.id.fl_fragment, new HomeFragment(this)).commit();

    }



    private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
            = new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            switch (item.getItemId()) {
                case R.id.navigation_home:
                    getSupportFragmentManager().beginTransaction().replace(R.id.fl_fragment,new HomeFragment(MainActivity.this)).commit();
                    break;
                case R.id.entertainment:
                    getSupportFragmentManager().beginTransaction().replace(R.id.fl_fragment,new Entertainment()).commit();
                    break;

                case R.id.login:
                    getSupportFragmentManager().beginTransaction().replace(R.id.fl_fragment,new Login()).commit();
                    break;

                case R.id.about_us:
                    getSupportFragmentManager().beginTransaction().replace(R.id.fl_fragment,new AboutUs()).commit();
                    break;
            }
            return true;
        }
    };

    public ProgressBar getProgressBarMain(){
        return progressBarMain;
    }


    @Override
    public void onBackPressed() {
        if (doubleBackToExitPressedOnce) {
            super.onBackPressed();
            return;
        }

        this.doubleBackToExitPressedOnce = true;
        Utils.displayShortToastMessage(this, "Please click BACK again to exit");

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                doubleBackToExitPressedOnce=false;
            }
        }, 2000);

    }

    @Override
    public void onItemClick(View view, int position) {
        Intent intent = new Intent(this, FoodOrderActivity.class);
        intent.putExtra("foodID",ResourceManager.getFoodDetailsInstance().getItemId());
        startActivity(intent);
    }


    @Override
    public void onFeedbackReceived(ArrayList<CustomerFeedback> customerFeedbacks, int foodID, ProgressBar progressBar,boolean isSuccess) {
        progressBar.setVisibility(View.GONE);
        if(isSuccess){
            ResourceManager.setCustomerFeedbackArrayList(customerFeedbacks);
            // Once feebacks are received "CustomerFeedbackActivity" is proceed
            Intent intent = new Intent(this, CustomerFeedbackActivity.class);
            intent.putExtra("toComment", true);
            intent.putExtra("foodID",foodID);

            startActivity(intent);
        }else{
            Utils.displayShortToastMessage(this,"Try again.");
        }

    }

    @Override
    public void onFoodCancelled(boolean isSuccess) {
        progressBarMain.setVisibility(View.INVISIBLE);
        Utils.displayLongToastMessage(this,"Food order is cancelled successfully.");
        getSupportFragmentManager().beginTransaction().replace(R.id.fl_fragment,new CustomerOrderdListFragment(this)).commit();

    }

    @Override
    public void onLoginResponse(boolean isSuccess) {
        progressBarMain.setVisibility(View.INVISIBLE);

        if (isSuccess){
            String staffPost=ResourceManager.getLoggedStaff().getPost();
            MyPreferences.setBooleanPrefrences(Constants.IS_USER_LOGGED_IN,true,this);

                if(staffPost.equals("manager") ){
                    //login for admin or manager : It is supposed to be redirect to webview,
                    MyPreferences.setIntPrefrences(Constants.LAST_LOGGED_USER,Constants.ADMIN_ID,this);
                    Utils.activityTransitionRemovingHistory(this, new Intent(this, AdminActivity.class));


                }else if(staffPost.equals("chef")){
                    //login for chef,
                    MyPreferences.setIntPrefrences(Constants.LAST_LOGGED_USER,Constants.CHEF_ID,this);
                    Utils.activityTransitionRemovingHistory(this, new Intent(this, ChefActivity.class));


                }else if(staffPost.equals("waiter")){
                    //login for waiter
                    MyPreferences.setIntPrefrences(Constants.LAST_LOGGED_USER,Constants.WAITER_ID,this);
                    Utils.activityTransitionRemovingHistory(this, new Intent(this, WaiterActivity.class));

                }else if(staffPost.equals("cashier")) {
                    //login for cashier
                            /*When user opens app without Internet then only foodmenu list is available as saved data  but not food orders with table
                            As cashier logs in and internet is available then app crashes since there is no data about tables.
                            Therefore, we need to bring table data.*/

                    if (ResourceManager.isFoodOrdersWithTableDataAvailable()) {
                        //login for cashier
                        MyPreferences.setIntPrefrences(Constants.LAST_LOGGED_USER,Constants.CASHIER_ID,this);
                        Utils.activityTransitionRemovingHistory(this, new Intent(this, CashierActivity.class));
                    } else {
                        Utils.displayShortToastMessage(this, "Please restart app once again.");
                    }
                }
        }else{
            Utils.displayShortToastMessage(this, "You have entered wrong credentials.");
        }
    }
}
<file_sep>/app/src/main/java/com/sujan/info/thespicelounge/fragments/CustomerOrderdListFragment.java
package com.sujan.info.thespicelounge.fragments;


import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;

import com.sujan.info.thespicelounge.Adapters.OrderedListAdapterCust;
import com.sujan.info.thespicelounge.CustomerFeedbackActivity;
import com.sujan.info.thespicelounge.MainActivity;
import com.sujan.info.thespicelounge.R;
import com.sujan.info.thespicelounge.Utils.ResourceManager;
import com.sujan.info.thespicelounge.Utils.Utils;
import com.sujan.info.thespicelounge.interfaceT.feedbackListener;
import com.sujan.info.thespicelounge.models.FoodDetails;
import com.sujan.info.thespicelounge.models.OrderDetail;
import com.sujan.info.thespicelounge.webservices.GetCustomerFeedbacks;

/**
 * A simple {@link Fragment} subclass.
 */
@SuppressLint("ValidFragment")
public class CustomerOrderdListFragment extends Fragment implements OrderedListAdapterCust.FeedbackClickListener{

    MainActivity mContext;
    OrderedListAdapterCust orderedListAdapter;
    RecyclerView customerOrderRecyclerView;
    feedbackListener feedbackListener;
    ProgressBar progressBarFeedbacks;


    public CustomerOrderdListFragment(MainActivity context) {
        // Required empty public constructor
        mContext=context;
        feedbackListener=context;
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.ordered_item_list_of_customer, container, false);

    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        init();
    }

    private void init() {

        progressBarFeedbacks=(ProgressBar)mContext.findViewById(R.id.progressBarFeedbacks);
        customerOrderRecyclerView= (RecyclerView)mContext.findViewById(R.id.customer_orders_list_recycler);
        customerOrderRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        orderedListAdapter = new OrderedListAdapterCust(mContext);
        orderedListAdapter.setFeedbackClickListener(this);
        customerOrderRecyclerView.setAdapter(orderedListAdapter);
    }



    @Override
    public void onFeedbackClick(View view, int position) {
        OrderDetail orderDetail=orderedListAdapter.getItem(position);
        if(orderDetail.getFoodStatus()==0){
            Utils.showAlertDialogBeforeCancelOrder(mContext,mContext,orderDetail.getTableNum(),orderDetail.getOrderID());

        }else {

            // Run api to get feedbacks
            progressBarFeedbacks.setVisibility(View.VISIBLE);
            new GetCustomerFeedbacks(mContext,orderedListAdapter.getItem(position).getItemId(),progressBarFeedbacks).execute();

        }
    }

}
