Update new version

This commit is contained in:
Nezumi
2023-04-26 11:23:42 +07:00
parent aea02984ee
commit 893f30839e
6 changed files with 45 additions and 36 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ android {
minSdk 26 minSdk 26
targetSdk 30 targetSdk 30
versionCode 1 versionCode 1
versionName "0.5.1" versionName "0.5.2"
configurations.all { configurations.all {
resolutionStrategy { resolutionStrategy {
+1 -1
View File
@@ -12,7 +12,7 @@
"filters": [], "filters": [],
"attributes": [], "attributes": [],
"versionCode": 1, "versionCode": 1,
"versionName": "0.5.1", "versionName": "0.5.2",
"outputFile": "app-release.apk" "outputFile": "app-release.apk"
} }
], ],
@@ -58,6 +58,8 @@ import com.google.android.gms.location.SettingsClient;
import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.tasks.OnFailureListener; import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener; import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.sjapps.library.customdialog.BasicDialog; import com.sjapps.library.customdialog.BasicDialog;
import com.sjapps.library.customdialog.DialogButtonEvents; import com.sjapps.library.customdialog.DialogButtonEvents;
import com.sjapps.library.customdialog.SJDialog; import com.sjapps.library.customdialog.SJDialog;
@@ -119,7 +121,6 @@ public class OrderDetailActivity extends AppCompatActivity {
initComponent(); initComponent();
initData(); initData();
getFCMTokenUser(); getFCMTokenUser();
@@ -142,40 +143,38 @@ public class OrderDetailActivity extends AppCompatActivity {
btn_shipping.setOnClickListener(new View.OnClickListener() { btn_shipping.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (Common.CURRENT_ORDER == null) {
//Change order status startLocationService();
FoodApiToken.apiService.changeStatusOrder(order.getUser().getId(), order.getId(), "SHIPPING").enqueue(new Callback<CustomResponse>() {
@Override
public void onResponse(Call<CustomResponse> call, Response<CustomResponse> response) {
if(response.code() == 200){
//If success
LatLng latLng = new LatLng(order.getLat(), order.getLng()); //Change order status
addGeofence(latLng, GEOFENCE_RADIUS); FoodApiToken.apiService.changeStatusOrder(order.getUser().getId(), order.getId(), "SHIPPING").enqueue(new Callback<CustomResponse>() {
@Override
public void onResponse(Call<CustomResponse> call, Response<CustomResponse> response) {
if(response.code() == 200){
//If success
Common.CURRENT_ORDER = order; LatLng latLng = new LatLng(order.getLat(), order.getLng());
addGeofence(latLng, GEOFENCE_RADIUS);
startLocationService(); Common.CURRENT_ORDER = order;
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("google.navigation:q=" + order.getLat() + "," + order.getLng() + "&mode=l"));
intent.setPackage("com.google.android.apps.maps"); Intent intent = new Intent(Intent.ACTION_VIEW,
startActivity(intent); Uri.parse("google.navigation:q=" + order.getLat() + "," + order.getLng() + "&mode=l"));
} else { intent.setPackage("com.google.android.apps.maps");
//If error startActivity(intent);
Toast.makeText(OrderDetailActivity.this, "", Toast.LENGTH_SHORT).show(); } else {
} //If error
Toast.makeText(OrderDetailActivity.this, "Đã có lỗi xảy ra! Mã lỗi: " + response.code(), Toast.LENGTH_SHORT).show();
} }
}
@Override @Override
public void onFailure(Call<CustomResponse> call, Throwable t) { public void onFailure(Call<CustomResponse> call, Throwable t) {
Toast.makeText(OrderDetailActivity.this, Common.ERROR_CONNECT_SERVER, Toast.LENGTH_SHORT).show(); Toast.makeText(OrderDetailActivity.this, Common.ERROR_CONNECT_SERVER, Toast.LENGTH_SHORT).show();
} }
}); });
} else{
Common.showErrorDialog(OrderDetailActivity.this, "Không thể lấy được thông tin đơn, vui lòng thử lại sau!");
}
} }
}); });
@@ -305,6 +304,14 @@ public class OrderDetailActivity extends AppCompatActivity {
@Override @Override
public void onResponse(Call<CustomResponse> call, Response<CustomResponse> response) { public void onResponse(Call<CustomResponse> call, Response<CustomResponse> response) {
if(response.code() == 200){ if(response.code() == 200){
//Remove position on database
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference orderDatabase = database.getReference("Order");
orderDatabase.child(order.getOrderTrackingNumber()).removeValue();
//Show notification
new AestheticDialog.Builder(OrderDetailActivity.this, DialogStyle.TOASTER, DialogType.SUCCESS) new AestheticDialog.Builder(OrderDetailActivity.this, DialogStyle.TOASTER, DialogType.SUCCESS)
.setTitle("THÔNG BÁO!") .setTitle("THÔNG BÁO!")
.setMessage("Đã thay đổi trạng thái đơn thành công!") .setMessage("Đã thay đổi trạng thái đơn thành công!")
@@ -587,6 +594,8 @@ public class OrderDetailActivity extends AppCompatActivity {
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
stopLocationService();
if(Common.CURRENT_LOCATION != null){ if(Common.CURRENT_LOCATION != null){
changeLayoutButton(Common.CURRENT_LOCATION.getLatitude(), Common.CURRENT_LOCATION.getLongitude()); changeLayoutButton(Common.CURRENT_LOCATION.getLatitude(), Common.CURRENT_LOCATION.getLongitude());
} }
@@ -33,8 +33,8 @@ import retrofit2.Response;
public class CancelOrder extends Fragment { public class CancelOrder extends Fragment {
private static int CURRENT_PAGE = 0; private static int CURRENT_PAGE = 0;
private static final int PAGE_SIZE = 8; private static final int PAGE_SIZE = 8;
private static final String SORT_BY = "id"; private static final String SORT_BY = "orderTime";
private static final String SORT_DIR = "asc"; private static final String SORT_DIR = "desc";
private static boolean LAST_PAGE = false; private static boolean LAST_PAGE = false;
private final List<Order> listOrders = new ArrayList<>(); private final List<Order> listOrders = new ArrayList<>();
RecyclerView recyclerView; RecyclerView recyclerView;
@@ -33,8 +33,8 @@ import retrofit2.Response;
public class CompletedOrder extends Fragment { public class CompletedOrder extends Fragment {
private static int CURRENT_PAGE = 0; private static int CURRENT_PAGE = 0;
private static final int PAGE_SIZE = 8; private static final int PAGE_SIZE = 8;
private static final String SORT_BY = "id"; private static final String SORT_BY = "orderTime";
private static final String SORT_DIR = "asc"; private static final String SORT_DIR = "desc";
private static boolean LAST_PAGE = false; private static boolean LAST_PAGE = false;
private final List<Order> listOrders = new ArrayList<>(); private final List<Order> listOrders = new ArrayList<>();
RecyclerView recyclerView; RecyclerView recyclerView;
@@ -33,8 +33,8 @@ import retrofit2.Response;
public class ConfirmedOrder extends Fragment { public class ConfirmedOrder extends Fragment {
private static int CURRENT_PAGE = 0; private static int CURRENT_PAGE = 0;
private static final int PAGE_SIZE = 8; private static final int PAGE_SIZE = 8;
private static final String SORT_BY = "id"; private static final String SORT_BY = "orderTime";
private static final String SORT_DIR = "asc"; private static final String SORT_DIR = "desc";
private static boolean LAST_PAGE = false; private static boolean LAST_PAGE = false;
private final List<Order> listOrders = new ArrayList<>(); private final List<Order> listOrders = new ArrayList<>();
RecyclerView recyclerView; RecyclerView recyclerView;