mirror of
https://github.com/Nezumi-2711/Foodify.git
synced 2026-09-22 13:38:41 +00:00
Fix bug
This commit is contained in:
Generated
-17
@@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="deploymentTargetDropDown">
|
|
||||||
<runningDeviceTargetSelectedWithDropDown>
|
|
||||||
<Target>
|
|
||||||
<type value="RUNNING_DEVICE_TARGET" />
|
|
||||||
<deviceKey>
|
|
||||||
<Key>
|
|
||||||
<type value="VIRTUAL_DEVICE_PATH" />
|
|
||||||
<value value="C:\Users\phanh\.android\avd\Pixel_3a_API_33_x86_64.avd" />
|
|
||||||
</Key>
|
|
||||||
</deviceKey>
|
|
||||||
</Target>
|
|
||||||
</runningDeviceTargetSelectedWithDropDown>
|
|
||||||
<timeTargetWasSelectedWithDropDown value="2023-03-29T09:35:50.968141600Z" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
@@ -31,7 +31,7 @@ public interface FoodApi {
|
|||||||
Gson gson = new GsonBuilder().setDateFormat("HH:mm:ss dd-MM-yyyy").setLenient().create();
|
Gson gson = new GsonBuilder().setDateFormat("HH:mm:ss dd-MM-yyyy").setLenient().create();
|
||||||
|
|
||||||
FoodApi apiService = new Retrofit.Builder()
|
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()
|
.build()
|
||||||
.create(FoodApi.class);
|
.create(FoodApi.class);
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public interface FoodApiToken {
|
|||||||
|
|
||||||
FoodApiToken apiService = new Retrofit.Builder()
|
FoodApiToken apiService = new Retrofit.Builder()
|
||||||
.client(client)
|
.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()
|
.build()
|
||||||
.create(FoodApiToken.class);
|
.create(FoodApiToken.class);
|
||||||
|
|
||||||
|
|||||||
@@ -169,18 +169,28 @@ public class SignInActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<User> call, Response<User> response) {
|
public void onResponse(Call<User> call, Response<User> response) {
|
||||||
if(response.code() == 200){
|
if(response.code() == 200){
|
||||||
|
|
||||||
User userData = response.body();
|
User userData = response.body();
|
||||||
if(userData != null){
|
if(userData != null){
|
||||||
|
|
||||||
//Check user is lock or not
|
//Check user is lock or not
|
||||||
if(!userData.isLocked()){
|
if(!userData.isLocked()){
|
||||||
|
|
||||||
|
//Check role account
|
||||||
|
if(userData.getRole().getRoleName().equals("ROLE_USER")){
|
||||||
Common.CURRENT_USER = userData;
|
Common.CURRENT_USER = userData;
|
||||||
|
|
||||||
//Dismiss progress bar
|
//Dismiss progress bar
|
||||||
progressLayout.setVisibility(View.GONE);
|
progressLayout.setVisibility(View.GONE);
|
||||||
|
|
||||||
startActivity(new Intent(SignInActivity.this, MainActivity.class));
|
startActivity(new Intent(SignInActivity.this, MainActivity.class));
|
||||||
|
} else {
|
||||||
|
Toast.makeText(SignInActivity.this, "Tài khoản không hợp lệ! Vui lòng kiểm tra lại!", Toast.LENGTH_SHORT).show();
|
||||||
|
FirebaseAuth.getInstance().signOut();
|
||||||
|
|
||||||
|
//Dismiss progress bar
|
||||||
|
progressLayout.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Toast.makeText(SignInActivity.this, "Tài khoản của bạn đã bị khoá!", Toast.LENGTH_SHORT).show();
|
Toast.makeText(SignInActivity.this, "Tài khoản của bạn đã bị khoá!", Toast.LENGTH_SHORT).show();
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ public class SearchFragment extends Fragment {
|
|||||||
|
|
||||||
//If search not found
|
//If search not found
|
||||||
if(listFoodSearch.size() == 0){
|
if(listFoodSearch.size() == 0){
|
||||||
|
end_of_list_text_view.setVisibility(View.GONE);
|
||||||
searchNotFound.setVisibility(View.VISIBLE);
|
searchNotFound.setVisibility(View.VISIBLE);
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
@@ -245,6 +246,10 @@ public class SearchFragment extends Fragment {
|
|||||||
FoodApi.apiService.listFoodByCategory(statusCategoryChecked, page, LIMIT, "id", "asc").enqueue(new Callback<Foods>() {
|
FoodApi.apiService.listFoodByCategory(statusCategoryChecked, page, LIMIT, "id", "asc").enqueue(new Callback<Foods>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<Foods> call, Response<Foods> response) {
|
public void onResponse(Call<Foods> call, Response<Foods> response) {
|
||||||
|
|
||||||
|
searchNotFound.setVisibility(View.GONE);
|
||||||
|
end_of_list_text_view.setVisibility(View.GONE);
|
||||||
|
|
||||||
//Init total page and total elements value
|
//Init total page and total elements value
|
||||||
LAST_PAGE = response.body().getPage().isLast();
|
LAST_PAGE = response.body().getPage().isLast();
|
||||||
loadFoodAdapter(response);
|
loadFoodAdapter(response);
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.capstone.foodify.Model;
|
||||||
|
|
||||||
|
public class Role {
|
||||||
|
private int id;
|
||||||
|
private String roleName;
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoleName() {
|
||||||
|
return roleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoleName(String roleName) {
|
||||||
|
this.roleName = roleName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@ public class User implements Serializable {
|
|||||||
private boolean isLocked;
|
private boolean isLocked;
|
||||||
private String phoneNumber;
|
private String phoneNumber;
|
||||||
private String roleName;
|
private String roleName;
|
||||||
|
private Role role;
|
||||||
private int defaultAddress;
|
private int defaultAddress;
|
||||||
private List<Address> addresses;
|
private List<Address> addresses;
|
||||||
|
|
||||||
@@ -128,4 +129,12 @@ public class User implements Serializable {
|
|||||||
public void setAddresses(List<Address> addresses) {
|
public void setAddresses(List<Address> addresses) {
|
||||||
this.addresses = addresses;
|
this.addresses = addresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Role getRole() {
|
||||||
|
return role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRole(Role role) {
|
||||||
|
this.role = role;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user