mirror of
https://github.com/Nezumi-2711/PRM392.git
synced 2026-09-22 13:48:29 +00:00
Change Password Function
This commit is contained in:
@@ -85,20 +85,37 @@ public class OrderStatus extends AppCompatActivity {
|
||||
viewHolder.txtOrderAddress.setText(model.getAddress());
|
||||
viewHolder.txtOrderPhone.setText(model.getPhone());
|
||||
|
||||
viewHolder.setItemClickListener(new ItemClickListener() {
|
||||
//Event Button
|
||||
viewHolder.btnEdit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view, int position, boolean isLongClick) {
|
||||
if(!isLongClick){
|
||||
Intent trackingOrder = new Intent(OrderStatus.this, TrackingOrder.class);
|
||||
Common.currentRequest = model;
|
||||
startActivity(trackingOrder);
|
||||
}
|
||||
// else {
|
||||
// Intent orderDetail = new Intent(OrderStatus.this, OrderDetail.class);
|
||||
// Common.currentRequest = model;
|
||||
// orderDetail.putExtra("OrderId", adapter.getRef(position).getKey());
|
||||
// startActivity(orderDetail);
|
||||
// }
|
||||
public void onClick(View v) {
|
||||
showUpdateDialog(adapter.getRef(i).getKey(), adapter.getItem(i));
|
||||
}
|
||||
});
|
||||
|
||||
viewHolder.btnRemove.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
deleteOrder(adapter.getRef(i).getKey());
|
||||
}
|
||||
});
|
||||
|
||||
viewHolder.btnDetail.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent orderDetail = new Intent(OrderStatus.this, OrderDetail.class);
|
||||
Common.currentRequest = model;
|
||||
orderDetail.putExtra("OrderId", adapter.getRef(i).getKey());
|
||||
startActivity(orderDetail);
|
||||
}
|
||||
});
|
||||
|
||||
viewHolder.btnDirection.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent trackingOrder = new Intent(OrderStatus.this, TrackingOrder.class);
|
||||
Common.currentRequest = model;
|
||||
startActivity(trackingOrder);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -107,18 +124,9 @@ public class OrderStatus extends AppCompatActivity {
|
||||
recyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(@NonNull MenuItem item) {
|
||||
if(item.getTitle().equals(Common.UPDATE))
|
||||
showUpdateDialog(adapter.getRef(item.getOrder()).getKey(), adapter.getItem(item.getOrder()));
|
||||
else if(item.getTitle().equals(Common.DELETE))
|
||||
deleteOrder(adapter.getRef(item.getOrder()).getKey());
|
||||
|
||||
return super.onContextItemSelected(item);
|
||||
}
|
||||
|
||||
private void deleteOrder(String key) {
|
||||
requests.child(key).removeValue();
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void showUpdateDialog(String key, Request item) {
|
||||
@@ -142,6 +150,7 @@ public class OrderStatus extends AppCompatActivity {
|
||||
item.setStatus(String.valueOf(spinner.getSelectedIndex()));
|
||||
|
||||
requests.child(localKey).setValue(item);
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
sendOrderStatusToUser(localKey, item);
|
||||
}
|
||||
|
||||
+9
-22
@@ -2,6 +2,7 @@ package com.waterbase.foodifyServer.ViewHolder;
|
||||
|
||||
import android.view.ContextMenu;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -10,11 +11,11 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.waterbase.foodifyServer.Interface.ItemClickListener;
|
||||
import com.waterbase.foodifyServer.R;
|
||||
|
||||
public class OrderViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnCreateContextMenuListener{
|
||||
public class OrderViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
public TextView txtOrderId, txtOrderStatus, txtOrderPhone, txtOrderAddress;
|
||||
|
||||
private ItemClickListener itemClickListener;
|
||||
public Button btnEdit, btnRemove, btnDetail, btnDirection;
|
||||
|
||||
public OrderViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
@@ -24,25 +25,11 @@ public class OrderViewHolder extends RecyclerView.ViewHolder implements View.OnC
|
||||
txtOrderStatus = (TextView) itemView.findViewById(R.id.order_status);
|
||||
txtOrderPhone = (TextView) itemView.findViewById(R.id.order_phone);
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnCreateContextMenuListener(this);
|
||||
btnEdit = (Button) itemView.findViewById(R.id.btnEdit);
|
||||
btnDetail = (Button)itemView.findViewById(R.id.btnDetail);
|
||||
btnDirection = (Button)itemView.findViewById(R.id.btnDirection);
|
||||
btnRemove = (Button)itemView.findViewById(R.id.btnRemove);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setItemClickListener(ItemClickListener itemClickListener) {
|
||||
this.itemClickListener = itemClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
itemClickListener.onClick(v, getAdapterPosition(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu contextMenu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
||||
contextMenu.setHeaderTitle("Tuỳ chọn");
|
||||
|
||||
contextMenu.add(0,0, getAdapterPosition(), "Cập nhật");
|
||||
contextMenu.add(0,1, getAdapterPosition(), "Xoá");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,59 +9,113 @@
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="9"
|
||||
android:layout_width="0dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/order_id"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:gravity="center_vertical|start"
|
||||
android:textAllCaps="true"
|
||||
android:textStyle="bold"
|
||||
android:text="#11111"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="9"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/order_status"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:gravity="center_vertical|start"
|
||||
android:textAllCaps="true"
|
||||
android:textStyle="italic"
|
||||
android:text="Status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:id="@+id/order_id"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:gravity="center_vertical|start"
|
||||
android:textAllCaps="true"
|
||||
android:textStyle="bold"
|
||||
android:text="#11111"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/order_phone"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:gravity="center_vertical|start"
|
||||
android:textAllCaps="true"
|
||||
android:textStyle="italic"
|
||||
android:text="Phone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
android:id="@+id/order_status"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:gravity="center_vertical|start"
|
||||
android:textAllCaps="true"
|
||||
android:textStyle="italic"
|
||||
android:text="Status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/order_phone"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:gravity="center_vertical|start"
|
||||
android:textAllCaps="true"
|
||||
android:textStyle="italic"
|
||||
android:text="Phone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/order_address"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:gravity="center_vertical|start"
|
||||
android:textAllCaps="true"
|
||||
android:textStyle="italic"
|
||||
android:text="Address"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/order_address"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:gravity="center_vertical|start"
|
||||
android:textAllCaps="true"
|
||||
android:textStyle="italic"
|
||||
android:text="Address"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight="4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<info.hoang8f.widget.FButton
|
||||
android:id="@+id/btnEdit"
|
||||
android:text="Chỉnh sửa"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:cornerRadius="0dp"
|
||||
app:fButtonColor="@color/white"
|
||||
/>
|
||||
|
||||
<info.hoang8f.widget.FButton
|
||||
android:id="@+id/btnRemove"
|
||||
android:text="Xoá"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:cornerRadius="0dp"
|
||||
app:fButtonColor="@color/white"
|
||||
/>
|
||||
|
||||
<info.hoang8f.widget.FButton
|
||||
android:id="@+id/btnDetail"
|
||||
android:text="Chi tiết"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:cornerRadius="0dp"
|
||||
app:fButtonColor="@color/white"
|
||||
/>
|
||||
|
||||
<info.hoang8f.widget.FButton
|
||||
android:id="@+id/btnDirection"
|
||||
android:text="Hướng đi"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:cornerRadius="0dp"
|
||||
app:fButtonColor="@color/white"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
Reference in New Issue
Block a user