mirror of
https://github.com/Nezumi-2711/Foodify.git
synced 2026-09-22 13:38:41 +00:00
Add order detail screen, fix calculate of price food
This commit is contained in:
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
<bytecodeTargetLevel target="11" />
|
<bytecodeTargetLevel target="17" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
Generated
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
<option name="testRunner" value="GRADLE" />
|
<option name="testRunner" value="GRADLE" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="Embedded JDK" />
|
<option name="gradleJvm" value="JDK" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
|||||||
Generated
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="jbr-11" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class FoodDetailActivity extends AppCompatActivity {
|
|||||||
private ImageView back_image, not_favorite, is_favorite;
|
private ImageView back_image, not_favorite, is_favorite;
|
||||||
private String foodId = "";
|
private String foodId = "";
|
||||||
private Food food;
|
private Food food;
|
||||||
private TextView foodName_txt, shopName_txt, discount_txt, price_txt, total_txt, countRating_txt, description_content_txt;
|
private TextView foodName_txt, shopName_txt, discount_txt, price_txt, countRating_txt, description_content_txt;
|
||||||
private ConstraintLayout content_view;
|
private ConstraintLayout content_view;
|
||||||
private Button add_to_basket_button;
|
private Button add_to_basket_button;
|
||||||
private float totalPrice, price;
|
private float totalPrice, price;
|
||||||
@@ -79,7 +79,6 @@ public class FoodDetailActivity extends AppCompatActivity {
|
|||||||
add_to_basket_button = findViewById(R.id.add_to_basket_button);
|
add_to_basket_button = findViewById(R.id.add_to_basket_button);
|
||||||
not_favorite = findViewById(R.id.not_favorite);
|
not_favorite = findViewById(R.id.not_favorite);
|
||||||
is_favorite = findViewById(R.id.is_favorite);
|
is_favorite = findViewById(R.id.is_favorite);
|
||||||
total_txt = findViewById(R.id.total_text_view);
|
|
||||||
countRating_txt = findViewById(R.id.count_rating_text_view);
|
countRating_txt = findViewById(R.id.count_rating_text_view);
|
||||||
description_content_txt = findViewById(R.id.content_description_text_view);
|
description_content_txt = findViewById(R.id.content_description_text_view);
|
||||||
recyclerView_review = findViewById(R.id.recycler_view_review);
|
recyclerView_review = findViewById(R.id.recycler_view_review);
|
||||||
@@ -279,12 +278,9 @@ public class FoodDetailActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initData() {
|
private void initData() {
|
||||||
//Set data price to calculate
|
|
||||||
price = food.getCost();
|
|
||||||
|
|
||||||
foodName_txt.setText(food.getName());
|
foodName_txt.setText(food.getName());
|
||||||
shopName_txt.setText(food.getShop().getName());
|
shopName_txt.setText(food.getShop().getName());
|
||||||
price_txt.setText(Common.changeCurrencyUnit(food.getCost()));
|
|
||||||
description_content_txt.setText(food.getDescription());
|
description_content_txt.setText(food.getDescription());
|
||||||
countRating_txt.setText(food.getReviewCount() + " rating");
|
countRating_txt.setText(food.getReviewCount() + " rating");
|
||||||
|
|
||||||
@@ -301,11 +297,22 @@ public class FoodDetailActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
imageSlider.setImageList(slideModels, ScaleTypes.FIT);
|
imageSlider.setImageList(slideModels, ScaleTypes.FIT);
|
||||||
|
|
||||||
//Show discount percent when value greater than 0
|
//Show discount percent when value greater than 0 and show the final cost after discount!
|
||||||
if (food.getDiscountPercent() > 0) {
|
if (food.getDiscountPercent() > 0) {
|
||||||
discount_txt.setText("-" + food.getDiscountPercent() + "%");
|
discount_txt.setText("-" + food.getDiscountPercent() + "%");
|
||||||
|
|
||||||
|
float finalCost = food.getCost() - (food.getCost() * food.getDiscountPercent() / 100);
|
||||||
|
price_txt.setText(Common.changeCurrencyUnit(finalCost));
|
||||||
|
|
||||||
|
//Set data price to calculate
|
||||||
|
price = finalCost;
|
||||||
} else {
|
} else {
|
||||||
discount_txt.setVisibility(View.GONE);
|
discount_txt.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
price_txt.setText(Common.changeCurrencyUnit(food.getCost()));
|
||||||
|
|
||||||
|
//Set data price to calculate
|
||||||
|
price = food.getCost();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,40 +1,422 @@
|
|||||||
package com.capstone.foodify.Activity;
|
package com.capstone.foodify.Activity;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.RadioButton;
|
||||||
|
import android.widget.RadioGroup;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.capstone.foodify.API.FoodApi;
|
||||||
import com.capstone.foodify.Adapter.OrderDetailAdapter;
|
import com.capstone.foodify.Adapter.OrderDetailAdapter;
|
||||||
|
import com.capstone.foodify.Common;
|
||||||
|
import com.capstone.foodify.Model.Address;
|
||||||
|
import com.capstone.foodify.Model.Basket;
|
||||||
|
import com.capstone.foodify.Model.DistrictWardResponse;
|
||||||
import com.capstone.foodify.Model.OrderDetail;
|
import com.capstone.foodify.Model.OrderDetail;
|
||||||
import com.capstone.foodify.R;
|
import com.capstone.foodify.R;
|
||||||
|
import com.google.android.material.textfield.TextInputLayout;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class OrderCheckOutActivity extends AppCompatActivity {
|
import retrofit2.Call;
|
||||||
|
import retrofit2.Callback;
|
||||||
|
import retrofit2.Response;
|
||||||
|
|
||||||
public List<OrderDetail> listOrderDetails = new ArrayList<>();
|
public class OrderCheckOutActivity extends AppCompatActivity {
|
||||||
|
private static String finalAddress = null;
|
||||||
|
ImageView back_image;
|
||||||
OrderDetailAdapter adapter;
|
OrderDetailAdapter adapter;
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
|
TextView txt_userName, txt_phone, edt_address_detect, errorTextDistrictWard, txt_total;
|
||||||
|
TextInputLayout textInput_address;
|
||||||
|
EditText edt_address;
|
||||||
|
Spinner spn_list_address, spn_district, spn_ward;
|
||||||
|
ConstraintLayout manual_input_address_layout;
|
||||||
|
Button change_address_button, confirm_address_button;
|
||||||
|
RadioButton list_address_input, auto_detect_location, manual_input_address, radio_button_selected;
|
||||||
|
RadioGroup address_option;
|
||||||
|
float total;
|
||||||
|
private static final ArrayList<String> wardList = new ArrayList<>();
|
||||||
|
private static final ArrayList<String> districtList = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_order_check_out);
|
setContentView(R.layout.activity_order_check_out);
|
||||||
|
|
||||||
|
//Check user is login or not!
|
||||||
|
if(Common.CURRENT_USER == null)
|
||||||
|
startActivity(new Intent(this, SignInActivity.class));
|
||||||
|
|
||||||
|
|
||||||
|
//Init Component
|
||||||
|
txt_userName = findViewById(R.id.txt_userName);
|
||||||
|
txt_phone = findViewById(R.id.txt_phone);
|
||||||
|
spn_list_address = findViewById(R.id.list_address);
|
||||||
|
spn_district = findViewById(R.id.district);
|
||||||
|
spn_ward = findViewById(R.id.ward);
|
||||||
|
edt_address_detect = findViewById(R.id.edt_address_detect);
|
||||||
|
manual_input_address_layout = findViewById(R.id.manual_input_address_layout);
|
||||||
adapter = new OrderDetailAdapter();
|
adapter = new OrderDetailAdapter();
|
||||||
recyclerView = findViewById(R.id.list_order);
|
recyclerView = findViewById(R.id.list_order);
|
||||||
|
back_image = findViewById(R.id.back_image);
|
||||||
|
change_address_button = findViewById(R.id.change_address_button);
|
||||||
|
confirm_address_button = findViewById(R.id.confirm_address_button);
|
||||||
|
list_address_input = findViewById(R.id.list_address_input);
|
||||||
|
auto_detect_location = findViewById(R.id.auto_detect_location);
|
||||||
|
manual_input_address = findViewById(R.id.manual_input_address);
|
||||||
|
edt_address = findViewById(R.id.edt_address);
|
||||||
|
address_option = findViewById(R.id.address_option);
|
||||||
|
errorTextDistrictWard = findViewById(R.id.errorTextDistrictWard);
|
||||||
|
textInput_address = findViewById(R.id.textInput_address);
|
||||||
|
txt_total = findViewById(R.id.txt_total);
|
||||||
|
|
||||||
for(int i = 0; i < 5; i++){
|
if(getIntent() != null){
|
||||||
listOrderDetails.add(new OrderDetail());
|
total = getIntent().getFloatExtra("total", 0);
|
||||||
|
txt_total.setText(Common.changeCurrencyUnit(total));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Show list food in basket
|
||||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, RecyclerView.VERTICAL, false);
|
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, RecyclerView.VERTICAL, false);
|
||||||
recyclerView.setLayoutManager(linearLayoutManager);
|
recyclerView.setLayoutManager(linearLayoutManager);
|
||||||
|
|
||||||
adapter.setData(listOrderDetails);
|
adapter.setData(Common.LIST_BASKET_FOOD);
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
|
showListAddressUser();
|
||||||
|
|
||||||
|
//Get list district, ward
|
||||||
|
initDataDistrictWard();
|
||||||
|
|
||||||
|
//Set user name and phone
|
||||||
|
txt_userName.setText(Common.CURRENT_USER.getFullName());
|
||||||
|
txt_phone.setText(Common.CURRENT_USER.getPhoneNumber());
|
||||||
|
|
||||||
|
//Set event for change address button
|
||||||
|
change_address_button.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
confirm_address_button.setEnabled(true);
|
||||||
|
change_address_button.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
enabledAllInputAddressOption();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Set event for confirm address button
|
||||||
|
confirm_address_button.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
int selectedOptionId = address_option.getCheckedRadioButtonId();
|
||||||
|
|
||||||
|
radio_button_selected = findViewById(selectedOptionId);
|
||||||
|
|
||||||
|
if(radio_button_selected == list_address_input){
|
||||||
|
//Action 1
|
||||||
|
finalAddress = spn_list_address.getSelectedItem().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(radio_button_selected == auto_detect_location){
|
||||||
|
//Action 2
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(radio_button_selected == manual_input_address){
|
||||||
|
//Action 3
|
||||||
|
if(validForm()){
|
||||||
|
if(spn_district.getSelectedItem().toString().equals("Huyện Hoàng Sa")){
|
||||||
|
finalAddress = edt_address.getText().toString() + ", " + spn_district.getSelectedItem().toString();
|
||||||
|
} else {
|
||||||
|
finalAddress = edt_address.getText().toString() + ", " + spn_ward.getSelectedItem().toString() + ", " + spn_district.getSelectedItem().toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(finalAddress == null){
|
||||||
|
Toast.makeText(OrderCheckOutActivity.this, "Bạn chưa chọn địa chỉ!", Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(OrderCheckOutActivity.this, finalAddress, Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
confirm_address_button.setEnabled(false);
|
||||||
|
change_address_button.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
disableAllInputAddressOption();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Set event for back icon
|
||||||
|
back_image.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
onBackPressed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean validForm(){
|
||||||
|
//Valid data
|
||||||
|
boolean dataHasValidate = true;
|
||||||
|
|
||||||
|
//Check address
|
||||||
|
if(edt_address.getText().toString().length() < 8) {
|
||||||
|
textInput_address.setError("Trường địa chỉ của bạn tối thiếu từ 8 ký tự trở lên");
|
||||||
|
dataHasValidate = false;
|
||||||
|
} else {
|
||||||
|
textInput_address.setErrorEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check district and ward
|
||||||
|
if(spn_district.getSelectedItem().toString().equals("---Quận") || spn_ward.getSelectedItem().toString().equals("---Phường")){
|
||||||
|
|
||||||
|
if(!spn_district.getSelectedItem().toString().equals("Huyện Hoàng Sa")){
|
||||||
|
errorTextDistrictWard.setVisibility(View.VISIBLE);
|
||||||
|
dataHasValidate = false;
|
||||||
|
} else{
|
||||||
|
errorTextDistrictWard.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
errorTextDistrictWard.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dataHasValidate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initDataDistrictWard(){
|
||||||
|
if(districtList.size() == 0){
|
||||||
|
getListDistrict();
|
||||||
|
} else {
|
||||||
|
setAdapter(districtList, "---Quận", spn_district);
|
||||||
|
}
|
||||||
|
getListWard(0);
|
||||||
|
|
||||||
|
//Add event for district spinner
|
||||||
|
spn_district.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
|
getListWard(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNothingSelected(AdapterView<?> adapterView) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void disableAllInputAddressOption(){
|
||||||
|
list_address_input.setEnabled(false);
|
||||||
|
auto_detect_location.setEnabled(false);
|
||||||
|
manual_input_address.setEnabled(false);
|
||||||
|
|
||||||
|
spn_list_address.setEnabled(false);
|
||||||
|
edt_address.setEnabled(false);
|
||||||
|
spn_ward.setEnabled(false);
|
||||||
|
spn_district.setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void enabledAllInputAddressOption(){
|
||||||
|
list_address_input.setEnabled(true);
|
||||||
|
auto_detect_location.setEnabled(true);
|
||||||
|
manual_input_address.setEnabled(true);
|
||||||
|
|
||||||
|
spn_list_address.setEnabled(true);
|
||||||
|
edt_address.setEnabled(true);
|
||||||
|
spn_ward.setEnabled(true);
|
||||||
|
spn_district.setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showListAddressUser(){
|
||||||
|
List<String> listAddress = new ArrayList<>();
|
||||||
|
String defaultAddress = "";
|
||||||
|
|
||||||
|
//Get all list address
|
||||||
|
for(Address tempAddress: Common.CURRENT_USER.getAddresses()){
|
||||||
|
String fullAddress;
|
||||||
|
|
||||||
|
if(tempAddress.getWard().equals("---Phường")){
|
||||||
|
fullAddress = tempAddress.getAddress() + ", " + tempAddress.getDistrict();
|
||||||
|
} else {
|
||||||
|
fullAddress = tempAddress.getAddress() + ", " + tempAddress.getWard() + ", " + tempAddress.getDistrict();
|
||||||
|
}
|
||||||
|
|
||||||
|
listAddress.add(fullAddress);
|
||||||
|
|
||||||
|
if(tempAddress.getId() == Common.CURRENT_USER.getDefaultAddress()){
|
||||||
|
defaultAddress = fullAddress;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, listAddress);
|
||||||
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
|
||||||
|
spn_list_address.setAdapter(adapter);
|
||||||
|
spn_list_address.setSelection(listAddress.indexOf(defaultAddress));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onRadioButtonClicked(View view) {
|
||||||
|
// Is the button now checked?
|
||||||
|
boolean checked = ((RadioButton) view).isChecked();
|
||||||
|
|
||||||
|
// Check which radio button was clicked
|
||||||
|
switch(view.getId()) {
|
||||||
|
case R.id.list_address_input:
|
||||||
|
if (checked){
|
||||||
|
//If option 1 is checked
|
||||||
|
//Config UI
|
||||||
|
spn_list_address.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
edt_address_detect.setVisibility(View.GONE);
|
||||||
|
manual_input_address_layout.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
//Reset address;
|
||||||
|
finalAddress = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case R.id.auto_detect_location:
|
||||||
|
if (checked){
|
||||||
|
//If option 2 is checked
|
||||||
|
//Config UI
|
||||||
|
edt_address_detect.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
spn_list_address.setVisibility(View.GONE);
|
||||||
|
manual_input_address_layout.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
//Reset address;
|
||||||
|
finalAddress = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case R.id.manual_input_address:
|
||||||
|
if (checked){
|
||||||
|
//If option 3 is checked
|
||||||
|
//Config UI
|
||||||
|
manual_input_address_layout.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
spn_list_address.setVisibility(View.GONE);
|
||||||
|
edt_address_detect.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
//Reset address;
|
||||||
|
finalAddress = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getListDistrict() {
|
||||||
|
|
||||||
|
districtList.add("---Quận");
|
||||||
|
|
||||||
|
FoodApi.apiService.districtResponse().enqueue(new Callback<List<DistrictWardResponse>>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<List<DistrictWardResponse>> call, Response<List<DistrictWardResponse>> response) {
|
||||||
|
List<DistrictWardResponse> districtResponse = response.body();
|
||||||
|
if(districtResponse != null){
|
||||||
|
for(DistrictWardResponse tempDistrict: districtResponse){
|
||||||
|
districtList.add(tempDistrict.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setAdapter(districtList, "---Quận", spn_district);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<List<DistrictWardResponse>> call, Throwable t) {
|
||||||
|
Toast.makeText(OrderCheckOutActivity.this, "Đã xảy ra lỗi hệ thống. Vui lòng thử lại sau!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getListWard(int districtCode) {
|
||||||
|
|
||||||
|
if(wardList.size() > 1)
|
||||||
|
wardList.clear();
|
||||||
|
|
||||||
|
if(wardList.size() == 0)
|
||||||
|
wardList.add("---Phường");
|
||||||
|
|
||||||
|
spn_ward.setEnabled(false);
|
||||||
|
|
||||||
|
if(districtCode != 0){
|
||||||
|
FoodApi.apiService.wardResponse(districtCode).enqueue(new Callback<List<DistrictWardResponse>>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<List<DistrictWardResponse>> call, Response<List<DistrictWardResponse>> response) {
|
||||||
|
List<DistrictWardResponse> wardData = response.body();
|
||||||
|
|
||||||
|
if(wardData != null){
|
||||||
|
for(DistrictWardResponse tempWard: wardData){
|
||||||
|
wardList.add(tempWard.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(wardList.size() <= 1){
|
||||||
|
spn_ward.setEnabled(false);
|
||||||
|
} else {
|
||||||
|
spn_ward.setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
setAdapter(wardList, "---Phường", spn_ward);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<List<DistrictWardResponse>> call, Throwable t) {
|
||||||
|
Toast.makeText(OrderCheckOutActivity.this, "Đã xảy ra lỗi hệ thống. Vui lòng thử lại sau!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setAdapter(wardList, "---Phường", spn_ward);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAdapter(ArrayList<String> data, String defaultItem, Spinner dataSpinner){
|
||||||
|
OrderCheckOutActivity.MySpinnerAdapter adapterWard = new OrderCheckOutActivity.MySpinnerAdapter(getApplicationContext(), android.R.layout.simple_spinner_item, data);
|
||||||
|
dataSpinner.setAdapter(adapterWard); // this will set list of values to spinner
|
||||||
|
dataSpinner.setSelection(data.indexOf(defaultItem));//set selected value in spinner
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class MySpinnerAdapter extends ArrayAdapter<String> {
|
||||||
|
// Initialise custom font, for example:
|
||||||
|
Typeface font = Typeface.createFromAsset(getContext().getAssets(),
|
||||||
|
"font/bebas.ttf");
|
||||||
|
|
||||||
|
// (In reality I used a manager which caches the Typeface objects)
|
||||||
|
// Typeface font = FontManager.getInstance().getFont(getContext(), BLAMBOT);
|
||||||
|
|
||||||
|
private MySpinnerAdapter(Context context, int resource, List<String> items) {
|
||||||
|
super(context, resource, items);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Affects default (closed) state of the spinner
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
TextView view = (TextView) super.getView(position, convertView, parent);
|
||||||
|
view.setTypeface(font);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Affects opened state of the spinner
|
||||||
|
@Override
|
||||||
|
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||||
|
TextView view = (TextView) super.getDropDownView(position, convertView, parent);
|
||||||
|
view.setTypeface(font);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ public class OrderDetailActivity extends AppCompatActivity {
|
|||||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, RecyclerView.VERTICAL, false);
|
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, RecyclerView.VERTICAL, false);
|
||||||
recyclerView.setLayoutManager(linearLayoutManager);
|
recyclerView.setLayoutManager(linearLayoutManager);
|
||||||
|
|
||||||
adapter.setData(listOrderDetails);
|
// adapter.setData(listOrderDetails);
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
back_image.setOnClickListener(new View.OnClickListener() {
|
back_image.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|||||||
@@ -54,9 +54,24 @@ public class BasketAdapter extends RecyclerView.Adapter<BasketAdapter.BasketView
|
|||||||
//Init data
|
//Init data
|
||||||
holder.foodName.setText(foodBasket.getName());
|
holder.foodName.setText(foodBasket.getName());
|
||||||
holder.shopName.setText(foodBasket.getShopName());
|
holder.shopName.setText(foodBasket.getShopName());
|
||||||
holder.price.setText(Common.changeCurrencyUnit(foodBasket.getCost()));
|
|
||||||
holder.quantity.setNumber(foodBasket.getQuantity());
|
holder.quantity.setNumber(foodBasket.getQuantity());
|
||||||
|
|
||||||
|
//Check value discountPercent
|
||||||
|
float cost = 0;
|
||||||
|
if(foodBasket.getDiscountPercent() > 0){
|
||||||
|
|
||||||
|
//Calculate final cost when apply discountPercent
|
||||||
|
cost = foodBasket.getCost() - (foodBasket.getCost() * foodBasket.getDiscountPercent()/100);
|
||||||
|
|
||||||
|
//Show discountPercent value on screen
|
||||||
|
holder.discount.setVisibility(View.VISIBLE);
|
||||||
|
holder.discount.setText("-" + foodBasket.getDiscountPercent()+ "%");
|
||||||
|
} else {
|
||||||
|
cost = foodBasket.getCost();
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.price.setText(Common.changeCurrencyUnit(cost));
|
||||||
|
|
||||||
//Check food image is null or not null
|
//Check food image is null or not null
|
||||||
if(foodBasket.getImg() == null){
|
if(foodBasket.getImg() == null){
|
||||||
holder.imageView.setImageResource(R.drawable.default_image_food);
|
holder.imageView.setImageResource(R.drawable.default_image_food);
|
||||||
@@ -88,9 +103,10 @@ public class BasketAdapter extends RecyclerView.Adapter<BasketAdapter.BasketView
|
|||||||
float total = 0;
|
float total = 0;
|
||||||
|
|
||||||
for(Basket foodTemp: listBasketFood){
|
for(Basket foodTemp: listBasketFood){
|
||||||
total += (foodTemp.getCost()) * (Float.parseFloat(foodTemp.getQuantity())) * (100 - foodTemp.getDiscount())/100;
|
total += (foodTemp.getCost()) * (Float.parseFloat(foodTemp.getQuantity())) * (100 - foodTemp.getDiscountPercent())/100;
|
||||||
}
|
}
|
||||||
basketFragment.total.setText(Common.changeCurrencyUnit(total));
|
basketFragment.total.setText(Common.changeCurrencyUnit(total));
|
||||||
|
basketFragment.totalFloat = total;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -102,7 +118,7 @@ public class BasketAdapter extends RecyclerView.Adapter<BasketAdapter.BasketView
|
|||||||
|
|
||||||
public static class BasketViewHolder extends RecyclerView.ViewHolder{
|
public static class BasketViewHolder extends RecyclerView.ViewHolder{
|
||||||
|
|
||||||
TextView foodName, shopName, price, total;
|
TextView foodName, shopName, price, total, discount;
|
||||||
public LinearLayout layoutForeGround;
|
public LinearLayout layoutForeGround;
|
||||||
ImageView imageView;
|
ImageView imageView;
|
||||||
ElegantNumberButton quantity;
|
ElegantNumberButton quantity;
|
||||||
@@ -117,6 +133,7 @@ public class BasketAdapter extends RecyclerView.Adapter<BasketAdapter.BasketView
|
|||||||
imageView = itemView.findViewById(R.id.image_view);
|
imageView = itemView.findViewById(R.id.image_view);
|
||||||
quantity = itemView.findViewById(R.id.quantity);
|
quantity = itemView.findViewById(R.id.quantity);
|
||||||
total = itemView.findViewById(R.id.total_text_view);
|
total = itemView.findViewById(R.id.total_text_view);
|
||||||
|
discount = itemView.findViewById(R.id.discount);
|
||||||
|
|
||||||
layoutForeGround = itemView.findViewById(R.id.layout_foreground);
|
layoutForeGround = itemView.findViewById(R.id.layout_foreground);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import android.widget.TextView;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.capstone.foodify.Common;
|
||||||
|
import com.capstone.foodify.Model.Basket;
|
||||||
import com.capstone.foodify.Model.OrderDetail;
|
import com.capstone.foodify.Model.OrderDetail;
|
||||||
import com.capstone.foodify.R;
|
import com.capstone.foodify.R;
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
@@ -17,12 +19,12 @@ import java.util.List;
|
|||||||
|
|
||||||
public class OrderDetailAdapter extends RecyclerView.Adapter<OrderDetailAdapter.OrderDetailViewHolder>{
|
public class OrderDetailAdapter extends RecyclerView.Adapter<OrderDetailAdapter.OrderDetailViewHolder>{
|
||||||
|
|
||||||
public List<OrderDetail> listOrderDetails;
|
public List<Basket> listFoodInBasket;
|
||||||
|
|
||||||
public OrderDetailAdapter(){}
|
public OrderDetailAdapter(){}
|
||||||
|
|
||||||
public void setData(List<OrderDetail> listOrderDetails){
|
public void setData(List<Basket> listFoodInBasket){
|
||||||
this.listOrderDetails = listOrderDetails;
|
this.listFoodInBasket = listFoodInBasket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -35,28 +37,43 @@ public class OrderDetailAdapter extends RecyclerView.Adapter<OrderDetailAdapter.
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull OrderDetailViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull OrderDetailViewHolder holder, int position) {
|
||||||
OrderDetail orderDetail = listOrderDetails.get(position);
|
Basket food = listFoodInBasket.get(position);
|
||||||
|
|
||||||
if(orderDetail == null)
|
if(food == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Picasso.get().load("https://images.unsplash.com/photo-1546069901-ba9599a7e63c?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxleHBsb3JlLWZlZWR8MXx8fGVufDB8fHx8&w=1000&q=80").into(holder.image_view);
|
Picasso.get().load(food.getImg()).into(holder.image_view);
|
||||||
holder.food_name.setText("Food Name");
|
holder.food_name.setText(food.getName());
|
||||||
holder.shop_name.setText("Shop Name");
|
holder.shop_name.setText(food.getShopName());
|
||||||
holder.price.setText("120000 đ");
|
holder.quantity.setText("Số lượng: " + food.getQuantity());
|
||||||
holder.quantity.setText("Số lượng: 2");
|
|
||||||
|
//Check value discountPercent
|
||||||
|
float cost = 0;
|
||||||
|
if(food.getDiscountPercent() > 0){
|
||||||
|
|
||||||
|
//Calculate final cost when apply discountPercent
|
||||||
|
cost = food.getCost() - (food.getCost() * food.getDiscountPercent()/100);
|
||||||
|
|
||||||
|
//Show discountPercent value on screen
|
||||||
|
holder.discount.setVisibility(View.VISIBLE);
|
||||||
|
holder.discount.setText("-" + food.getDiscountPercent()+ "%");
|
||||||
|
} else {
|
||||||
|
cost = food.getCost();
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.price.setText(Common.changeCurrencyUnit(cost));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
if(listOrderDetails != null)
|
if(listFoodInBasket != null)
|
||||||
return listOrderDetails.size();
|
return listFoodInBasket.size();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OrderDetailViewHolder extends RecyclerView.ViewHolder{
|
public class OrderDetailViewHolder extends RecyclerView.ViewHolder{
|
||||||
ImageView image_view;
|
ImageView image_view;
|
||||||
TextView food_name, shop_name, price, quantity;
|
TextView food_name, shop_name, price, quantity, discount;
|
||||||
|
|
||||||
public OrderDetailViewHolder(@NonNull View itemView) {
|
public OrderDetailViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
@@ -67,6 +84,7 @@ public class OrderDetailAdapter extends RecyclerView.Adapter<OrderDetailAdapter.
|
|||||||
shop_name = itemView.findViewById(R.id.shop_name_text_view);
|
shop_name = itemView.findViewById(R.id.shop_name_text_view);
|
||||||
price = itemView.findViewById(R.id.price_text_view);
|
price = itemView.findViewById(R.id.price_text_view);
|
||||||
quantity = itemView.findViewById(R.id.quantity_text_view);
|
quantity = itemView.findViewById(R.id.quantity_text_view);
|
||||||
|
discount = itemView.findViewById(R.id.discount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
@@ -37,8 +38,10 @@ public class BasketFragment extends Fragment implements ItemTouchHelperListener
|
|||||||
private RelativeLayout listBasketFoodView;
|
private RelativeLayout listBasketFoodView;
|
||||||
private Button btnCheckOut;
|
private Button btnCheckOut;
|
||||||
public ConstraintLayout empty_layout;
|
public ConstraintLayout empty_layout;
|
||||||
|
|
||||||
public TextView total;
|
public TextView total;
|
||||||
|
public float totalFloat;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
@@ -76,7 +79,14 @@ public class BasketFragment extends Fragment implements ItemTouchHelperListener
|
|||||||
btnCheckOut.setOnClickListener(new View.OnClickListener() {
|
btnCheckOut.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
startActivity(new Intent(getContext(), OrderCheckOutActivity.class));
|
if(Common.LIST_BASKET_FOOD.size() == 0){
|
||||||
|
Toast.makeText(getContext(), "Giỏ hàng của bạn hiện đang trống!", Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
Intent intent = new Intent(getContext(), OrderCheckOutActivity.class);
|
||||||
|
intent.putExtra("total", totalFloat);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -7,16 +7,16 @@ public class Basket {
|
|||||||
private float cost;
|
private float cost;
|
||||||
private String shopName;
|
private String shopName;
|
||||||
private String quantity;
|
private String quantity;
|
||||||
private float discount;
|
private float discountPercent;
|
||||||
|
|
||||||
public Basket(String id, String img, String name, float cost, String shopName, String quantity, float discount) {
|
public Basket(String id, String img, String name, float cost, String shopName, String quantity, float discountPercent) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.img = img;
|
this.img = img;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.cost = cost;
|
this.cost = cost;
|
||||||
this.shopName = shopName;
|
this.shopName = shopName;
|
||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
this.discount = discount;
|
this.discountPercent = discountPercent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
@@ -66,12 +66,11 @@ public class Basket {
|
|||||||
public void setQuantity(String quantity) {
|
public void setQuantity(String quantity) {
|
||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
}
|
}
|
||||||
|
public float getDiscountPercent() {
|
||||||
public float getDiscount() {
|
return discountPercent;
|
||||||
return discount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDiscount(float discount) {
|
public void setDiscountPercent(float discountPercent) {
|
||||||
this.discount = discount;
|
this.discountPercent = discountPercent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class Order {
|
|||||||
private float total;
|
private float total;
|
||||||
private String status;
|
private String status;
|
||||||
private int address_id;
|
private int address_id;
|
||||||
private List<OrderDetail> listOrderDetail;
|
private List<OrderDetail> orderDetails;
|
||||||
|
|
||||||
public Order(String orderTrackingNumber) {
|
public Order(String orderTrackingNumber) {
|
||||||
this.orderTrackingNumber = orderTrackingNumber;
|
this.orderTrackingNumber = orderTrackingNumber;
|
||||||
@@ -100,10 +100,10 @@ public class Order {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderDetail> getListOrderDetail() {
|
public List<OrderDetail> getListOrderDetail() {
|
||||||
return listOrderDetail;
|
return orderDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setListOrderDetail(List<OrderDetail> listOrderDetail) {
|
public void setListOrderDetail(List<OrderDetail> listOrderDetail) {
|
||||||
this.listOrderDetail = listOrderDetail;
|
this.orderDetails = listOrderDetail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,6 @@
|
|||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/textView"
|
app:layout_constraintTop_toBottomOf="@id/textView"
|
||||||
tools:listitem="@layout/item_order_detail"
|
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -102,6 +101,7 @@
|
|||||||
android:textSize="15sp"
|
android:textSize="15sp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/txt_userName"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -137,6 +137,7 @@
|
|||||||
android:textSize="15sp"
|
android:textSize="15sp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/txt_phone"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -156,22 +157,25 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
|
<RadioGroup
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:layout_marginEnd="10dp"
|
android:layout_marginEnd="10dp"
|
||||||
|
android:checkedButton="@id/list_address_input"
|
||||||
app:layout_constraintTop_toBottomOf="@id/textView3"
|
app:layout_constraintTop_toBottomOf="@id/textView3"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:id="@+id/address_option"
|
android:id="@+id/address_option"
|
||||||
>
|
>
|
||||||
<RadioButton android:id="@+id/radio_pirates"
|
<RadioButton android:id="@+id/list_address_input"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:buttonTint="@color/primaryColor"
|
android:buttonTint="@color/primaryColor"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Chọn địa chỉ dưới đây:"/>
|
android:text="Theo danh sách địa chỉ của bạn:"
|
||||||
|
android:onClick="onRadioButtonClicked"
|
||||||
|
/>
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/list_address"
|
android:id="@+id/list_address"
|
||||||
@@ -181,29 +185,36 @@
|
|||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/auto_detect_location"
|
android:id="@+id/auto_detect_location"
|
||||||
android:text="Lấy vị trí thiết bị của bạn"
|
|
||||||
android:buttonTint="@color/primaryColor"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
android:buttonTint="@color/primaryColor"
|
||||||
|
android:onClick="onRadioButtonClicked"
|
||||||
|
android:text="Lấy vị trí thiết bị của bạn" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/edt_address_detect"
|
android:id="@+id/edt_address_detect"
|
||||||
android:hint="Đang lấy vị trí...."
|
android:hint="Đang lấy vị trí...."
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:enabled="false"
|
||||||
android:inputType="textMultiLine"
|
android:inputType="textMultiLine"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<RadioButton android:id="@+id/radio_ninjas"
|
<RadioButton android:id="@+id/manual_input_address"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:buttonTint="@color/primaryColor"
|
android:buttonTint="@color/primaryColor"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Tự nhập thủ công"/>
|
android:text="Tự nhập thủ công"
|
||||||
|
android:onClick="onRadioButtonClicked"
|
||||||
|
/>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/manual_input_address_layout"
|
||||||
|
android:visibility="gone"
|
||||||
|
>
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
android:id="@+id/textInput_address"
|
android:id="@+id/textInput_address"
|
||||||
@@ -258,17 +269,56 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/errorTextDistrictWard"
|
||||||
|
android:text="Bạn chưa chọn quận huyện!"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textColor="#b00020"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/linearLayout_district_ward"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
android:visibility="gone"
|
||||||
|
/>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/confirm_address_button"
|
||||||
|
android:text="Xác nhận"
|
||||||
|
android:textAllCaps="false"
|
||||||
|
android:backgroundTint="@color/primaryColor"
|
||||||
|
android:layout_width="120dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/address_option"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/change_address_button"
|
||||||
|
android:text="Thay đổi"
|
||||||
|
android:textAllCaps="false"
|
||||||
|
android:backgroundTint="@color/secondary"
|
||||||
|
android:layout_width="120dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/address_option"
|
||||||
|
android:visibility="gone"
|
||||||
|
/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:layout_marginEnd="10dp"
|
android:layout_marginEnd="10dp"
|
||||||
app:layout_constraintTop_toBottomOf="@id/address_option"
|
app:layout_constraintTop_toBottomOf="@id/confirm_address_button"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:id="@+id/shipper_cost_layout"
|
android:id="@+id/shipper_cost_layout"
|
||||||
@@ -320,6 +370,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/txt_total"
|
||||||
android:text="500.000 VNĐ"
|
android:text="500.000 VNĐ"
|
||||||
android:fontFamily="@font/opensans"
|
android:fontFamily="@font/opensans"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
|
|||||||
@@ -105,15 +105,32 @@
|
|||||||
app:layout_constraintTop_toBottomOf="@id/text_view_1"
|
app:layout_constraintTop_toBottomOf="@id/text_view_1"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/price_text_view"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="2dp"
|
android:layout_marginTop="2dp"
|
||||||
android:fontFamily="@font/bebas"
|
>
|
||||||
android:text="$5.00"
|
|
||||||
android:textColor="@color/primaryColor"
|
<TextView
|
||||||
android:textSize="20sp" />
|
android:id="@+id/price_text_view"
|
||||||
|
android:text="$5.00"
|
||||||
|
android:textSize="25sp"
|
||||||
|
android:textColor="@color/primaryColor"
|
||||||
|
android:fontFamily="@font/bebas"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/discount"
|
||||||
|
android:text="-59%"
|
||||||
|
android:textSize="8sp"
|
||||||
|
android:textColor="@color/red"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<com.cepheuen.elegantnumberbutton.view.ElegantNumberButton
|
<com.cepheuen.elegantnumberbutton.view.ElegantNumberButton
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/image_view"
|
android:id="@+id/image_view"
|
||||||
android:layout_width="110dp"
|
android:layout_width="95dp"
|
||||||
android:layout_height="110dp"
|
android:layout_height="95dp"
|
||||||
android:src="@drawable/food"
|
android:src="@drawable/food"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
app:riv_corner_radius="10dip"
|
app:riv_corner_radius="10dip"
|
||||||
@@ -25,29 +25,31 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
>
|
>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/food_name_text_view"
|
android:id="@+id/food_name_text_view"
|
||||||
android:text="@string/food_name"
|
android:text="@string/food_name"
|
||||||
android:textSize="18sp"
|
android:textSize="15sp"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:fontFamily="@font/opensans"
|
android:fontFamily="@font/opensans"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="47dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginStart="5dp"
|
android:layout_marginStart="5dp"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:layout_marginEnd="10dp"
|
android:layout_marginEnd="10dp"
|
||||||
|
android:layout_weight="0.4"
|
||||||
app:layout_constraintStart_toEndOf="@id/image_view"
|
app:layout_constraintStart_toEndOf="@id/image_view"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="0dp"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
android:layout_weight="0.5"
|
||||||
>
|
>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@@ -61,7 +63,7 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/shop_name_text_view"
|
android:id="@+id/shop_name_text_view"
|
||||||
android:text="Shop Name"
|
android:text="Shop Name"
|
||||||
android:textSize="16sp"
|
android:textSize="15sp"
|
||||||
android:textColor="@color/secondary"
|
android:textColor="@color/secondary"
|
||||||
android:fontFamily="@font/opensans"
|
android:fontFamily="@font/opensans"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -71,28 +73,44 @@
|
|||||||
app:layout_constraintTop_toBottomOf="@id/text_view_1"
|
app:layout_constraintTop_toBottomOf="@id/text_view_1"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/price_text_view"
|
android:layout_width="match_parent"
|
||||||
android:text="$5.00"
|
|
||||||
android:textSize="25sp"
|
|
||||||
android:textColor="@color/primaryColor"
|
|
||||||
android:fontFamily="@font/bebas"
|
|
||||||
android:layout_width="220dp"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="2dp"
|
android:layout_marginTop="2dp"
|
||||||
/>
|
>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/price_text_view"
|
||||||
|
android:text="$5.00"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textColor="@color/primaryColor"
|
||||||
|
android:fontFamily="@font/bebas"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/discount"
|
||||||
|
android:text="-59%"
|
||||||
|
android:textSize="8sp"
|
||||||
|
android:textColor="@color/red"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/quantity_text_view"
|
android:id="@+id/quantity_text_view"
|
||||||
android:text="Số lượng: 5"
|
android:text="Số lượng: 10"
|
||||||
android:fontFamily="@font/opensans"
|
android:fontFamily="@font/opensans"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_weight="0.4"
|
android:layout_weight="0.3"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user