mirror of
https://github.com/Nezumi-2711/PRM392.git
synced 2026-09-22 13:48:29 +00:00
Fix UI
This commit is contained in:
@@ -10,7 +10,7 @@ android {
|
||||
minSdk 23
|
||||
targetSdk 30
|
||||
versionCode 1
|
||||
versionName "93.0"
|
||||
versionName "94.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@@ -38,7 +38,9 @@ import com.waterbase.foodify.Model.Food;
|
||||
import com.waterbase.foodify.Model.Order;
|
||||
import com.waterbase.foodify.Model.Rating;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
import info.hoang8f.widget.FButton;
|
||||
import io.github.inflationx.calligraphy3.CalligraphyConfig;
|
||||
@@ -201,6 +203,9 @@ public class FoodDetail extends AppCompatActivity implements RatingDialogListene
|
||||
}
|
||||
|
||||
private void getDetailFood(String foodId) {
|
||||
Locale locale = new Locale("vi", "VN");
|
||||
NumberFormat fmt = NumberFormat.getCurrencyInstance(locale);
|
||||
|
||||
foods.child(foodId).addValueEventListener(new ValueEventListener() {
|
||||
@Override
|
||||
public void onDataChange(DataSnapshot dataSnapshot) {
|
||||
@@ -211,7 +216,7 @@ public class FoodDetail extends AppCompatActivity implements RatingDialogListene
|
||||
|
||||
collapsingToolbarLayout.setTitle(currentFood.getName());
|
||||
|
||||
food_price.setText(currentFood.getPrice());
|
||||
food_price.setText(fmt.format(Long.parseLong(currentFood.getPrice())));
|
||||
|
||||
food_name.setText(currentFood.getName());
|
||||
|
||||
|
||||
@@ -41,8 +41,10 @@ import com.waterbase.foodify.Model.Food;
|
||||
import com.waterbase.foodify.Model.Order;
|
||||
import com.waterbase.foodify.ViewHolder.FoodViewHolder;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import io.github.inflationx.calligraphy3.CalligraphyConfig;
|
||||
import io.github.inflationx.calligraphy3.CalligraphyInterceptor;
|
||||
@@ -271,6 +273,10 @@ public class FoodList extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void loadListFood(String categoryId) {
|
||||
|
||||
Locale locale = new Locale("vi", "VN");
|
||||
NumberFormat fmt = NumberFormat.getCurrencyInstance(locale);
|
||||
|
||||
//Create query by category Id
|
||||
Query searchByName = foodList.orderByChild("menuId").equalTo(categoryId);
|
||||
//Create Options with query
|
||||
@@ -284,16 +290,18 @@ public class FoodList extends AppCompatActivity {
|
||||
viewHolder.food_name.setText(model.getName());
|
||||
|
||||
if (Integer.parseInt(model.getDiscount()) > 0) {
|
||||
String foodPrice = model.getPrice() + "đ";
|
||||
|
||||
|
||||
String foodPrice = fmt.format(Long.parseLong(model.getPrice()));
|
||||
long newFoodPrice = Long.parseLong(model.getPrice()) - Long.parseLong(model.getPrice()) * Long.parseLong(model.getDiscount()) / 100;
|
||||
SpannableStringBuilder spnBuilder = new SpannableStringBuilder(foodPrice);
|
||||
StrikethroughSpan strikethroughSpan = new StrikethroughSpan();
|
||||
spnBuilder.setSpan(strikethroughSpan, 0, foodPrice.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
viewHolder.food_price.setText(spnBuilder);
|
||||
viewHolder.newPrice.setText(newFoodPrice + "đ");
|
||||
viewHolder.newPrice.setText(fmt.format(newFoodPrice));
|
||||
viewHolder.discount.setText("- " + model.getDiscount() + "%");
|
||||
} else {
|
||||
viewHolder.food_price.setText(String.format("%s đ", model.getPrice()));
|
||||
viewHolder.food_price.setText(fmt.format(Long.parseLong(model.getPrice())));
|
||||
viewHolder.discount.setVisibility(View.GONE);
|
||||
viewHolder.newPrice.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user