mirror of
https://github.com/Nezumi-2711/PRM392.git
synced 2026-09-22 13:48:29 +00:00
Improve Layout
This commit is contained in:
@@ -46,6 +46,13 @@ public class Common {
|
|||||||
return "Giao thành công";
|
return "Giao thành công";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String convertCodePaymentToStatus(String status) {
|
||||||
|
if(status.equals("0"))
|
||||||
|
return "CHƯA THANH TOÁN";
|
||||||
|
else
|
||||||
|
return "ĐÃ THANH TOÁN";
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isConnectedToInternet(Context context) {
|
public static boolean isConnectedToInternet(Context context) {
|
||||||
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public class OrderStatus extends AppCompatActivity {
|
|||||||
orderViewHolder.txtOrderStatus.setText("Tình trạng đơn: " + Common.convertCodeToStatus(model.getStatus()));
|
orderViewHolder.txtOrderStatus.setText("Tình trạng đơn: " + Common.convertCodeToStatus(model.getStatus()));
|
||||||
orderViewHolder.txtOrderAddress.setText("Địa chỉ: " + model.getAddress());
|
orderViewHolder.txtOrderAddress.setText("Địa chỉ: " + model.getAddress());
|
||||||
orderViewHolder.txtOrderDate.setText("Ngày đặt: " + Common.getDate(Long.parseLong(adapter.getRef(i).getKey())));
|
orderViewHolder.txtOrderDate.setText("Ngày đặt: " + Common.getDate(Long.parseLong(adapter.getRef(i).getKey())));
|
||||||
orderViewHolder.txtOrderPayment.setText("Tình trạng thanh toán: " + model.getPaymentStatus());
|
orderViewHolder.txtOrderPayment.setText("Tình trạng thanh toán: " + Common.convertCodePaymentToStatus(model.getPaymentStatus()));
|
||||||
orderViewHolder.btn_delete.setOnClickListener(new View.OnClickListener() {
|
orderViewHolder.btn_delete.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
@@ -20,12 +20,12 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="start"
|
android:layout_gravity="start"
|
||||||
android:background="@color/overlayBackground"
|
android:background="@color/white"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
app:headerLayout="@layout/nav_header_home"
|
app:headerLayout="@layout/nav_header_home"
|
||||||
|
|
||||||
app:itemIconTint="@color/white"
|
app:itemIconTint="@color/black"
|
||||||
app:itemTextColor="@color/white"
|
app:itemTextColor="@color/black"
|
||||||
app:menu="@menu/activity_main_drawer" />
|
app:menu="@menu/activity_main_drawer" />
|
||||||
|
|
||||||
</androidx.drawerlayout.widget.DrawerLayout>
|
</androidx.drawerlayout.widget.DrawerLayout>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/nav_header_height"
|
android:layout_height="@dimen/nav_header_height"
|
||||||
android:background="@color/fbutton_color_transparent"
|
android:background="@color/purple_500"
|
||||||
android:gravity="bottom"
|
android:gravity="bottom"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||||
@@ -14,11 +14,11 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/imageView"
|
android:id="@+id/imageView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="80dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="80dp"
|
||||||
android:contentDescription="@string/nav_header_desc"
|
android:contentDescription="@string/nav_header_desc"
|
||||||
android:paddingTop="@dimen/nav_header_vertical_spacing"
|
android:paddingTop="@dimen/nav_header_vertical_spacing"
|
||||||
app:srcCompat="@mipmap/ic_launcher_round" />
|
app:srcCompat="@drawable/avatar" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/txtFullName"
|
android:id="@+id/txtFullName"
|
||||||
|
|||||||
@@ -45,6 +45,13 @@ public class Common {
|
|||||||
return "Giao thành công";
|
return "Giao thành công";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String coverCodePaymentToStatus(String code){
|
||||||
|
if(code.equals("0"))
|
||||||
|
return "CHƯA THANH TOÁN";
|
||||||
|
else
|
||||||
|
return "ĐÃ THANH TOÁN";
|
||||||
|
}
|
||||||
|
|
||||||
public static IGeoCoordinates getGeoCodeService() {
|
public static IGeoCoordinates getGeoCodeService() {
|
||||||
return RetrofitClient.getClient(baseUrl).create(IGeoCoordinates.class);
|
return RetrofitClient.getClient(baseUrl).create(IGeoCoordinates.class);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class OrderStatus extends AppCompatActivity {
|
|||||||
FirebaseDatabase db;
|
FirebaseDatabase db;
|
||||||
DatabaseReference requests;
|
DatabaseReference requests;
|
||||||
|
|
||||||
MaterialSpinner spinner;
|
MaterialSpinner spinnerOrder, spinnerPayment;
|
||||||
|
|
||||||
APIService mService;
|
APIService mService;
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ public class OrderStatus extends AppCompatActivity {
|
|||||||
viewHolder.txtOrderStatus.setText("Tình trạng đơn: " + Common.coverCodeToStatus(model.getStatus()));
|
viewHolder.txtOrderStatus.setText("Tình trạng đơn: " + Common.coverCodeToStatus(model.getStatus()));
|
||||||
viewHolder.txtOrderAddress.setText("Địa chỉ giao hàng: " + model.getAddress());
|
viewHolder.txtOrderAddress.setText("Địa chỉ giao hàng: " + model.getAddress());
|
||||||
viewHolder.txtOrderPhone.setText("Số điện thoại giao hàng: " + model.getPhone());
|
viewHolder.txtOrderPhone.setText("Số điện thoại giao hàng: " + model.getPhone());
|
||||||
viewHolder.txtOrderPayment.setText("Tình trạng thanh toán: " + model.getPaymentStatus());
|
viewHolder.txtOrderPayment.setText("Tình trạng thanh toán: " + Common.coverCodePaymentToStatus(model.getPaymentStatus()));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -167,8 +167,8 @@ public class OrderStatus extends AppCompatActivity {
|
|||||||
LayoutInflater inflater = this.getLayoutInflater();
|
LayoutInflater inflater = this.getLayoutInflater();
|
||||||
final View view = inflater.inflate(R.layout.update_order_layout, null);
|
final View view = inflater.inflate(R.layout.update_order_layout, null);
|
||||||
|
|
||||||
spinner = (MaterialSpinner) view.findViewById(R.id.statusSpinner);
|
spinnerOrder = (MaterialSpinner) view.findViewById(R.id.statusOrderSpinner);
|
||||||
spinner.setItems("ĐÃ NHẬN ĐƠN", "ĐANG TRÊN ĐƯỜNG", "GIAO THÀNH CÔNG");
|
spinnerOrder.setItems("ĐÃ NHẬN ĐƠN", "ĐANG TRÊN ĐƯỜNG", "GIAO THÀNH CÔNG");
|
||||||
|
|
||||||
//Set value default spinner
|
//Set value default spinner
|
||||||
requests.orderByKey().equalTo(key)
|
requests.orderByKey().equalTo(key)
|
||||||
@@ -177,7 +177,27 @@ public class OrderStatus extends AppCompatActivity {
|
|||||||
public void onDataChange(DataSnapshot dataSnapshot) {
|
public void onDataChange(DataSnapshot dataSnapshot) {
|
||||||
for(DataSnapshot postSnapShot: dataSnapshot.getChildren()) {
|
for(DataSnapshot postSnapShot: dataSnapshot.getChildren()) {
|
||||||
Request data = postSnapShot.getValue(Request.class);
|
Request data = postSnapShot.getValue(Request.class);
|
||||||
spinner.setSelectedIndex(Integer.parseInt(data.getStatus()));
|
spinnerOrder.setSelectedIndex(Integer.parseInt(data.getStatus()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCancelled(DatabaseError databaseError) {
|
||||||
|
Toast.makeText(OrderStatus.this, "Đã có lỗi từ hệ thống, vui lòng thử lại sau!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
spinnerPayment = (MaterialSpinner) view.findViewById(R.id.statusPaymentSpinner);
|
||||||
|
spinnerPayment.setItems("CHƯA THANH TOÁN", "ĐÃ THANH TOÁN");
|
||||||
|
|
||||||
|
//Set value default spinner
|
||||||
|
requests.orderByKey().equalTo(key)
|
||||||
|
.addValueEventListener(new ValueEventListener() {
|
||||||
|
@Override
|
||||||
|
public void onDataChange(DataSnapshot dataSnapshot) {
|
||||||
|
for(DataSnapshot postSnapShot: dataSnapshot.getChildren()) {
|
||||||
|
Request data = postSnapShot.getValue(Request.class);
|
||||||
|
spinnerPayment.setSelectedIndex(Integer.parseInt(data.getPaymentStatus()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +214,8 @@ public class OrderStatus extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
dialog.dismiss();;
|
dialog.dismiss();;
|
||||||
item.setStatus(String.valueOf(spinner.getSelectedIndex()));
|
item.setStatus(String.valueOf(spinnerOrder.getSelectedIndex()));
|
||||||
|
item.setPaymentStatus(String.valueOf(spinnerPayment.getSelectedIndex()));
|
||||||
|
|
||||||
requests.child(localKey).setValue(item);
|
requests.child(localKey).setValue(item);
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
|||||||
@@ -8,8 +8,41 @@
|
|||||||
app:cardElevation="4dp"
|
app:cardElevation="4dp"
|
||||||
>
|
>
|
||||||
|
|
||||||
<com.jaredrummler.materialspinner.MaterialSpinner
|
<LinearLayout
|
||||||
android:id="@+id/statusSpinner"
|
android:orientation="vertical"
|
||||||
|
android:layout_margin="10dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"
|
||||||
|
>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="Tình trạng đơn hàng"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:textStyle="italic"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<com.jaredrummler.materialspinner.MaterialSpinner
|
||||||
|
android:id="@+id/statusOrderSpinner"
|
||||||
|
android:backgroundTint="@color/backgroundSpinner"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:text="Tình trạng thanh toán"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:textStyle="italic"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<com.jaredrummler.materialspinner.MaterialSpinner
|
||||||
|
android:id="@+id/statusPaymentSpinner"
|
||||||
|
android:backgroundTint="@color/backgroundSpinner"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
@@ -17,4 +17,5 @@
|
|||||||
|
|
||||||
<color name="overlayBackground">#7f333639</color>
|
<color name="overlayBackground">#7f333639</color>
|
||||||
<color name="overlayActionBar">#0e0d0e</color>
|
<color name="overlayActionBar">#0e0d0e</color>
|
||||||
|
<color name="backgroundSpinner">#E3E3E3</color>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user