Commit 90585346 by Wyh

1、外送頁面接口拆分。優化代碼 2、更多報表頁面切換日期底部報表數據不刷新問題處理 3、供應鏈新增食材,sn碼

parent b5f2771d
......@@ -30,7 +30,6 @@ public class OrderListBean {
* printStatus : 0
* timeSecond : 406956678
*/
private int id;
private String createTime;
//訂單編號
......
......@@ -2,7 +2,6 @@ package com.gingersoft.gsa.delivery_pick_mode.model.viewModel
import android.app.Dialog
import android.content.Context
import android.util.Log
import android.view.Gravity
import android.view.WindowManager
import android.widget.TextView
......@@ -40,8 +39,6 @@ import com.gingersoft.gsa.delivery_pick_mode.data.model.bean.*
import com.gingersoft.gsa.delivery_pick_mode.ui.adapter.DeliveryAdapter
import com.gingersoft.gsa.delivery_pick_mode.util.OtherOrderUtils
import com.jess.arms.utils.ArmsUtils
import com.xuexiang.rxutil2.rxjava.RxJavaUtils
import io.reactivex.disposables.Disposable
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
......@@ -49,7 +46,11 @@ import kotlinx.coroutines.withContext
class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
companion object {
//0,1
var fragmentStatus = arrayOf("0,1,2,3,8", "0,1", "2", "3", "3")
//訂單類型:0為所有,2是外送,7是自取。
//第四個為2(外送),是因為第四個頁面是“送貨中”,只有外送有
//第五個為7(自取),因為第五個頁面是待取餐,只有自取有
var fragmentType = arrayOf(0, 0, 0, 2, 7)
val PrintCode = 1001//打印
val SendCode = 1002//指派送貨
......@@ -99,7 +100,8 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
//餐廳營業信息
val restaurantBusinessInfo = MutableLiveData<RestaurantBusinessInfo>()
var appointmentType = MutableLiveData<Int>() //0為即時單,1為預約單
var appointmentType = 0 //0為即時單,1為預約單
//服務費
var addServiceChargeBean = MutableLiveData<AddServiceChargeBean>()
......@@ -214,33 +216,36 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
LoganManager.w_delivery(LoganManager.EVENT_ERROR, "金額驗證不通過:${GsonUtils.GsonString(orderInfo)}")
return@launch
}
//即時單
// orderDetail.order_type = dataList[0].order_type
if (orderDetail.order_type == 7) {
//如果是自取單,將物流類型改為本店
orderDetail.companyType = 0
}
//交通工具類型
var trafficType = ""
if (orderDetail.companyType == 2) {
//lalamove
val transportationBean = getTransportationConfig(restaurantId)
if (transportationBean.success && transportationBean.data != null && transportationBean.data.list != null) {
for (value in transportationBean.data.list) {
if (value.status == 1) {
//默認交通工具,判斷價格是不是在這個金額範圍內,如果在,則不提示,如果不在,提示用戶修改交通工具
trafficType = value.type.toString()
if (orderDetail.appointmentType == 0) {
//即時單
if (orderDetail.order_type == 7) {
//如果是自取單,將物流類型改為本店
orderDetail.companyType = 0
}
//交通工具類型
var trafficType = ""
//是不是lalamove
if (orderDetail.companyType == 2) {
val transportationBean = getTransportationConfig(restaurantId)
if (transportationBean.success && transportationBean.data != null && transportationBean.data.list != null) {
for (value in transportationBean.data.list) {
if (value.status == 1) {
//默認交通工具
trafficType = value.type.toString()
}
}
}
}
//狀態改為已確認
confirmOrder(orderDetail, 2, trafficType, restaurantId, isPrintPrj = true, isPrintBill = true) {
receiveNextOrder()
}
} else {
// 預約單,狀態改為待製作
updateOrderAndPrint(restaurantId, orderDetail, 8, false) {
receiveNextOrder()
}
}
// confirmOrder(orderDetail, 2, trafficType, restaurantId, isPrintPrj = true, isPrintBill = true) {
// receiveNextOrder()
// }
// //預約單
// updateOrderAndPrint(restaurantId, orderDetail, 8, false) {
// receiveNextOrder()
// }
}
}
}
......@@ -274,10 +279,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
*/
fun getNewOrderList(page: Int, status: String, type: Int, orderNo: String = "") {
launch({
if (appointmentType.value == null) {
appointmentType.value = 0
}
repository.getNewOrderList(restaurantId, appointmentType.value!!, page, 10, status, orderNo, phone, type).apply {
repository.getNewOrderList(restaurantId, appointmentType, page, 10, status, orderNo, phone, type).apply {
val jsonToList = GsonUtils.jsonToList(data, OrderListBean::class.java)
if (page > 1) {
//加載更多
......
......@@ -196,14 +196,16 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen
layout_booking_order.background = ContextCompat.getDrawable(this, R.drawable.shape_right_white_radius_btn)
tv_immediate_order.setTextColor(ContextCompat.getColor(this, R.color.white))
tv_booking_order.setTextColor(ContextCompat.getColor(this, R.color.theme_333_color))
pageViewModel.appointmentType.postValue(0)
pageViewModel.appointmentType = 0
getCurrentPageOrderList()
}
layout_booking_order.setOnClickListener {
it.background = ContextCompat.getDrawable(this, R.drawable.shape_right_themecolor_radius_btn)
layout_immediate_order.background = ContextCompat.getDrawable(this, R.drawable.shape_left_white_radius_btn)
tv_booking_order.setTextColor(ContextCompat.getColor(this, R.color.white))
tv_immediate_order.setTextColor(ContextCompat.getColor(this, R.color.theme_333_color))
pageViewModel.appointmentType.postValue(1)
pageViewModel.appointmentType = 1
getCurrentPageOrderList()
}
}
......
......@@ -43,33 +43,12 @@ class PlaceholderFragment : BaseFragment(R.layout.fragment_other_order) {
refresh_layout.finishRefresh()
refresh_layout.finishLoadMore()
})
// 綁定狀態,如果這個值發生變化,並且是當前頁,就去獲取訂單列表
// refreshState.observe(viewLifecycleOwner, Observer {
// if (position == it) {
// page = 1
// getOrderList()
// }
// })
// 綁定監聽當前fragment的數據項
// mFragmentData[position].observe(viewLifecycleOwner, Observer {
// it?.let {
// layout_nodata.setState(it.size <= 0)
// adapter.setData(it)
// }
// })
newOrderList.observe(viewLifecycleOwner, Observer {
it?.let {
layout_nodata.setState(it.size <= 0)
adapter.setData(it)
}
})
//切換預約單狀態監聽
appointmentType.observe(viewLifecycleOwner, Observer {
if (position <= 1) {
//判斷小於1是因為只有 前兩個狀態才有預約單
refresh()
}
})
}
// 初始化recyclerview
initRecyclerView()
......@@ -105,7 +84,7 @@ class PlaceholderFragment : BaseFragment(R.layout.fragment_other_order) {
intent.putExtra("isRead", data.isRead)
//傳遞是否是預約單
if (position <= 1) {
if (pageViewModel.appointmentType.value == 1) {
if (pageViewModel.appointmentType == 1) {
//預約單
intent.putExtra("isBookingOrder", true)
}
......
......@@ -19,7 +19,7 @@
android:theme="@style/AppTheme">
<activity android:name=".mvp.ui.activity.menu.ShellActivity" />
<activity
android:name=".mvp.ui.activity.NewMainActivity"
android:name=".mvp.ui.activity.menu.FoodMenuManageActivity"
android:launchMode="singleTask"
android:alwaysRetainTaskState="true" />
<activity android:name=".mvp.ui.activity.ExpandListActivity" />
......@@ -32,7 +32,7 @@
<activity android:name=".mvp.ui.activity.LookLogActivity" />
<activity android:name=".mvp.ui.activity.OriginalPrintPaperActivity" />
<activity
android:name=".mvp.ui.activity.menu.FoodMenuManageActivity"
android:name=".mvp.ui.activity.NewMainActivity"
android:launchMode="singleTask"
android:theme="@style/MainTheme">
<intent-filter>
......
......@@ -55,7 +55,6 @@ import java.util.Map;
import butterknife.BindView;
import butterknife.OnClick;
import static com.gingersoft.gsa.cloud.common.utils.time.TimeUtils.DEFAULT_DATE_Y;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......@@ -236,16 +235,20 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
//將數據以時間為key,數據為value存入map
Map<String, MainBusinessBean.DataBean> map = new HashMap<>();
for (int i = 0; i < data.size(); i++) {
int size = manyDay;
if (data.size() <= manyDay) {
size = data.size();
}
for (int i = 0; i < size; i++) {
map.put(data.get(i).getStartingTime(), data.get(i));
}
//y軸 數據間隔
double yAxisTickInterval = 0;
//第一條線
int year = cal.get(Calendar.YEAR);
for (int i = 0; i < manyDay; i++) {
//通過今年年份+月份+日期,獲取對應的對象
MainBusinessBean.DataBean bean = map.get(TimeUtils.getDistanceDate(0, Calendar.YEAR, DEFAULT_DATE_Y) + xData[i]);
MainBusinessBean.DataBean bean = map.get(year + "-" + xData[i]);
if (bean != null) {
chartData[i] = bean.getTotalAmount();
yAxisTickInterval = Math.max(yAxisTickInterval, bean.getTotalAmount());
......@@ -308,10 +311,25 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
);
}
/**
* 每日營業詳情
*/
private DailyBusinessView dailyBusinessView;
/**
* 賬單分析
*/
private BillingAnalysisReportView billingAnalysisReportView;
/**
* 營業金額淨值詳情
*/
private OperatingReportView netOperatingAmountView;
/**
* 訂單詳情
*/
private OperatingReportView orderDetailsReportView;
/**
* 折扣詳情
*/
private OperatingReportView discountDetailsReportView;
private View[] printViews = new View[5];
......@@ -382,7 +400,7 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
}
}
} else {
netOperatingAmountView.notifyData(dailyReportBeans);
netOperatingAmountView.setNewData(dailyReportBeans);
}
}
......@@ -400,7 +418,7 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
}
}
} else {
orderDetailsReportView.notifyData(dailyReportBeans);
orderDetailsReportView.setNewData(dailyReportBeans);
}
}
......@@ -415,7 +433,7 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
layout_report_print.addView(discountDetailsReportView);
}
} else {
discountDetailsReportView.notifyData(dailyReportBeans);
discountDetailsReportView.setNewData(dailyReportBeans);
}
}
......@@ -424,7 +442,7 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
public void onClick(View v) {
int viewId = v.getId();
if (viewId == R.id.btn_print_business) {
if(printViews != null) {
if (printViews != null) {
//打印
LinearLayout layout = new LinearLayout(mContext);
layout.removeAllViews();
......
......@@ -267,7 +267,7 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
netOperatingAmountView.setOnReLoadListener(() -> getDeliveryReport());
layoutSales.addView(netOperatingAmountView);
} else {
netOperatingAmountView.notifyData(dailyReportBeans);
netOperatingAmountView.setNewData(dailyReportBeans);
}
}
......
......@@ -41,7 +41,6 @@ public class DailyBusinessView extends BaseReloadView {
this.businessBeans = businessBeans;
}
public DailyBusinessView(@NonNull Context context, @Nullable AttributeSet attrs) {
this(context, attrs, -1);
}
......@@ -75,10 +74,10 @@ public class DailyBusinessView extends BaseReloadView {
@Override
public void refreshData() {
notifyData();
setData();
}
public void notifyData() {
public void setData() {
if (printBusinessInfoAdapter == null) {
mBusinessDetails.setLayoutManager(new GridLayoutManager(getContext(), 3) {
@Override
......
......@@ -69,7 +69,6 @@ public class OperatingReportView extends BaseReloadView {
if (isPrint) {
tvTitle.setTextSize(30);
}
notifyData(dailyReportBeans);
return view.findViewById(R.id.layout_business_info);
}
......@@ -82,31 +81,9 @@ public class OperatingReportView extends BaseReloadView {
}
}
// private void init(Context mContext, String title, List<DailyReportBean> dailyReportBeans, int spanCount) {
// View view = View.inflate(mContext, R.layout.layout_report_net_operating_value_details, null);
// TextView tvTitle = view.findViewById(R.id.tv_report_title);
// tvTitle.setText(title);
//
// RecyclerView rv = view.findViewById(R.id.rv_business_details);
// LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext) {
// @Override
// public boolean canScrollVertically() {
// return false;
// }
// };
// rv.setLayoutManager(linearLayoutManager);
// adapter = new DailyBusinessAdapter(mContext, dailyReportBeans, spanCount, isPrint);
// rv.setAdapter(adapter);
//
// if (isPrint) {
// tvTitle.setTextSize(30);
// }
// notifyData(dailyReportBeans);
// addView(view);
// }
public void notifyData(List<DailyReportBean> dailyReportBeans) {
public void setNewData(List<DailyReportBean> dailyReportBeans) {
this.dailyReportBeans = dailyReportBeans;
notifyData();
}
}
......@@ -64,7 +64,7 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_business_details"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</com.lihang.ShadowLayout>
\ No newline at end of file
......@@ -58,6 +58,10 @@ dependencies {
annotationProcessor rootProject.ext.dependencies["butterknife-compiler"]
implementation rootProject.ext.dependencies["BaseRecyclerViewAdapter"]
debugImplementation rootProject.ext.dependencies["canary-debug"]
releaseImplementation rootProject.ext.dependencies["canary-release"]
testImplementation rootProject.ext.dependencies["canary-release"]
implementation rootProject.ext.dependencies["glide"]
annotationProcessor rootProject.ext.dependencies["glide-compiler"]
implementation 'com.github.yalantis:ucrop:2.2.6'
......
package com.gingersoft.supply_chain.di.component;
import dagger.BindsInstance;
import dagger.Component;
import com.jess.arms.di.component.AppComponent;
import com.gingersoft.supply_chain.di.module.BuyIngredientsModule;
import com.gingersoft.supply_chain.mvp.contract.BuyIngredientsContract;
import com.jess.arms.di.scope.FragmentScope;
import com.gingersoft.supply_chain.mvp.ui.fragment.food.BuyIngredientsFragment;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 03/10/2021 14:55
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@FragmentScope
@Component(modules = BuyIngredientsModule.class, dependencies = AppComponent.class)
public interface BuyIngredientsComponent {
void inject(BuyIngredientsFragment fragment);
@Component.Builder
interface Builder {
@BindsInstance
BuyIngredientsComponent.Builder view(BuyIngredientsContract.View view);
BuyIngredientsComponent.Builder appComponent(AppComponent appComponent);
BuyIngredientsComponent build();
}
}
\ No newline at end of file
package com.gingersoft.supply_chain.di.module;
import com.jess.arms.di.scope.FragmentScope;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import com.gingersoft.supply_chain.mvp.contract.BuyIngredientsContract;
import com.gingersoft.supply_chain.mvp.model.BuyIngredientsModel;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 03/10/2021 14:55
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@Module
public abstract class BuyIngredientsModule {
@Binds
abstract BuyIngredientsContract.Model bindBuyIngredientsModel(BuyIngredientsModel model);
}
\ No newline at end of file
package com.gingersoft.supply_chain.mvp.contract;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean;
import com.gingersoft.supply_chain.mvp.bean.FoodByCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.FoodListInfoBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel;
import com.qmuiteam.qmui.widget.section.QMUISection;
import java.util.List;
import java.util.Map;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 03/10/2021 14:55
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public interface BuyIngredientsContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
/**
* 加載分類
*
* @param foodCategoryTrees 所有分類層級信息
*/
void loadCategory(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees);
/**
* 加載右側食品
* @param purchaseFoodListVOS 食品信息
*/
void loadRightFoodIngredients(List<PurchaseFoodBean> purchaseFoodListVOS);
/**
* 加載失敗
*/
void loadFail();
/**
* 加載食品
* @param food
*/
void loadFood(List<QMUISection<CategoryBean, PurchaseFoodBean>> food);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {
Observable<FoodListInfoBean> getFoodIngredientsData(Map<String, Object> map);
Observable<BaseResult> getFoodBySupplierId(Map<String, Object> map);
Observable<BaseResult> deleteFood(int foodId);
Observable<OrderCategoryBean> getCategoryTrees(Map<String, Object> map);
Observable<FoodByCategoryResultBean> getFoodByCategory(Map<String, Object> map);
}
}
package com.gingersoft.supply_chain.mvp.model;
import android.app.Application;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.FoodByCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.FoodListInfoBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.server.SupplierServer;
import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
import com.jess.arms.di.scope.FragmentScope;
import javax.inject.Inject;
import com.gingersoft.supply_chain.mvp.contract.BuyIngredientsContract;
import java.util.Map;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 03/10/2021 14:55
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@FragmentScope
public class BuyIngredientsModel extends BaseModel implements BuyIngredientsContract.Model {
@Inject
Gson mGson;
@Inject
Application mApplication;
@Inject
public BuyIngredientsModel(IRepositoryManager repositoryManager) {
super(repositoryManager);
}
@Override
public void onDestroy() {
super.onDestroy();
this.mGson = null;
this.mApplication = null;
}
@Override
public Observable<FoodListInfoBean> getFoodIngredientsData(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getFoodIngredientsData(map);
}
@Override
public Observable<BaseResult> getFoodBySupplierId(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getFoodBySupplierId(map);
}
@Override
public Observable<BaseResult> deleteFood(int foodId) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).deleteFood(foodId);
}
@Override
public Observable<OrderCategoryBean> getCategoryTrees(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getCategoryTrees(map);
}
@Override
public Observable<FoodByCategoryResultBean> getFoodByCategory(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getFoodByCategory(map);
}
}
\ No newline at end of file
package com.gingersoft.supply_chain.mvp.presenter;
import android.app.Application;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean;
import com.gingersoft.supply_chain.mvp.bean.CategoryFoodTreeBean;
import com.gingersoft.supply_chain.mvp.bean.FoodByCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.jess.arms.integration.AppManager;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.http.imageloader.ImageLoader;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.schedulers.Schedulers;
import lombok.val;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import javax.inject.Inject;
import com.gingersoft.supply_chain.mvp.contract.BuyIngredientsContract;
import com.jess.arms.utils.RxLifecycleUtils;
import com.qmuiteam.qmui.widget.section.QMUISection;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import com.xuexiang.rxutil2.rxjava.task.RxIOTask;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Description: 選購食材
*/
@FragmentScope
public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContract.Model, BuyIngredientsContract.View> {
@Inject
RxErrorHandler mErrorHandler;
@Inject
Application mApplication;
@Inject
ImageLoader mImageLoader;
@Inject
AppManager mAppManager;
/**
* 緩存分類,區分分類級別
* 用於顯示
*/
private List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees;
/**
* 存儲所有分類id和名字,包括下面的所有食材,如果沒有食材,需要調用獲取食材接口然後存放在這個集合裡面
* 之後點擊一個分類,可以通過這個集合去拿到之前已經通過接口獲取到的食材信息
* <p>
* 用於快速獲取某個分類下的食材
*/
private List<CategoryFoodTreeBean> categoryFoodTreeBeans;
private Map<Integer, List<QMUISection<CategoryBean, PurchaseFoodBean>>> foodSectionMap = new HashMap<>();
@Inject
public BuyIngredientsPresenter(BuyIngredientsContract.Model model, BuyIngredientsContract.View rootView) {
super(model, rootView);
}
@Override
public void onDestroy() {
super.onDestroy();
this.mErrorHandler = null;
this.mAppManager = null;
this.mImageLoader = null;
this.mApplication = null;
}
/**
* 獲取分類的結構:所有分類和分類的子分類都有
*/
public void getCategoryTrees() {
if (foodCategoryTrees != null) {
mRootView.loadCategory(foodCategoryTrees);
return;
}
Map<String, Object> map = new HashMap<>(2);
Constant.addBrandId(map);
Constant.addRestaurantId(map);
mModel.getCategoryTrees(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new ErrorHandleSubscriber<OrderCategoryBean>(mErrorHandler) {
@Override
public void onNext(OrderCategoryBean orderCategoryBean) {
if (orderCategoryBean.isSuccess()) {
if (categoryFoodTreeBeans == null) {
categoryFoodTreeBeans = new ArrayList<>();
}
List<OrderCategoryBean.FoodCategoryTrees> data = orderCategoryBean.getData();
conversionCategoryTree(data);
foodCategoryTrees = new ArrayList<>();
foodCategoryTrees.addAll(data);
mRootView.loadCategory(data);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(orderCategoryBean.getErrMsg())) {
mRootView.showMessage(orderCategoryBean.getErrMsg());
} else {
mRootView.showMessage(Constant.GET_INFO_ERROR);
}
}
/**
* 將分類轉換為categoryFoodTreeBeans,方便之後存取分類和分類下的食品
*/
private void conversionCategoryTree(List<OrderCategoryBean.FoodCategoryTrees> data) {
if (data == null) {
return;
}
RxJavaUtils.doInIOThread(new RxIOTask<Object>(0) {
@Override
public Void doInIOThread(Object o) {
for (OrderCategoryBean.FoodCategoryTrees category : data) {
CategoryFoodTreeBean categoryFoodTreeBean = new CategoryFoodTreeBean();
List<Integer> categoryId = new ArrayList<>();
List<String> categoryName = new ArrayList<>();
categoryId.add(category.getId());
categoryName.add(category.getName());
if (category.getFoodCategoryTrees() != null) {
for (OrderCategoryBean.FoodCategoryTrees secondCategory : category.getFoodCategoryTrees()) {
categoryId.add(secondCategory.getId());
categoryName.add(secondCategory.getName());
if (secondCategory.getFoodCategoryTrees() != null) {
for (OrderCategoryBean.FoodCategoryTrees thirdCategory : secondCategory.getFoodCategoryTrees()) {
categoryId.add(thirdCategory.getId());
categoryName.add(thirdCategory.getName());
}
}
}
}
categoryFoodTreeBean.setCategoryIds(categoryId);
categoryFoodTreeBean.setCategoryNames(categoryName);
categoryFoodTreeBeans.add(categoryFoodTreeBean);
}
return null;
}
});
}
});
}
public void getFoodByCategoryId() {
}
/**
* 根據一級分類獲取下面所有包括子分類的食品
*
* @param parentCategoryId 父分類id
*/
public void getFoodByCategoryId(int parentCategoryId) {
Map<String, Object> map = new HashMap<>(5);
map.put("pageSize", 1000);
map.put("pageIndex", 0);
Constant.addBrandId(map);
Constant.addRestaurantId(map);
map.put("parentId", parentCategoryId);
mModel.getFoodByCategory(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("獲取中..."))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterNext(dis -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<FoodByCategoryResultBean>(mErrorHandler) {
@Override
public void onNext(@NonNull FoodByCategoryResultBean info) {
if (info.isSuccess()) {
//保存分類下食品
savFoodToCategory(info);
//這個接口是一級分類才調用,所以直接顯示所有食材,讓用戶可以滾動列表
//將食品和分類整合到一起,List<QMUISection<CategoryBean, PurchaseFoodBean>>
val sections = foodToList(info.getData());
foodSectionMap.put(parentCategoryId, sections);
mRootView.loadFood(sections);
// mRootView.loadRightFoodIngredients(filterThisCategoryFood(categoryId, info.getData()));
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
mRootView.loadFail();
} else {
mRootView.loadFail();
}
}
/**
* 保存食品信息到分類數據中
* @param info
*/
private void savFoodToCategory(@NonNull FoodByCategoryResultBean info) {
RxJavaUtils.doInIOThread(new RxIOTask<FoodByCategoryResultBean>(info) {
@Override
public Void doInIOThread(FoodByCategoryResultBean info) {
//將本次獲取到的食品存入到緩存中
for (CategoryFoodTreeBean categoryFoodTreeBean : categoryFoodTreeBeans) {
if (categoryFoodTreeBean.getCategoryIds().contains(parentCategoryId)) {
categoryFoodTreeBean.setFoodInfo(info.getData());
break;
}
}
return null;
}
});
}
});
}
/**
* 將食品列表轉為帶分類用於顯示的列表
*
* @return
*/
public List<QMUISection<CategoryBean, PurchaseFoodBean>> foodToList(List<PurchaseFoodBean> data) {
if (data == null) {
return null;
}
List<QMUISection<CategoryBean, PurchaseFoodBean>> sections = new ArrayList<>();
CategoryBean categoryBean = new CategoryBean();
List<PurchaseFoodBean> purchaseFoodBeans = new ArrayList<>();
for (int i = 0; i < data.size(); i++) {
PurchaseFoodBean purchaseFoodBean = data.get(i);
if (categoryBean.getId() == null) {
categoryBean.setId(purchaseFoodBean.getFoodCategoryId());
} else {
if (!categoryBean.getId().equals(purchaseFoodBean.getFoodCategoryId())) {
sections.add(new QMUISection<>(categoryBean, purchaseFoodBeans));
categoryBean = new CategoryBean();
categoryBean.setId(purchaseFoodBean.getFoodCategoryId());
purchaseFoodBeans = new ArrayList<>();
}
}
purchaseFoodBeans.add(purchaseFoodBean);
if (i == data.size() - 1) {
//最後一個食品
sections.add(new QMUISection<>(categoryBean, purchaseFoodBeans));
}
}
//由於食的數據中沒有分類名稱,需要去分類的緩存中取出對應的分類名
for (QMUISection<CategoryBean, PurchaseFoodBean> section : sections) {
CategoryBean header = section.getHeader();
for (CategoryFoodTreeBean categoryFoodTreeBean : categoryFoodTreeBeans) {
if (categoryFoodTreeBean.getCategoryIds().contains(header.getId())) {
header.setCategoryName(categoryFoodTreeBean.getCategoryNames().get(categoryFoodTreeBean.getCategoryIds().indexOf(header.getId())));
}
}
}
return sections;
}
/**
* 篩選出這個分類下的食材
*
* @param categoryId 分類id
* @param foodInfo 所有食材
* @return 當前分類下的食材
*/
private @NotNull List<PurchaseFoodBean> filterThisCategoryFood(Integer categoryId, List<PurchaseFoodBean> foodInfo) {
//從所有食材中篩選出自己分類下的食材
List<PurchaseFoodBean> foods = new ArrayList<>();
//用於提前終止循環,如果已經拿到過這個分類下的數據,後面沒有這個分類下的數據了,就終止循環
boolean hasFood = false;
for (PurchaseFoodBean purchaseFoodBean : foodInfo) {
if (categoryId.equals(purchaseFoodBean.getFoodCategoryId())) {
hasFood = true;
foods.add(purchaseFoodBean);
} else if (hasFood) {
break;
}
}
return foods;
}
}
package com.gingersoft.supply_chain.mvp.ui.fragment.food;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.gingersoft.gsa.cloud.common.loadsir.EmptyCallback;
import com.gingersoft.gsa.cloud.common.loadsir.ErrorCallback;
import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerBuyIngredientsComponent;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.contract.BuyIngredientsContract;
import com.gingersoft.supply_chain.mvp.presenter.BuyIngredientsPresenter;
import com.gingersoft.supply_chain.mvp.ui.adapter.BuyIngredientsAdapter;
import com.gingersoft.supply_chain.mvp.ui.adapter.FirstLevelCategoryAdapter;
import com.gingersoft.supply_chain.mvp.ui.adapter.SecondCategoryAdapter;
import com.gingersoft.supply_chain.mvp.ui.fragment.BaseSupplyChainFragment;
import com.gingersoft.supply_chain.mvp.ui.widget.ShowSecondCategoryPopup;
import com.gingersoft.supply_chain.mvp.utils.ViewUtils;
import com.jess.arms.di.component.AppComponent;
import com.kingja.loadsir.callback.Callback;
import com.kingja.loadsir.core.LoadService;
import com.kingja.loadsir.core.LoadSir;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.enums.PopupPosition;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import com.qmuiteam.qmui.alpha.QMUIAlphaImageButton;
import com.qmuiteam.qmui.alpha.QMUIAlphaTextView;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.qmuiteam.qmui.widget.section.QMUISection;
import com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import butterknife.BindView;
import butterknife.OnClick;
import lombok.val;
/**
* Description: 選購食材
*/
public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredientsPresenter> implements BuyIngredientsContract.View, View.OnClickListener {
@BindView(R2.id.topbar_food_ingredients)
QMUITopBar topbarFoodIngredients;
@BindView(R2.id.layout_purchase_food_content)
RelativeLayout layoutContent;
@BindView(R2.id.ed_food_ingredients_search)
EditText edFoodIngredientsSearch;
@BindView(R2.id.layout_food_ingredients_search)
LinearLayout layoutFoodIngredientsSearch;
@BindView(R2.id.tv_switch_food_ingredients_show_type)
QMUIAlphaTextView tvSwitchFoodIngredientsShowType;
@BindView(R2.id.rv_food_ingredients_category)
RecyclerView rvFirstCategory;
private FirstLevelCategoryAdapter firstLevelCategoryAdapter;
@BindView(R2.id.layout_right_content)
LinearLayout layoutRightContent;
@BindView(R2.id.layout_ingredients_left)
LinearLayout layoutIngredientsLeft;
@BindView(R2.id.rv_food_ingredients_second_category)
RecyclerView rvSecondCategory;
private SecondCategoryAdapter secondCategoryAdapter;
@BindView(R2.id.section_food_ingredients)
QMUIStickySectionLayout sectionFood;
private BuyIngredientsAdapter adapter;
// @BindView(R2.id.rv_food_ingredients)
// RecyclerView rvFoodIngredients;
@BindView(R2.id.srl_supplier)
LinearLayout srlSupplier;
@BindView(R2.id.btn_new_food_ingredient)
QMUIAlphaButton btnNewFoodIngredient;
@BindView(R2.id.btn_food_ingredients_confirm)
QMUIAlphaButton btnFoodIngredientsConfirm;
@BindView(R2.id.tv_ingredients_food_num)
TextView tvIngredientsFoodNum;
@BindView(R2.id.btn_food_ingredients_cancel)
QMUIAlphaButton btnFoodIngredientsCancel;
@BindView(R2.id.layout_food_ingredients_btn)
LinearLayout layoutFoodIngredientsBtn;
@BindView(R2.id.btn_switch_row)
QMUIAlphaImageButton btnSwitchRow;
@BindView(R2.id.layout_category)
LinearLayout layoutCategory;
@BindView(R2.id.card_show_more_category)
CardView cardMoreCategory;
@BindView(R2.id.iv_unfold_arrow)
ImageView ivUnfoldArrow;
@BindView(R2.id.tv_unfold_category)
TextView tvUnfoldCategory;
TextView tvShoppingCart;
/**
* 0單列
* 1雙列
*/
private boolean isSinger = true;
private LoadService fullRegister;
public static BuyIngredientsFragment newInstance() {
BuyIngredientsFragment fragment = new BuyIngredientsFragment();
return fragment;
}
@Override
public void setupFragmentComponent(@NonNull AppComponent appComponent) {
DaggerBuyIngredientsComponent //如找不到该类,请编译一下项目
.builder()
.appComponent(appComponent)
.view(this)
.build()
.inject(this);
}
@Override
public View initView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_buy_ingredients, container, false);
}
@Override
public void initData(@Nullable Bundle savedInstanceState) {
initTopBar();
loadService = LoadSir.getDefault().register(layoutRightContent, (Callback.OnReloadListener) v -> {
});
fullRegister = LoadSir.getDefault().register(layoutContent, (Callback.OnReloadListener) v -> {
});
//獲取一級分類
mPresenter.getCategoryTrees();
}
private void initTopBar() {
initTopBar(topbarFoodIngredients, "食材管理");
View view = View.inflate(requireContext(), R.layout.view_shopping_car, null);
tvShoppingCart = view.findViewById(R.id.tv_purchase_cart_number);
topbarFoodIngredients.addRightView(view, R.id.qmui_shopping_cart);
}
@OnClick({R2.id.layout_food_ingredients_search, R2.id.tv_switch_food_ingredients_show_type, R2.id.btn_food_ingredients_confirm,
R2.id.btn_food_ingredients_cancel, R2.id.btn_switch_row, R2.id.card_show_more_category})
@Override
public void onClick(View v) {
int viewId = v.getId();
if (viewId == R.id.layout_food_ingredients_search) {
//跳轉搜索頁面
jumpToSearch();
} else if (viewId == R.id.btn_switch_row) {
//切換顯示單雙列
switchShowSingerOrDouble();
} else if (viewId == R.id.tv_switch_food_ingredients_show_type) {
//切換顯示分類或是顯示供應商
switchShowCategoryOrSupplier();
} else if (viewId == R.id.card_show_more_category) {
//展開分類
unfoldCategory();
} else if (viewId == R.id.btn_food_ingredients_confirm) {
//確認
confirm();
} else if (viewId == R.id.btn_food_ingredients_cancel) {
//取消
killMyself();
}
}
/**
* 跳轉到搜索頁面
*/
private void jumpToSearch() {
}
/**
* 切換顯示單列或雙列
*/
private void switchShowSingerOrDouble() {
//切換單雙列
isSinger = !isSinger;
sectionFood.setLayoutManager(isSinger ? new LinearLayoutManager(requireContext()) : getDoubleRowManager());
adapter.setShowDoubleRow(isSinger);
btnSwitchRow.setImageResource(isSinger ? R.drawable.ic_single_row : R.drawable.ic_double_row);
sectionFood.setAdapter(adapter);
}
/**
* 切換顯示分類或供應商
*/
private void switchShowCategoryOrSupplier() {
}
/**
* 展開二級分類
*/
private void unfoldCategory() {
if (secondCategoryAdapter == null) {
return;
}
new XPopup.Builder(requireContext())
.atView(layoutCategory)
.hasShadowBg(false)
.popupPosition(PopupPosition.Bottom)
.asCustom(new ShowSecondCategoryPopup(requireContext(), secondCategoryAdapter.getSelectIndex(), layoutCategory.getWidth(), secondCategoryAdapter.getData(), (adapter, view, position) -> {
//二級分類滾動顯示,當前彈窗顯示三級分類,顯示三級分類在popup內部處理
secondCategoryAdapter.getOnItemClickListener().onItemClick(secondCategoryAdapter, view, position);
}))
.show();
}
/**
* 確認,進入購物車頁面
*/
private void confirm() {
}
@Override
public void loadCategory(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees) {
if (foodCategoryTrees.size() > 0) {
fullRegister.showSuccess();
loadService.showSuccess();
if (firstLevelCategoryAdapter == null) {
firstLevelCategoryAdapter = new FirstLevelCategoryAdapter(foodCategoryTrees, requireContext());
rvFirstCategory.setAdapter(firstLevelCategoryAdapter);
firstLevelCategoryAdapter.setOnItemClickListener((adapter, view, position) -> {
//切換右側顯示的二級分類和食材
firstLevelCategoryAdapter.setSelectedIndex(position);
ViewUtils.moveToCenterByVertical(rvFirstCategory, position);
loadSecondCategory(firstLevelCategoryAdapter.getData().get(position).getFoodCategoryTrees());
//獲取當前分類所有食材
mPresenter.getFoodByCategoryId(firstLevelCategoryAdapter.getItem(position).getId());
});
//默認選中第0個分類
firstLevelCategoryAdapter.getOnItemClickListener().onItemClick(firstLevelCategoryAdapter, null, 0);
} else {
firstLevelCategoryAdapter.setList(foodCategoryTrees);
}
} else {
fullRegister.showCallback(ErrorCallback.class);
}
}
@Override
public void loadRightFoodIngredients(List<PurchaseFoodBean> purchaseFoodListVOS) {
// 點擊一二三級分類,都是清空當前頁面所有食材,然後顯示當前級別分類下的食材
// 滑動則是判斷底部,一直累加數據
sectionFood.setLayoutManager(new LinearLayoutManager(requireContext()));
}
@Override
public void loadFail() {
loadService.showCallback(EmptyCallback.class);
}
/**
* 加載二級分類
*
* @param foodCategoryTrees
*/
private void loadSecondCategory(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees) {
secondCategoryAdapter = new SecondCategoryAdapter(requireContext(), foodCategoryTrees);
rvSecondCategory.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
rvSecondCategory.setAdapter(secondCategoryAdapter);
OnItemClickListener onItemClickListener = (adapter, view, position) -> {
secondCategoryAdapter.setSelectIndex(position);
ViewUtils.moveToCenterByHorizontal(rvSecondCategory, position);
//加載當前分類下的食品
};
secondCategoryAdapter.setOnItemClickListener(onItemClickListener);
//默認選中第0個
if (foodCategoryTrees != null && foodCategoryTrees.size() > 0) {
onItemClickListener.onItemClick(secondCategoryAdapter, rvSecondCategory, 0);
}
}
@Override
public void loadFood(List<QMUISection<CategoryBean, PurchaseFoodBean>> food) {
if (adapter == null) {
adapter = new BuyIngredientsAdapter(requireContext(), food);
sectionFood.setAdapter(adapter);
} else {
adapter.setData(food);
}
if (isSinger) {
sectionFood.setLayoutManager(new LinearLayoutManager(requireContext()));
} else {
sectionFood.setLayoutManager(getDoubleRowManager());
}
}
@NotNull
private GridLayoutManager getDoubleRowManager() {
val gridLayoutManager = new GridLayoutManager(requireContext(), 2);
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return adapter.getItemIndex(position) < 0 ? gridLayoutManager.getSpanCount() : 1;
}
});
return gridLayoutManager;
}
}
......@@ -353,12 +353,16 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
totalAmount = MoneyUtil.sum(totalAmount, value);
setTotalAmount();
});
//食材點擊事件
orderDetailsFoodAdapter.setOnItemClickListener((adapter, view, position) -> {
PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean infoVosBean = orderDetailsFoodAdapter.getData().get(position);
// if(infoVosBean.getStatus() == PurchaseOrderDetailsBean.COMPLETE_RECEIVED){
// //已經全部收貨的,不讓選中
// return;
// }
//判斷是不是sn食材
infoVosBean.setChecked(!infoVosBean.isChecked());
adapter.notifyItemChanged(position);
//修改選中狀態後,重新計算入庫總價
......@@ -413,7 +417,6 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/supply_chain_bg_color"
android:orientation="vertical">
<com.qmuiteam.qmui.widget.QMUITopBar
android:id="@+id/topbar_food_ingredients"
android:layout_width="match_parent"
android:layout_height="@dimen/head_height"
android:background="@color/theme_color"
android:fitsSystemWindows="true"
app:qmui_topbar_title_color="@color/theme_white_color" />
<RelativeLayout
android:id="@+id/layout_purchase_food_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/layout_food_ingredients_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_8"
android:layout_marginTop="@dimen/dp_4"
android:layout_marginRight="@dimen/dp_10"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/layout_food_ingredients_search"
android:layout_width="0dp"
android:layout_height="@dimen/dp_40"
android:layout_weight="1"
android:background="@drawable/shape_white_eight_corners_bg"
android:orientation="horizontal">
<ImageView
android:layout_width="@dimen/dp_24"
android:layout_height="@dimen/dp_24"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dp_10"
android:src="@drawable/ic_search" />
<EditText
android:id="@+id/ed_food_ingredients_search"
style="@style/supplier_search_style"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_8"
android:layout_marginRight="@dimen/dp_5"
android:layout_weight="1"
android:background="@null"
android:hint="搜索食材名稱" />
</LinearLayout>
<com.qmuiteam.qmui.alpha.QMUIAlphaImageButton
android:id="@+id/btn_switch_row"
android:layout_width="@dimen/dp_26"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:src="@drawable/ic_single_row" />
</LinearLayout>
<LinearLayout
android:id="@+id/srl_supplier"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/layout_food_ingredients_btn"
android:layout_below="@id/layout_food_ingredients_top"
android:layout_marginTop="@dimen/dp_5"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/layout_ingredients_left"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_switch_food_ingredients_show_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginRight="@dimen/dp_7"
android:background="@drawable/shape_light_small_app_btn"
android:gravity="center"
android:paddingLeft="@dimen/dp_4"
android:paddingTop="@dimen/dp_5"
android:paddingRight="@dimen/dp_4"
android:paddingBottom="@dimen/dp_5"
android:text="@string/str_species"
android:textColor="@color/white"
android:textSize="@dimen/dp_14" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_food_ingredients_category"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout_right_content"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:orientation="vertical">
<!-- 二級分類 -->
<LinearLayout
android:id="@+id/layout_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_food_ingredients_second_category"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<androidx.cardview.widget.CardView
android:id="@+id/card_show_more_category"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@color/white"
app:cardElevation="@dimen/dp_10">
<LinearLayout
android:layout_width="@dimen/dp_58"
android:layout_height="match_parent"
android:background="@color/white"
android:gravity="center">
<ImageView
android:id="@+id/iv_unfold_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_inverted_triangle_66" />
<TextView
android:id="@+id/tv_unfold_category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_3"
android:text="展開"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_12" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
<!-- 食材 -->
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/dp_5">
<com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout
android:id="@+id/section_food_ingredients"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
<!-- <androidx.recyclerview.widget.RecyclerView-->
<!-- android:id="@+id/rv_food_ingredients"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_marginTop="@dimen/dp_5"-->
<!-- app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />-->
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/layout_food_ingredients_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_20"
android:layout_marginBottom="@dimen/dp_10"
android:orientation="horizontal">
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_new_food_ingredient"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape_app_btn"
android:gravity="center"
android:text="+新增食材"
android:textColor="@color/white"
android:textSize="@dimen/dp_16"
android:visibility="gone" />
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_food_ingredients_confirm"
style="@style/Save_Btn_Style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginRight="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_5"
android:text="確定"
android:visibility="visible" />
<TextView
android:id="@+id/tv_ingredients_food_num"
android:layout_width="@dimen/dp_20"
android:layout_height="@dimen/dp_20"
android:layout_gravity="right"
android:autoSizeMaxTextSize="@dimen/dp_8"
android:autoSizeMinTextSize="@dimen/dp_4"
android:background="@drawable/ui_shape_red_oval"
android:gravity="center"
android:text="3"
android:textColor="@color/white"
android:textSize="@dimen/dp_12"
android:visibility="gone"
app:layout_constraintRight_toRightOf="@id/iv_shopping_cart"
app:layout_constraintTop_toTopOf="@id/iv_shopping_cart" />
</FrameLayout>
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_food_ingredients_cancel"
style="@style/Cancel_Btn_Style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_5"
android:layout_weight="1"
android:text="取消"
android:visibility="visible" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
......@@ -33,4 +33,5 @@
<string name="str_determine">確定</string>
<string name="str_delete_category_tip">是否確認刪除該類別【%1$s】,子類和食材將一同刪除?</string>
<string name="str_preview">預覽</string>
</resources>
\ No newline at end of file
......@@ -65,7 +65,7 @@ public class MyAppLifecycles implements AppLifecycles {
private void initLeakCanary(Application application) {
//leakCanary内存泄露检查
mRefWatcher = BuildConfig.USE_CANARY ? LeakCanary.install(application) : RefWatcher.DISABLED;
// mRefWatcher = BuildConfig.USE_CANARY ? LeakCanary.install(application) : RefWatcher.DISABLED;
}
public RefWatcher getRefWatcher() {
......
......@@ -81,8 +81,11 @@ class OrderDetails {
var RECEIVER: String? = null
var TOTAL_AMOUNT: String? = null
//後台不會返回
//訂單類型#1:餐廳訂單;2:線上外賣訂單3:扫码点餐;4固定二维码订单;5:预点餐;6:積分訂單;7:自取订单;8:冷鏈
var order_type: Int = 0
//是否是預約單 0 :即時單 1:是預約單
var appointmentType: Int = 0
var orderPayType: Int = 0//0店內支付,1為貨到付款,2是在線支付
var isDelete: Int = 1 //默認為1,為0是第三方物流,其他則是本店配送
var payTime: String? = null
......
......@@ -103,6 +103,9 @@ public class TimePickerUtils {
*/
public static TimePickerView showReportTimePicker(Context mContext, Calendar startTime, Calendar endTime, Calendar defaultTime, OnTimeSelectListener onTimeSelectListener) {
//打開時間選擇器
Calendar rangStartTime = Calendar.getInstance();
rangStartTime.set(2015, 1, 1);
rangStartTime.set(Calendar.DAY_OF_YEAR, rangStartTime.getActualMinimum(Calendar.DAY_OF_YEAR));
TimePickerView pvTime = new TimePickerBuilder(mContext, onTimeSelectListener)
.setType(new boolean[]{true, true, true, false, false, false})
.setCancelText("取消")//取消按钮文字
......@@ -119,7 +122,7 @@ public class TimePickerUtils {
// .setTitleBgColor(0xFF666666)//标题背景颜色 Night mode
// .setBgColor(0xFF333333)//滚轮背景颜色 Night mode
// .setDate(selectedDate)// 如果不设置的话,默认是系统时间*/
.setRangDate(startTime, endTime)//時間是今年第一天到今天
.setRangDate(rangStartTime, endTime)//時間是2015年到今天
.setLabel("", "", "", "", "", "")
.isCenterLabel(false) //是否只显示中间选中项的label文字,false则每项item全部都带有label。
// .isDialog(true)//是否显示为对话框样式
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/Multi_Layout_Style"
android:layout_width="match_parent"
android:gravity="center_vertical">
......@@ -15,6 +16,8 @@
android:id="@+id/switch_multi_boolean_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:shadowColor="@color/trans"
android:thumb="@drawable/shape_thumb_on"
android:track="@drawable/selector_switch_track" />
android:track="@drawable/selector_switch_track"
app:trackTint="@color/theme_color" />
</LinearLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment