<?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:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="@dimen/text_size_smaller"
android:layout_marginBottom="@dimen/text_size_smaller">
<Button
android:id="@+id/df_all_item_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="All (13)"
android:paddingRight="@dimen/text_size_medium_small"
android:paddingLeft="@dimen/text_size_medium_small"
android:fontFamily="@font/source_sans_pro_regular"
android:layout_marginLeft="@dimen/text_size_medium_small"
android:background="@drawable/list_border"/>
<Button
android:id="@+id/df_preparing_item_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Preparing (13)"
android:paddingRight="@dimen/text_size_medium_small"
android:paddingLeft="@dimen/text_size_medium_small"
android:fontFamily="@font/source_sans_pro_regular"
android:layout_marginLeft="@dimen/text_size_medium_small"
android:background="@drawable/list_border"/>
<Button
android:id="@+id/df_ready_item_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ready (13)"
android:paddingRight="@dimen/text_size_medium_small"
android:paddingLeft="@dimen/text_size_medium_small"
android:fontFamily="@font/source_sans_pro_regular"
android:layout_marginLeft="@dimen/text_size_medium_small"
android:background="@drawable/list_border"/>
<Button
android:id="@+id/df_out_for_delivery_item_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Out for delivery (13)"
android:paddingRight="@dimen/text_size_medium_small"
android:paddingLeft="@dimen/text_size_medium_small"
android:fontFamily="@font/source_sans_pro_regular"
android:layout_marginLeft="@dimen/text_size_medium_small"
android:background="@drawable/list_border"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height=".5dp"
android:background="@color/silver"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<!-- <LinearLayout-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_weight="1">-->
<!-- <include layout="@layout/delivery_order_state_selector"-->
<!-- </LinearLayout>-->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/delivery_order_selector_rv"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"/>
<LinearLayout
android:layout_width=".5dp"
android:layout_height="match_parent"
android:background="@color/silver"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.7"
android:layout_gravity="center"
android:gravity="center"
android:paddingTop="@dimen/text_size_small"
android:paddingBottom="@dimen/text_size_small"
android:orientation="horizontal">
<TextView
android:id="@+id/deliveryAtTv"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="@color/black"
android:textSize="@dimen/text_size_medium_small"
android:fontFamily="@font/source_sans_pro_regular"
android:text="Delivery At: "/>
<TextView
android:id="@+id/deliveryAmountTv"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="@color/black"
android:textSize="@dimen/text_size_medium_small"
android:fontFamily="@font/source_sans_pro_regular"
android:layout_marginLeft="@dimen/text_size_extra_large"
android:text="Delivery At: "/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height=".5dp"
android:background="@color/silver"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2.6"
android:orientation="vertical">
<TextView
android:id="@+id/menu_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingTop="@dimen/text_size_small"
android:paddingBottom="@dimen/text_size_small"
android:textSize="@dimen/text_size_medium_small"
android:textColor="@color/black"
android:fontFamily="@font/source_sans_pro_regular"
android:text=""/>
<TextView
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:layout_gravity="center"
android:gravity="center"
android:textSize="@dimen/text_size_medium_small"
android:fontFamily="@font/source_sans_pro_regular"
android:text=""/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height=".5dp"
android:background="@color/silver"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4.3"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="@dimen/text_size_extra_large"
android:layout_marginRight="@dimen/text_size_extra_large"
android:orientation="vertical">
<TextView
android:id="@+id/deliveryPickUpTime"
style="?android:attr/spinnerStyle"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:paddingRight="@dimen/text_size_medium_small"
android:paddingLeft="@dimen/text_size_medium_small"
android:fontFamily="@font/source_sans_pro_regular"
android:text="Select rider pickup time "
android:textColor="@color/black"
android:textSize="@dimen/text_size_medium_small" />
<TextView
android:id="@+id/deliveryPickUpTimeshow"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:visibility="gone"
android:gravity="center"
android:paddingRight="@dimen/text_size_medium_small"
android:paddingLeft="@dimen/text_size_medium_small"
android:fontFamily="@font/source_sans_pro_regular"
android:text="Select rider pickup time "
android:textColor="@color/black"
android:textSize="@dimen/text_size_medium_small" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center"
android:layout_marginBottom="@dimen/text_size_small"
android:layout_marginTop="@dimen/text_size_small"
android:layout_weight="1.5">
<Button
android:id="@+id/deliveryStatusChangeBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:text="Preparing (13)"
android:textColor="@color/white"
android:paddingRight="@dimen/text_size_medium_small"
android:paddingLeft="@dimen/text_size_medium_small"
android:fontFamily="@font/source_sans_pro_regular"
android:background="@drawable/list_border"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width=".5dp"
android:layout_height="match_parent"
android:background="@color/silver"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:padding="@dimen/text_size_medium_small"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/text_size_medium_small"
android:fontFamily="@font/source_sans_pro_regular"
android:text="Customer details: "/>
<TextView
android:id="@+id/customerNameTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textSize="@dimen/text_size_medium_small"
android:fontFamily="@font/source_sans_pro_regular"
android:text="Customer details: "/>
<TextView
android:id="@+id/customerphoneNumberTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textSize="@dimen/text_size_medium_small"
android:fontFamily="@font/source_sans_pro_regular"
android:text="Customer details: "/>
<TextView
android:id="@+id/customerAddressTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textSize="@dimen/text_size_medium_small"
android:fontFamily="@font/source_sans_pro_regular"
android:text="Customer details: "/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height=".5dp"
android:background="@color/silver"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3.5"
android:paddingTop="@dimen/text_size_small"
android:paddingBottom="@dimen/text_size_small"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/riderDetailsLL"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center_vertical"
android:paddingLeft="@dimen/text_size_medium_small">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/text_size_medium_small"
android:fontFamily="@font/source_sans_pro_regular"
android:text="Rider details: "/>
<TextView
android:id="@+id/riderNameTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textSize="@dimen/text_size_medium_small"
android:fontFamily="@font/source_sans_pro_regular"
android:text="Rider details: "/>
<TextView
android:id="@+id/riderphoneNumberTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textSize="@dimen/text_size_medium_small"
android:fontFamily="@font/source_sans_pro_regular"
android:text="Rider details: "/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:gravity="center_horizontal|bottom"
android:layout_weight="1">
<TextView
android:id="@+id/trackRiderBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Track rider"
android:textColor="@color/black"
android:paddingRight="@dimen/text_size_medium_small"
android:paddingLeft="@dimen/text_size_medium_small"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:textAllCaps="true"
android:layout_marginBottom="5dp"
android:fontFamily="@font/source_sans_pro_regular"
android:background="@drawable/list_border"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width=".5dp"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/text_size_medium_small"
android:layout_marginBottom="@dimen/text_size_medium_small"
android:background="@color/silver"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/orderDetailsTV"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:textColor="@color/text_color_active_blue"
android:textSize="@dimen/text_size_medium_small"
android:fontFamily="@font/source_sans_pro_regular"
android:text="Order details "/>
<TextView
android:id="@+id/cancelOrderTV"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:textColor="@color/silver"
android:textSize="@dimen/text_size_medium_small"
android:fontFamily="@font/source_sans_pro_regular"
android:text="Cancel order "/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height=".5dp"
android:background="@color/silver"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Sourse :
import android.app.TimePickerDialog; import android.os.Bundle; import android.text.InputType; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.TimePicker; import android.widget.Toast; import com.dfoe.frimaster.FragmentForDashBorad.InventryViewHistry.CustomListAdapter.ViewHolder; import com.dfoe.frimaster.R; import com.dfoe.frimaster.modals.OrderDetailsData; import com.dfoe.frimaster.util.UtilConstants; import java.util.ArrayList; import java.util.Calendar; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.DefaultItemAnimator; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import okhttp3.internal.Util; public class DeliveryFragment extends Fragment { RecyclerView deliveryOrderList; DeliveryOrderItemsAdapter mDeliveryOrderItemsAdapter; ArrayList<OrderDetailsData> mOrderDetails; int visibleorderPosition = 0; int orderStatusFilterval = -1; TextView deliveryAtTv, amountPaidTv, riderPickUpTimeTv, customerNameTV, customerPhoneNumberTV, customerAddressTV,menu_name,message,deliveryPickUpTimeshow; Button orderStatusChangingBtn; TextView riderNameTV, riderPhoneNumberTV; LinearLayout riderDetailsLL; Button orderStatusAllBtn, orderStatusPreparingBtn, orderStatusReadyBtn, orderStatusOutForDeliveryBtn; TimePickerDialog picker; @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View v = inflater.inflate(R.layout.fragment_delivery, null); deliveryAtTv = v.findViewById(R.id.deliveryAtTv); amountPaidTv = v.findViewById(R.id.deliveryAmountTv); riderPickUpTimeTv = v.findViewById(R.id.deliveryPickUpTime); orderStatusChangingBtn = v.findViewById(R.id.deliveryStatusChangeBtn); customerAddressTV = v.findViewById(R.id.customerAddressTV); customerNameTV = v.findViewById(R.id.customerNameTV); customerPhoneNumberTV = v.findViewById(R.id.customerphoneNumberTV); riderNameTV = v.findViewById(R.id.riderNameTV); riderPhoneNumberTV = v.findViewById(R.id.riderphoneNumberTV); riderDetailsLL = v.findViewById(R.id.riderDetailsLL); deliveryOrderList = v.findViewById(R.id.delivery_order_selector_rv); orderStatusAllBtn = v.findViewById(R.id.df_all_item_btn); orderStatusPreparingBtn = v.findViewById(R.id.df_preparing_item_btn); orderStatusReadyBtn = v.findViewById(R.id.df_ready_item_btn); orderStatusOutForDeliveryBtn = v.findViewById(R.id.df_out_for_delivery_item_btn); menu_name = v.findViewById(R.id.menu_name); message = v.findViewById(R.id.message); deliveryPickUpTimeshow= v.findViewById(R.id.deliveryPickUpTimeshow); // Used in rider time riderPickUpTimeTv.setInputType(InputType.TYPE_NULL); riderPickUpTimeTv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Calendar cldr = Calendar.getInstance(); int hour = cldr.get(Calendar.HOUR_OF_DAY); int minutes = cldr.get(Calendar.MINUTE); // time picker dialog picker = new TimePickerDialog(getActivity(), new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker tp, int sHour, int sMinute) { deliveryPickUpTimeshow.setText("Rider pickup at:"+sHour + ":" + sMinute); deliveryPickUpTimeshow.setVisibility(View.VISIBLE); riderPickUpTimeTv.setVisibility(View.GONE); } }, hour, minutes, true); picker.show(); } }); mOrderDetails = new ArrayList<>(); OrderDetailsData orderItems = new OrderDetailsData(); orderItems.setOrderNumber(112); orderItems.setOrderStatus(1); orderItems.setPinVal(112); orderItems.setDeliveryTime("04:30PM"); orderItems.setAmountPaid(110); orderItems.setCurrencyCode("$"); orderItems.setRideName("peter"); orderItems.setCustomerContactNo("7827273087"); orderItems.setCustomerName("peter"); orderItems.setCustomerContactNo("9999999999"); orderItems.setCustomerAddress("Boyle Estates, 96510 Lucile Falls, New Gillian"); orderItems.setRiderPhoneNo("1234567890"); orderItems.setMenuName("1 x Chicken burger, 1"); orderItems.setMenuMessage("Provide extra sachets of ketchup "); mOrderDetails.add(orderItems); orderItems = new OrderDetailsData(); orderItems.setOrderNumber(113); orderItems.setOrderStatus(0); orderItems.setPinVal(113); orderItems.setDeliveryTime("03:30PM"); orderItems.setAmountPaid(120); orderItems.setCurrencyCode("RM"); orderItems.setMenuName("1 x Chicken burger, 1 x Golden fries (Medium), 2 x Coke (Small)"); orderItems.setMenuMessage("Provide extra salt "); mOrderDetails.add(orderItems); orderItems = new OrderDetailsData(); orderItems.setOrderNumber(114); orderItems.setOrderStatus(3); orderItems.setPinVal(114); orderItems.setDeliveryTime("02:30PM"); orderItems.setAmountPaid(140); orderItems.setCurrencyCode("R"); orderItems.setMenuName("1 x Golden fries (Medium), 2 x Coke (Small)"); orderItems.setMenuMessage("Provide extra salat "); mOrderDetails.add(orderItems); orderItems = new OrderDetailsData(); orderItems.setOrderNumber(115); orderItems.setOrderStatus(4); orderItems.setPinVal(115); orderItems.setDeliveryTime("04:30PM"); orderItems.setAmountPaid(110); orderItems.setCurrencyCode("$"); mOrderDetails.add(orderItems); orderItems = new OrderDetailsData(); orderItems.setOrderNumber(116); orderItems.setOrderStatus(1); orderItems.setDeliveryTime("04:30PM"); orderItems.setAmountPaid(110); orderItems.setCurrencyCode("$"); orderItems.setPinVal(116); mOrderDetails.add(orderItems); mDeliveryOrderItemsAdapter = new DeliveryOrderItemsAdapter(mOrderDetails); RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity()); deliveryOrderList.setLayoutManager(mLayoutManager); deliveryOrderList.setItemAnimator(new DefaultItemAnimator()); deliveryOrderList.setAdapter(mDeliveryOrderItemsAdapter); filterOrderByStatus(orderStatusFilterval); if (orderStatusFilterval == -1) { orderStatusAllBtn.setBackgroundColor(getResources().getColor(R.color.bg_delivery_selected_item)); } else if (orderStatusFilterval == 1) { orderStatusPreparingBtn.setBackgroundColor(getResources().getColor(R.color.bg_delivery_selected_item)); } else if (orderStatusFilterval == 3) { orderStatusReadyBtn.setBackgroundColor(getResources().getColor(R.color.bg_delivery_selected_item)); } else if (orderStatusFilterval == 4) { orderStatusOutForDeliveryBtn.setBackgroundColor(getResources().getColor(R.color.bg_delivery_selected_item)); } orderStatusAllBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { resetOrderStatusButtonbg(); orderStatusAllBtn.setBackgroundColor(getResources().getColor(R.color.bg_delivery_selected_item)); visibleorderPosition = 0; filterOrderByStatus(-1); } }); orderStatusPreparingBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { resetOrderStatusButtonbg(); orderStatusPreparingBtn.setBackgroundColor(getResources().getColor(R.color.bg_delivery_selected_item)); visibleorderPosition = 0; filterOrderByStatus(1); } }); orderStatusReadyBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { resetOrderStatusButtonbg(); orderStatusReadyBtn.setBackgroundColor(getResources().getColor(R.color.bg_delivery_selected_item)); visibleorderPosition = 0; filterOrderByStatus(3); } }); orderStatusOutForDeliveryBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { resetOrderStatusButtonbg(); orderStatusOutForDeliveryBtn.setBackgroundColor(getResources().getColor(R.color.bg_delivery_selected_item)); visibleorderPosition = 0; filterOrderByStatus(4); } }); updateNosToOrderStatuses(); return v; } public class DeliveryOrderItemsAdapter extends RecyclerView.Adapter<DeliveryOrderItemsAdapter.OrderViewHolder> { ArrayList<OrderDetailsData> mOrderDetails = new ArrayList<>(); public DeliveryOrderItemsAdapter(ArrayList<OrderDetailsData> mOrderDetails) { this.mOrderDetails = mOrderDetails; updateOrderDetails(mOrderDetails.get(visibleorderPosition)); } public void updateData(ArrayList<OrderDetailsData> mOrderDetails) { this.mOrderDetails = mOrderDetails; updateOrderDetails(mOrderDetails.get(visibleorderPosition)); notifyDataSetChanged(); } @NonNull @Override public OrderViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View itemView = LayoutInflater.from(parent.getContext()) .inflate(R.layout.delivery_order_items_view, parent, false); return new OrderViewHolder(itemView); } @Override public void onBindViewHolder(@NonNull OrderViewHolder holder, final int position) { final OrderDetailsData mOrderItem = mOrderDetails.get(position); holder.orderNoTV.setText("ORDER# " + mOrderItem.getOrderNumber()); holder.pinTV.setText("PIN: " + mOrderItem.getPinVal()); if (mOrderItem.getOrderStatus() == 0) { holder.orderStatusBtn.setBackgroundColor(getResources().getColor(R.color.bg_new_order)); holder.orderStatusBtn.setText("New order"); } else if (mOrderItem.getOrderStatus() == 1) { holder.orderStatusBtn.setBackgroundColor(getResources().getColor(R.color.bg_preparing)); holder.orderStatusBtn.setText("Preparing"); } else if (mOrderItem.getOrderStatus() == 3) { holder.orderStatusBtn.setBackgroundColor(getResources().getColor(R.color.bg_ready)); holder.orderStatusBtn.setText("Ready"); } else if (mOrderItem.getOrderStatus() == 4) { holder.orderStatusBtn.setBackgroundColor(getResources().getColor(R.color.bg_out_for_del)); holder.orderStatusBtn.setText("Out for delivery"); } if (visibleorderPosition == position) { holder.deliveryOrderItemLL.setBackgroundColor(getResources().getColor(R.color.bg_delivery_selected_item)); } else { holder.deliveryOrderItemLL.setBackgroundColor(getResources().getColor(R.color.white)); } holder.deliveryOrderItemLL.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { visibleorderPosition = position; updateOrderDetails(mOrderItem); notifyDataSetChanged(); } }); } @Override public int getItemCount() { return mOrderDetails.size(); } public class OrderViewHolder extends RecyclerView.ViewHolder { TextView orderNoTV, pinTV; TextView orderStatusBtn; LinearLayout deliveryOrderItemLL; public OrderViewHolder(View mView) { super(mView); orderNoTV = mView.findViewById(R.id.deliveryItemOrderNoTv); pinTV = mView.findViewById(R.id.deliveryItemOrderPinTv); orderStatusBtn = mView.findViewById(R.id.deliveryItemOrderStatusBtn); deliveryOrderItemLL = mView.findViewById(R.id.deliveryItemLL); } } } public void updateOrderDetails(final OrderDetailsData morderItemDetails) { deliveryAtTv.setText("Delivery at: " + morderItemDetails.getDeliveryTime()); amountPaidTv.setText("Amount paid: " + morderItemDetails.getCurrencyCode() + morderItemDetails.getAmountPaid()); menu_name.setText(" " + morderItemDetails.getMenuName()); message.setText(" " + morderItemDetails.getMenuMessage()); // orderStatusChangingBtn.setTag(morderItemDetails); customerAddressTV.setText(morderItemDetails.getCustomerAddress()); customerNameTV.setText(morderItemDetails.getCustomerName()); customerPhoneNumberTV.setText(morderItemDetails.getCustomerContactNo()); riderNameTV.setText(morderItemDetails.getRideName()); riderPhoneNumberTV.setText(morderItemDetails.getRiderPhoneNo()); if (morderItemDetails.getOrderStatus() == 0 /*|| morderItemDetails.getOrderStatus()==4*/) { riderDetailsLL.setVisibility(View.INVISIBLE); } else { riderDetailsLL.setVisibility(View.VISIBLE); } orderStatusChangingBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (morderItemDetails.getOrderStatus() == 0 && TextUtils.isEmpty(morderItemDetails.getPickUpTime())) { UtilConstants.showAlertDialog(getContext(), "Please select pickup time before accepting the order."); return; } //TODO call Api to change the Order Sttatus } }); if (morderItemDetails.getOrderStatus() == 0) { riderPickUpTimeTv.setText("Select rider pickup time"); } else { riderPickUpTimeTv.setText("Rider pickup at " + morderItemDetails.getPickUpTime()); } if (morderItemDetails.getOrderStatus() == 0) { orderStatusChangingBtn.setBackgroundColor(getResources().getColor(R.color.bg_new_order)); orderStatusChangingBtn.setText("Accept Order"); } else if (morderItemDetails.getOrderStatus() == 1) { orderStatusChangingBtn.setBackgroundColor(getResources().getColor(R.color.bg_preparing)); orderStatusChangingBtn.setText("Mark as prepared"); } else if (morderItemDetails.getOrderStatus() == 3) { orderStatusChangingBtn.setBackgroundColor(getResources().getColor(R.color.bg_ready)); orderStatusChangingBtn.setText("Confirm pickup"); } else if (morderItemDetails.getOrderStatus() == 4) { orderStatusChangingBtn.setBackgroundColor(getResources().getColor(R.color.bg_out_for_del)); orderStatusChangingBtn.setText("Out for delivery"); } } public void resetOrderStatusButtonbg() { orderStatusAllBtn.setBackground(getResources().getDrawable(R.drawable.list_border)); orderStatusPreparingBtn.setBackground(getResources().getDrawable(R.drawable.list_border)); orderStatusReadyBtn.setBackground(getResources().getDrawable(R.drawable.list_border)); orderStatusOutForDeliveryBtn.setBackground(getResources().getDrawable(R.drawable.list_border)); } public void filterOrderByStatus(int status) { orderStatusFilterval = status; if (status == -1) { mDeliveryOrderItemsAdapter.updateData(mOrderDetails); } else { ArrayList<OrderDetailsData> mOrderList = new ArrayList<>(); for (int i = 0; i < mOrderDetails.size(); i++) { if (status == mOrderDetails.get(i).getOrderStatus()) { mOrderList.add(mOrderDetails.get(i)); } } mDeliveryOrderItemsAdapter.updateData(mOrderList); } // updateOrderDetails(mOrderDetails.get(visibleorderPosition)); } public void updateNosToOrderStatuses() { int all = 0, preparing = 0, ready = 0, outForDelivery = 0; all = mOrderDetails.size(); for (int i = 0; i < mOrderDetails.size(); i++) { if (mOrderDetails.get(i).getOrderStatus() == 1) { preparing++; } else if (mOrderDetails.get(i).getOrderStatus() == 3) { ready++; } else if (mOrderDetails.get(i).getOrderStatus() == 4) { outForDelivery++; } } orderStatusAllBtn.setText("ALL (" + all + ")"); orderStatusPreparingBtn.setText("PREPARING (" + preparing + ")"); orderStatusReadyBtn.setText("READY (" + ready + ")"); orderStatusOutForDeliveryBtn.setText("OUT FOR DELIVERY (" + outForDelivery + ")"); } }
public class OrderDetailsData { private int orderNumber; private int orderStatus; private int pinVal; private String deliveryTime; private String pickUpTime; private double amountPaid; private String customerName; private String customerContactNo; private String customerAddress; private String rideName; private String riderPhoneNo; private String currencyCode; private String menuName; private String menuMessage; public String getCurrencyCode() { return currencyCode; } public void setCurrencyCode(String currencyCode) { this.currencyCode = currencyCode; } public String getDeliveryTime() { return deliveryTime; } public void setDeliveryTime(String deliveryTime) { this.deliveryTime = deliveryTime; } public String getPickUpTime() { return pickUpTime; } public void setPickUpTime(String pickUpTime) { this.pickUpTime = pickUpTime; } public double getAmountPaid() { return amountPaid; } public void setAmountPaid(double amountPaid) { this.amountPaid = amountPaid; } public String getCustomerName() { return customerName; } public void setCustomerName(String customerName) { this.customerName = customerName; } public String getCustomerContactNo() { return customerContactNo; } public void setCustomerContactNo(String customerContactNo) { this.customerContactNo = customerContactNo; } public String getCustomerAddress() { return customerAddress; } public void setCustomerAddress(String customerAddress) { this.customerAddress = customerAddress; } public String getRideName() { return rideName; } public void setRideName(String rideName) { this.rideName = rideName; } public String getRiderPhoneNo() { return riderPhoneNo; } public void setRiderPhoneNo(String riderPhoneNo) { this.riderPhoneNo = riderPhoneNo; } public int getOrderNumber() { return orderNumber; } public void setOrderNumber(int orderNumber) { this.orderNumber = orderNumber; } public int getOrderStatus() { return orderStatus; } public void setOrderStatus(int orderStatus) { this.orderStatus = orderStatus; } public int getPinVal() { return pinVal; } public void setPinVal(int pinVal) { this.pinVal = pinVal; } public String getMenuName() { return menuName; } public void setMenuName(String menuName) { this.menuName = menuName; } public String getMenuMessage() { return menuMessage; } public void setMenuMessage(String menuMessage) { this.menuMessage = menuMessage; } }
No comments:
Post a Comment