mirror of
https://github.com/Nezumi-2711/Foodify.git
synced 2026-09-22 20:00:50 +00:00
Fix bug
This commit is contained in:
@@ -31,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);
|
||||
|
||||
|
||||
@@ -49,7 +49,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);
|
||||
|
||||
|
||||
@@ -169,18 +169,28 @@ public class SignInActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onResponse(Call<User> call, Response<User> response) {
|
||||
if(response.code() == 200){
|
||||
|
||||
User userData = response.body();
|
||||
if(userData != null){
|
||||
|
||||
//Check user is lock or not
|
||||
if(!userData.isLocked()){
|
||||
|
||||
Common.CURRENT_USER = userData;
|
||||
//Check role account
|
||||
if(userData.getRole().getRoleName().equals("ROLE_USER")){
|
||||
Common.CURRENT_USER = userData;
|
||||
|
||||
//Dismiss progress bar
|
||||
progressLayout.setVisibility(View.GONE);
|
||||
//Dismiss progress bar
|
||||
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{
|
||||
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(listFoodSearch.size() == 0){
|
||||
end_of_list_text_view.setVisibility(View.GONE);
|
||||
searchNotFound.setVisibility(View.VISIBLE);
|
||||
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>() {
|
||||
@Override
|
||||
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
|
||||
LAST_PAGE = response.body().getPage().isLast();
|
||||
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 String phoneNumber;
|
||||
private String roleName;
|
||||
private Role role;
|
||||
private int defaultAddress;
|
||||
private List<Address> addresses;
|
||||
|
||||
@@ -128,4 +129,12 @@ public class User implements Serializable {
|
||||
public void setAddresses(List<Address> addresses) {
|
||||
this.addresses = addresses;
|
||||
}
|
||||
|
||||
public Role getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(Role role) {
|
||||
this.role = role;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user