mirror of
https://github.com/Nezumi-2711/Foodify.git
synced 2026-09-22 20:00:50 +00:00
Fix layout, bug and improvement performance app
This commit is contained in:
@@ -31,11 +31,11 @@ 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);
|
||||
|
||||
@GET("products/enable?pageNo=0&pageSize=10&sortBy=id&sortDir=asc")
|
||||
@GET("products/random?pageSize=10")
|
||||
Call<Foods> recommendFood();
|
||||
|
||||
@GET("products/enable?pageNo=0&pageSize=10&sortBy=createdTime&sortDir=desc")
|
||||
|
||||
@@ -50,7 +50,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);
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
@@ -74,6 +76,40 @@ public class ChangePasswordActivity extends AppCompatActivity {
|
||||
textInput_password.setErrorEnabled(false);
|
||||
}
|
||||
});
|
||||
|
||||
edtPassword.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
textInput_password.setErrorEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
edtPasswordConfirm.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
textInput_password_confirm.setErrorEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean validateData(){
|
||||
|
||||
@@ -208,7 +208,9 @@ public class FoodDetailActivity extends AppCompatActivity {
|
||||
shopName_txt.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startActivity(new Intent(FoodDetailActivity.this, ShopDetailActivity.class));
|
||||
Intent intent = new Intent(FoodDetailActivity.this, ShopDetailActivity.class);
|
||||
intent.putExtra("ShopId", food.getShop().getId());
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
super.onStart();
|
||||
|
||||
//Get user from Paper
|
||||
user = Paper.book().read("user");
|
||||
// user = Paper.book().read("user");
|
||||
|
||||
// Check if user is signed in (non-null) and update UI accordingly.
|
||||
user = mAuth.getCurrentUser();
|
||||
@@ -117,6 +117,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
if (userData != null) {
|
||||
Common.CURRENT_USER = userData;
|
||||
HomeFragment.setNameUser();
|
||||
|
||||
progressLayout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.capstone.foodify.Activity;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
@@ -17,12 +18,15 @@ public class OrderActivity extends AppCompatActivity {
|
||||
ViewPager2 viewPager2;
|
||||
ViewPagerAdapter viewPagerAdapter;
|
||||
ImageView back_image;
|
||||
public static Activity orderActivity;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_order);
|
||||
|
||||
orderActivity = this;
|
||||
|
||||
//Init Component
|
||||
tabLayout = findViewById(R.id.tab_layout);
|
||||
viewPager2 = findViewById(R.id.view_pager);
|
||||
|
||||
@@ -388,7 +388,7 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onClick(@NonNull AestheticDialog.Builder builder) {
|
||||
Common.LIST_BASKET_FOOD.clear();
|
||||
startActivity(new Intent(OrderCheckOutActivity.this, OrderActivity.class));
|
||||
startActivity(new Intent(OrderCheckOutActivity.this, MainActivity.class));
|
||||
builder.dismiss();
|
||||
finish();
|
||||
}
|
||||
|
||||
@@ -138,6 +138,9 @@ public class OrderDetailActivity extends AppCompatActivity {
|
||||
.setOnClickListener(new OnDialogClickListener() {
|
||||
@Override
|
||||
public void onClick(@NonNull AestheticDialog.Builder builder) {
|
||||
|
||||
OrderActivity.orderActivity.finish();
|
||||
|
||||
startActivity(new Intent(OrderDetailActivity.this, OrderActivity.class));
|
||||
builder.dismiss();
|
||||
finish();
|
||||
|
||||
@@ -40,11 +40,10 @@ public class ShopDetailActivity extends AppCompatActivity {
|
||||
private static boolean LAST_PAGE = false;
|
||||
private int shopId;
|
||||
private List<Food> listFood = new ArrayList<>();
|
||||
TextView content_description_text_view, student_shop_text_view, end_of_list_text_view;
|
||||
TextView content_description_text_view, student_shop_text_view, end_of_list_text_view, txt_shop_name;
|
||||
ImageView imageShop, back_image;
|
||||
RecyclerView recycler_view_food_shop;
|
||||
FoodShopAdapter adapter;
|
||||
private CollapsingToolbarLayout collapsingToolbarLayout;
|
||||
private NestedScrollView nestedScrollView;
|
||||
private ProgressBar progressBar;
|
||||
private Shop shop;
|
||||
@@ -60,13 +59,13 @@ public class ShopDetailActivity extends AppCompatActivity {
|
||||
recycler_view_food_shop = findViewById(R.id.recycler_view_food_shop);
|
||||
back_image = findViewById(R.id.back_image);
|
||||
adapter = new FoodShopAdapter(this);
|
||||
collapsingToolbarLayout = findViewById(R.id.collapsing);
|
||||
content_description_text_view = findViewById(R.id.content_description_text_view);
|
||||
student_shop_text_view = findViewById(R.id.student_shop_text_view);
|
||||
nestedScrollView = findViewById(R.id.food_detail);
|
||||
progressBar = findViewById(R.id.progress_bar);
|
||||
end_of_list_text_view = findViewById(R.id.end_of_list_text);
|
||||
progressLayout = findViewById(R.id.progress_layout);
|
||||
txt_shop_name = findViewById(R.id.txt_shop_name);
|
||||
|
||||
//Get data
|
||||
if (getIntent() != null)
|
||||
@@ -159,7 +158,7 @@ public class ShopDetailActivity extends AppCompatActivity {
|
||||
private void initData(Shop shop) {
|
||||
//Init data
|
||||
Picasso.get().load(shop.getImageUrl()).into(imageShop);
|
||||
collapsingToolbarLayout.setTitle(shop.getName());
|
||||
txt_shop_name.setText(shop.getName());
|
||||
content_description_text_view.setText(shop.getDescription());
|
||||
|
||||
//If shop is studentShop, enable tag student shop
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.capstone.foodify.Activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
@@ -17,6 +19,7 @@ import com.capstone.foodify.Fragment.HomeFragment;
|
||||
import com.capstone.foodify.Model.User;
|
||||
import com.capstone.foodify.R;
|
||||
import com.google.android.gms.tasks.OnCompleteListener;
|
||||
import com.google.android.gms.tasks.OnFailureListener;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
@@ -26,6 +29,7 @@ import com.google.firebase.auth.AuthResult;
|
||||
import com.google.firebase.auth.FirebaseAuth;
|
||||
import com.google.firebase.auth.FirebaseUser;
|
||||
import com.google.firebase.auth.GetTokenResult;
|
||||
import com.google.firebase.auth.SignInMethodQueryResult;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -99,6 +103,24 @@ public class SignInActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
edt_password.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
textInput_password.setErrorEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initData(){
|
||||
@@ -146,7 +168,26 @@ public class SignInActivity extends AppCompatActivity {
|
||||
|
||||
mAuth.setLanguageCode("vi");
|
||||
|
||||
mAuth.signInWithEmailAndPassword(edt_email.getText().toString(), edt_password.getText().toString())
|
||||
mAuth.fetchSignInMethodsForEmail(email)
|
||||
.addOnCompleteListener(new OnCompleteListener<SignInMethodQueryResult>() {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<SignInMethodQueryResult> task) {
|
||||
|
||||
boolean isNewUser = task.getResult().getSignInMethods().isEmpty();
|
||||
|
||||
if (isNewUser) {
|
||||
Toast.makeText(SignInActivity.this, "Tài khoản chưa được đăng ký! Vui lòng đăng ký để tiếp tục sử dụng!", Toast.LENGTH_SHORT).show();
|
||||
progressLayout.setVisibility(View.GONE);
|
||||
} else {
|
||||
signInMethod();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void signInMethod(){
|
||||
mAuth.signInWithEmailAndPassword(email, password)
|
||||
.addOnCompleteListener(SignInActivity.this, new OnCompleteListener<AuthResult>() {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<AuthResult> task) {
|
||||
@@ -155,7 +196,7 @@ public class SignInActivity extends AppCompatActivity {
|
||||
FirebaseUser user = mAuth.getCurrentUser();
|
||||
|
||||
//Save user
|
||||
Paper.book().write("user", user);
|
||||
// Paper.book().write("user", user);
|
||||
|
||||
user.getIdToken(true)
|
||||
.addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
@@ -103,6 +104,7 @@ public class VerifyAccountActivity extends AppCompatActivity {
|
||||
//Init text changedListener
|
||||
textChangedListenerEditTextOTP();
|
||||
|
||||
|
||||
//Add event to confirm button
|
||||
confirm_code.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -283,104 +285,119 @@ public class VerifyAccountActivity extends AppCompatActivity {
|
||||
inputCode1.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
if(inputCode1.getText().toString().length()== 0) //size as per your requirement
|
||||
{
|
||||
inputCode2.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
// Nothing to do
|
||||
if (s.length() == 1) {
|
||||
inputCode2.requestFocus(View.FOCUS_DOWN);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
// Nothing to do
|
||||
}
|
||||
});
|
||||
|
||||
inputCode2.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
if(inputCode2.getText().toString().length()== 0) //size as per your requirement
|
||||
{
|
||||
inputCode3.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
// Nothing to do
|
||||
if(count == 0) {
|
||||
inputCode1.requestFocus(View.FOCUS_DOWN);
|
||||
} else {
|
||||
if (s.length() == 1) {
|
||||
inputCode3.requestFocus(View.FOCUS_DOWN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
// Nothing to do
|
||||
}
|
||||
});
|
||||
|
||||
inputCode3.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
if(inputCode3.getText().toString().length()== 0) //size as per your requirement
|
||||
{
|
||||
inputCode4.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
// Nothing to do
|
||||
if(count == 0) {
|
||||
inputCode2.requestFocus(View.FOCUS_DOWN);
|
||||
} else {
|
||||
if (s.length() == 1) {
|
||||
inputCode4.requestFocus(View.FOCUS_DOWN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
// Nothing to do
|
||||
}
|
||||
});
|
||||
|
||||
inputCode4.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
if(inputCode4.getText().toString().length()== 0) //size as per your requirement
|
||||
{
|
||||
inputCode5.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
// Nothing to do
|
||||
if(count == 0) {
|
||||
inputCode3.requestFocus(View.FOCUS_DOWN);
|
||||
} else {
|
||||
if (s.length() == 1) {
|
||||
inputCode5.requestFocus(View.FOCUS_DOWN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
// Nothing to do
|
||||
}
|
||||
});
|
||||
|
||||
inputCode5.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
if(inputCode5.getText().toString().length()== 0) //size as per your requirement
|
||||
{
|
||||
inputCode6.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
// Nothing to do
|
||||
if(count == 0) {
|
||||
inputCode4.requestFocus(View.FOCUS_DOWN);
|
||||
} else {
|
||||
if (s.length() == 1) {
|
||||
inputCode6.requestFocus(View.FOCUS_DOWN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
});
|
||||
|
||||
inputCode6.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
if(count == 0) {
|
||||
inputCode5.requestFocus(View.FOCUS_DOWN);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
// Nothing to do
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void requestSMSPermission()
|
||||
{
|
||||
String permission = Manifest.permission.RECEIVE_SMS;
|
||||
|
||||
@@ -51,9 +51,9 @@ public class FoodAdapter extends RecyclerView.Adapter<FoodAdapter.FoodViewHolder
|
||||
}
|
||||
|
||||
String foodName = food.getName();
|
||||
if(foodName.length() >= 30){
|
||||
if(foodName.length() >= 24){
|
||||
StringBuilder stringBuilder = new StringBuilder(food.getName());
|
||||
stringBuilder.replace(30, food.getName().length(), "..." );
|
||||
stringBuilder.replace(24, food.getName().length(), "..." );
|
||||
holder.name.setText(stringBuilder);
|
||||
} else {
|
||||
holder.name.setText(foodName);
|
||||
|
||||
@@ -49,7 +49,16 @@ public class ShopAdapter extends RecyclerView.Adapter<ShopAdapter.ShopViewHolder
|
||||
|
||||
//Init data
|
||||
Picasso.get().load(shop.getImageUrl()).into(holder.imageView);
|
||||
holder.shopName.setText(shop.getName());
|
||||
|
||||
String shopName = shop.getName();
|
||||
|
||||
if(shopName.length() >= 24){
|
||||
StringBuilder stringBuilder = new StringBuilder(shop.getName());
|
||||
stringBuilder.replace(24, shop.getName().length(), "..." );
|
||||
holder.shopName.setText(stringBuilder);
|
||||
} else {
|
||||
holder.shopName.setText(shopName);
|
||||
}
|
||||
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
||||
@@ -128,7 +128,7 @@ public class HomeFragment extends Fragment {
|
||||
List<Menu> listMenu = new ArrayList<>();
|
||||
|
||||
listMenu.add(new Menu("Món ăn khuyến nghị", listFood));
|
||||
listMenu.add(new Menu("Món ăn phổ biến", recentFood));
|
||||
listMenu.add(new Menu("Món ăn được thêm gần đây", recentFood));
|
||||
|
||||
return listMenu;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ public class ProfileFragment extends Fragment {
|
||||
FirebaseAuth.getInstance().signOut();
|
||||
|
||||
//Delete user from local storage
|
||||
Paper.book().delete("user");
|
||||
// Paper.book().delete("user");
|
||||
|
||||
Common.TOKEN = null;
|
||||
Common.CURRENT_USER = null;
|
||||
|
||||
Reference in New Issue
Block a user