Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
supplier
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王宇航
supplier
Commits
9cd1b8c8
Commit
9cd1b8c8
authored
Jul 22, 2021
by
jason
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
菜品 相关 代码同步
parent
d4deaba5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
1306 additions
and
90 deletions
+1306
-90
component-supply-chain/src/main/java/com/gingersoft/supply_chain/di/component/DishesComponent.java
+34
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/di/module/DishesModule.java
+28
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/bean/DishesBean.java
+84
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/bean/DishesInfo.java
+0
-77
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/bean/DishesResultBean.java
+1
-1
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/content/DishesFoodList.java
+206
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/contract/DishesContract.java
+57
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/contract/OtherFunctionContract.java
+3
-4
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/model/DishesModel.java
+57
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/model/OtherFunctionModel.java
+3
-2
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/presenter/DishesPresenter.java
+140
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/presenter/OtherFunctionPresenter.java
+0
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/server/SupplierServer.java
+14
-1
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/dishes/DishNode.java
+107
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/dishes/DishProvider.java
+45
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/dishes/DishesGroupNode.java
+129
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/dishes/DishesGroupProvider.java
+81
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/dishes/DishesTreeAdapter.java
+32
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/fragment/DishesFragment.java
+134
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/fragment/FunctionListFragment.java
+13
-1
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/fragment/food/OtherFunctionFragment.java
+11
-4
component-supply-chain/src/main/res/layout/fragment_dishes.xml
+86
-0
component-supply-chain/src/main/res/layout/item_dish_group.xml
+22
-0
component-supply-chain/src/main/res/layout/item_dishes.xml
+17
-0
component-supply-chain/src/main/res/values/strings.xml
+2
-0
No files found.
component-supply-chain/src/main/java/com/gingersoft/supply_chain/di/component/DishesComponent.java
0 → 100644
View file @
9cd1b8c8
package
com
.
gingersoft
.
supply_chain
.
di
.
component
;
import
com.gingersoft.supply_chain.di.module.DishesModule
;
import
com.gingersoft.supply_chain.mvp.contract.DishesContract
;
import
com.gingersoft.supply_chain.mvp.ui.fragment.DishesFragment
;
import
com.jess.arms.di.component.AppComponent
;
import
com.jess.arms.di.scope.FragmentScope
;
import
dagger.BindsInstance
;
import
dagger.Component
;
/**
* ================================================
* ================================================
*/
@FragmentScope
@Component
(
modules
=
DishesModule
.
class
,
dependencies
=
AppComponent
.
class
)
public
interface
DishesComponent
{
void
inject
(
DishesFragment
fragment
);
@Component
.
Builder
interface
Builder
{
@BindsInstance
DishesComponent
.
Builder
view
(
DishesContract
.
View
view
);
DishesComponent
.
Builder
appComponent
(
AppComponent
appComponent
);
DishesComponent
build
();
}
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/di/module/DishesModule.java
0 → 100644
View file @
9cd1b8c8
package
com
.
gingersoft
.
supply_chain
.
di
.
module
;
import
com.gingersoft.supply_chain.mvp.contract.DishesContract
;
import
com.gingersoft.supply_chain.mvp.model.DishesModel
;
import
dagger.Binds
;
import
dagger.Module
;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 2021/07/21 14:28
* <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
//构建DishesModule时,将View的实现类传进来,这样就可以提供View的实现类给presenter
public
abstract
class
DishesModule
{
@Binds
abstract
DishesContract
.
Model
bindDishesModel
(
DishesModel
model
);
}
\ No newline at end of file
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/bean/DishesBean.java
0 → 100644
View file @
9cd1b8c8
package
com
.
gingersoft
.
supply_chain
.
mvp
.
bean
;
import
lombok.Data
;
@Data
public
class
DishesBean
implements
Comparable
<
DishesBean
>
{
private
int
id
;
private
int
parentId
;
private
int
restaurantId
;
private
boolean
isParent
;
private
int
seqNo
;
private
String
foodName
;
@Override
public
int
compareTo
(
DishesBean
dishesBean
)
{
return
this
.
id
-
dishesBean
.
id
;
}
// private boolean autoMod;
// private int lunchboxPrice;
// private boolean serviceCharge;
// private int invisible;
// private int riceponInvisible;
// private int cost;
// private String startDate;
// private String endDate;
// private int totalSold;
// private int isSold;
// private String createBy;
// private String createTime;
// private String updateBy;
// private String updateTime;
// private int periodId;
// private String posFId;
// private int ablediscount;
// private int takeaway;
// private int limitAmount;
// private int limitType;
// private String foodSummary;
// private String foodName1;
// private String foodName2;
// private int printTo;
// private int printToBill;
// private int conditions;
// private int isRt;
// private int deletes;
// private String periodName1;
// private String startDateStr;
// private String endDateStr;
// private double price;
// private int marketPrice;
// private int blueEdit;
// private int cartEdit;
// private int autoMerge;
// private String foodDesc;
// private String imageUrl;
// private int colorId;
// private int deptId;
// private int approve;
// private int printFont;
// private int advPrice;
// private int pointsAdd;
// private int pointsRatio;
// private int pointsRedeem;
// private int ktPrintMainItem;
// private int ktShowPrice;
// private int toPax;
// private int foodType;
// private int majorMainId;
// private int isTimingFood;
// private int minLongTime;
// private int unitTime;
// private int unitPrice;
// private int freeLongTime;
// private String fId;
// private String plu;
// private String printseting;
// private int isPrintQueueCode;
// private int queueHeadId;
// private String imgUrlSmall;
// private String freePeriodBegin;
// private int agreementType;
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/bean/DishesInfo.java
deleted
100644 → 0
View file @
d4deaba5
package
com
.
gingersoft
.
supply_chain
.
mvp
.
bean
;
import
lombok.Data
;
@Data
public
class
DishesInfo
{
private
int
id
;
private
int
parentId
;
private
int
restaurantId
;
private
boolean
isParent
;
private
int
seqNo
;
private
String
foodName
;
private
boolean
autoMod
;
private
int
lunchboxPrice
;
private
boolean
serviceCharge
;
private
int
invisible
;
private
int
riceponInvisible
;
private
int
cost
;
private
String
startDate
;
private
String
endDate
;
private
int
totalSold
;
private
int
isSold
;
private
String
createBy
;
private
String
createTime
;
private
String
updateBy
;
private
String
updateTime
;
private
int
periodId
;
private
String
posFId
;
private
int
ablediscount
;
private
int
takeaway
;
private
int
limitAmount
;
private
int
limitType
;
private
String
foodSummary
;
private
String
foodName1
;
private
String
foodName2
;
private
int
printTo
;
private
int
printToBill
;
private
int
conditions
;
private
int
isRt
;
private
int
deletes
;
private
String
periodName1
;
private
String
startDateStr
;
private
String
endDateStr
;
private
double
price
;
private
int
marketPrice
;
private
int
blueEdit
;
private
int
cartEdit
;
private
int
autoMerge
;
private
String
foodDesc
;
private
String
imageUrl
;
private
int
colorId
;
private
int
deptId
;
private
int
approve
;
private
int
printFont
;
private
int
advPrice
;
private
int
pointsAdd
;
private
int
pointsRatio
;
private
int
pointsRedeem
;
private
int
ktPrintMainItem
;
private
int
ktShowPrice
;
private
int
toPax
;
private
int
foodType
;
private
int
majorMainId
;
private
int
isTimingFood
;
private
int
minLongTime
;
private
int
unitTime
;
private
int
unitPrice
;
private
int
freeLongTime
;
private
String
fId
;
private
String
plu
;
private
String
printseting
;
private
int
isPrintQueueCode
;
private
int
queueHeadId
;
private
String
imgUrlSmall
;
private
String
freePeriodBegin
;
private
int
agreementType
;
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/bean/DishesResultBean.java
View file @
9cd1b8c8
...
...
@@ -15,6 +15,6 @@ public class DishesResultBean {
@Data
public
static
class
DataBean
{
private
int
count
;
private
List
<
Dishes
Info
>
list
;
private
List
<
Dishes
Bean
>
list
;
}
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/content/DishesFoodList.java
0 → 100644
View file @
9cd1b8c8
package
com
.
gingersoft
.
supply_chain
.
mvp
.
content
;
import
com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean
;
import
com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean
;
import
com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean
;
import
com.xuexiang.rxutil2.rxjava.RxJavaUtils
;
import
com.xuexiang.rxutil2.rxjava.task.RxIOTask
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author zjs.
* Use:需要緩存用戶選中的食品
*/
public
class
DishesFoodList
{
/**
* 供應商信息map
* 有時候PurchaseFoodBean中的供應商信息不可靠,比如:用戶將食品添加到購物車中,然後又去供應商列表修改供應商信息,這時候需要更新供應商信息
*/
private
static
Map
<
Integer
,
SupplierInfoBean
>
supplierInfoBeanMap
;
/**
* key為食品id
* value為食品信息
*/
private
static
Map
<
Integer
,
PurchaseFoodBean
>
foodBeanMap
;
private
static
DishesFoodList
shoppingCart
;
public
static
DishesFoodList
getInstance
()
{
if
(
shoppingCart
==
null
)
{
shoppingCart
=
new
DishesFoodList
();
}
return
shoppingCart
;
}
public
ArrayList
<
PurchaseFoodBean
>
getCartFoods
()
{
return
new
ArrayList
<>(
getFoodBeanMap
().
values
());
}
public
Map
<
Integer
,
PurchaseFoodBean
>
getFoodBeanMap
()
{
if
(
foodBeanMap
==
null
)
{
foodBeanMap
=
new
HashMap
<>();
}
return
foodBeanMap
;
}
public
Map
<
Integer
,
SupplierInfoBean
>
getSupplierInfoBeanMap
()
{
if
(
supplierInfoBeanMap
==
null
)
{
supplierInfoBeanMap
=
new
HashMap
<>();
}
return
supplierInfoBeanMap
;
}
public
SupplierInfoBean
getSupplierById
(
int
supplierId
)
{
return
getSupplierInfoBeanMap
().
get
(
supplierId
);
}
public
void
updateSupplier
(
SupplierInfoBean
supplierInfoBean
)
{
getSupplierInfoBeanMap
().
put
(
supplierInfoBean
.
getId
(),
supplierInfoBean
);
}
public
void
addAllFood
(
Collection
<
PurchaseFoodBean
>
purchaseFoodBeans
)
{
for
(
PurchaseFoodBean
purchaseFoodBean
:
purchaseFoodBeans
)
{
addFood
(
purchaseFoodBean
);
}
}
/**
* 添加食品時記錄供應商信息,對供應商進行修改時,需要修改食材的供應商信息
*
* @param purchaseFoodBean 食品
*/
public
void
addFood
(
PurchaseFoodBean
purchaseFoodBean
)
{
getFoodBeanMap
().
put
(
purchaseFoodBean
.
getId
(),
purchaseFoodBean
);
if
(
getSupplierInfoBeanMap
().
get
(
purchaseFoodBean
.
getSupplierId
())
==
null
)
{
getSupplierInfoBeanMap
().
put
(
purchaseFoodBean
.
getSupplierId
(),
SupplierInfoBean
.
generateSupplierByFood
(
purchaseFoodBean
));
}
}
/**
* 替換食品信息
*
* @param purchaseFoodBean 食品信息
*/
public
void
replaceFood
(
PurchaseFoodBean
purchaseFoodBean
)
{
//從食品緩衝中拿到這個食品
PurchaseFoodBean
mapFood
=
getFoodBeanMap
().
get
(
purchaseFoodBean
.
getId
());
//食品不為空並且這個食品的供應商還存在
if
(
mapFood
!=
null
&&
getSupplierInfoBeanMap
().
get
(
purchaseFoodBean
.
getSupplierId
())
!=
null
)
{
//將要替換的食品數量同步為當前緩存中的數量
purchaseFoodBean
.
setFoodQuantity
(
mapFood
.
getFoodQuantity
());
//用新的食材數據替換掉舊的,避免有可能修改了其他信息
getFoodBeanMap
().
put
(
purchaseFoodBean
.
getId
(),
purchaseFoodBean
);
}
}
public
void
removeFood
(
PurchaseFoodBean
purchaseFoodBean
)
{
getFoodBeanMap
().
remove
(
purchaseFoodBean
.
getId
());
}
public
void
clear
()
{
getFoodBeanMap
().
clear
();
}
public
PurchaseFoodBean
getFoodByFoodId
(
int
foodId
)
{
for
(
PurchaseFoodBean
cartFood
:
getCartFoods
())
{
if
(
cartFood
.
getId
()
==
foodId
)
{
return
cartFood
;
}
}
return
null
;
}
public
void
removeFoodsByFoodId
(
int
foodId
)
{
foodBeanMap
.
remove
(
foodId
);
}
public
void
removeFoodsBySupplier
(
int
supplierId
)
{
RxJavaUtils
.
doInIOThread
(
new
RxIOTask
<
Object
>(
0
)
{
@Override
public
Void
doInIOThread
(
Object
o
)
{
//刪除供應商成功後,需要從購物車數據中將這個供應商的食材都刪除掉
List
<
PurchaseFoodBean
>
cartFoods
=
DishesFoodList
.
getInstance
().
getCartFoods
();
Iterator
<
PurchaseFoodBean
>
iterator
=
cartFoods
.
iterator
();
while
(
iterator
.
hasNext
())
{
PurchaseFoodBean
next
=
iterator
.
next
();
if
(
next
.
getSupplierId
()
!=
null
&&
next
.
getSupplierId
()
==
supplierId
)
{
iterator
.
remove
();
}
}
return
null
;
}
});
}
public
void
removeFoodsByCategoryId
(
int
categoryId
)
{
RxJavaUtils
.
doInIOThread
(
new
RxIOTask
<
Object
>(
0
)
{
@Override
public
Void
doInIOThread
(
Object
o
)
{
//刪除供應商成功後,需要從購物車數據中將這個供應商的食材都刪除掉
List
<
PurchaseFoodBean
>
cartFoods
=
DishesFoodList
.
getInstance
().
getCartFoods
();
Iterator
<
PurchaseFoodBean
>
iterator
=
cartFoods
.
iterator
();
while
(
iterator
.
hasNext
())
{
PurchaseFoodBean
next
=
iterator
.
next
();
if
(
next
.
getFoodCategoryId
()
!=
null
&&
next
.
getFoodCategoryId
()
==
categoryId
)
{
iterator
.
remove
();
}
}
return
null
;
}
});
}
public
void
removeFoodsByCategoryTress
(
OrderCategoryBean
.
FoodCategoryTrees
foodCategoryTrees
)
{
RxJavaUtils
.
doInIOThread
(
new
RxIOTask
<
Object
>(
0
)
{
@Override
public
Void
doInIOThread
(
Object
o
)
{
//刪除分類成功後,需要從購物車數據中將這個分類的食材都刪除掉
List
<
PurchaseFoodBean
>
cartFoods
=
DishesFoodList
.
getInstance
().
getCartFoods
();
Iterator
<
PurchaseFoodBean
>
iterator
=
cartFoods
.
iterator
();
while
(
iterator
.
hasNext
())
{
PurchaseFoodBean
next
=
iterator
.
next
();
if
(
next
.
getFoodCategoryId
()
!=
null
&&
next
.
getFoodCategoryId
()
==
foodCategoryTrees
.
getId
())
{
iterator
.
remove
();
}
}
//分類中的刪除完了,需要刪除分類下子分類的食材
List
<
OrderCategoryBean
.
FoodCategoryTrees
>
childCategory
=
foodCategoryTrees
.
getFoodCategoryTrees
();
if
(
childCategory
!=
null
)
{
//遍歷二級分類
for
(
OrderCategoryBean
.
FoodCategoryTrees
categoryTrees
:
childCategory
)
{
for
(
PurchaseFoodBean
cartFood
:
cartFoods
)
{
if
(
cartFood
.
getFoodCategoryId
()
==
categoryTrees
.
getId
())
{
cartFoods
.
remove
(
cartFood
);
break
;
}
}
//對三級分類進行遍歷
List
<
OrderCategoryBean
.
FoodCategoryTrees
>
thirdCategory
=
categoryTrees
.
getFoodCategoryTrees
();
removeFoodsByCategoryTress
(
thirdCategory
);
}
}
return
null
;
}
});
}
public
void
removeFoodsByCategoryTress
(
List
<
OrderCategoryBean
.
FoodCategoryTrees
>
thirdCategory
)
{
if
(
thirdCategory
!=
null
)
{
for
(
OrderCategoryBean
.
FoodCategoryTrees
trees
:
thirdCategory
)
{
for
(
PurchaseFoodBean
cartFood
:
getCartFoods
())
{
if
(
cartFood
.
getFoodCategoryId
()
==
trees
.
getId
())
{
getFoodBeanMap
().
remove
(
cartFood
.
getId
());
}
}
}
}
}
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/contract/DishesContract.java
0 → 100644
View file @
9cd1b8c8
package
com
.
gingersoft
.
supply_chain
.
mvp
.
contract
;
import
com.gingersoft.gsa.cloud.common.bean.BaseResult
;
import
com.gingersoft.supply_chain.mvp.bean.BuyIngredientsBean
;
import
com.gingersoft.supply_chain.mvp.bean.DishesResultBean
;
import
com.jess.arms.mvp.IModel
;
import
com.jess.arms.mvp.IView
;
import
java.util.List
;
import
java.util.Map
;
import
io.reactivex.Observable
;
/**
*
*/
public
interface
DishesContract
{
interface
View
extends
IView
{
/**
* 加載菜品組數據
*/
void
loadDishGroupInfo
(
DishesResultBean
dishGroup
);
void
loadDishesInfo
(
DishesResultBean
dishes
);
/**
* 加載失敗
*/
void
loadFail
();
/**
* 結束加載並且沒有更多數據了
*/
void
finishLoad
(
boolean
noData
);
/**
* 加載食品
*
* @param buyIngredientsBeans 顯示的食材
*/
void
loadFood
(
List
<
BuyIngredientsBean
>
buyIngredientsBeans
);
void
selectDishGroupByIndex
(
int
position
);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface
Model
extends
IModel
{
Observable
<
DishesResultBean
>
getDishGroupData
(
Map
<
String
,
Object
>
map
);
Observable
<
DishesResultBean
>
getDishesData
(
Map
<
String
,
Object
>
map
);
Observable
<
BaseResult
>
bindDishes
(
Map
<
String
,
Object
>
map
);
}
}
\ No newline at end of file
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/contract/OtherFunctionContract.java
View file @
9cd1b8c8
...
...
@@ -2,12 +2,11 @@ package com.gingersoft.supply_chain.mvp.contract;
import
com.gingersoft.gsa.cloud.common.bean.BaseResult
;
import
com.gingersoft.supply_chain.mvp.bean.BuyIngredientsBean
;
import
com.gingersoft.supply_chain.mvp.bean.DishesResultBean
;
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.jess.arms.mvp.IView
;
import
com.jess.arms.mvp.IModel
;
import
com.jess.arms.mvp.IView
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -69,7 +68,7 @@ public interface OtherFunctionContract {
Observable
<
OrderCategoryBean
>
getCategoryTrees
(
Map
<
String
,
Object
>
map
);
Observable
<
DishesResultBean
>
getFoodList
(
Map
<
String
,
Object
>
map
);
//
Observable<FoodByCategoryResultBean> getFoodByCategory(Map<String, Object> map);
//
Observable<DishesResultBean> getFoodList(Map<String, Object> map);
Observable
<
FoodByCategoryResultBean
>
getFoodByCategory
(
Map
<
String
,
Object
>
map
);
}
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/model/DishesModel.java
0 → 100644
View file @
9cd1b8c8
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.DishesResultBean
;
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.DishesContract
;
import
java.util.Map
;
import
io.reactivex.Observable
;
/**
*/
@FragmentScope
public
class
DishesModel
extends
BaseModel
implements
DishesContract
.
Model
{
@Inject
Gson
mGson
;
@Inject
Application
mApplication
;
@Inject
public
DishesModel
(
IRepositoryManager
repositoryManager
)
{
super
(
repositoryManager
);
}
@Override
public
void
onDestroy
()
{
super
.
onDestroy
();
this
.
mGson
=
null
;
this
.
mApplication
=
null
;
}
@Override
public
Observable
<
DishesResultBean
>
getDishGroupData
(
Map
<
String
,
Object
>
map
)
{
return
mRepositoryManager
.
obtainRetrofitService
(
SupplierServer
.
class
).
getDishesList
(
map
);
}
@Override
public
Observable
<
DishesResultBean
>
getDishesData
(
Map
<
String
,
Object
>
map
)
{
return
mRepositoryManager
.
obtainRetrofitService
(
SupplierServer
.
class
).
getDishesList
(
map
);
}
@Override
public
Observable
<
BaseResult
>
bindDishes
(
Map
<
String
,
Object
>
map
)
{
return
null
;
}
}
\ No newline at end of file
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/model/OtherFunctionModel.java
View file @
9cd1b8c8
...
...
@@ -69,7 +69,7 @@ public class OtherFunctionModel extends BaseModel implements OtherFunctionContra
}
@Override
public
Observable
<
DishesResultBean
>
getFoodList
(
Map
<
String
,
Object
>
map
)
{
return
mRepositoryManager
.
obtainRetrofitService
(
SupplierServer
.
class
).
getFood
List
(
map
);
public
Observable
<
FoodByCategoryResultBean
>
getFoodByCategory
(
Map
<
String
,
Object
>
map
)
{
return
mRepositoryManager
.
obtainRetrofitService
(
SupplierServer
.
class
).
getFood
ByCategory
(
map
);
}
}
\ No newline at end of file
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/presenter/DishesPresenter.java
0 → 100644
View file @
9cd1b8c8
package
com
.
gingersoft
.
supply_chain
.
mvp
.
presenter
;
import
android.app.Application
;
import
com.gingersoft.gsa.cloud.common.constans.AppConstant
;
import
com.gingersoft.gsa.cloud.common.utils.other.TextUtil
;
import
com.gingersoft.supply_chain.mvp.bean.DishesBean
;
import
com.gingersoft.supply_chain.mvp.bean.DishesResultBean
;
import
com.gingersoft.supply_chain.mvp.contract.DishesContract
;
import
com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishNode
;
import
com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishesGroupNode
;
import
com.jess.arms.di.scope.FragmentScope
;
import
com.jess.arms.http.imageloader.ImageLoader
;
import
com.jess.arms.integration.AppManager
;
import
com.jess.arms.mvp.BasePresenter
;
import
com.jess.arms.utils.LogUtils
;
import
com.jess.arms.utils.RxLifecycleUtils
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.inject.Inject
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.schedulers.Schedulers
;
import
me.jessyan.rxerrorhandler.core.RxErrorHandler
;
import
me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber
;
/**
* ================================================
* 菜品
* ================================================
*/
@FragmentScope
public
class
DishesPresenter
extends
BasePresenter
<
DishesContract
.
Model
,
DishesContract
.
View
>
{
@Inject
RxErrorHandler
mErrorHandler
;
@Inject
Application
mApplication
;
@Inject
ImageLoader
mImageLoader
;
@Inject
AppManager
mAppManager
;
@Inject
public
DishesPresenter
(
DishesContract
.
Model
model
,
DishesContract
.
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
getDishesData
()
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
2
);
// map.put("","0");
AppConstant
.
addBrandId
(
map
);
AppConstant
.
addRestaurantId
(
map
);
mModel
.
getDishesData
(
map
)
//發送請求
.
subscribeOn
(
Schedulers
.
io
())
//切換到io異步線程
.
doOnSubscribe
(
disposable
->
mRootView
.
showLoading
(
AppConstant
.
GET_INFO_LOADING
))
//顯示加載提示框
.
subscribeOn
(
AndroidSchedulers
.
mainThread
())
//切換到主線程,上面的提示框就在主線程
.
observeOn
(
AndroidSchedulers
.
mainThread
())
//切換到主線程,隱藏提示框在主線程
.
doAfterTerminate
(()
->
mRootView
.
hideLoading
())
//任務執行完成後,隱藏提示框
.
compose
(
RxLifecycleUtils
.
bindToLifecycle
(
mRootView
))
//綁定生命週期,頁面隱藏時斷開請求
.
observeOn
(
AndroidSchedulers
.
mainThread
())
//切換到主線程
.
subscribe
(
new
ErrorHandleSubscriber
<
DishesResultBean
>(
mErrorHandler
)
{
//mErrorHandler是統一的錯誤處理
@Override
public
void
onNext
(
DishesResultBean
orderCategoryBean
)
{
//數據處理
if
(
orderCategoryBean
.
isSuccess
())
{
DishesResultBean
.
DataBean
data
=
orderCategoryBean
.
getData
();
if
(
data
!=
null
)
{
//將分類食品的list容量設置為一級分類的數量,這樣就不用擔心之後加載不同position的分類數據時,計算位置了
LogUtils
.
warnInfo
(
" zjs ="
+
data
.
getCount
());
List
<
DishesBean
>
list
=
data
.
getList
();
List
<
DishesBean
>
plist
=
new
ArrayList
<>();
List
<
DishesBean
>
clist
=
new
ArrayList
<>();
List
<
DishesGroupNode
>
pNodes
=
new
ArrayList
<>();
List
<
DishNode
>
cNodes
=
new
ArrayList
<>();
// Collections.sort(list);
long
start
=
System
.
currentTimeMillis
();
LogUtils
.
warnInfo
(
" zjs ="
+
list
.
size
()
+
" start"
+
start
);
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
DishesBean
dishesBean
=
list
.
get
(
i
);
if
(
dishesBean
.
isParent
())
{
clist
.
add
(
dishesBean
);
//子菜单
// DishNode cNode=new DishNode(dishesBean);
// cNodes.add(cNode);
}
else
{
plist
.
add
(
dishesBean
);
//父菜单
DishesGroupNode
groupNode
=
new
DishesGroupNode
(
dishesBean
);
pNodes
.
add
(
groupNode
);
}
LogUtils
.
warnInfo
(
" zjs ="
+
list
.
get
(
i
).
toString
());
}
int
len
=
clist
.
size
();
for
(
int
i
=
0
;
i
<
pNodes
.
size
();
i
++)
{
DishesGroupNode
groupNode
=
pNodes
.
get
(
i
);
List
<
DishNode
>
subNode
=
new
ArrayList
<>();
for
(
int
j
=
0
;
j
<
len
;
j
++)
{
DishesBean
dishesBean
=
clist
.
get
(
i
);
if
(
groupNode
.
getId
()
==
dishesBean
.
getParentId
())
{
DishNode
cNode
=
new
DishNode
(
dishesBean
);
subNode
.
add
(
cNode
);
}
}
groupNode
.
setDishNodes
(
subNode
);
}
LogUtils
.
warnInfo
(
" zjs end="
+(
System
.
currentTimeMillis
()-
start
));
}
//第一次加載初始化數量
// initCategoryGoodsSize(data);
// mRootView.initCategoryInfo(data);
}
else
if
(
TextUtil
.
isNotEmptyOrNullOrUndefined
(
orderCategoryBean
.
getErrMsg
()))
{
mRootView
.
showMessage
(
orderCategoryBean
.
getErrMsg
());
}
else
{
mRootView
.
showMessage
(
AppConstant
.
GET_INFO_ERROR
);
}
}
});
}
}
\ No newline at end of file
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/presenter/OtherFunctionPresenter.java
View file @
9cd1b8c8
This diff is collapsed.
Click to expand it.
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/server/SupplierServer.java
View file @
9cd1b8c8
...
...
@@ -554,6 +554,19 @@ public interface SupplierServer {
*/
@Headers
({
"Domain-Name: ricepon-purchase"
})
@GET
(
"purchaseDishesConversion/getPurchaseDishesConversionDishes"
+
RetrofitUrlManager
.
IDENTIFICATION_PATH_SIZE
+
2
)
Observable
<
DishesResultBean
>
getFoodList
(
@QueryMap
Map
<
String
,
Object
>
map
);
Observable
<
DishesResultBean
>
getDishesList
(
@QueryMap
Map
<
String
,
Object
>
map
);
/**
* 菜品綁定食材
* http://a.ricepon.com:58201/ricepon-purchase/api/
* purchaseDishesConversion/getPurchaseDishesConversionDishes?
* parentId=9615&restaurantId=25
* isParent: 0
*/
@Headers
({
"Domain-Name: ricepon-purchase"
})
@GET
(
"purchaseDishesConversion/getPurchaseDishesConversionDishes"
+
RetrofitUrlManager
.
IDENTIFICATION_PATH_SIZE
+
2
)
Observable
<
DishesResultBean
>
bindFoods
(
@QueryMap
Map
<
String
,
Object
>
map
);
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/dishes/DishNode.java
0 → 100644
View file @
9cd1b8c8
package
com
.
gingersoft
.
supply_chain
.
mvp
.
ui
.
adapter
.
dishes
;
import
androidx.annotation.Nullable
;
import
com.chad.library.adapter.base.entity.node.BaseExpandNode
;
import
com.chad.library.adapter.base.entity.node.BaseNode
;
import
com.gingersoft.supply_chain.mvp.bean.DishesBean
;
import
java.util.List
;
public
class
DishNode
extends
BaseExpandNode
{
private
int
id
;
private
int
parentId
;
private
int
restaurantId
;
private
boolean
isParent
;
private
int
seqNo
;
private
String
foodName
;
private
List
<
BaseNode
>
childNode
;
public
DishNode
(
DishesBean
dishesBean
)
{
this
.
id
=
dishesBean
.
getId
();
this
.
parentId
=
dishesBean
.
getParentId
();
this
.
restaurantId
=
dishesBean
.
getRestaurantId
();
this
.
isParent
=
dishesBean
.
isParent
();
this
.
seqNo
=
dishesBean
.
getSeqNo
();
this
.
foodName
=
dishesBean
.
getFoodName
();
}
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
public
int
getParentId
()
{
return
parentId
;
}
public
void
setParentId
(
int
parentId
)
{
this
.
parentId
=
parentId
;
}
public
int
getRestaurantId
()
{
return
restaurantId
;
}
public
void
setRestaurantId
(
int
restaurantId
)
{
this
.
restaurantId
=
restaurantId
;
}
public
boolean
isParent
()
{
return
isParent
;
}
public
void
setParent
(
boolean
parent
)
{
isParent
=
parent
;
}
public
int
getSeqNo
()
{
return
seqNo
;
}
public
void
setSeqNo
(
int
seqNo
)
{
this
.
seqNo
=
seqNo
;
}
public
String
getFoodName
()
{
return
foodName
;
}
public
void
setFoodName
(
String
foodName
)
{
this
.
foodName
=
foodName
;
}
public
DishNode
(
List
<
BaseNode
>
childNode
)
{
this
.
childNode
=
childNode
;
setExpanded
(
false
);
}
public
String
getTitle
()
{
return
foodName
;
}
@Override
public
String
toString
()
{
return
"DishNode{"
+
"id="
+
id
+
", parentId="
+
parentId
+
", restaurantId="
+
restaurantId
+
", isParent="
+
isParent
+
", seqNo="
+
seqNo
+
", foodName='"
+
foodName
+
'\''
+
", childNode="
+
childNode
+
'}'
;
}
@Nullable
@Override
public
List
<
BaseNode
>
getChildNode
()
{
return
childNode
;
}
}
\ No newline at end of file
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/dishes/DishProvider.java
0 → 100644
View file @
9cd1b8c8
package
com
.
gingersoft
.
supply_chain
.
mvp
.
ui
.
adapter
.
dishes
;
import
android.view.View
;
import
com.chad.library.adapter.base.entity.node.BaseNode
;
import
com.chad.library.adapter.base.provider.BaseNodeProvider
;
import
com.chad.library.adapter.base.viewholder.BaseViewHolder
;
import
com.gingersoft.supply_chain.R
;
import
org.jetbrains.annotations.NotNull
;
public
class
DishProvider
extends
BaseNodeProvider
{
@Override
public
int
getItemViewType
()
{
return
DishesTreeAdapter
.
DISHESSINGLE
;
}
@Override
public
int
getLayoutId
()
{
return
R
.
layout
.
item_dishes
;
}
@Override
public
void
convert
(
@NotNull
BaseViewHolder
helper
,
@NotNull
BaseNode
data
)
{
DishNode
entity
=
(
DishNode
)
data
;
helper
.
setText
(
R
.
id
.
tv_dish_title
,
entity
.
getTitle
());
if
(
entity
.
isExpanded
())
{
helper
.
setImageResource
(
R
.
id
.
iv_dishes_group_icon
,
R
.
mipmap
.
keyboard_delete_img
);
}
else
{
helper
.
setImageResource
(
R
.
id
.
iv_dishes_group_icon
,
R
.
mipmap
.
keyboard_back_img
);
}
}
@Override
public
void
onClick
(
@NotNull
BaseViewHolder
helper
,
@NotNull
View
view
,
BaseNode
data
,
int
position
)
{
DishNode
entity
=
(
DishNode
)
data
;
if
(
entity
.
isExpanded
())
{
getAdapter
().
collapse
(
position
);
}
else
{
getAdapter
().
expandAndCollapseOther
(
position
);
}
}
}
\ No newline at end of file
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/dishes/DishesGroupNode.java
0 → 100644
View file @
9cd1b8c8
package
com
.
gingersoft
.
supply_chain
.
mvp
.
ui
.
adapter
.
dishes
;
import
com.chad.library.adapter.base.entity.node.BaseExpandNode
;
import
com.chad.library.adapter.base.entity.node.BaseNode
;
import
com.gingersoft.supply_chain.mvp.bean.DishesBean
;
import
org.jetbrains.annotations.Nullable
;
import
java.util.List
;
public
class
DishesGroupNode
extends
BaseExpandNode
{
private
int
id
;
private
int
parentId
;
private
int
restaurantId
;
private
boolean
isParent
;
private
int
seqNo
;
private
String
foodName
;
private
List
<
DishNode
>
dishNodes
;
private
List
<
BaseNode
>
childNode
;
public
DishesGroupNode
(
DishesBean
dishesBean
)
{
this
.
id
=
dishesBean
.
getId
();
this
.
parentId
=
dishesBean
.
getParentId
();
this
.
restaurantId
=
dishesBean
.
getRestaurantId
();
this
.
isParent
=
dishesBean
.
isParent
();
this
.
seqNo
=
dishesBean
.
getSeqNo
();
this
.
foodName
=
dishesBean
.
getFoodName
();
}
public
DishesGroupNode
(
int
id
,
int
parentId
,
int
restaurantId
,
boolean
isParent
,
int
seqNo
,
String
foodName
)
{
this
.
id
=
id
;
this
.
parentId
=
parentId
;
this
.
restaurantId
=
restaurantId
;
this
.
isParent
=
isParent
;
this
.
seqNo
=
seqNo
;
this
.
foodName
=
foodName
;
}
public
List
<
DishNode
>
getDishNodes
()
{
return
dishNodes
;
}
public
void
setDishNodes
(
List
<
DishNode
>
dishNodes
)
{
this
.
dishNodes
=
dishNodes
;
}
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
public
int
getParentId
()
{
return
parentId
;
}
public
void
setParentId
(
int
parentId
)
{
this
.
parentId
=
parentId
;
}
public
int
getRestaurantId
()
{
return
restaurantId
;
}
public
void
setRestaurantId
(
int
restaurantId
)
{
this
.
restaurantId
=
restaurantId
;
}
public
boolean
isParent
()
{
return
isParent
;
}
public
void
setParent
(
boolean
parent
)
{
isParent
=
parent
;
}
public
int
getSeqNo
()
{
return
seqNo
;
}
public
void
setSeqNo
(
int
seqNo
)
{
this
.
seqNo
=
seqNo
;
}
public
String
getFoodName
()
{
return
foodName
;
}
public
void
setFoodName
(
String
foodName
)
{
this
.
foodName
=
foodName
;
}
public
void
setChildNode
(
List
<
BaseNode
>
childNode
)
{
this
.
childNode
=
childNode
;
}
public
DishesGroupNode
(
List
<
BaseNode
>
childNode
)
{
this
.
childNode
=
childNode
;
setExpanded
(
false
);
}
public
String
getTitle
()
{
return
foodName
;
}
@Override
public
String
toString
()
{
return
"DishesGroupNode{"
+
"id="
+
id
+
", parentId="
+
parentId
+
", restaurantId="
+
restaurantId
+
", isParent="
+
isParent
+
", seqNo="
+
seqNo
+
", foodName='"
+
foodName
+
'\''
+
", childNode="
+
childNode
+
'}'
;
}
@Nullable
@Override
public
List
<
BaseNode
>
getChildNode
()
{
return
dishNodes
;
}
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/dishes/DishesGroupProvider.java
0 → 100644
View file @
9cd1b8c8
package
com
.
gingersoft
.
supply_chain
.
mvp
.
ui
.
adapter
.
dishes
;
import
android.view.View
;
import
android.view.animation.DecelerateInterpolator
;
import
android.widget.ImageView
;
import
androidx.core.view.ViewCompat
;
import
com.chad.library.adapter.base.entity.node.BaseNode
;
import
com.chad.library.adapter.base.provider.BaseNodeProvider
;
import
com.chad.library.adapter.base.viewholder.BaseViewHolder
;
import
com.gingersoft.supply_chain.R
;
import
org.jetbrains.annotations.NotNull
;
import
java.util.List
;
public
class
DishesGroupProvider
extends
BaseNodeProvider
{
@Override
public
int
getItemViewType
()
{
return
DishesTreeAdapter
.
DISHESGROUP
;
}
@Override
public
int
getLayoutId
()
{
return
R
.
layout
.
item_dish_group
;
}
@Override
public
void
convert
(
@NotNull
BaseViewHolder
baseViewHolder
,
BaseNode
baseNode
)
{
DishesGroupNode
entity
=
(
DishesGroupNode
)
baseNode
;
baseViewHolder
.
setText
(
R
.
id
.
tv_dishes_group_title
,
entity
.
getTitle
());
baseViewHolder
.
setImageResource
(
R
.
id
.
iv_dishes_group_icon
,
R
.
mipmap
.
ic_launcher
);
setArrowSpin
(
baseViewHolder
,
baseNode
,
false
);
}
@Override
public
void
convert
(
@NotNull
BaseViewHolder
helper
,
@NotNull
BaseNode
data
,
@NotNull
List
<?>
payloads
)
{
for
(
Object
payload
:
payloads
)
{
if
(
payload
instanceof
Integer
&&
(
int
)
payload
==
DishesTreeAdapter
.
EXPAND_COLLAPSE_PAYLOAD
)
{
// 增量刷新,使用动画变化箭头
setArrowSpin
(
helper
,
data
,
true
);
}
}
}
private
void
setArrowSpin
(
BaseViewHolder
helper
,
BaseNode
data
,
boolean
isAnimate
)
{
DishesGroupNode
entity
=
(
DishesGroupNode
)
data
;
ImageView
imageView
=
helper
.
getView
(
R
.
id
.
iv_dishes_group_icon
);
if
(
entity
.
isExpanded
())
{
if
(
isAnimate
)
{
ViewCompat
.
animate
(
imageView
).
setDuration
(
200
)
.
setInterpolator
(
new
DecelerateInterpolator
())
.
rotation
(
0
f
)
.
start
();
}
else
{
imageView
.
setRotation
(
0
f
);
}
}
else
{
if
(
isAnimate
)
{
ViewCompat
.
animate
(
imageView
).
setDuration
(
200
)
.
setInterpolator
(
new
DecelerateInterpolator
())
.
rotation
(
90
f
)
.
start
();
}
else
{
imageView
.
setRotation
(
90
f
);
}
}
}
@Override
public
void
onClick
(
@NotNull
BaseViewHolder
helper
,
@NotNull
View
view
,
BaseNode
data
,
int
position
)
{
// 这里使用payload进行增量刷新(避免整个item刷新导致的闪烁,不自然)
getAdapter
().
expandOrCollapse
(
position
,
true
,
true
,
DishesTreeAdapter
.
EXPAND_COLLAPSE_PAYLOAD
);
}
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/dishes/DishesTreeAdapter.java
0 → 100644
View file @
9cd1b8c8
package
com
.
gingersoft
.
supply_chain
.
mvp
.
ui
.
adapter
.
dishes
;
import
com.chad.library.adapter.base.BaseNodeAdapter
;
import
com.chad.library.adapter.base.entity.node.BaseNode
;
import
org.jetbrains.annotations.NotNull
;
import
java.util.List
;
public
class
DishesTreeAdapter
extends
BaseNodeAdapter
{
public
static
final
int
DISHESGROUP
=
1
;
public
static
final
int
DISHESSINGLE
=
2
;
public
DishesTreeAdapter
()
{
super
();
addNodeProvider
(
new
DishesGroupProvider
());
addNodeProvider
(
new
DishProvider
());
}
@Override
protected
int
getItemType
(
@NotNull
List
<?
extends
BaseNode
>
list
,
int
i
)
{
BaseNode
node
=
list
.
get
(
i
);
if
(
node
instanceof
DishesGroupNode
)
{
return
DISHESGROUP
;
}
else
if
(
node
instanceof
DishNode
)
{
return
DISHESSINGLE
;
}
return
-
1
;
}
public
static
final
int
EXPAND_COLLAPSE_PAYLOAD
=
110
;
}
\ No newline at end of file
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/fragment/DishesFragment.java
0 → 100644
View file @
9cd1b8c8
package
com
.
gingersoft
.
supply_chain
.
mvp
.
ui
.
fragment
;
import
android.os.Bundle
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.chad.library.adapter.base.entity.node.BaseNode
;
import
com.gingersoft.supply_chain.R
;
import
com.gingersoft.supply_chain.R2
;
import
com.gingersoft.supply_chain.di.component.DaggerDishesComponent
;
import
com.gingersoft.supply_chain.mvp.bean.BuyIngredientsBean
;
import
com.gingersoft.supply_chain.mvp.bean.DishesResultBean
;
import
com.gingersoft.supply_chain.mvp.contract.DishesContract
;
import
com.gingersoft.supply_chain.mvp.presenter.DishesPresenter
;
import
com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishNode
;
import
com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishesGroupNode
;
import
com.gingersoft.supply_chain.mvp.ui.adapter.dishes.DishesTreeAdapter
;
import
com.gingersoft.supply_chain.mvp.ui.widget.CenterLayoutManager
;
import
com.jess.arms.di.component.AppComponent
;
import
com.qmuiteam.qmui.widget.QMUITopBar
;
import
java.util.ArrayList
;
import
java.util.List
;
import
butterknife.BindView
;
/**
* Created on 2021/07/21 14:28
*
* @author zjs
* module name is DishesFragment
*/
public
class
DishesFragment
extends
BaseSupplyChainFragment
<
DishesPresenter
>
implements
DishesContract
.
View
{
@BindView
(
R2
.
id
.
topbar_food_ingredients
)
QMUITopBar
topbarFoodIngredients
;
@BindView
(
R2
.
id
.
rv_dishes
)
RecyclerView
rvDishesGroup
;
@BindView
(
R2
.
id
.
rv_dishes_food
)
RecyclerView
rvDishes
;
public
static
DishesFragment
newInstance
()
{
DishesFragment
fragment
=
new
DishesFragment
();
return
fragment
;
}
@Override
public
void
setupFragmentComponent
(
@NonNull
AppComponent
appComponent
)
{
DaggerDishesComponent
//如找不到该类,请编译一下项目
.
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_dishes
,
container
,
false
);
}
@Override
public
void
initData
(
@Nullable
Bundle
savedInstanceState
)
{
//setToolBarNoBack(toolbar, "Dishes");
initTopBar
(
topbarFoodIngredients
,
getString
(
R
.
string
.
str_dishes
));
mPresenter
.
getDishesData
();
}
private
void
initDishes
(){
DishesTreeAdapter
dishesTreeAdapter
=
new
DishesTreeAdapter
();
dishesTreeAdapter
.
setList
(
getEntity
());
rvDishes
.
setLayoutManager
(
new
CenterLayoutManager
(
requireContext
(),
LinearLayoutManager
.
HORIZONTAL
,
false
));
rvDishes
.
setAdapter
(
dishesTreeAdapter
);
}
private
List
<
BaseNode
>
getEntity
()
{
List
<
BaseNode
>
list
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
List
<
BaseNode
>
secondNodeList
=
new
ArrayList
<>();
for
(
int
n
=
0
;
n
<=
3
;
n
++)
{
DishNode
seNode
=
new
DishNode
(
secondNodeList
,
"Second Node "
+
n
);
secondNodeList
.
add
(
seNode
);
}
DishesGroupNode
entity
=
new
DishesGroupNode
(
secondNodeList
,
"First Node "
+
i
);
// 模拟 默认第0个是展开的
entity
.
setExpanded
(
i
==
0
);
list
.
add
(
entity
);
}
return
list
;
}
@Override
public
void
loadDishGroupInfo
(
DishesResultBean
dishGroup
)
{
}
@Override
public
void
loadDishesInfo
(
DishesResultBean
dishes
)
{
}
@Override
public
void
loadFail
()
{
}
@Override
public
void
finishLoad
(
boolean
noData
)
{
}
@Override
public
void
loadFood
(
List
<
BuyIngredientsBean
>
buyIngredientsBeans
)
{
}
@Override
public
void
selectDishGroupByIndex
(
int
position
)
{
}
}
\ No newline at end of file
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/fragment/FunctionListFragment.java
View file @
9cd1b8c8
...
...
@@ -10,11 +10,13 @@ import androidx.annotation.Nullable;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.gingersoft.gsa.cloud.common.BuildConfig
;
import
com.gingersoft.gsa.cloud.common.utils.log.LogUtil
;
import
com.gingersoft.gsa.cloud.common.utils.other.SPUtils
;
import
com.gingersoft.gsa.cloud.database.bean.Function
;
import
com.gingersoft.supply_chain.R
;
import
com.gingersoft.supply_chain.R2
;
import
com.gingersoft.supply_chain.di.component.DaggerFunctionListComponent
;
import
com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean
;
import
com.gingersoft.supply_chain.mvp.bean.PurchaseFunctionBean
;
import
com.gingersoft.supply_chain.mvp.contract.FunctionListContract
;
import
com.gingersoft.supply_chain.mvp.presenter.FunctionListPresenter
;
...
...
@@ -157,7 +159,8 @@ public class FunctionListFragment extends BaseSupplyChainFragment<FunctionListPr
new
XPopup
.
Builder
(
requireContext
()).
asCustom
(
new
UpdateRestaurantInfoPop
(
requireContext
())).
show
();
break
;
case
"菜品Boom"
:
start
(
OtherFunctionFragment
.
newInstance
());
start
(
DishesFragment
.
newInstance
());
// startForResult(OtherFunctionFragment.newInstance(),12345);
break
;
default
:
...
...
@@ -172,4 +175,13 @@ public class FunctionListFragment extends BaseSupplyChainFragment<FunctionListPr
mTopBar
.
addLeftBackImageButton
().
setOnClickListener
(
v
->
killMyself
());
}
@Override
public
void
onFragmentResult
(
int
requestCode
,
int
resultCode
,
Bundle
data
)
{
super
.
onFragmentResult
(
requestCode
,
resultCode
,
data
);
LogUtil
.
e
(
"zjs"
,
" onFragmentResult ="
+
requestCode
+
" resultCode="
+
resultCode
);
if
(
data
!=
null
)
{
ArrayList
<
PurchaseFoodBean
>
purchaseFood
=
(
ArrayList
<
PurchaseFoodBean
>)
data
.
getSerializable
(
"zjs"
);
LogUtil
.
e
(
"zjs"
,
" purchaseFood ="
+
purchaseFood
.
size
());
}
}
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/fragment/food/OtherFunctionFragment.java
View file @
9cd1b8c8
...
...
@@ -57,12 +57,16 @@ import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import
org.jetbrains.annotations.NotNull
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
import
butterknife.BindView
;
import
butterknife.OnClick
;
import
lombok.val
;
import
static
com
.
gingersoft
.
supply_chain
.
mvp
.
ui
.
fragment
.
category
.
CategorySelectFragment
.
SELECT_CATEGORY_DATA_KEY
;
import
static
com
.
gingersoft
.
supply_chain
.
mvp
.
ui
.
fragment
.
category
.
CategorySelectFragment
.
SELECT_FOOD_CATEGORY_RESULT_CODE
;
import
static
com
.
gingersoft
.
supply_chain
.
mvp
.
ui
.
fragment
.
food
.
NewFoodIngredientsFragment
.
EDIT_FOOD_RESULT_CODE
;
...
...
@@ -236,7 +240,7 @@ public class OtherFunctionFragment extends BaseSupplyChainFragment<OtherFunction
}
protected
void
initTopBar
()
{
initTopBar
(
topbarFoodIngredients
,
getString
(
R
.
string
.
str_title_purchase_order
));
initTopBar
(
topbarFoodIngredients
,
getString
(
R
.
string
.
str_title_purchase_order
));
//zjs 採購的
View
view
=
View
.
inflate
(
requireContext
(),
R
.
layout
.
view_shopping_car
,
null
);
tvShoppingCart
=
view
.
findViewById
(
R
.
id
.
tv_purchase_cart_number
);
RelativeLayout
.
LayoutParams
layoutParams
=
new
RelativeLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
WRAP_CONTENT
,
LinearLayout
.
LayoutParams
.
MATCH_PARENT
);
...
...
@@ -445,10 +449,13 @@ public class OtherFunctionFragment extends BaseSupplyChainFragment<OtherFunction
* 確認,進入購物車頁面
*/
protected
void
confirm
()
{
List
<
PurchaseFoodBean
>
purchaseFood
=
mPresenter
.
getPurchaseFood
();
Array
List
<
PurchaseFoodBean
>
purchaseFood
=
mPresenter
.
getPurchaseFood
();
if
(
CollectionUtils
.
isNotNullOrEmpty
(
purchaseFood
))
{
startForResult
(
ShoppingCatFragment
.
newInstance
(),
TO_SHOPPING_CART_REQUEST_CODE
);
setFragmentResult
(
RESULT_OK
,
null
);
LogUtil
.
e
(
"zjs"
,
" purchaseFood "
+
purchaseFood
.
size
());
Bundle
bundle
=
new
Bundle
();
bundle
.
putSerializable
(
"zjs"
,
(
Serializable
)
purchaseFood
);
setFragmentResult
(
RESULT_OK
,
bundle
);
killMyself
();
}
else
{
showMessage
(
"請選擇食材"
);
}
...
...
component-supply-chain/src/main/res/layout/fragment_dishes.xml
0 → 100644
View file @
9cd1b8c8
<?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"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:animateLayoutChanges=
"true"
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"
app:qmui_topbar_title_color=
"@color/theme_white_color"
/>
<LinearLayout
android:orientation=
"horizontal"
android:layout_width=
"match_parent"
android:layout_weight=
"1"
android:layout_height=
"0dp"
>
<!--菜品-->
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv_dishes"
android:layout_width=
"0dp"
android:layout_weight=
"1"
android:layout_height=
"match_parent"
>
</androidx.recyclerview.widget.RecyclerView>
<!-- 食材 -->
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id=
"@+id/refreshLayout"
android:layout_width=
"0dp"
android:layout_weight=
"4"
android:layout_height=
"match_parent"
>
<com.scwang.smartrefresh.layout.header.ClassicsHeader
android:id=
"@+id/fresh_header"
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/dp_30"
app:srlAccentColor=
"#aaa"
app:srlDrawableArrow=
"@drawable/ic_pulling"
app:srlDrawableMarginRight=
"@dimen/dp_5"
app:srlDrawableSize=
"@dimen/dp_12"
app:srlEnableLastTime=
"false"
app:srlFinishDuration=
"300"
app:srlPrimaryColor=
"@color/trans"
app:srlTextFinish=
"加載完成"
app:srlTextPulling=
"下滑查看上一分類"
app:srlTextRefreshing=
"正在飛速加載..."
app:srlTextRelease=
"釋放查看上一分類"
app:srlTextSizeTitle=
"@dimen/dp_12"
/>
<com.gingersoft.supply_chain.mvp.ui.widget.StickyHeaderLayout
android:id=
"@+id/view_stick_head"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv_dishes_food"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
app:layoutManager=
"androidx.recyclerview.widget.LinearLayoutManager"
/>
</com.gingersoft.supply_chain.mvp.ui.widget.StickyHeaderLayout>
<com.scwang.smartrefresh.layout.footer.ClassicsFooter
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/dp_30"
app:srlDrawableArrow=
"@drawable/ic_push"
app:srlDrawableMarginRight=
"@dimen/dp_5"
app:srlDrawableSize=
"@dimen/dp_12"
app:srlTextFailed=
"加載完成"
app:srlTextLoading=
"正在飛速加載中..."
app:srlTextPulling=
"上拉加載更多"
app:srlTextRelease=
"釋放查看下一分類"
app:srlTextSizeTitle=
"@dimen/dp_12"
/>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
component-supply-chain/src/main/res/layout/item_dish_group.xml
0 → 100644
View file @
9cd1b8c8
<?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"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:animateLayoutChanges=
"true"
android:background=
"@color/supply_chain_bg_color"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/tv_dishes_group_title"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
<ImageView
android:id=
"@+id/iv_dishes_group_icon"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
\ No newline at end of file
component-supply-chain/src/main/res/layout/item_dishes.xml
0 → 100644
View file @
9cd1b8c8
<?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"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:animateLayoutChanges=
"true"
android:background=
"@color/supply_chain_bg_color"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/tv_dish_title"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
\ No newline at end of file
component-supply-chain/src/main/res/values/strings.xml
View file @
9cd1b8c8
...
...
@@ -100,4 +100,5 @@
<string
name=
"str_order_del_contact_supplier"
>
訂單已刪除,請打電話聯繫供應商訂單刪除!
</string>
<string
name=
"str_order_num"
>
單號:%1$s
</string>
<string
name=
"str_dishes"
>
菜单
</string>
</resources>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment