mirror of
https://github.com/Nezumi-2711/Foodify.git
synced 2026-09-22 20:00:50 +00:00
Add some validate and remove animation when change page
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.capstone.foodify.API;
|
||||
|
||||
import com.capstone.foodify.Model.Category;
|
||||
import com.capstone.foodify.Model.Comment;
|
||||
import com.capstone.foodify.Model.DistrictWardResponse;
|
||||
import com.capstone.foodify.Model.Food;
|
||||
@@ -32,7 +31,7 @@ public interface FoodApi {
|
||||
Gson gson = new GsonBuilder().setDateFormat("HH:mm:ss dd-MM-yyyy").setLenient().create();
|
||||
|
||||
FoodApi apiService = new Retrofit.Builder()
|
||||
.baseUrl("http://192.168.1.183:8080/api/").addConverterFactory(GsonConverterFactory.create(gson))
|
||||
.baseUrl("https://foodify-backend-production.up.railway.app/api/").addConverterFactory(GsonConverterFactory.create(gson))
|
||||
.build()
|
||||
.create(FoodApi.class);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public interface FoodApiToken {
|
||||
|
||||
FoodApiToken apiService = new Retrofit.Builder()
|
||||
.client(client)
|
||||
.baseUrl("http://192.168.1.183:8080/api/").addConverterFactory(GsonConverterFactory.create(gson))
|
||||
.baseUrl("https://foodify-backend-production.up.railway.app/api/").addConverterFactory(GsonConverterFactory.create(gson))
|
||||
.build()
|
||||
.create(FoodApiToken.class);
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@ public class FoodDetailActivity extends AppCompatActivity {
|
||||
|
||||
IS_BUY = response.body().isTrue();
|
||||
|
||||
} else {
|
||||
} else if(response.code() != 404){
|
||||
Toast.makeText(FoodDetailActivity.this, "Đã xảy ra lỗi hệ thống! Mã lỗi: " + response.code(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,21 +211,21 @@ public class MainActivity extends AppCompatActivity {
|
||||
int id = item.getItemId();
|
||||
switch (id) {
|
||||
case R.id.activity_home:
|
||||
viewPager2.setCurrentItem(0);
|
||||
viewPager2.setCurrentItem(0, false);
|
||||
break;
|
||||
case R.id.activity_search:
|
||||
viewPager2.setCurrentItem(1);
|
||||
viewPager2.setCurrentItem(1, false);
|
||||
break;
|
||||
case R.id.activity_basket:
|
||||
if(Common.CURRENT_USER != null){
|
||||
viewPager2.setCurrentItem(2);
|
||||
viewPager2.setCurrentItem(2, false);
|
||||
} else {
|
||||
startActivity(new Intent(MainActivity.this, SignInActivity.class));
|
||||
}
|
||||
break;
|
||||
case R.id.activity_profile:
|
||||
if(Common.CURRENT_USER != null){
|
||||
viewPager2.setCurrentItem(3);
|
||||
viewPager2.setCurrentItem(3, false);
|
||||
} else {
|
||||
startActivity(new Intent(MainActivity.this, SignInActivity.class));
|
||||
}
|
||||
|
||||
@@ -141,12 +141,23 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
//Reload user data
|
||||
Common.reloadUser(this);
|
||||
|
||||
//Check current location is null or not
|
||||
if(Common.CURRENT_LOCATION == null){
|
||||
auto_detect_location.setEnabled(false);
|
||||
new AestheticDialog.Builder(OrderCheckOutActivity.this, DialogStyle.FLAT, DialogType.INFO)
|
||||
.setTitle("Thông báo")
|
||||
.setMessage("Tính năng \"Lấy vị trí theo thiết bị của bạn\" sẽ không khả dụng do ứng dụng chưa được cấp quyền vị trí!")
|
||||
.setCancelable(true).show();
|
||||
}
|
||||
|
||||
|
||||
//Get intent from previous activity
|
||||
if(getIntent() != null){
|
||||
totalProduct = getIntent().getFloatExtra("total", 0);
|
||||
txt_total.setText(Common.changeCurrencyUnit(total));
|
||||
}
|
||||
|
||||
|
||||
|
||||
getLocationShop();
|
||||
|
||||
StrictMode.ThreadPolicy policy = new
|
||||
@@ -239,6 +250,9 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
if(LAT_SHOP != 0.0 && LNG_SHOP != 0.0){
|
||||
total = 0;
|
||||
getDistanceAndCalculateShipCost(finalAddress);
|
||||
|
||||
btn_Pay.setEnabled(true);
|
||||
btn_ZaloPay.setEnabled(true);
|
||||
} else {
|
||||
new AestheticDialog.Builder(OrderCheckOutActivity.this, DialogStyle.FLAT, DialogType.INFO)
|
||||
.setTitle("Thông báo!")
|
||||
@@ -247,6 +261,9 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
.setCancelable(true)
|
||||
.show();
|
||||
progress_layout.setVisibility(View.GONE);
|
||||
|
||||
btn_Pay.setEnabled(false);
|
||||
btn_ZaloPay.setEnabled(false);
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -260,6 +277,9 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
|
||||
txt_total.setText(Common.changeCurrencyUnit(total));
|
||||
progress_layout.setVisibility(View.GONE);
|
||||
|
||||
btn_Pay.setEnabled(true);
|
||||
btn_ZaloPay.setEnabled(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -625,9 +645,12 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
|
||||
private void enabledAllInputAddressOption(){
|
||||
list_address_input.setEnabled(true);
|
||||
manual_input_address.setEnabled(true);
|
||||
take_food_from_shop.setEnabled(true);
|
||||
auto_detect_location.setEnabled(true);
|
||||
manual_input_address.setEnabled(true);
|
||||
if(Common.CURRENT_LOCATION != null){
|
||||
//If current location not null;
|
||||
auto_detect_location.setEnabled(true);
|
||||
}
|
||||
|
||||
spn_list_address.setEnabled(true);
|
||||
edt_address.setEnabled(true);
|
||||
|
||||
Reference in New Issue
Block a user