1.:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:keepScreenOn="true"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:background="@color/white"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@drawable/bg_border_layout"
android:orientation="horizontal"
android:layout_weight="1">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"></LinearLayout>
<LinearLayout
android:id="@+id/back_btn"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3">
<ImageView
android:clickable="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:src="@drawable/ic_left_arrow"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="88">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"></LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="2"
android:gravity="center"
android:orientation="vertical"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal"
android:layout_weight="2">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"></LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"></LinearLayout>
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="match_parent"
android:layout_weight="2"
android:layout_height="0dp"
android:src="@drawable/ic_menu_icon"
android:id="@+id/restuarnt_img" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"></LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="@dimen/text_size_medium_small"
android:layout_height="match_parent"></LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:orientation="horizontal"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/masterName"
android:gravity="center"
android:textStyle="bold"
android:textSize="@dimen/text_size_large"
android:fontFamily="@font/source_sans_pro_bold"
android:text="FruFresh "/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textSize="@dimen/text_size_large"
android:fontFamily="@font/source_sans_pro_regular"
android:text="Master "/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"></LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"></LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:src="@drawable/ic_fri_logo"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"></LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="1">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="70"
android:background="#DFDFDF"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4.3"></LinearLayout>
<LinearLayout
android:clickable="true"
android:focusable="true"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4.3">
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4.3"></LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="87.1">
<TextView
android:id="@+id/seat_name"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left|center_vertical"
android:fontFamily="@font/source_sans_pro_regular"
android:gravity="left|center_vertical"
android:text="Table #1"
android:textSize="@dimen/text_size_large" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="30"
android:background="#D2D2D2"
android:layout_height="match_parent">
<TextView
android:layout_marginBottom="1dp"
android:layout_marginRight="1dp"
android:background="@color/white"
android:id="@+id/cart_txt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_gravity="center"
android:fontFamily="@font/source_sans_pro_regular"
android:text="Cart ( 0 )"
android:textSize="@dimen/text_size_large" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="8">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="70">
<ListView
android:id="@+id/catergory_listview"
android:layout_width="0dp"
android:layout_height="match_parent"
android:divider="@android:color/transparent"
android:layout_weight="20"></ListView>
<LinearLayout
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="#D2D2D2"></LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="80">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2.5"></LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="95">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2.5"></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:background="@drawable/bg_corner_radius_layout"
android:layout_weight="10">
<EditText
android:id="@+id/edit_dish"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:imeOptions="actionDone"
android:singleLine="true"
android:maxLines="1"
android:fontFamily="@font/source_sans_pro_regular"
android:layout_marginLeft="10dp"
android:background="#00000000"
android:textSize="@dimen/text_size_medium_small"
android:hint="Search dish"/>
<LinearLayout
android:layout_width="wrap_content"
android:orientation="vertical"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"></LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="2"
android:layout_marginRight="10dp"
android:scaleType="centerInside"
android:src="@drawable/ic_serach"
android:id="@+id/serach_btn"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"></LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2.5"></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="10">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/foot_type_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2.5"></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="85">
<GridView
android:id="@+id/menu_gridview"
android:layout_width="0dp"
android:numColumns="3"
android:layout_marginLeft="5dp"
android:layout_height="match_parent"
android:verticalSpacing="@dimen/text_size_more_large"
android:horizontalSpacing="@dimen/text_size_large"
android:layout_weight="80"></GridView>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2.5"></LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="#D2D2D2"></LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="30">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="8dp"
android:layout_weight="90">
<ListView
android:layout_width="match_parent"
android:divider="@android:color/transparent"
android:dividerHeight="@dimen/text_size_medium"
android:listSelector="@android:color/transparent"
android:layout_height="match_parent"
android:id="@+id/orderDeatils_listview"></ListView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#D2D2D2"></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="@dimen/text_size_small"
android:layout_weight="10">
<androidx.cardview.widget.CardView
android:id="@+id/update_order_button"
android:layout_width="0dp"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true"
android:clipChildren="false"
app:cardCornerRadius="@dimen/text_size_medium"
app:cardBackgroundColor="#30A400"
android:background="@color/black"
android:layout_marginBottom="2dp"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="false"
android:layout_weight="20.5">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#30A400"
android:clickable="false"
android:focusable="false"
android:fontFamily="@font/source_sans_pro_regular"
android:gravity="center"
android:text="UPDATE"
android:textColor="@color/white"
android:textSize="@dimen/text_size_medium" />
</androidx.cardview.widget.CardView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
2.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content"
android:layout_marginLeft="10dp"
android:background="@color/white"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/food_type_layout"
android:layout_width="wrap_content"
android:background="@drawable/bg_border_with_corner_radiuslayout"
android:layout_height="match_parent">
<TextView
android:id="@+id/food_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:clickable="false"
android:focusable="false"
android:fontFamily="@font/source_sans_pro_regular"
android:gravity="center"
android:text="UPDATE"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:textColor="#343434"
android:textSize="@dimen/text_size_small" />
</LinearLayout>
</LinearLayout>
3.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_margin="8dp"
android:layout_height="50dp">
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="0dp"
android:layout_weight="1.5">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:id="@+id/menu_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/source_sans_pro_regular"
android:gravity="left|center_vertical"
android:text="Cheese pepperoni pizza"
android:textColor="#717171"
android:textSize="@dimen/text_size_small" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:id="@+id/menu_price"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/source_sans_pro_regular"
android:gravity="center"
android:text=""
android:textColor="#717171"
android:textSize="@dimen/text_size_medium_small" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.05"></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:id="@+id/menu_quantity_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/source_sans_pro_regular"
android:gravity="left|center_vertical"
android:text="Cheese pepperoni pizza"
android:textColor="#717171"
android:textSize="@dimen/text_size_small" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="1">
<ImageView
android:id="@+id/img_decrease_quantity"
android:layout_width="0dp"
android:clickable="true"
android:layout_height="match_parent"
android:src="@drawable/ic_minus"
android:layout_weight="1"/>
<TextView
android:id="@+id/quantity"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:fontFamily="@font/source_sans_pro_regular"
android:gravity="center"
android:text=""
android:textColor="#717171"
android:textSize="@dimen/text_size_small" />
<ImageView
android:id="@+id/img_increase_quantity"
android:layout_width="0dp"
android:clickable="true"
android:src="@drawable/ic_plus"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
4.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/icon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:background="@color/white"
android:orientation="vertical">
<LinearLayout
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="300dp"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:layout_weight="8">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="5"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/caterogery_image"
android:src="@drawable/ic_left_arrow"
android:layout_weight="80"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#717171"
android:text="Table #1"
android:fontFamily="@font/source_sans_pro_regular"
android:textSize="@dimen/text_size_small"
android:id="@+id/caterogry_name"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"></LinearLayout>
</LinearLayout>
</LinearLayout>
5.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:background="@color/white"
android:orientation="vertical">
<LinearLayout
android:id="@+id/main_layout"
android:layout_width="300dp"
android:layout_height="300dp"
android:orientation="vertical"
android:background="@drawable/bg_corner_radius_layout"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="3dp"
android:layout_weight="0.66">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:id="@+id/menu_images"
/>
<ImageView
android:layout_width="@dimen/text_size_medium"
android:layout_height="@dimen/text_size_medium"
android:id="@+id/menu_type_image"
android:layout_margin="10dp"
android:layout_gravity="top|right"/>
</FrameLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center"
android:layout_margin="3dp"
android:orientation="vertical"
android:layout_weight="0.34">
<TextView
android:layout_width="match_parent"
android:layout_weight="2"
android:layout_height="0dp"
android:gravity="center"
android:fontFamily="@font/source_sans_pro_regular"
android:id="@+id/menu_item_name"
android:textSize="@dimen/text_size_small"
android:text=""/>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:gravity="center"
android:layout_weight="1"
android:fontFamily="@font/source_sans_pro_regular"
android:id="@+id/menu_item_price"
android:textSize="@dimen/text_size_small"
android:text=""/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Sourse code:
import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.text.Editable; import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.EditText; import android.widget.GridView; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.cardview.widget.CardView; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.dfoe.frimaster.DataBaseServices.MasterDB; import com.squareup.picasso.Callback; import com.squareup.picasso.Picasso; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import de.hdodenhof.circleimageview.CircleImageView; public class OrderMenuActivity extends AppCompatActivity implements View.OnClickListener,ShowListenerResponse { ListView catergory_listview; GridView menu_gridview; ArrayList<Integer> caterogery_ids; public int caterogry_id; CaterogryListAdapter caterogryListAdapter; MasterDB db; public int table_id,seat_id; public JSONArray menu_details; MenuGridViewAdapter menuGridViewAdapter; ImageView serach_btn; ListView orderDeatils_listview; Context context; MenuOrderListAdapter menuOrderListAdapter; ArrayList<OrderDeatlsClass> orderDeatlslist; CardView update_order_button; LinearLayout back_btn; TextView cart_txt,masterName; public static OrderMenuHandler orderMenuHandler; EditText edit_dish; public boolean PendingorderStatus = false; public String RestaurantImage = ""; CircleImageView restuarnt_img; RecyclerView foot_type_recycler_view; JSONArray foodTypearray; FoodTypeViewAdapterAdapter foodTypeViewAdapterAdapter; ArrayList<Integer> selectedfoodTypeIds; ProgressDialog progressDialog; private Basesalertdialog alertdialogs; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); //will hide the title getSupportActionBar().hide(); // hide the title bar setContentView(R.layout.activity_order_menu_layout); db = MasterDB.getInstance(OrderMenuActivity.this); context = OrderMenuActivity.this; Bundle extras = getIntent().getExtras(); if (extras != null) { table_id = extras.getInt("table_id"); seat_id = extras.getInt("seat_id"); } selectedfoodTypeIds = new ArrayList<>(); catergory_listview = (ListView)findViewById(R.id.catergory_listview); menu_gridview = (GridView)findViewById(R.id.menu_gridview); serach_btn = (ImageView)findViewById(R.id.serach_btn); update_order_button = (CardView)findViewById(R.id.update_order_button); back_btn = (LinearLayout)findViewById(R.id.back_btn); back_btn.setOnClickListener(this); update_order_button.setOnClickListener(this); orderMenuHandler = new OrderMenuHandler(); orderDeatils_listview = (ListView)findViewById(R.id.orderDeatils_listview); foot_type_recycler_view = (RecyclerView)findViewById(R.id.foot_type_recycler_view); alertdialogs = new Basesalertdialog(OrderMenuActivity.this); ConnectivityManager cm = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting(); if (!isConnected) { //finish(); new AlertDialog.Builder(this) .setTitle("Not Connected to Internet") .setIcon(android.R.drawable.ic_dialog_alert) .setCancelable(false) .setMessage("Please Connect to Internet") .setPositiveButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { // finishAffinity(); } }).create().show(); } foodTypearray = new JSONArray(); try { JSONObject object = new JSONObject(); object.put("foodtype_id",0); object.put("name","All"); foodTypearray.put(object); JSONArray array = db.getFoodType(); if(array != null) { for(int count = 0; count<array.length(); count++) { JSONObject object1= array.getJSONObject(count); foodTypearray.put(object1); } } } catch (Exception ex) { } foodTypeViewAdapterAdapter = new FoodTypeViewAdapterAdapter(OrderMenuActivity.this); foot_type_recycler_view.setAdapter(foodTypeViewAdapterAdapter); foot_type_recycler_view.setLayoutManager(new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.HORIZONTAL, false)); masterName = (TextView)findViewById(R.id.masterName); masterName.setText(DashBoard.RestaurantName+ " "); edit_dish = (EditText)findViewById(R.id.edit_dish); restuarnt_img = (CircleImageView)findViewById(R.id.restuarnt_img); RestaurantImage = db.getRestaurantImage(); Picasso.with(OrderMenuActivity.this).load(RestaurantImage).error(R.drawable.ic_fri_logo).into(restuarnt_img, new Callback() { @Override public void onSuccess() { } @Override public void onError() { } }); edit_dish.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { if(caterogry_id != 0) { caterogry_id = 0; caterogryListAdapter.notifyDataSetChanged(); getMenuDeatils(caterogry_id); } } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if(edit_dish.getText().toString().trim().equals("")) { caterogry_id = 0; getMenuDeatils(caterogry_id); } } }); serach_btn.setOnClickListener(this); caterogery_ids = db.RestaurantCaterogryDeatils(); if(caterogery_ids != null) { if(caterogery_ids.size() > 0) { caterogryListAdapter = new CaterogryListAdapter(OrderMenuActivity.this); catergory_listview.setAdapter(caterogryListAdapter); } } orderDeatlslist = new ArrayList<>(); // ArrayList<Integer> orderIds = db.getOrderIDBasedOnseat_id(seat_id,table_id);// if(orderIds != null)// {// if(orderIds.size() > 0)// {// for(int count = 0; count < orderIds.size(); count++)// {// OrderDeatlsClass orderDeatlsClass = db.getOrderDeatilsBasedOnIdForMenuScreen(orderIds.get(count));// if(orderDeatlsClass != null)// {// orderDeatlslist.add(orderDeatlsClass);// }// }//// }// } menuOrderListAdapter = new MenuOrderListAdapter(context); orderDeatils_listview.setAdapter(menuOrderListAdapter); cart_txt = (TextView)findViewById(R.id.cart_txt); cart_txt.setText("Cart ( "+orderDeatlslist.size()+" )"); catergory_listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { caterogry_id = caterogery_ids.get(i); selectedfoodTypeIds = new ArrayList<>(); if(foodTypeViewAdapterAdapter != null) foodTypeViewAdapterAdapter.notifyDataSetChanged(); caterogryListAdapter.notifyDataSetChanged(); getMenuDeatils(caterogry_id); } }); menu_gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { showDialogForSelstingMenuQuantityItem(i); } }); getMenuDeatils(caterogry_id); super.onCreate(savedInstanceState); } @Override public void onBackPressed() { } @Override protected void onDestroy() { orderMenuHandler = null; super.onDestroy(); } public void showDialogForSelstingMenuQuantityItem(final int position) { try { final JSONArray menu_pice_details = menu_details.getJSONObject(position).getJSONArray("menu_price_deatils"); if(menu_pice_details.length() == 1) { PendingorderStatus = true; ArrayList<Integer> orderIds = db.getOrderNoBasedOnseat_id(seat_id,table_id); int orderNo = 0; if(orderIds != null) { if(orderIds.size() > 0) { orderNo = orderIds.get(0); int menu_price_id = menu_pice_details.getJSONObject(0).getInt("menu_price_id"); db.deleteResDEltedOrders(menu_details.getJSONObject(position).getInt("menu_id"),orderNo,menu_price_id,table_id,seat_id); } } OrderDeatlsClass order = new OrderDeatlsClass(); order.setMenu_id(menu_details.getJSONObject(position).getInt("menu_id")); order.setMenu_name(menu_details.getJSONObject(position).getString("menu_name")); int menu_price_id = menu_pice_details.getJSONObject(0).getInt("menu_price_id"); order.setMenu_price_id(menu_pice_details.getJSONObject(0).getInt("menu_price_id")); order.setMenu_price(menu_pice_details.getJSONObject(0).getDouble("menu_price")); order.setQuantity_name(menu_pice_details.getJSONObject(0).getString("quantity_name")); boolean status = false; for (int i = 0; i < orderDeatlslist.size(); i++) { if (orderDeatlslist.get(i).getMenu_id() == menu_details.getJSONObject(position).getInt("menu_id")) { if(menu_price_id == orderDeatlslist.get(i).getMenu_price_id()) { int quantity = orderDeatlslist.get(i).getQuantity(); orderDeatlslist.get(i).setQuantity(quantity + 1); status = true; } } } if (!status) { order.setQuantity(1); orderDeatlslist.add(order); } int totalquantity = 0; for (OrderDeatlsClass orderdetail:orderDeatlslist) { totalquantity += orderdetail.getQuantity(); } cart_txt.setText("Cart ("+totalquantity+")"); menuOrderListAdapter.notifyDataSetChanged(); } else if(menu_pice_details.length() > 1) { final Dialog OrderQuantityDialog = new Dialog(context, android.R.style.Theme_Black_NoTitleBar); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); OrderQuantityDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); OrderQuantityDialog.setContentView(R.layout.dialog_chossing_menu_quantity_layout); LinearLayout second_layout = (LinearLayout)OrderQuantityDialog.findViewById(R.id.second_layout); LinearLayout thrid_layout = (LinearLayout)OrderQuantityDialog.findViewById(R.id.thrid_layout); LinearLayout fourth_layout = (LinearLayout)OrderQuantityDialog.findViewById(R.id.fourth_layout); final ImageView first_menu_price_img = (ImageView)OrderQuantityDialog.findViewById(R.id.first_menu_price_img); final ImageView second_menu_price_img = (ImageView)OrderQuantityDialog.findViewById(R.id.second_menu_price_img); final ImageView thrid_menu_price_img = (ImageView)OrderQuantityDialog.findViewById(R.id.thrid_menu_price_img); final ImageView fourth_menu_price_img = (ImageView)OrderQuantityDialog.findViewById(R.id.fourth_menu_price_img); first_menu_price_img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(view.getTag().toString().equals("1")) { first_menu_price_img.setImageResource(R.drawable.ic_unselected_item); second_menu_price_img.setImageResource(R.drawable.ic_unselected_item); thrid_menu_price_img.setImageResource(R.drawable.ic_unselected_item); fourth_menu_price_img.setImageResource(R.drawable.ic_unselected_item); view.setTag("2"); second_menu_price_img.setTag("2"); thrid_menu_price_img.setTag("2"); fourth_menu_price_img.setTag("2"); } else { first_menu_price_img.setImageResource(R.drawable.ic_selected_item); second_menu_price_img.setImageResource(R.drawable.ic_unselected_item); thrid_menu_price_img.setImageResource(R.drawable.ic_unselected_item); fourth_menu_price_img.setImageResource(R.drawable.ic_unselected_item); view.setTag("1"); second_menu_price_img.setTag("2"); thrid_menu_price_img.setTag("2"); fourth_menu_price_img.setTag("2"); } } }); second_menu_price_img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(view.getTag().toString().equals("1")) { first_menu_price_img.setImageResource(R.drawable.ic_unselected_item); second_menu_price_img.setImageResource(R.drawable.ic_unselected_item); thrid_menu_price_img.setImageResource(R.drawable.ic_unselected_item); fourth_menu_price_img.setImageResource(R.drawable.ic_unselected_item); view.setTag("2"); first_menu_price_img.setTag("2"); thrid_menu_price_img.setTag("2"); fourth_menu_price_img.setTag("2"); } else { second_menu_price_img.setImageResource(R.drawable.ic_selected_item); first_menu_price_img.setImageResource(R.drawable.ic_unselected_item); thrid_menu_price_img.setImageResource(R.drawable.ic_unselected_item); fourth_menu_price_img.setImageResource(R.drawable.ic_unselected_item); view.setTag("1"); first_menu_price_img.setTag("2"); thrid_menu_price_img.setTag("2"); fourth_menu_price_img.setTag("2"); } } }); thrid_menu_price_img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(view.getTag().toString().equals("1")) { first_menu_price_img.setImageResource(R.drawable.ic_unselected_item); second_menu_price_img.setImageResource(R.drawable.ic_unselected_item); thrid_menu_price_img.setImageResource(R.drawable.ic_unselected_item); fourth_menu_price_img.setImageResource(R.drawable.ic_unselected_item); view.setTag("2"); first_menu_price_img.setTag("2"); second_menu_price_img.setTag("2"); fourth_menu_price_img.setTag("2"); } else { first_menu_price_img.setImageResource(R.drawable.ic_unselected_item); second_menu_price_img.setImageResource(R.drawable.ic_unselected_item); thrid_menu_price_img.setImageResource(R.drawable.ic_selected_item); fourth_menu_price_img.setImageResource(R.drawable.ic_unselected_item); view.setTag("1"); first_menu_price_img.setTag("2"); second_menu_price_img.setTag("2"); fourth_menu_price_img.setTag("2"); } } }); fourth_menu_price_img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(view.getTag().toString().equals("1")) { first_menu_price_img.setImageResource(R.drawable.ic_unselected_item); second_menu_price_img.setImageResource(R.drawable.ic_unselected_item); thrid_menu_price_img.setImageResource(R.drawable.ic_unselected_item); fourth_menu_price_img.setImageResource(R.drawable.ic_unselected_item); view.setTag("2"); first_menu_price_img.setTag("2"); second_menu_price_img.setTag("2"); thrid_menu_price_img.setTag("2"); } else { first_menu_price_img.setImageResource(R.drawable.ic_unselected_item); second_menu_price_img.setImageResource(R.drawable.ic_unselected_item); thrid_menu_price_img.setImageResource(R.drawable.ic_unselected_item); fourth_menu_price_img.setImageResource(R.drawable.ic_selected_item); view.setTag("1"); first_menu_price_img.setTag("2"); second_menu_price_img.setTag("2"); thrid_menu_price_img.setTag("2"); } } }); TextView first_menu_txt =(TextView)OrderQuantityDialog.findViewById(R.id.first_menu_txt); TextView first_menu_price_txt =(TextView)OrderQuantityDialog.findViewById(R.id.first_menu_price_txt); TextView second_menu_txt =(TextView)OrderQuantityDialog.findViewById(R.id.second_menu_txt); TextView second_menu_price_txt =(TextView)OrderQuantityDialog.findViewById(R.id.second_menu_price_txt); TextView thrid_menu_txt =(TextView)OrderQuantityDialog.findViewById(R.id.thrid_menu_txt); TextView thrid_menu_price_txt =(TextView)OrderQuantityDialog.findViewById(R.id.thrid_menu_price_txt); TextView fourth_menu_txt =(TextView)OrderQuantityDialog.findViewById(R.id.fourth_menu_txt); TextView fourth_menu_price_txt =(TextView)OrderQuantityDialog.findViewById(R.id.fourth_menu_price_txt); CardView confirm_button = (CardView)OrderQuantityDialog.findViewById(R.id.confirm_button); confirm_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { OrderDeatlsClass order = new OrderDeatlsClass(); Boolean status = false; int menu_price_id = 0; if(first_menu_price_img.getTag().equals("1")) { menu_price_id = menu_pice_details.getJSONObject(0).getInt("menu_price_id"); order.setMenu_price_id(menu_pice_details.getJSONObject(0).getInt("menu_price_id")); order.setMenu_price(menu_pice_details.getJSONObject(0).getDouble("menu_price")); order.setQuantity_name(menu_pice_details.getJSONObject(0).getString("quantity_name")); } else if(second_menu_price_img.getTag().equals("1")) { menu_price_id = menu_pice_details.getJSONObject(1).getInt("menu_price_id"); order.setMenu_price_id(menu_pice_details.getJSONObject(1).getInt("menu_price_id")); order.setMenu_price(menu_pice_details.getJSONObject(1).getDouble("menu_price")); order.setQuantity_name(menu_pice_details.getJSONObject(1).getString("quantity_name")); } else if(thrid_menu_price_img.getTag().equals("1")) { menu_price_id = menu_pice_details.getJSONObject(2).getInt("menu_price_id"); order.setMenu_price_id(menu_pice_details.getJSONObject(2).getInt("menu_price_id")); order.setMenu_price(menu_pice_details.getJSONObject(2).getDouble("menu_price")); order.setQuantity_name(menu_pice_details.getJSONObject(2).getString("quantity_name")); } else if(fourth_menu_price_img.getTag().equals("1")) { menu_price_id = menu_pice_details.getJSONObject(3).getInt("menu_price_id"); order.setMenu_price_id(menu_pice_details.getJSONObject(3).getInt("menu_price_id")); order.setMenu_price(menu_pice_details.getJSONObject(3).getDouble("menu_price")); order.setQuantity_name(menu_pice_details.getJSONObject(3).getString("quantity_name")); } // ArrayList<Integer> orderIds = db.getOrderNoBasedOnseat_id(seat_id,table_id);// int orderNo = 0;// if(orderIds != null)// {// if(orderIds.size() > 0)// {// orderNo = orderIds.get(0);// db.deleteResDEltedOrders(menu_details.getJSONObject(position).getInt("menu_id"),orderNo,menu_price_id,table_id,seat_id);// }//// } if(menu_price_id != 0) { order.setMenu_id(menu_details.getJSONObject(position).getInt("menu_id")); order.setMenu_name(menu_details.getJSONObject(position).getString("menu_name")); for (int i = 0; i < orderDeatlslist.size(); i++) { if (orderDeatlslist.get(i).getMenu_id() == menu_details.getJSONObject(position).getInt("menu_id")) { if(menu_price_id == orderDeatlslist.get(i).getMenu_price_id()) { int quantity = orderDeatlslist.get(i).getQuantity(); orderDeatlslist.get(i).setQuantity(quantity + 1); status = true; } } } if (!status) { order.setQuantity(1); orderDeatlslist.add(order); } int totalquantity = 0; for (OrderDeatlsClass orderdetail:orderDeatlslist) { totalquantity += orderdetail.getQuantity(); } PendingorderStatus = true; cart_txt.setText("Cart ("+totalquantity+")"); menuOrderListAdapter.notifyDataSetChanged(); } } catch (Exception ex) { } OrderQuantityDialog.cancel(); } }); first_menu_price_txt.setText(DashBoard.currency+" " + menu_pice_details.getJSONObject(0).getDouble("menu_price")); first_menu_txt.setText("" + menu_pice_details.getJSONObject(0).getString("quantity_name")); second_menu_price_txt.setText(DashBoard.currency+" " + menu_pice_details.getJSONObject(1).getDouble("menu_price")); second_menu_txt.setText("" + menu_pice_details.getJSONObject(1).getString("quantity_name")); if(menu_pice_details.length() == 2) { thrid_layout.setVisibility(View.INVISIBLE); fourth_layout.setVisibility(View.INVISIBLE); } else if(menu_pice_details.length() == 3) { fourth_layout.setVisibility(View.INVISIBLE); thrid_menu_price_txt.setText(DashBoard.currency+" " + menu_pice_details.getJSONObject(2).getDouble("menu_price")); thrid_menu_txt.setText("" + menu_pice_details.getJSONObject(2).getString("quantity_name")); } else if(menu_pice_details.length() == 3) { fourth_menu_price_txt.setText(DashBoard.currency+" " + menu_pice_details.getJSONObject(3).getDouble("menu_price")); fourth_menu_txt.setText("" + menu_pice_details.getJSONObject(3).getString("quantity_name")); } LinearLayout layout1 = (LinearLayout)OrderQuantityDialog.findViewById(R.id.layout1); LinearLayout layout2 = (LinearLayout)OrderQuantityDialog.findViewById(R.id.layout2); LinearLayout layout3 = (LinearLayout)OrderQuantityDialog.findViewById(R.id.layout3); LinearLayout layout4 = (LinearLayout)OrderQuantityDialog.findViewById(R.id.layout4); layout1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { OrderQuantityDialog.cancel(); } }); layout2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { OrderQuantityDialog.cancel(); } }); layout3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { OrderQuantityDialog.cancel(); } }); layout4.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { OrderQuantityDialog.cancel(); } }); OrderQuantityDialog.setCancelable(true); OrderQuantityDialog.show(); } } catch (Exception ex) { } } public void getMenuDeatils(int caterogry_id) { JSONArray array = db.RestaurantMenuDeatilsBasedOnCaterogryID(caterogry_id); if(array != null) { menu_details = array; try { menuGridViewAdapter = new MenuGridViewAdapter(); menu_gridview.setAdapter(menuGridViewAdapter); } catch (Exception e) { e.printStackTrace(); } } } @Override public void onClick(View view) { switch (view.getId()) { case R.id.serach_btn: if(!edit_dish.getText().toString().trim().equals("")) { JSONArray array = db.RestaurantMenuDeatilsBasedOnCaterogryIDAndMenuName(edit_dish.getText().toString().trim()); if (array != null) { menu_details = array; try { menuGridViewAdapter.notifyDataSetChanged(); } catch (Exception e) { e.printStackTrace(); } } else { menu_details = new JSONArray(); menuGridViewAdapter.notifyDataSetChanged(); } } break; case R.id.update_order_button: if(orderDeatlslist.size() > 0 && PendingorderStatus) { if (DashBoard.socketIoClass.client.connected()) { try { ArrayList<Integer> orderIds = db.getOrderNoBasedOnseat_id(seat_id,table_id); int orderNo = 0; if(orderIds != null) { if(orderIds.size() > 0) orderNo = orderIds.get(0); } JSONObject object = new JSONObject(); object.put("type", "restaurant_orders"); JSONObject messgae = new JSONObject(); messgae.put("SocketId", DashBoard.socketIoClass.mySocketId); messgae.put("user_id", DashBoard.user_id); messgae.put("restaurant_id", DashBoard.restaurant_id); messgae.put("order_no", orderNo); JSONArray array = new JSONArray(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss "); String currentDateandTime = sdf.format(new Date()); for (int i = 0; i < orderDeatlslist.size(); i++) { JSONObject orderDeatils = new JSONObject(); orderDeatils.put("menu_item_id", orderDeatlslist.get(i).getMenu_id()); orderDeatils.put("menu_price_id", orderDeatlslist.get(i).getMenu_price_id()); orderDeatils.put("table_number", table_id); orderDeatils.put("order_date", currentDateandTime); orderDeatils.put("item_quantity", orderDeatlslist.get(i).getQuantity()); orderDeatils.put("seat_id", seat_id); array.put(orderDeatils); } messgae.put("orders", array); if(orderNo > 0) { // JSONArray array1 = db.getFeletedOrderDeatils(table_id, seat_id, orderNo); JSONArray array1 = new JSONArray(); messgae.put("deleted_orders", array1); } object.put("message", messgae); DashBoard.socketIoClass.sendMessage(object); progressDialog = new ProgressDialog(OrderMenuActivity.this); progressDialog.setTitle("Please Wait"); // Setting Title progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); // Progress Dialog Style Spinner progressDialog.show(); // Display Progress Dialog progressDialog.setCancelable(false); new Thread(new Runnable() { public void run() { try { Thread.sleep(10); } catch (Exception e) { e.printStackTrace(); } } }).start(); update_order_button.setEnabled(false); } catch (Exception ex) { } } } else { Toast.makeText(OrderMenuActivity.this,"No Order Update",Toast.LENGTH_LONG).show(); } break; case R.id.back_btn: Intent j = new Intent(OrderMenuActivity.this, SeatViewLayout.class); j.putExtra("table_id",String.valueOf(table_id)); j.putExtra("seat_id",seat_id); startActivity(j); finish(); break; } } @Override protected void onPause() { try { progressDialog.dismiss(); }catch (Exception ex) {} super.onPause(); } @Override public void callback(String value) { } public class FoodTypeViewAdapterAdapter extends RecyclerView.Adapter<FoodTypeViewAdapterAdapter.MyViewHolder> { private LayoutInflater inflater; public FoodTypeViewAdapterAdapter(Context ctx){ inflater = LayoutInflater.from(ctx); } @Override public FoodTypeViewAdapterAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = inflater.inflate(R.layout.recycelview_item_for_foodtype_layout, parent, false); MyViewHolder holder = new MyViewHolder(view); return holder; } @Override public void onBindViewHolder(FoodTypeViewAdapterAdapter.MyViewHolder holder, int position) { try { final int current = position; JSONObject object = foodTypearray.getJSONObject(position); if(object.has("name")) { holder.food_type.setText(object.getString("name")); } if(object.has("foodtype_id")) { if(selectedfoodTypeIds.contains(object.getInt("foodtype_id"))) { holder.food_type_layout.setBackgroundResource(R.drawable.bg_border_with_gray_color_layout); } else { holder.food_type_layout.setBackgroundResource(R.drawable.bg_border_with_corner_radiuslayout); } holder.food_type_layout.setTag(position); holder.food_type_layout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { int post = Integer.parseInt(view.getTag().toString()); JSONObject object1 = foodTypearray.getJSONObject(post); int id = object1.getInt("foodtype_id"); if(!selectedfoodTypeIds.contains(id)) { view.setBackgroundResource(R.drawable.bg_border_with_gray_color_layout); selectedfoodTypeIds.add(id); } else { view.setBackgroundResource(R.drawable.bg_border_with_corner_radiuslayout); int index = selectedfoodTypeIds.indexOf(id); if(index > -1) selectedfoodTypeIds.remove(index); } if(selectedfoodTypeIds.contains(0)) getMenuDeatils(caterogry_id); else { if (selectedfoodTypeIds.size() > 0) { String type_ids = ""; for (int i = 0; i < selectedfoodTypeIds.size(); i++) { if (i == 0) type_ids += selectedfoodTypeIds.get(i); else type_ids += ", " + selectedfoodTypeIds.get(i); } ArrayList<Integer> menu_ids = db.getMenuIdBasedOnFoodTypeId(type_ids, caterogry_id); if (menu_ids != null) { String menu_item_ids = ""; for (int i = 0; i < menu_ids.size(); i++) { if (i == 0) menu_item_ids += menu_ids.get(i); else menu_item_ids += ", " + menu_ids.get(i); } menu_details = db.RestaurantMenuDeatilsBasedOnFoodType(menu_item_ids); menuGridViewAdapter.notifyDataSetChanged(); } else { menu_details = new JSONArray(); menuGridViewAdapter.notifyDataSetChanged(); } } else getMenuDeatils(caterogry_id); } } catch (Exception ex) { } } }); } } catch (Exception ex) { } } @Override public int getItemCount() { return foodTypearray.length(); } class MyViewHolder extends RecyclerView.ViewHolder{ public TextView food_type; public LinearLayout food_type_layout; public MyViewHolder(View itemView) { super(itemView); food_type = (TextView) itemView.findViewById(R.id.food_type); food_type_layout = (LinearLayout) itemView.findViewById(R.id.food_type_layout); } } } public class OrderMenuHandler extends Handler { public static final int OrderUpdated = 1; public static final int OrdernotUpdated = 2; @Override public void handleMessage(@NonNull Message msg) { switch (msg.what) { case OrderUpdated: Toast.makeText(context,"Order updated.",Toast.LENGTH_LONG).show(); Intent j = new Intent(OrderMenuActivity.this, SeatViewLayout.class); j.putExtra("table_id",String.valueOf(table_id)); j.putExtra("seat_id",seat_id); startActivity(j); finish(); break; case OrdernotUpdated: Toast.makeText(context,"Order not updated.",Toast.LENGTH_LONG).show(); break; } } } public class MenuOrderListAdapter extends BaseAdapter { Context context; public MenuOrderListAdapter(Context context) { this.context = context; } @Override public int getCount() { int count = orderDeatlslist.size(); return count; } @Override public Object getItem(int position) { if (orderDeatlslist == null) return null; if (position < 0) return null; return orderDeatlslist.get(position); } @Override public long getItemId(int arg0) { return 0; } @Override public View getView(final int position, View convertView, ViewGroup parent) { final TextView menu_name,menu_quantity_name; ImageView img_decrease_quantity,img_increase_quantity; final LayoutInflater inflater = (LayoutInflater) OrderMenuActivity.this .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.listview_item_for_menu_ordered_layout, null); int textviewmargin =(int)(DashBoard.screenHeight * 0.10); menu_name = (TextView)convertView.findViewById(R.id.menu_name); final TextView menu_price = (TextView)convertView.findViewById(R.id.menu_price); menu_quantity_name = (TextView)convertView.findViewById(R.id.menu_quantity_name); img_increase_quantity = (ImageView)convertView.findViewById(R.id.img_increase_quantity); img_decrease_quantity = (ImageView)convertView.findViewById(R.id.img_decrease_quantity); final TextView quantity = (TextView)convertView.findViewById(R.id.quantity); img_decrease_quantity.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { PendingorderStatus = true; int itemqunatity = orderDeatlslist.get(position).getQuantity(); itemqunatity -= 1; if (itemqunatity == 0) { // ArrayList<Integer> orderIds = db.getOrderNoBasedOnseat_id(seat_id,table_id);// if(orderIds != null) {// if(orderIds.size() > 0) {// ArrayList<Integer> status1 = db.statusOrderExists(orderDeatlslist.get(position).getMenu_id(), orderDeatlslist.get(position).getMenu_price_id(), table_id, seat_id,orderIds.get(0));// if (status1 != null) {// if(status1.size() > 0)// db.insertResTableDeletedOrderDeatils(orderDeatlslist.get(position).getMenu_id(),orderIds.get(0), orderDeatlslist.get(position).getMenu_price_id(), table_id, seat_id,status1.get(0));// }// }// } orderDeatlslist.remove(position); notifyDataSetChanged(); } else { orderDeatlslist.get(position).setQuantity(itemqunatity); quantity.setText("" + orderDeatlslist.get(position).getQuantity()); double menuprice = (Double) (orderDeatlslist.get(position).getMenu_price() * orderDeatlslist.get(position).getQuantity()); menu_price.setText(DashBoard.currency + " " + menuprice); } int totalquantity = 0; for (OrderDeatlsClass orderdetail : orderDeatlslist) { totalquantity += orderdetail.getQuantity(); } cart_txt.setText("Cart (" + totalquantity + ")"); } }); img_increase_quantity.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { PendingorderStatus = true; int itemqunatity = orderDeatlslist.get(position).getQuantity(); itemqunatity += 1; orderDeatlslist.get(position).setQuantity(itemqunatity); quantity.setText("" + orderDeatlslist.get(position).getQuantity()); double menuprice = (Double)(orderDeatlslist.get(position).getMenu_price() * orderDeatlslist.get(position).getQuantity()); menu_price.setText(DashBoard.currency+" "+menuprice); int totalquantity = 0; for (OrderDeatlsClass orderdetail:orderDeatlslist) { totalquantity += orderdetail.getQuantity(); } cart_txt.setText("Cart ("+totalquantity+")"); } }); LinearLayout main_layout = (LinearLayout)convertView.findViewById(R.id.main_layout); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, textviewmargin); params.setMargins(0,0,0,0); main_layout.setLayoutParams(params); double menuprice = (Double)(orderDeatlslist.get(position).getMenu_price() * orderDeatlslist.get(position).getQuantity()); menu_name.setText(orderDeatlslist.get(position).getMenu_name()); menu_price.setText(DashBoard.currency+" "+menuprice); menu_quantity_name.setText(orderDeatlslist.get(position).getQuantity_name()); quantity.setText("" + orderDeatlslist.get(position).getQuantity()); convertView.setTag(position); return convertView; } } public class CaterogryListAdapter extends BaseAdapter { Context context; public CaterogryListAdapter(Context context) { this.context = context; } @Override public int getCount() { int count = caterogery_ids.size(); return count; } @Override public Object getItem(int position) { if (caterogery_ids == null) return null; if (position < 0) return null; return caterogery_ids.get(position); } @Override public long getItemId(int arg0) { return 0; } @Override public View getView(final int position, View convertView, ViewGroup parent) { TextView caterogry_name; ImageView caterogery_image; final LayoutInflater inflater = (LayoutInflater) OrderMenuActivity.this .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.actvity_caterogry_listview_layout, null); caterogry_name = (TextView) convertView.findViewById(R.id.caterogry_name); caterogery_image = (ImageView)convertView.findViewById(R.id.caterogery_image); int textviewmargin =(int)(DashBoard.screenHeight * 0.15); LinearLayout main_layout = (LinearLayout)convertView.findViewById(R.id.main_layout); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, textviewmargin); params.setMargins(0,0,0,0); main_layout.setLayoutParams(params); convertView.setTag(position); if (caterogry_id == caterogery_ids.get(position)) main_layout.setBackgroundColor(Color.parseColor("#D2D2D2")); else main_layout.setBackgroundColor(Color.parseColor("#ffffff")); if(caterogery_ids.get(position) == 0) { caterogry_name.setText("All"); caterogery_image.setImageResource(R.drawable.ic_fri_logo); } else { JSONObject object = db.RestaurantCaterogryDetailsBasedOnCaterogery(caterogery_ids.get(position)); if (object.has("caterogery_name")) { try { caterogry_name.setText(object.getString("caterogery_name")); if (object.has("caterogery_image")) { String URL = object.getString("caterogery_image"); Picasso.with(OrderMenuActivity.this).load(URL).error(R.drawable.ic_fri_logo).into(caterogery_image, new Callback() { @Override public void onSuccess() { } @Override public void onError() { } }); } } catch (Exception ex) { } } } return convertView; } } private class MenuGridViewAdapter extends BaseAdapter { public MenuGridViewAdapter() { } @Override public long getItemId(int arg0) { return 0; } @Override public Object getItem(int position) { try { return menu_details.getJSONObject(position); } catch (JSONException e) { e.printStackTrace(); return null; } } @Override public int getCount() { return menu_details.length(); } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolderGridView holder = null; LayoutInflater inflater = (LayoutInflater) DashBoard.mActivity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.activity_menu_item_layout, null); holder = new ViewHolderGridView(); holder.main_layout = (LinearLayout) convertView.findViewById(R.id.main_layout); int width = (int) (DashBoard.screenWidth * 0.7); int width1 = (int) (width * 0.80); width = (int) (width * 0.22); int height = (int) (width1 * 0.45); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width,height); holder.main_layout.setLayoutParams(params); holder.menu_type_image = (ImageView) convertView.findViewById(R.id.menu_type_image); holder.menu_images = (ImageView) convertView.findViewById(R.id.menu_images); holder.menu_item_name = (TextView) convertView.findViewById(R.id.menu_item_name); holder.menu_item_price = (TextView) convertView.findViewById(R.id.menu_item_price); try { holder.menu_item_price.setText("" +menu_details.getJSONObject(position).getJSONArray("menu_price_deatils").getJSONObject(0).getDouble("menu_price")); holder.menu_item_name.setText("" +menu_details.getJSONObject(position).getString("menu_name")); String imageUrl = menu_details.getJSONObject(position).getJSONArray("menu_image_deatils").getJSONObject(0).getString("menu_image_name"); if(menu_details.getJSONObject(position).getString("menu_type").equals("0")) holder.menu_type_image.setImageResource(R.drawable.ic_non_veg); else holder.menu_type_image.setImageResource(R.drawable.ic_veg); Picasso.with(OrderMenuActivity.this).load(imageUrl).error(R.drawable.ic_fri_logo).into(holder.menu_images, new Callback() { @Override public void onSuccess() { } @Override public void onError() { } }); } catch (Exception ex) { } return convertView; } public class ViewHolderGridView { public TextView menu_item_price,menu_item_name; public ImageView menu_images,menu_type_image; public LinearLayout main_layout; } } }
No comments:
Post a Comment