Commit 84221077 by Wyh

1、供应链新的食材列表优化完成 2、切换环境按钮文字修改为确认 3、修改打包包名 4、心跳定时切换成RxJavaUtils

parent 68fb2115
...@@ -66,11 +66,9 @@ android { ...@@ -66,11 +66,9 @@ android {
def date = new Date() def date = new Date()
def formattedDate = date.format('yyyy-MM-dd') def formattedDate = date.format('yyyy-MM-dd')
if (variant.buildType.name == 'release') { if (variant.buildType.name == 'release') {
fileName = "${formattedDate}_GSA-Cloud_${variant.mergedFlavor.versionName}_正式版_.apk" fileName = "正式版_GSA-Cloud_${variant.mergedFlavor.versionName}_${formattedDate}.apk"
} else if (variant.buildType.name == 'Test') {
fileName = "${formattedDate}_GSA-Cloud_${variant.mergedFlavor.versionName}_測試版_.apk"
} else if (variant.buildType.name == 'debug') { } else if (variant.buildType.name == 'debug') {
fileName = "${formattedDate}_GSA-Cloud_${variant.mergedFlavor.versionName}_debug_.apk" fileName = "测试版_GSA-Cloud_${variant.mergedFlavor.versionName}_${formattedDate}.apk"
} }
outputFileName = fileName outputFileName = fileName
} }
......
...@@ -121,12 +121,10 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem ...@@ -121,12 +121,10 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
boolean isLogin = (boolean) SPUtils.get(UserConstans.AUTO_LOGIN, false); boolean isLogin = (boolean) SPUtils.get(UserConstans.AUTO_LOGIN, false);
if (isLogin) { if (isLogin) {
if (!TextUtils.isEmpty(UserContext.newInstance().getLoginToken()) && RestaurantInfoManager.newInstance().getRestaurantId() != 0) { if (!TextUtils.isEmpty(UserContext.newInstance().getLoginToken()) && RestaurantInfoManager.newInstance().getRestaurantId() != 0) {
//自動登陸 //自動登陸
UserContext.newInstance().setState(new LoginedState()); UserContext.newInstance().setState(new LoginedState());
int restaurantId = RestaurantInfoManager.newInstance().getRestaurantId(); int restaurantId = RestaurantInfoManager.newInstance().getRestaurantId();
if (restaurantId != 0) { if (restaurantId > 0) {
//已经选择过餐厅 直接进入 //已经选择过餐厅 直接进入
// jumpDownloadActivity(); // jumpDownloadActivity();
//需要驗證登陸人數 //需要驗證登陸人數
...@@ -135,7 +133,7 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem ...@@ -135,7 +133,7 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
} }
//调整选择餐厅页面 //调整选择餐厅页面
Intent intent = new Intent(mContext, ChooseRestaurantActivity.class); Intent intent = new Intent(mContext, ChooseRestaurantActivity.class);
Class clazz = getClass(); Class clazz = WelcomeActivity.this.getClass();
intent.putExtra("form", clazz.getName()); intent.putExtra("form", clazz.getName());
launchActivity(intent); launchActivity(intent);
} else { } else {
......
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
android:layout_height="@dimen/head_height" android:layout_height="@dimen/head_height"
android:layout_margin="@dimen/dp_20" android:layout_margin="@dimen/dp_20"
android:background="@color/theme_color" android:background="@color/theme_color"
android:text="清除用戶信息" android:text="@string/str_determine"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="@dimen/sp_16" /> android:textSize="@dimen/sp_16" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -21,6 +21,13 @@ public class Constant { ...@@ -21,6 +21,13 @@ public class Constant {
public static final int PAGE_SIZE = 10; public static final int PAGE_SIZE = 10;
public static final int PURCHASE_FOOD_MAX = 9999; public static final int PURCHASE_FOOD_MAX = 9999;
/** /**
* 长按时,初始间隔
*/
public static final int LONG_CLICK_INIT_TIME = 500;
public static final int LONG_CLICK_DECREASE_TIME = 100;
/**
* 庫存消耗——盤點消耗的id * 庫存消耗——盤點消耗的id
*/ */
public static final int INVENTORY_CONSUME_ID = 5; public static final int INVENTORY_CONSUME_ID = 5;
......
...@@ -48,7 +48,7 @@ public interface BuyIngredientsContract { ...@@ -48,7 +48,7 @@ public interface BuyIngredientsContract {
/** /**
* 結束加載並且沒有更多數據了 * 結束加載並且沒有更多數據了
*/ */
void finishLoadNoMoreData(); void finishLoad(boolean noData);
/** /**
* 加載食品 * 加載食品
......
...@@ -582,7 +582,7 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac ...@@ -582,7 +582,7 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
public void loadNextCategoryFood(boolean isSupplier, int position, List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees) { public void loadNextCategoryFood(boolean isSupplier, int position, List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees) {
List<BuyIngredientsBean> buyIngredientsBeans = null; List<BuyIngredientsBean> buyIngredientsBeans = null;
if (isSupplier) { if (isSupplier) {
if(supplierFoods.get(position) != null){ if (supplierFoods.get(position) != null) {
buyIngredientsBeans = new ArrayList<>(); buyIngredientsBeans = new ArrayList<>();
buyIngredientsBeans.add(supplierFoods.get(position)); buyIngredientsBeans.add(supplierFoods.get(position));
} }
...@@ -605,12 +605,12 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac ...@@ -605,12 +605,12 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
Log.e("eee", "下一個"); Log.e("eee", "下一個");
loadNextCategoryFood(isSupplier, position, foodCategoryTrees); loadNextCategoryFood(isSupplier, position, foodCategoryTrees);
} else { } else {
mRootView.finishLoadNoMoreData(); mRootView.finishLoad(true);
} }
} else { } else {
Log.e("eee", "loadNextCategoryFood未加載"); Log.e("eee", "loadNextCategoryFood未加載");
//加載 //加載
mRootView.selectFirstCategoryByIndex(position); // mRootView.selectFirstCategoryByIndex(position);
if (isHasLocationInfo(isSupplier, position)) { if (isHasLocationInfo(isSupplier, position)) {
loadCacheFood(isSupplier, position, false, false); loadCacheFood(isSupplier, position, false, false);
} else { } else {
...@@ -639,6 +639,9 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac ...@@ -639,6 +639,9 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
* @param index 分類下標 * @param index 分類下標
*/ */
public BuyIngredientsBean getFirstCategoryByIndex(int index) { public BuyIngredientsBean getFirstCategoryByIndex(int index) {
if (index >= showFoods.size()) {
return null;
}
BuyIngredientsBean buyIngredientsBean = showFoods.get(index); BuyIngredientsBean buyIngredientsBean = showFoods.get(index);
boolean isParent = buyIngredientsBean.parentId == 0; boolean isParent = buyIngredientsBean.parentId == 0;
for (int i = index; i > -1; i--) { for (int i = index; i > -1; i--) {
...@@ -669,18 +672,36 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac ...@@ -669,18 +672,36 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
BuyIngredientsBean buyIngredientsBean = supplierFoods.get(position); BuyIngredientsBean buyIngredientsBean = supplierFoods.get(position);
if (buyIngredientsBean != null) { if (buyIngredientsBean != null) {
showFoods.add(addToHead ? 0 : showFoods.size(), buyIngredientsBean); showFoods.add(addToHead ? 0 : showFoods.size(), buyIngredientsBean);
List<BuyIngredientsBean> buyIngredientsBeans = new ArrayList<>();
buyIngredientsBeans.add(buyIngredientsBean);
mRootView.loadFood(buyIngredientsBeans, addToHead, isReset);
} }
} else { } else {
List<BuyIngredientsBean> buyIngredientsBeans = categoryFoods.get(position); List<BuyIngredientsBean> buyIngredientsBeans = categoryFoods.get(position);
if (CollectionUtils.isNotNullOrEmpty(buyIngredientsBeans) && !showFoods.contains(buyIngredientsBeans.get(0))) { if (CollectionUtils.isNotNullOrEmpty(buyIngredientsBeans)) {
if (showFoods.contains(buyIngredientsBeans.get(0))) {
//如果列表中已经有这个分类的数据,则加载上一个分类
position -= 1;
if (position >= 0 && position < categoryFoods.size()) {
loadCacheFood(isSupplier, position, addToHead, isReset);
} else {
mRootView.finishLoad(false);
}
} else {
Log.e("eee", "加载分类缓存");
if (addToHead) { if (addToHead) {
showFoods.addAll(0, categoryFoods.get(position)); showFoods.addAll(0, categoryFoods.get(position));
} else { } else {
showFoods.addAll(categoryFoods.get(position)); showFoods.addAll(categoryFoods.get(position));
} }
mRootView.loadFood(categoryFoods.get(position), addToHead, isReset);
}
} else {
Log.e("eee", "没有分类缓存" + position);
//需要通过接口
getFoodByCategory(position, foodCategoryTrees.get(position), addToHead, isReset);
} }
} }
mRootView.loadFood(showFoods, addToHead, isReset);
} }
......
...@@ -482,7 +482,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient ...@@ -482,7 +482,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
//食材所屬供應商 //食材所屬供應商
purchaseFoodBean.setSupplierName(infoMultiBeans.get(supplierIndex).getShowValue()); purchaseFoodBean.setSupplierName(infoMultiBeans.get(supplierIndex).getShowValue());
//食材名稱 //食材名稱
purchaseFoodBean.setName(infoMultiBeans.get(foodNameIndex).getShowValue().trim()); purchaseFoodBean.setName(TextUtil.getNotNullStrAndTrim(infoMultiBeans.get(foodNameIndex).getShowValue()));
//食材類別名稱 //食材類別名稱
purchaseFoodBean.setFoodCategoryName(getCategoryName()); purchaseFoodBean.setFoodCategoryName(getCategoryName());
//食材基本單位 //食材基本單位
......
...@@ -139,7 +139,7 @@ public class NewFoodUnitPresenter extends BasePresenter<NewFoodUnitContract.Mode ...@@ -139,7 +139,7 @@ public class NewFoodUnitPresenter extends BasePresenter<NewFoodUnitContract.Mode
} }
} }
foodUnit.setUnitContent(infoMultiBeans.get(1).getShowValue()); foodUnit.setUnitContent(infoMultiBeans.get(1).getShowValue());
foodUnit.setRemarks(infoMultiBeans.get(2).getShowValue().trim()); foodUnit.setRemarks(TextUtil.getNotNullStrAndTrim(infoMultiBeans.get(2).getShowValue()));
return foodUnit; return foodUnit;
} }
} }
...@@ -510,16 +510,16 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode ...@@ -510,16 +510,16 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
supplierInfoBean = new SupplierInfoBean(); supplierInfoBean = new SupplierInfoBean();
} }
//供應商編號 //供應商編號
supplierInfoBean.setSupplierNo(infoMultiBeans.get(supplierNoIndex).getShowValue().trim()); supplierInfoBean.setSupplierNo(TextUtil.getNotNullStrAndTrim(infoMultiBeans.get(supplierNoIndex).getShowValue()));
//供應商名稱 //供應商名稱
supplierInfoBean.setSupplierName(infoMultiBeans.get(supplierNameIndex).getShowValue().trim()); supplierInfoBean.setSupplierName(TextUtil.getNotNullStrAndTrim(infoMultiBeans.get(supplierNameIndex).getShowValue()));
//聯繫人 //聯繫人
supplierInfoBean.setContacts(infoMultiBeans.get(contactsIndex).getShowValue().trim()); supplierInfoBean.setContacts(TextUtil.getNotNullStrAndTrim(infoMultiBeans.get(contactsIndex).getShowValue()));
//手機號碼 //手機號碼
String telephone = infoMultiBeans.get(telephoneIndex).getShowValue().trim(); String telephone = TextUtil.getNotNullStrAndTrim(infoMultiBeans.get(telephoneIndex).getShowValue());
supplierInfoBean.setContactInformation(telephone); supplierInfoBean.setContactInformation(telephone);
//地址 //地址
supplierInfoBean.setAddress(infoMultiBeans.get(addressIndex).getShowValue().trim()); supplierInfoBean.setAddress(TextUtil.getNotNullStrAndTrim(infoMultiBeans.get(addressIndex).getShowValue()));
//餐廳信息 //餐廳信息
supplierInfoBean.setRestaurantId(Constant.getRestaurantId()); supplierInfoBean.setRestaurantId(Constant.getRestaurantId());
supplierInfoBean.setBrandId(Constant.getBrandId()); supplierInfoBean.setBrandId(Constant.getBrandId());
...@@ -566,7 +566,7 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode ...@@ -566,7 +566,7 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
} }
deleteNullContact(contacts); deleteNullContact(contacts);
supplierInfoBean.setSupplierContacts(contacts); supplierInfoBean.setSupplierContacts(contacts);
supplierInfoBean.setRemarks(infoMultiBeans.get(remarkIndex).getShowValue().trim()); supplierInfoBean.setRemarks(TextUtil.getNotNullStrAndTrim(infoMultiBeans.get(remarkIndex).getShowValue()));
return supplierInfoBean; return supplierInfoBean;
} }
......
...@@ -38,17 +38,6 @@ public class BuyIngredientsAdapter extends GroupedRecyclerViewAdapter<BuyIngredi ...@@ -38,17 +38,6 @@ public class BuyIngredientsAdapter extends GroupedRecyclerViewAdapter<BuyIngredi
isSinger = showType; isSinger = showType;
} }
// public BuyIngredientsBean getHeaderDataByPosition(int position) {
// if (position < buyIngredientsBeans.size()) {
// return buyIngredientsBeans.get(position);
// }
// return null;
// }
//
// public List<BuyIngredientsBean> getData() {
// return buyIngredientsBeans;
// }
@Override @Override
public int getGroupCount() { public int getGroupCount() {
return getData() == null ? 0 : getData().size(); return getData() == null ? 0 : getData().size();
...@@ -113,7 +102,7 @@ public class BuyIngredientsAdapter extends GroupedRecyclerViewAdapter<BuyIngredi ...@@ -113,7 +102,7 @@ public class BuyIngredientsAdapter extends GroupedRecyclerViewAdapter<BuyIngredi
itemViewHolder.setText(R.id.tv_food_item_unit, purchaseFoodBean.getBasicUnitName()); itemViewHolder.setText(R.id.tv_food_item_unit, purchaseFoodBean.getBasicUnitName());
} }
itemViewHolder.setText(R.id.tv_food_item_price, String.format(mContext.getString(R.string.amount_string), purchaseFoodBean.getUnitPrice())); itemViewHolder.setText(R.id.tv_food_item_price, String.format(mContext.getString(R.string.amount_string), purchaseFoodBean.getUnitPrice()));
EditText edNumberInput = (EditText) itemViewHolder.get(R.id.ed_food_ingredient_number); EditText edNumberInput = itemViewHolder.get(R.id.ed_food_ingredient_number);
edNumberInput.setText(String.valueOf(purchaseFoodBean.getFoodQuantity()), TextView.BufferType.EDITABLE); edNumberInput.setText(String.valueOf(purchaseFoodBean.getFoodQuantity()), TextView.BufferType.EDITABLE);
//如果數量小於等於0,就不顯示減號和數量 //如果數量小於等於0,就不顯示減號和數量
setSubAndNumShow(itemViewHolder, purchaseFoodBean.getFoodQuantity() <= 0); setSubAndNumShow(itemViewHolder, purchaseFoodBean.getFoodQuantity() <= 0);
...@@ -189,7 +178,7 @@ public class BuyIngredientsAdapter extends GroupedRecyclerViewAdapter<BuyIngredi ...@@ -189,7 +178,7 @@ public class BuyIngredientsAdapter extends GroupedRecyclerViewAdapter<BuyIngredi
*/ */
public void setLongClick(BaseViewHolder itemViewHolder, int groupPosition, int childPosition, PurchaseFoodBean purchaseFoodBean, boolean addOrSub) { public void setLongClick(BaseViewHolder itemViewHolder, int groupPosition, int childPosition, PurchaseFoodBean purchaseFoodBean, boolean addOrSub) {
//開啟線程 //開啟線程
EditText edNumberInput = (EditText) itemViewHolder.get(R.id.ed_food_ingredient_number); EditText edNumberInput = itemViewHolder.get(R.id.ed_food_ingredient_number);
ThreadPoolManager.getInstence().putExecutableTasks(() -> { ThreadPoolManager.getInstence().putExecutableTasks(() -> {
int number = 0; int number = 0;
if (TextUtil.isNotEmptyOrNullOrUndefined(edNumberInput)) { if (TextUtil.isNotEmptyOrNullOrUndefined(edNumberInput)) {
......
...@@ -26,7 +26,7 @@ public class ImageAdapter extends BaseQuickAdapter<String, BaseViewHolder> { ...@@ -26,7 +26,7 @@ public class ImageAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
@Override @Override
protected void convert(@NotNull BaseViewHolder viewHolder, String s) { protected void convert(@NotNull BaseViewHolder viewHolder, String s) {
GlideUtils.display(getContext(), viewHolder.getView(R.id.iv_img), s, R.drawable.img_small_default); GlideUtils.display(getContext(), viewHolder.getView(R.id.iv_img), s);
viewHolder.setGone(R.id.iv_img_delete, notShowDelete); viewHolder.setGone(R.id.iv_img_delete, notShowDelete);
} }
} }
...@@ -112,13 +112,27 @@ public class OrderDetailsFoodAdapter extends BaseQuickAdapter<PurchaseOrderDetai ...@@ -112,13 +112,27 @@ public class OrderDetailsFoodAdapter extends BaseQuickAdapter<PurchaseOrderDetai
viewHolder.setText(R.id.tv_order_details_item_warehouse_total_amount, String.format(formatAmount, item.getTotalAmount())); viewHolder.setText(R.id.tv_order_details_item_warehouse_total_amount, String.format(formatAmount, item.getTotalAmount()));
//食品數量 //食品數量
EditText edFoodNum = viewHolder.getView(R.id.ed_food_num); EditText edFoodNum = viewHolder.getView(R.id.ed_food_num);
//食品單價
EditText edUnitPrice = viewHolder.getView(R.id.ed_food_unit_price);
//SN食材不可編輯數量 //SN食材不可編輯數量
if(item.getFoodMarkSn() == PurchaseFoodBean.HAS_SN){ if (item.getFoodMarkSn() == PurchaseFoodBean.HAS_SN) {
edFoodNum.setEnabled(false); edFoodNum.setEnabled(false);
edFoodNum.setTextColor(ContextCompat.getColor(getContext(), R.color.color_aaa)); edFoodNum.setTextColor(ContextCompat.getColor(getContext(), R.color.color_aaa));
edUnitPrice.setTextColor(ContextCompat.getColor(getContext(), R.color.color_3c));
edUnitPrice.setEnabled(true);
} else {
if (item.getStatus() == PurchaseOrderDetailsBean.COMPLETE_RECEIVED) {
//全部收貨的不可編輯數量和金額
edFoodNum.setEnabled(false);
edUnitPrice.setEnabled(false);
edFoodNum.setTextColor(ContextCompat.getColor(getContext(), R.color.color_aaa));
edUnitPrice.setTextColor(ContextCompat.getColor(getContext(), R.color.color_aaa));
} else { } else {
edFoodNum.setTextColor(ContextCompat.getColor(getContext(), R.color.color_3c));
edFoodNum.setEnabled(true); edFoodNum.setEnabled(true);
edUnitPrice.setEnabled(true);
edFoodNum.setTextColor(ContextCompat.getColor(getContext(), R.color.color_3c));
edUnitPrice.setTextColor(ContextCompat.getColor(getContext(), R.color.color_3c));
}
} }
edFoodNum.setFilters(inputFilters); edFoodNum.setFilters(inputFilters);
//已入庫數量 //已入庫數量
...@@ -178,8 +192,6 @@ public class OrderDetailsFoodAdapter extends BaseQuickAdapter<PurchaseOrderDetai ...@@ -178,8 +192,6 @@ public class OrderDetailsFoodAdapter extends BaseQuickAdapter<PurchaseOrderDetai
edFoodNum.removeTextChangedListener(watcher); edFoodNum.removeTextChangedListener(watcher);
} }
}); });
//食品單價
EditText edUnitPrice = viewHolder.getView(R.id.ed_food_unit_price);
edUnitPrice.setFilters(inputFilters); edUnitPrice.setFilters(inputFilters);
edUnitPrice.setText(String.valueOf(item.getShowUnit().getUnitPrice())); edUnitPrice.setText(String.valueOf(item.getShowUnit().getUnitPrice()));
TextWatcher unitPriceWatcher = new TextWatcher() { TextWatcher unitPriceWatcher = new TextWatcher() {
......
...@@ -51,6 +51,7 @@ public class ShoppingCartAdapter extends BaseQuickAdapter<ShoppingCartBean, Shop ...@@ -51,6 +51,7 @@ public class ShoppingCartAdapter extends BaseQuickAdapter<ShoppingCartBean, Shop
private String amountUnitStr; private String amountUnitStr;
private String estimateDeliveryTimeStr; private String estimateDeliveryTimeStr;
public ShoppingCartAdapter(Context context, @Nullable List<ShoppingCartBean> data) { public ShoppingCartAdapter(Context context, @Nullable List<ShoppingCartBean> data) {
super(R.layout.item_shopping_cart, data); super(R.layout.item_shopping_cart, data);
this.context = context; this.context = context;
...@@ -86,7 +87,11 @@ public class ShoppingCartAdapter extends BaseQuickAdapter<ShoppingCartBean, Shop ...@@ -86,7 +87,11 @@ public class ShoppingCartAdapter extends BaseQuickAdapter<ShoppingCartBean, Shop
if (!hasFocus) { if (!hasFocus) {
//失去焦點時修改備註 //失去焦點時修改備註
ShoppingCartBean currentShoppingBean = getData().get(viewHolder.getAdapterPosition()); ShoppingCartBean currentShoppingBean = getData().get(viewHolder.getAdapterPosition());
currentShoppingBean.setRemarks(mEdRemarks.getText().toString().trim()); if (TextUtil.isNotEmptyOrNullOrUndefined(mEdRemarks)) {
currentShoppingBean.setRemarks("");
} else {
currentShoppingBean.setRemarks(TextUtil.getNotNullStrAndTrim(mEdRemarks.getText().toString()));
}
} }
}); });
if (shoppingCartBean.isFlashing()) { if (shoppingCartBean.isFlashing()) {
......
...@@ -32,7 +32,9 @@ import com.gingersoft.supply_chain.mvp.ui.fragment.food.MeasurementUnitFragment; ...@@ -32,7 +32,9 @@ import com.gingersoft.supply_chain.mvp.ui.fragment.food.MeasurementUnitFragment;
import com.gingersoft.supply_chain.mvp.ui.fragment.supplier.SupplierListFragment; import com.gingersoft.supply_chain.mvp.ui.fragment.supplier.SupplierListFragment;
import com.gingersoft.supply_chain.mvp.ui.fragment.food.FoodIngredientsFragment; import com.gingersoft.supply_chain.mvp.ui.fragment.food.FoodIngredientsFragment;
import com.gingersoft.supply_chain.mvp.ui.fragment.warehouse.WareHouseListFragment; import com.gingersoft.supply_chain.mvp.ui.fragment.warehouse.WareHouseListFragment;
import com.gingersoft.supply_chain.mvp.ui.widget.GoodsDetailsPopup;
import com.jess.arms.di.component.AppComponent; import com.jess.arms.di.component.AppComponent;
import com.lxj.xpopup.XPopup;
import com.qmuiteam.qmui.widget.QMUITopBar; import com.qmuiteam.qmui.widget.QMUITopBar;
import java.util.ArrayList; import java.util.ArrayList;
......
...@@ -163,7 +163,7 @@ public class CategoryFragment extends BaseSupplyChainFragment<CategoryPresenter> ...@@ -163,7 +163,7 @@ public class CategoryFragment extends BaseSupplyChainFragment<CategoryPresenter>
showMessage("請輸入分類名稱"); showMessage("請輸入分類名稱");
return; return;
} }
mPresenter.updateFoodCategory(mPresenter.toFoodCategoryBean(foodCategoryTrees.getParentId(), categoryPopup.getEditText().getText().toString().trim(), foodCategoryTrees.getId()), currentLevel, position); mPresenter.updateFoodCategory(mPresenter.toFoodCategoryBean(foodCategoryTrees.getParentId(), TextUtil.getNotNullStrAndTrim(categoryPopup.getEditText().getText().toString()), foodCategoryTrees.getId()), currentLevel, position);
}, () -> { }, () -> {
})) }))
.show(); .show();
...@@ -236,7 +236,7 @@ public class CategoryFragment extends BaseSupplyChainFragment<CategoryPresenter> ...@@ -236,7 +236,7 @@ public class CategoryFragment extends BaseSupplyChainFragment<CategoryPresenter>
return; return;
} }
//創建分類 //創建分類
mPresenter.addCategory(parentId, categoryPopup.getEditText().getText().toString().trim(), level); mPresenter.addCategory(parentId, TextUtil.getNotNullStrAndTrim(categoryPopup.getEditText().getText().toString()), level);
}, () -> { }, () -> {
})) }))
.show(); .show();
......
...@@ -43,6 +43,7 @@ import com.gingersoft.supply_chain.mvp.ui.adapter.SecondCategoryAdapter; ...@@ -43,6 +43,7 @@ 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.fragment.BaseSupplyChainFragment;
import com.gingersoft.supply_chain.mvp.ui.fragment.order.ShoppingCatFragment; import com.gingersoft.supply_chain.mvp.ui.fragment.order.ShoppingCatFragment;
import com.gingersoft.supply_chain.mvp.ui.widget.CenterLayoutManager; import com.gingersoft.supply_chain.mvp.ui.widget.CenterLayoutManager;
import com.gingersoft.supply_chain.mvp.ui.widget.GoodsDetailsPopup;
import com.gingersoft.supply_chain.mvp.ui.widget.GroupedGridLayoutManager; import com.gingersoft.supply_chain.mvp.ui.widget.GroupedGridLayoutManager;
import com.gingersoft.supply_chain.mvp.ui.widget.ShowSecondCategoryPopup; import com.gingersoft.supply_chain.mvp.ui.widget.ShowSecondCategoryPopup;
import com.gingersoft.supply_chain.mvp.ui.widget.StickyHeaderLayout; import com.gingersoft.supply_chain.mvp.ui.widget.StickyHeaderLayout;
...@@ -218,7 +219,6 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien ...@@ -218,7 +219,6 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
Log.e("eee", "没有更多数据了" + i); Log.e("eee", "没有更多数据了" + i);
setRefreshState(false); setRefreshState(false);
} }
}).setOnLoadMoreListener(refreshLayout -> { }).setOnLoadMoreListener(refreshLayout -> {
//加載下一個分類 //加載下一個分類
int i = firstLevelCategoryAdapter.getSelectedIndex() + 1; int i = firstLevelCategoryAdapter.getSelectedIndex() + 1;
...@@ -227,17 +227,16 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien ...@@ -227,17 +227,16 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
mPresenter.loadNextCategoryFood(isShowSupplier, i, firstLevelCategoryAdapter.getData()); mPresenter.loadNextCategoryFood(isShowSupplier, i, firstLevelCategoryAdapter.getData());
} else { } else {
Log.e("eee", "没有更多数据了" + i); Log.e("eee", "没有更多数据了" + i);
finishLoadNoMoreData(); finishLoad(true);
} }
}).setEnableAutoLoadMore(true); }).setEnableOverScrollBounce(false).setEnableAutoLoadMore(true);
loadDataByType(); loadDataByType();
} }
private void loadDataByType() { private void loadDataByType() {
//將購物車中的食品數據導出 //將購物車中的食品數據導出
//初始化購物車數量 //初始化購物車數量
tvShoppingCart.setText(mPresenter.tranShoppingCartToCache() + ""); setTvShoppingCartNum(mPresenter.tranShoppingCartToCache());
if (pageType == GET_FOOD_BY_SUPPLIER) { if (pageType == GET_FOOD_BY_SUPPLIER) {
Bundle arguments = getArguments(); Bundle arguments = getArguments();
if (arguments != null) { if (arguments != null) {
...@@ -366,11 +365,12 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien ...@@ -366,11 +365,12 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
return; return;
} }
int currentStickyGroup = stickyHeaderLayout.getCurrentStickyGroup(); int currentStickyGroup = stickyHeaderLayout.getCurrentStickyGroup();
Log.e("eee", dy + "當前組下標:" + currentStickyGroup);
//手指往上滑動,獲取下一個分類數據 //手指往上滑動,獲取下一個分類數據
//記錄當前滑動到哪個header,如果和上次不一致,頂部的分類就切換選中 //記錄當前滑動到哪個header,如果和上次不一致,頂部的分類就切換選中
if (currentStickyGroup != lastIndex) { if (currentStickyGroup != lastIndex) {
if (currentStickyGroup == -1) { if (currentStickyGroup == -1) {
currentStickyGroup = 0; return;
} }
lastIndex = currentStickyGroup; lastIndex = currentStickyGroup;
//拿到當前顯示的分類信息 //拿到當前顯示的分類信息
...@@ -378,10 +378,12 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien ...@@ -378,10 +378,12 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
if (headerDataByPosition == null) { if (headerDataByPosition == null) {
return; return;
} }
Log.e("eee", "當前分類名稱:" + headerDataByPosition.categoryName);
//頂部懸浮顯示的是一級分類 //頂部懸浮顯示的是一級分類
if (headerDataByPosition.parentId == 0) { if (headerDataByPosition.parentId == 0) {
//找到這個一級分類,左側一級分類切換到選中,頂部二級分類切換顯示 //找到這個一級分類,左側一級分類切換到選中,頂部二級分類切換顯示
int firstLevelCategoryIndex = firstLevelCategoryAdapter.getItemPosition(new OrderCategoryBean.FoodCategoryTrees(headerDataByPosition.id, headerDataByPosition.categoryName, headerDataByPosition.parentId)); int firstLevelCategoryIndex = firstLevelCategoryAdapter.getItemPosition(new OrderCategoryBean.FoodCategoryTrees(headerDataByPosition.id, headerDataByPosition.categoryName, headerDataByPosition.parentId));
Log.e("eee", "一級分類下標:" + firstLevelCategoryIndex);
if (firstLevelCategoryIndex > -1) { if (firstLevelCategoryIndex > -1) {
//判斷這個分類是否已經被加載了,如果已經加載過了,就需要往下找,一直找到沒有被加載那個 //判斷這個分類是否已經被加載了,如果已經加載過了,就需要往下找,一直找到沒有被加載那個
selectFirstCategoryByIndex(firstLevelCategoryIndex); selectFirstCategoryByIndex(firstLevelCategoryIndex);
...@@ -390,20 +392,24 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien ...@@ -390,20 +392,24 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
//二級或三級分類,同時也要判斷是否要切換一級分類 //二級或三級分類,同時也要判斷是否要切換一級分類
OrderCategoryBean.FoodCategoryTrees currentStickyCategory = new OrderCategoryBean.FoodCategoryTrees(headerDataByPosition.id, headerDataByPosition.categoryName, headerDataByPosition.parentId); OrderCategoryBean.FoodCategoryTrees currentStickyCategory = new OrderCategoryBean.FoodCategoryTrees(headerDataByPosition.id, headerDataByPosition.categoryName, headerDataByPosition.parentId);
int secondLevelCategoryIndex = secondCategoryAdapter.getItemPosition(currentStickyCategory); int secondLevelCategoryIndex = secondCategoryAdapter.getItemPosition(currentStickyCategory);
Log.e("eee", "二級分類下標:" + secondLevelCategoryIndex);
if (secondLevelCategoryIndex >= 0) { if (secondLevelCategoryIndex >= 0) {
secondCategoryAdapter.setSelectedIndex(secondLevelCategoryIndex); secondCategorySelect(secondLevelCategoryIndex, true);
ViewUtils.moveToCenterByHorizontal(rvSecondCategory, secondLevelCategoryIndex);
} else { } else {
//沒有這個二級或三級分類,判斷是否切換了一級分類 //沒有這個二級或三級分類,判斷是否切換了一級分類
BuyIngredientsBean firstCategory = mPresenter.getFirstCategoryByIndex(currentStickyGroup); BuyIngredientsBean firstCategory = mPresenter.getFirstCategoryByIndex(currentStickyGroup);
if (firstCategory != null) { if (firstCategory != null) {
Log.e("eee", "一級分類:" + firstCategory.categoryName);
OrderCategoryBean.FoodCategoryTrees foodCategoryTrees = new OrderCategoryBean.FoodCategoryTrees(firstCategory.id, firstCategory.categoryName, firstCategory.parentId); OrderCategoryBean.FoodCategoryTrees foodCategoryTrees = new OrderCategoryBean.FoodCategoryTrees(firstCategory.id, firstCategory.categoryName, firstCategory.parentId);
int firstCategoryIndex = firstLevelCategoryAdapter.getItemPosition(foodCategoryTrees); int firstCategoryIndex = firstLevelCategoryAdapter.getItemPosition(foodCategoryTrees);
if (firstCategoryIndex >= 0 && firstCategoryIndex < firstLevelCategoryAdapter.getItemCount()) { Log.e("eee", "一級分類下標:" + firstCategoryIndex);
if (firstCategoryIndex != firstLevelCategoryAdapter.getSelectedIndex()) {
if (firstCategoryIndex >= 0 && firstCategoryIndex != firstLevelCategoryAdapter.getSelectedIndex() && firstCategoryIndex < firstLevelCategoryAdapter.getItemCount()) {
selectFirstCategoryByIndex(firstCategoryIndex); selectFirstCategoryByIndex(firstCategoryIndex);
//切換一級分類後,再切換二級分類 //切換一級分類後,再切換二級分類
int secondLevelCategoryIndex2 = secondCategoryAdapter.getItemPosition(currentStickyCategory); // int secondLevelCategoryIndex2 = secondCategoryAdapter.getItemPosition(currentStickyCategory);
secondCategorySelect(secondLevelCategoryIndex2, secondLevelCategoryIndex2 >= 0); // secondCategorySelect(secondLevelCategoryIndex2, secondLevelCategoryIndex2 >= 0);
}
} }
} }
} }
...@@ -480,8 +486,13 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien ...@@ -480,8 +486,13 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
*/ */
private void confirm() { private void confirm() {
SupplyShoppingCart.getInstance().clear(); SupplyShoppingCart.getInstance().clear();
List<PurchaseFoodBean> purchaseFood = mPresenter.getPurchaseFood();
SupplyShoppingCart.getInstance().addAllFood(mPresenter.getPurchaseFood()); SupplyShoppingCart.getInstance().addAllFood(mPresenter.getPurchaseFood());
if (CollectionUtils.isNotNullOrEmpty(purchaseFood)) {
startForResult(ShoppingCatFragment.newInstance(), TO_SHOPPING_CART_REQUESTCODE); startForResult(ShoppingCatFragment.newInstance(), TO_SHOPPING_CART_REQUESTCODE);
} else {
showMessage("請選擇食材");
}
} }
/** /**
...@@ -517,7 +528,9 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien ...@@ -517,7 +528,9 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
*/ */
private void loadFirstCategoryInfo(int position, boolean addToHead, boolean isReset) { private void loadFirstCategoryInfo(int position, boolean addToHead, boolean isReset) {
//切換右側顯示的二級分類和食材 //切換右側顯示的二級分類和食材
selectFirstCategoryByIndex(position); // 现在改为在滑動事件中切換
// selectFirstCategoryByIndex(position);
Log.e("eee", "loadFirstCategoryInfo:" + position);
if (!mPresenter.isHasLocationInfo(isShowSupplier, position)) { if (!mPresenter.isHasLocationInfo(isShowSupplier, position)) {
//本地沒有緩衝才去查找 //本地沒有緩衝才去查找
//獲取點擊的分類的所有食材 //獲取點擊的分類的所有食材
...@@ -526,19 +539,20 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien ...@@ -526,19 +539,20 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
} else { } else {
mPresenter.getFoodByCategory(position, firstLevelCategoryAdapter.getItem(position), addToHead, isReset); mPresenter.getFoodByCategory(position, firstLevelCategoryAdapter.getItem(position), addToHead, isReset);
} }
Log.e("eee", "loadFirstCategoryInfo:"); Log.e("eee", "没有缓存");
} else { } else {
//本地有緩存,拿緩存中的數據 //本地有緩存,拿緩存中的數據
Log.e("eee", "讀緩存:" + position);
mPresenter.loadCacheFood(isShowSupplier, position, addToHead, isReset); mPresenter.loadCacheFood(isShowSupplier, position, addToHead, isReset);
Log.e("eee", "讀緩存:");
} }
} }
@Override @Override
public void selectFirstCategoryByIndex(int position) { public void selectFirstCategoryByIndex(int position) {
Log.e("eee", "selectFirstCategoryByIndex");
firstLevelCategoryAdapter.setSelectedIndex(position); firstLevelCategoryAdapter.setSelectedIndex(position);
ViewUtils.moveToCenterByVertical(rvFirstCategory, position);
loadSecondCategory(firstLevelCategoryAdapter.getItem(position).getFoodCategoryTrees()); loadSecondCategory(firstLevelCategoryAdapter.getItem(position).getFoodCategoryTrees());
ViewUtils.moveToCenterByVertical(rvFirstCategory, position);
} }
/** /**
...@@ -550,12 +564,15 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien ...@@ -550,12 +564,15 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
if (position > firstLevelCategoryAdapter.getItemCount()) { if (position > firstLevelCategoryAdapter.getItemCount()) {
return; return;
} }
Log.e("eee", "一级分类点击" + position);
//這個分類的數據是否已經在顯示列表中 //這個分類的數據是否已經在顯示列表中
int categoryIndex = mPresenter.isShowGoods(firstLevelCategoryAdapter.getItem(position)); int categoryIndex = mPresenter.isShowGoods(firstLevelCategoryAdapter.getItem(position));
Log.e("eee", "是否找到" + categoryIndex);
if (categoryIndex == -1) { if (categoryIndex == -1) {
//未顯示 //未顯示
//清空食材列表,重新加載當前下標分類的食品數據 //清空食材列表,重新加載當前下標分類的食品數據
mPresenter.clearShowFoods(); mPresenter.clearShowFoods();
selectFirstCategoryByIndex(position);
loadFirstCategoryInfo(position, false, true); loadFirstCategoryInfo(position, false, true);
} else { } else {
//已經在列表中了,只需要滾動到指定位置 //已經在列表中了,只需要滾動到指定位置
...@@ -571,8 +588,12 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien ...@@ -571,8 +588,12 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
} }
@Override @Override
public void finishLoadNoMoreData() { public void finishLoad(boolean noData) {
refreshLayout.finishLoadMoreWithNoMoreData(); refreshLayout.finishLoadMore();
refreshLayout.finishRefresh();
if (noData) {
refreshLayout.finishRefreshWithNoMoreData();
}
} }
/** /**
...@@ -581,7 +602,7 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien ...@@ -581,7 +602,7 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
* @param foodCategoryTrees * @param foodCategoryTrees
*/ */
private void loadSecondCategory(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees) { private void loadSecondCategory(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees) {
if (CollectionUtils.isNullOrEmpty(foodCategoryTrees)) { if (secondCategoryAdapter != null && CollectionUtils.isNullOrEmpty(foodCategoryTrees)) {
Log.e("eee", "沒有二級分類"); Log.e("eee", "沒有二級分類");
secondCategoryAdapter.setNewInstance(null); secondCategoryAdapter.setNewInstance(null);
return; return;
...@@ -590,14 +611,13 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien ...@@ -590,14 +611,13 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
secondCategoryAdapter = new SecondCategoryAdapter(requireContext(), foodCategoryTrees); secondCategoryAdapter = new SecondCategoryAdapter(requireContext(), foodCategoryTrees);
rvSecondCategory.setLayoutManager(new CenterLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)); rvSecondCategory.setLayoutManager(new CenterLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
rvSecondCategory.setAdapter(secondCategoryAdapter); rvSecondCategory.setAdapter(secondCategoryAdapter);
OnItemClickListener onItemClickListener = (a, view, position) -> { OnItemClickListener onItemClickListener = (a, view, position2) -> {
secondCategoryAdapter.setSelectedIndex(position); secondCategorySelect(position2, true);
ViewUtils.moveToCenterByHorizontal(rvSecondCategory, position);
//加載當前分類下的食品 //加載當前分類下的食品
//二級分類點擊 //二級分類點擊
//列表要定位到指定位置 //列表要定位到指定位置
//找到這個分類的下標 //找到這個分類的下標
int categoryIndex = mPresenter.getIndexInAllFood(adapter.getData(), secondCategoryAdapter.getItem(position)); int categoryIndex = mPresenter.getIndexInAllFood(adapter.getData(), secondCategoryAdapter.getItem(position2));
scrollToPosition(categoryIndex, (LinearLayoutManager) rvFoodIngredients.getLayoutManager()); scrollToPosition(categoryIndex, (LinearLayoutManager) rvFoodIngredients.getLayoutManager());
isUser = false; isUser = false;
}; };
...@@ -605,8 +625,9 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien ...@@ -605,8 +625,9 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
} else { } else {
secondCategoryAdapter.setNewInstance(foodCategoryTrees); secondCategoryAdapter.setNewInstance(foodCategoryTrees);
} }
Log.e("eee", "二級分類加載完成" + foodCategoryTrees.size());
//默認選中第0個 //默認選中第0個
secondCategorySelect(0, foodCategoryTrees != null && foodCategoryTrees.size() > 0); // secondCategorySelect(0, foodCategoryTrees != null && foodCategoryTrees.size() > 0);
layoutCategory.setVisibility(View.VISIBLE); layoutCategory.setVisibility(View.VISIBLE);
} }
...@@ -619,18 +640,55 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien ...@@ -619,18 +640,55 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
if (adapter == null) { if (adapter == null) {
adapter = new BuyIngredientsAdapter(requireContext(), buyIngredientsBeans); adapter = new BuyIngredientsAdapter(requireContext(), buyIngredientsBeans);
rvFoodIngredients.setAdapter(adapter); rvFoodIngredients.setAdapter(adapter);
adapter.setOnChildClickListener(new GroupedRecyclerViewAdapter.OnChildClickListener() { adapter.setOnChildClickListener((a, holder, groupPosition, childPosition) -> {
@Override
public void onChildClick(GroupedRecyclerViewAdapter a, BaseViewHolder holder, int groupPosition, int childPosition) {
BuyIngredientsBean buyIngredientsBean = adapter.getData().get(groupPosition); BuyIngredientsBean buyIngredientsBean = adapter.getData().get(groupPosition);
PurchaseFoodBean purchaseFoodBean = buyIngredientsBean.purchaseFoodList.get(childPosition); PurchaseFoodBean purchaseFoodBean = buyIngredientsBean.purchaseFoodList.get(childPosition);
// showMessage("食品名称:" + purchaseFoodBean.getName());
//显示弹窗 //显示弹窗
new XPopup.Builder(requireContext())
} .autoOpenSoftInput(false)
.autoFocusEditText(false)
.asCustom(new GoodsDetailsPopup(requireContext(), purchaseFoodBean)
.setOnFoodNumberChangeListener((purchaseFoodBean1, p, c, beforeNum, currentNum) -> {
foodNumberChanger(purchaseFoodBean, groupPosition, beforeNum, currentNum);
//需要刷新列表
adapter.notifyChildChanged(groupPosition, childPosition);
}))
.show();
}); });
adapter.setAnimationWithDefault(BaseQuickAdapter.AnimationType.AlphaIn); adapter.setAnimationWithDefault(BaseQuickAdapter.AnimationType.AlphaIn);
adapter.setOnFoodNumberChangeListener((purchaseFoodBean, parentCategoryIndex, categoryIndex, beforeNum, currentNum) -> { adapter.setOnFoodNumberChangeListener((purchaseFoodBean, parentCategoryIndex, categoryIndex, beforeNum, currentNum) -> foodNumberChanger(purchaseFoodBean, parentCategoryIndex, beforeNum, currentNum));
rvFoodIngredients.removeOnScrollListener(mFoodScrollListener);
rvFoodIngredients.addOnScrollListener(mFoodScrollListener);
setLayoutManager();
} else {
if (isReset) {
adapter.setNewInstance(buyIngredientsBeans);
} else {
int startIndex = 0;
int endIndex = 0;
if (!addToHead) {
//添加到尾部
startIndex = adapter.getItemCount() + 1;
}
for (BuyIngredientsBean buyIngredientsBean : buyIngredientsBeans) {
endIndex += buyIngredientsBean.purchaseFoodList.size() + 1;
}
endIndex += startIndex;
Log.e("eee", "開始:" + startIndex + "結束:" + endIndex);
adapter.addData(addToHead ? 0 : adapter.getData().size(), buyIngredientsBeans, startIndex, endIndex);
}
}
}
/**
* 食品数量改变时调用
*
* @param purchaseFoodBean 食品信息
* @param parentCategoryIndex 食品分类下标:食品所属分类在列表中的下标
* @param beforeNum 改变之前的数量
* @param currentNum 改变之后的数量
*/
private void foodNumberChanger(PurchaseFoodBean purchaseFoodBean, int parentCategoryIndex, int beforeNum, int currentNum) {
BuyIngredientsBean firstCategory = mPresenter.getFirstCategoryByIndex(parentCategoryIndex); BuyIngredientsBean firstCategory = mPresenter.getFirstCategoryByIndex(parentCategoryIndex);
Log.e("eee", parentCategoryIndex + "一級分類" + (firstCategory == null ? "null" : firstCategory.toString())); Log.e("eee", parentCategoryIndex + "一級分類" + (firstCategory == null ? "null" : firstCategory.toString()));
if (firstCategory != null) { if (firstCategory != null) {
...@@ -641,6 +699,9 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien ...@@ -641,6 +699,9 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
Log.e("eee", beforeNum + "數量:" + currentNum); Log.e("eee", beforeNum + "數量:" + currentNum);
OrderCategoryBean.FoodCategoryTrees item = firstLevelCategoryAdapter.getItem(firstCategoryByIndex); OrderCategoryBean.FoodCategoryTrees item = firstLevelCategoryAdapter.getItem(firstCategoryByIndex);
//正 //正
if (item.getSize() < 0) {
item.setSize(0);
}
if (beforeNum == 0) { if (beforeNum == 0) {
item.setSize(item.getSize() + 1); item.setSize(item.getSize() + 1);
} else { } else {
...@@ -651,28 +712,15 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien ...@@ -651,28 +712,15 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
} }
mPresenter.addFood(purchaseFoodBean); mPresenter.addFood(purchaseFoodBean);
shoppingCartNum += currentNum - beforeNum; shoppingCartNum += currentNum - beforeNum;
setTvShoppingCartNum(shoppingCartNum);
}
private void setTvShoppingCartNum(int num) {
tvShoppingCart.setText(String.valueOf(shoppingCartNum)); tvShoppingCart.setText(String.valueOf(shoppingCartNum));
}); if (num > 0) {
rvFoodIngredients.removeOnScrollListener(mFoodScrollListener); tvShoppingCart.setVisibility(View.VISIBLE);
rvFoodIngredients.addOnScrollListener(mFoodScrollListener);
setLayoutManager();
} else {
if (isReset) {
adapter.setList(buyIngredientsBeans);
} else { } else {
int startIndex = 0; tvShoppingCart.setVisibility(View.GONE);
int endIndex = 0;
if (!addToHead) {
//添加到尾部
startIndex = adapter.getItemCount()+1;
}
for (BuyIngredientsBean buyIngredientsBean : buyIngredientsBeans) {
endIndex += buyIngredientsBean.purchaseFoodList.size()+1;
}
endIndex += startIndex;
Log.e("eee", "開始:" + startIndex + "結束:" + endIndex);
adapter.addData(addToHead ? 0 : adapter.getData().size(), buyIngredientsBeans, startIndex, endIndex);
}
} }
} }
......
...@@ -304,7 +304,6 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI ...@@ -304,7 +304,6 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI
dialog.dismiss(); dialog.dismiss();
saveGoodsInfo(); saveGoodsInfo();
}, (view, dialog) -> { }, (view, dialog) -> {
dialog.dismiss();
isLeave = true; isLeave = true;
killMyself(); killMyself();
}); });
......
...@@ -231,7 +231,7 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr ...@@ -231,7 +231,7 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
* @param state 狀態,全部收貨還是部分收貨 * @param state 狀態,全部收貨還是部分收貨
*/ */
private void addWarehouse(int state) { private void addWarehouse(int state) {
AppDialog.getInstance().showWaringDialog(requireContext(), "是否確認收貨?", (view, dialog) -> { AppDialog.getInstance().showTipDialog(requireContext(), "是否確認收貨?", (view, dialog) -> {
mPresenter.addWarehouse(state, edRemark.getText() + "", totalAmount, orderDetailsFoodAdapter.getData()); mPresenter.addWarehouse(state, edRemark.getText() + "", totalAmount, orderDetailsFoodAdapter.getData());
setFragmentResult(RESULT_OK, null); setFragmentResult(RESULT_OK, null);
}); });
...@@ -267,10 +267,15 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr ...@@ -267,10 +267,15 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
//判斷有沒有SN食材,如果沒有,就顯示全選按妞 //判斷有沒有SN食材,如果沒有,就顯示全選按妞
if (orderDetailsBean.getStatus() == PurchaseOrderDetailsBean.COMPLETE_RECEIVED) { if (orderDetailsBean.getStatus() == PurchaseOrderDetailsBean.COMPLETE_RECEIVED) {
//全部收貨,顯示備註,備註不可編輯 //全部收貨,顯示備註,備註不可編輯
layoutRemarks.setVisibility(View.GONE);
edRemark.setEnabled(false); edRemark.setEnabled(false);
edRemark.setFocusable(false); edRemark.setFocusable(false);
edRemark.setBackground(null); edRemark.setBackground(null);
cbOrderDetailsAllSelected.setVisibility(View.VISIBLE); cbOrderDetailsAllSelected.setVisibility(View.VISIBLE);
if (TextUtil.isNotEmptyOrNullOrUndefined(orderDetailsBean.getWarehousingRemarks())) {
layoutInputRemark.setVisibility(View.VISIBLE);
layoutInputRemark.setCounterEnabled(false);
}
} else { } else {
cbOrderDetailsAllSelected.setVisibility(mPresenter.hasSnFood(orderDetailsBean.getPurchaseOrderDetailsInfoVOS()) ? View.GONE : View.VISIBLE); cbOrderDetailsAllSelected.setVisibility(mPresenter.hasSnFood(orderDetailsBean.getPurchaseOrderDetailsInfoVOS()) ? View.GONE : View.VISIBLE);
supplyTopBar.addRightImageButton(R.drawable.ic_take_pictures, R.id.id_take_pictures).setOnClickListener(this); supplyTopBar.addRightImageButton(R.drawable.ic_take_pictures, R.id.id_take_pictures).setOnClickListener(this);
...@@ -397,6 +402,8 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr ...@@ -397,6 +402,8 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
if (TextUtil.isNotEmptyOrNullOrUndefined(pic)) { if (TextUtil.isNotEmptyOrNullOrUndefined(pic)) {
new XPopup.Builder(requireContext()) new XPopup.Builder(requireContext())
.isDestroyOnDismiss(true) .isDestroyOnDismiss(true)
.isDarkTheme(true)
.enableDrag(false)
.asImageViewer((ImageView) view, pic, true, Color.parseColor("#f1f1f1"), -1, -1, false, -1, new ImageLoader()) .asImageViewer((ImageView) view, pic, true, Color.parseColor("#f1f1f1"), -1, -1, false, -1, new ImageLoader())
.show(); .show();
} }
...@@ -636,14 +643,25 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr ...@@ -636,14 +643,25 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
if (data != null) { if (data != null) {
Uri uri = data.getData(); Uri uri = data.getData();
if (uri != null) { if (uri != null) {
File file = SelectPicture.getInstance().uriToFileApiQ(requireContext(), uri); // File file = SelectPicture.getInstance().uriToFileApiQ(requireContext(), uri);
SelectPicture.getInstance().crop(Uri.fromFile(file), this); // SelectPicture.getInstance().crop(Uri.fromFile(file), this);
String filePath = FileUtils.getFilePathByUri(mContext, uri);
if (!TextUtils.isEmpty(filePath)) {
mPresenter.uploadPic(filePath);
}
} }
} }
} else if (requestCode == SelectPicture.TAKE_PHOTO && resultCode == RESULT_OK) { } else if (requestCode == SelectPicture.TAKE_PHOTO && resultCode == RESULT_OK) {
//拍照 //拍照
Uri cameraUri = SelectPicture.getInstance().getmCameraUri();
if (cameraUri != null) {
String filePath = FileUtils.getFilePathByUri(mContext, cameraUri);
if (!TextUtils.isEmpty(filePath)) {
mPresenter.uploadPic(filePath);
}
}
//拍照完成後需要裁剪 //拍照完成後需要裁剪
SelectPicture.getInstance().crop(SelectPicture.getInstance().getmCameraUri(), this); // SelectPicture.getInstance().crop(SelectPicture.getInstance().getmCameraUri(), this);
} else if (requestCode == REQUEST_CROP && resultCode == RESULT_OK && data != null) { } else if (requestCode == REQUEST_CROP && resultCode == RESULT_OK && data != null) {
final Uri resultUri = UCrop.getOutput(data); final Uri resultUri = UCrop.getOutput(data);
if (resultUri != null) { if (resultUri != null) {
......
package com.gingersoft.supply_chain.mvp.ui.fragment.order; package com.gingersoft.supply_chain.mvp.ui.fragment.order;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -129,7 +130,6 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr ...@@ -129,7 +130,6 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
}); });
initTopBar(); initTopBar();
initTabAndData(); initTabAndData();
getOrderList();
} }
private void getOrderList() { private void getOrderList() {
...@@ -142,9 +142,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr ...@@ -142,9 +142,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
@Override @Override
public void onSupportVisible() { public void onSupportVisible() {
super.onSupportVisible(); super.onSupportVisible();
if (tvCartGoodsNum != null) { setGoodsSize();
tvCartGoodsNum.setText(String.valueOf(SupplyShoppingCart.getInstance().getCartFoods().size()));
}
} }
private TextView tvCartGoodsNum; private TextView tvCartGoodsNum;
...@@ -154,8 +152,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr ...@@ -154,8 +152,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
mTopBar.setTitle("採購列表"); mTopBar.setTitle("採購列表");
View view = View.inflate(mContext, R.layout.layout_shopping_cart, null); View view = View.inflate(mContext, R.layout.layout_shopping_cart, null);
tvCartGoodsNum = view.findViewById(R.id.tv_purchase_cart_size); tvCartGoodsNum = view.findViewById(R.id.tv_purchase_cart_size);
tvCartGoodsNum.setText(String.valueOf(SupplyShoppingCart.getInstance().getCartFoods().size())); setGoodsSize();
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
mTopBar.addRightView(view, R.id.qmui_shopping_cart, layoutParams); mTopBar.addRightView(view, R.id.qmui_shopping_cart, layoutParams);
view.setOnClickListener(v -> { view.setOnClickListener(v -> {
...@@ -169,6 +166,21 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr ...@@ -169,6 +166,21 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
}); });
} }
/**
* 修改商品數量
*/
private void setGoodsSize() {
if (tvCartGoodsNum != null) {
int shoppingGoodsSize = SupplyShoppingCart.getInstance().getCartFoods().size();
if (shoppingGoodsSize > 0) {
tvCartGoodsNum.setVisibility(View.VISIBLE);
tvCartGoodsNum.setText(String.valueOf(shoppingGoodsSize));
} else {
tvCartGoodsNum.setVisibility(View.GONE);
}
}
}
private void initTabAndData() { private void initTabAndData() {
QMUITabBuilder builder = mTabSegment.tabBuilder() QMUITabBuilder builder = mTabSegment.tabBuilder()
.setNormalColor(ContextCompat.getColor(mContext, R.color.color_86)) .setNormalColor(ContextCompat.getColor(mContext, R.color.color_86))
...@@ -221,6 +233,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr ...@@ -221,6 +233,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
mTabSegment.addOnTabSelectedListener(new QMUIBasicTabSegment.OnTabSelectedListener() { mTabSegment.addOnTabSelectedListener(new QMUIBasicTabSegment.OnTabSelectedListener() {
@Override @Override
public void onTabSelected(int index) { public void onTabSelected(int index) {
Log.e("eee", "onTabSelected" + index);
orderStateIndex = index; orderStateIndex = index;
pageIndex = 0; pageIndex = 0;
getOrderList(); getOrderList();
...@@ -233,6 +246,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr ...@@ -233,6 +246,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
@Override @Override
public void onTabReselected(int index) { public void onTabReselected(int index) {
Log.e("eee", "onTabReselected" + index);
} }
......
...@@ -20,6 +20,7 @@ import com.chad.library.adapter.base.BaseQuickAdapter; ...@@ -20,6 +20,7 @@ import com.chad.library.adapter.base.BaseQuickAdapter;
import com.gingersoft.gsa.cloud.common.loadsir.EmptyCallback; import com.gingersoft.gsa.cloud.common.loadsir.EmptyCallback;
import com.gingersoft.gsa.cloud.common.loadsir.ErrorCallback; import com.gingersoft.gsa.cloud.common.loadsir.ErrorCallback;
import com.gingersoft.gsa.cloud.common.utils.inputFilter.InputFilterUtils; import com.gingersoft.gsa.cloud.common.utils.inputFilter.InputFilterUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.ui.animator.CustomAnimation1; import com.gingersoft.gsa.cloud.ui.animator.CustomAnimation1;
import com.gingersoft.supply_chain.R; import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2; import com.gingersoft.supply_chain.R2;
...@@ -131,7 +132,7 @@ public class WareHouseListFragment extends BaseSupplyChainFragment<WareHouseList ...@@ -131,7 +132,7 @@ public class WareHouseListFragment extends BaseSupplyChainFragment<WareHouseList
if (pageIndex == 0 && warehousingQueryAdapter != null) { if (pageIndex == 0 && warehousingQueryAdapter != null) {
warehousingQueryAdapter.setList(null); warehousingQueryAdapter.setList(null);
} }
mPresenter.getWarehousing(pageIndex, edWarehouseListSearch.getText().toString().trim()); mPresenter.getWarehousing(pageIndex, TextUtil.getNotNullStrAndTrim(edWarehouseListSearch.getText().toString()));
} }
//R2.id.tv_warehouse_item_unit_price, R2.id.tv_warehouse_item_inventory_quantity, R2.id.tv_warehouse_item_total_amount //R2.id.tv_warehouse_item_unit_price, R2.id.tv_warehouse_item_inventory_quantity, R2.id.tv_warehouse_item_total_amount
......
...@@ -3,6 +3,7 @@ package com.gingersoft.supply_chain.mvp.ui.fragment.warehouse; ...@@ -3,6 +3,7 @@ package com.gingersoft.supply_chain.mvp.ui.fragment.warehouse;
import android.animation.LayoutTransition; import android.animation.LayoutTransition;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.os.Bundle; import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -49,6 +50,8 @@ import com.kingja.loadsir.core.LoadSir; ...@@ -49,6 +50,8 @@ import com.kingja.loadsir.core.LoadSir;
import com.qmuiteam.qmui.widget.QMUITopBar; import com.qmuiteam.qmui.widget.QMUITopBar;
import com.scwang.smartrefresh.layout.SmartRefreshLayout; import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -298,6 +301,7 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD ...@@ -298,6 +301,7 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
.setOnCancelListener(() -> showList(View.VISIBLE)); .setOnCancelListener(() -> showList(View.VISIBLE));
return; return;
} }
inventoryConsumptionView.setEdit(false).setHint(getString(R.string.str_sn_not_edit));
//初始化掃碼view //初始化掃碼view
scanSnView = new ScanSnView(this).setOnScanResultListener((popup, scanResult) -> { scanSnView = new ScanSnView(this).setOnScanResultListener((popup, scanResult) -> {
if (scanResult.isEmpty()) { if (scanResult.isEmpty()) {
...@@ -319,8 +323,12 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD ...@@ -319,8 +323,12 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
}).init(); }).init();
scanSnView.setOnSingerResultListener((isAdd, snCode, currentSnCodeNumber) -> { scanSnView.setOnSingerResultListener((isAdd, snCode, currentSnCodeNumber) -> {
//inventoryConsumptionView.setConsumptionNumber(currentSnCodeNumber) //inventoryConsumptionView.setConsumptionNumber(currentSnCodeNumber)
//添加或移除某個sn碼 //添加sn碼
scanSnView.setConfirmBtnState(); scanSnView.setConfirmBtnState();
inventoryConsumptionView.setConsumptionNumber(currentSnCodeNumber);
}).setOnDeleteSnCodeListener((snCode, position) -> {
//刪除SN碼
inventoryConsumptionView.setConsumptionNumber(inventoryConsumptionView.getConsumptionNum() - 1);
}); });
inventoryConsumptionView.setOnNumberChangeListener(num -> { inventoryConsumptionView.setOnNumberChangeListener(num -> {
//輸入數量發生變化時 //輸入數量發生變化時
...@@ -407,30 +415,66 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD ...@@ -407,30 +415,66 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
RecyclerView rvInfo = view.findViewById(R.id.rv_print_consume_info); RecyclerView rvInfo = view.findViewById(R.id.rv_print_consume_info);
TextView tvUserName = view.findViewById(R.id.tv_print_consume_user_name); TextView tvUserName = view.findViewById(R.id.tv_print_consume_user_name);
TextView tvSnCodes = view.findViewById(R.id.tv_print_sn); TextView tvSnCodes = view.findViewById(R.id.tv_print_sn);
LinearLayout layoutSn = view.findViewById(R.id.layout_sn_list);
restaurantName.setText(String.format(getString(R.string.str_restaurant_outbound_order), RestaurantInfoManager.newInstance().getRestaurantName())); restaurantName.setText(String.format(getString(R.string.str_restaurant_outbound_order), RestaurantInfoManager.newInstance().getRestaurantName()));
tvDate.setText(TimeUtils.getCurrentDate(TimeUtils.DEFAULT_DATE_FORMAT_YMDHM)); tvDate.setText(TimeUtils.getCurrentDate(TimeUtils.DEFAULT_DATE_FORMAT_YMDHM));
tvFoodNo.setText(String.format(getString(R.string.str_no), purchaseWarehousingOrderDetailsVO.getFoodNo())); tvFoodNo.setText(String.format(getString(R.string.str_no), purchaseWarehousingOrderDetailsVO.getFoodNo()));
tvUserName.setText(String.format(getString(R.string.str_prepared), UserContext.newInstance().getMemberName())); tvUserName.setText(String.format(getString(R.string.str_prepared), UserContext.newInstance().getMemberName()));
List<OutboundOrderBean> outboundOrderBeans = new ArrayList<>(); List<OutboundOrderBean> outboundOrderBeans = new ArrayList<>();
outboundOrderBeans.add(new OutboundOrderBean("品名", purchaseWarehousingOrderDetailsVO.getName())); outboundOrderBeans.add(new OutboundOrderBean(getString(R.string.str_product_name), purchaseWarehousingOrderDetailsVO.getName()));
outboundOrderBeans.add(new OutboundOrderBean("單位", purchaseWarehousingOrderDetailsVO.getUnitName())); outboundOrderBeans.add(new OutboundOrderBean(getString(R.string.str_unit), purchaseWarehousingOrderDetailsVO.getUnitName()));
outboundOrderBeans.add(new OutboundOrderBean("數量", String.valueOf(foodNum))); outboundOrderBeans.add(new OutboundOrderBean(getString(R.string.str_number), String.valueOf(foodNum)));
outboundOrderBeans.add(new OutboundOrderBean("單價", String.valueOf(purchaseWarehousingOrderDetailsVO.getFoodPrice()))); outboundOrderBeans.add(new OutboundOrderBean(getString(R.string.str_unit_prices), String.valueOf(purchaseWarehousingOrderDetailsVO.getFoodPrice())));
outboundOrderBeans.add(new OutboundOrderBean("金額", String.valueOf(MoneyUtil.priceCalculation(purchaseWarehousingOrderDetailsVO.getFoodPrice(), foodNum)))); outboundOrderBeans.add(new OutboundOrderBean(getString(R.string.str_amount), String.valueOf(MoneyUtil.priceCalculation(purchaseWarehousingOrderDetailsVO.getFoodPrice(), foodNum))));
outboundOrderBeans.add(new OutboundOrderBean("消耗原因", consumptionReason)); outboundOrderBeans.add(new OutboundOrderBean(getString(R.string.str_inventory_reason), consumptionReason));
outboundOrderBeans.add(new OutboundOrderBean("備註", remarks)); outboundOrderBeans.add(new OutboundOrderBean(getString(R.string.str_remark), remarks));
if (CollectionUtils.isNotNullOrEmpty(snCodes)) { if (CollectionUtils.isNotNullOrEmpty(snCodes)) {
layoutSn.addView(getSnView(getString(R.string.str_serial_number), getString(R.string.str_sn_code)));
int size = snCodes.size();
for (int i = 0; i < size; i++) {
LinearLayout layout = getSnView(i + 1 + "", snCodes.get(i));
layoutSn.addView(layout);
}
//sn碼不為空 //sn碼不為空
tvSnCodes.setText(String.format(getString(R.string.str_sn_codes), CollectionUtils.listToCommaString(snCodes))); tvSnCodes.setText(String.format(getString(R.string.str_sn_codes), CollectionUtils.listToCommaString(snCodes)));
layoutSn.setVisibility(View.VISIBLE);
} else { } else {
tvSnCodes.setVisibility(View.GONE); tvSnCodes.setVisibility(View.GONE);
layoutSn.setVisibility(View.GONE);
} }
OutboundOrderAdapter outboundOrderAdapter = new OutboundOrderAdapter(outboundOrderBeans); OutboundOrderAdapter outboundOrderAdapter = new OutboundOrderAdapter(outboundOrderBeans);
rvInfo.setAdapter(outboundOrderAdapter); rvInfo.setAdapter(outboundOrderAdapter);
return LayoutToBitmapUtils.getBitmapByView(requireContext(), view); return LayoutToBitmapUtils.getBitmapByView(requireContext(), view);
} }
@NotNull
private LinearLayout getSnView(String no, String snCode) {
LinearLayout layout = new LinearLayout(requireContext());
layout.setOrientation(LinearLayout.HORIZONTAL);
//序號
TextView tvNo = new TextView(requireContext());
tvNo.setTextSize(14);
tvNo.setTextColor(ContextCompat.getColor(requireContext(), R.color.black));
tvNo.setText(no);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.weight = 1;
layoutParams.setMargins(0, 5, 0, 0);
layout.addView(tvNo, layoutParams);
TextView tvSnCode = new TextView(requireContext());
tvSnCode.setTextColor(ContextCompat.getColor(requireContext(), R.color.black));
tvSnCode.setTextSize(14);
tvSnCode.setText(snCode);
LinearLayout.LayoutParams snCodeParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
snCodeParams.weight = 2;
snCodeParams.setMargins(0, 5, 0, 0);
layout.addView(tvSnCode, snCodeParams);
return layout;
}
/** /**
* 顯示消耗列表 * 顯示消耗列表
* *
......
...@@ -298,6 +298,7 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho ...@@ -298,6 +298,7 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho
snCodeSize -= 1; snCodeSize -= 1;
edWarehouseLoss.setText(String.valueOf(snCodeSize)); edWarehouseLoss.setText(String.valueOf(snCodeSize));
} }
}).setOnCancelListener(this::showList).init(); }).setOnCancelListener(this::showList).init();
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
layoutParams.topMargin = QMUIDisplayHelper.dp2px(requireContext(), 10); layoutParams.topMargin = QMUIDisplayHelper.dp2px(requireContext(), 10);
......
package com.gingersoft.supply_chain.mvp.ui.widget; package com.gingersoft.supply_chain.mvp.ui.widget;
import android.content.Context;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatEditText;
import androidx.core.content.ContextCompat;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.threadPool.ThreadPoolManager;
import com.gingersoft.gsa.cloud.ui.view.imageview.mask.PorterShapeImageView;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.gingersoft.supply_chain.mvp.ui.adapter.BuyIngredientsAdapter;
import com.google.android.material.textfield.TextInputEditText;
import com.lxj.xpopup.core.BasePopupView;
import com.lxj.xpopup.core.CenterPopupView;
import com.lxj.xpopup.util.KeyboardUtils;
import com.qmuiteam.qmui.layout.QMUIButton;
import com.qmuiteam.qmui.widget.textview.QMUISpanTouchFixTextView;
import butterknife.BindView;
import butterknife.ButterKnife;
/** /**
* @author 宇航. * @author 宇航.
* User: admin * User: admin
...@@ -7,5 +39,182 @@ package com.gingersoft.supply_chain.mvp.ui.widget; ...@@ -7,5 +39,182 @@ package com.gingersoft.supply_chain.mvp.ui.widget;
* Time: 10:07 * Time: 10:07
* Use: * Use:
*/ */
public class GoodsDetailsPopup { public class GoodsDetailsPopup extends CenterPopupView {
@BindView(R2.id.iv_goods_details)
PorterShapeImageView ivGoodsDetails;
@BindView(R2.id.tv_goods_name)
TextView tvGoodsName;
@BindView(R2.id.tv_supplier_name)
TextView tvSupplierName;
@BindView(R2.id.tv_goods_no)
TextView tvGoodsNo;
@BindView(R2.id.tv_goods_price)
QMUISpanTouchFixTextView tvGoodsPrice;
@BindView(R2.id.tv_goods_specification)
TextView tvGoodsSpecification;
@BindView(R2.id.tv_goods_stock)
TextView tvGoodsStock;
@BindView(R2.id.btn_food_operation_sub)
QMUIButton btnFoodOperationSub;
@BindView(R2.id.ed_food_ingredient_number)
AppCompatEditText edFoodIngredientNumber;
@BindView(R2.id.btn_food_operation_add)
QMUIButton btnFoodOperationAdd;
@BindView(R2.id.layout_operation_food_num)
LinearLayout layoutOperationFoodNum;
@BindView(R2.id.iv_popup_close)
ImageView ivPopupClose;
private PurchaseFoodBean purchaseFoodBean;
private BuyIngredientsAdapter.OnFoodNumberChangeListener onFoodNumberChangeListener;
public GoodsDetailsPopup(@NonNull Context context, PurchaseFoodBean purchaseFoodBean) {
super(context);
this.purchaseFoodBean = purchaseFoodBean;
}
@Override
protected int getImplLayoutId() {
return R.layout.layout_goods_details_popup;
}
@Override
protected void onCreate() {
super.onCreate();
ButterKnife.bind(this);
popupInfo.autoOpenSoftInput = false;
if (purchaseFoodBean.getImages() == null) {
ivGoodsDetails.setImageResource(R.drawable.img_small_default);
} else {
GlideUtils.display(getContext(), ivGoodsDetails, purchaseFoodBean.getImages(), R.drawable.img_small_default);
}
tvGoodsName.setText(purchaseFoodBean.getName());
tvSupplierName.setText(purchaseFoodBean.getSupplierName());
tvGoodsNo.setText(purchaseFoodBean.getFoodNo());
String price = String.format(getContext().getString(R.string.str_unit_price_colon_s), MoneyUtil.formatDouble(purchaseFoodBean.getUnitPrice()));
tvGoodsPrice.setText(TextUtil.getBoldSpannableString(price, ContextCompat.getColor(getContext(), R.color.required_color), 3, price.length()));
if (TextUtil.isNotEmptyOrNullOrUndefined(purchaseFoodBean.getPackingDescription())) {
tvGoodsSpecification.setText(purchaseFoodBean.getPackingDescription());
} else {
tvGoodsSpecification.setText(purchaseFoodBean.getBasicUnitName());
}
edFoodIngredientNumber.setText(purchaseFoodBean.getFoodQuantity() + "");
KeyboardUtils.hideSoftInput(this);
btnFoodOperationSub.setOnClickListener(v -> {
//减
if (purchaseFoodBean.getFoodQuantity() > 0) {
foodNumberChange(-1);
}
});
btnFoodOperationSub.setOnTouchListener(onBtnTouchListener);
btnFoodOperationSub.setOnLongClickListener(v -> {
//長按減號
setLongClick(false);
return true;
});
btnFoodOperationAdd.setOnTouchListener(onBtnTouchListener);
btnFoodOperationAdd.setOnLongClickListener(v -> {
//長按加號
setLongClick(true);
return true;
});
btnFoodOperationAdd.setOnClickListener(v -> {
//加
if (purchaseFoodBean.getFoodQuantity() < Constant.PURCHASE_FOOD_MAX) {
foodNumberChange(1);
}
});
ivPopupClose.setOnClickListener(this::onClick);
KeyboardUtils.hideSoftInput(this);
}
/**
* + - 按鈕觸摸事件
*/
private View.OnTouchListener onBtnTouchListener = (v, event) -> {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
longClick = true;
} else if (event.getAction() == MotionEvent.ACTION_UP) {
longClick = false;
}
return false;
};
private int delayTime = Constant.LONG_CLICK_INIT_TIME;
private boolean longClick = false;
/**
* 按鈕長按事件
*
* @param addOrSub 是+ or -
*/
public void setLongClick(boolean addOrSub) {
//開啟線程
ThreadPoolManager.getInstence().putExecutableTasks(() -> {
int number = purchaseFoodBean.getFoodQuantity();
delayTime = Constant.LONG_CLICK_INIT_TIME;
if (addOrSub) {
//+
while (longClick) {
if (number < Constant.PURCHASE_FOOD_MAX) {
try {
Thread.sleep(delayTime);
number++;
if (delayTime > Constant.LONG_CLICK_DECREASE_TIME) {
delayTime -= Constant.LONG_CLICK_DECREASE_TIME;
}
edFoodIngredientNumber.post(() -> foodNumberChange(1));
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
longClick = false;
}
}
} else {
//-
while (longClick) {
if (number > 0) {
try {
Thread.sleep(delayTime);
number--;
if (delayTime > Constant.LONG_CLICK_DECREASE_TIME) {
delayTime -= Constant.LONG_CLICK_DECREASE_TIME;
}
edFoodIngredientNumber.post(() -> foodNumberChange(-1));
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
longClick = false;
}
}
}
});
}
private void foodNumberChange(int changeNum) {
purchaseFoodBean.setFoodQuantity(purchaseFoodBean.getFoodQuantity() + changeNum);
edFoodIngredientNumber.setText(String.valueOf(purchaseFoodBean.getFoodQuantity()));
if (onFoodNumberChangeListener != null) {
onFoodNumberChangeListener.onChange(purchaseFoodBean, 0, 0, purchaseFoodBean.getFoodQuantity() - changeNum, purchaseFoodBean.getFoodQuantity());
}
}
public GoodsDetailsPopup setOnFoodNumberChangeListener(BuyIngredientsAdapter.OnFoodNumberChangeListener onFoodNumberChangeListener) {
this.onFoodNumberChangeListener = onFoodNumberChangeListener;
return this;
}
private void onClick(View v) {
dismiss();
}
} }
...@@ -9,7 +9,6 @@ import android.view.View; ...@@ -9,7 +9,6 @@ import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.widget.SwitchCompat; import androidx.appcompat.widget.SwitchCompat;
...@@ -17,6 +16,7 @@ import androidx.recyclerview.widget.GridLayoutManager; ...@@ -17,6 +16,7 @@ import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.common.utils.inputFilter.InputFilterUtils; import com.gingersoft.gsa.cloud.common.utils.inputFilter.InputFilterUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils; import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.ui.adapter.multi.RemarkProvider; import com.gingersoft.gsa.cloud.ui.adapter.multi.RemarkProvider;
import com.gingersoft.supply_chain.R; import com.gingersoft.supply_chain.R;
...@@ -59,6 +59,7 @@ public class InventoryConsumptionView extends FrameLayout { ...@@ -59,6 +59,7 @@ public class InventoryConsumptionView extends FrameLayout {
private ConsumptionReasonAdapter consumptionReasonAdapter; private ConsumptionReasonAdapter consumptionReasonAdapter;
private OnNumberChangeListener onNumberChangeListener; private OnNumberChangeListener onNumberChangeListener;
public InventoryConsumptionView(@NonNull Context context, List<ConsumeReasonBean> consumeReasonBeans, int maxConsumption) { public InventoryConsumptionView(@NonNull Context context, List<ConsumeReasonBean> consumeReasonBeans, int maxConsumption) {
super(context); super(context);
View rootView = LayoutInflater.from(context).inflate(R.layout.layout_inventory_consumption, null, false); View rootView = LayoutInflater.from(context).inflate(R.layout.layout_inventory_consumption, null, false);
...@@ -80,7 +81,7 @@ public class InventoryConsumptionView extends FrameLayout { ...@@ -80,7 +81,7 @@ public class InventoryConsumptionView extends FrameLayout {
if (i > maxConsumption) { if (i > maxConsumption) {
edInput.setError("不能超過當前庫存數量:" + maxConsumption); edInput.setError("不能超過當前庫存數量:" + maxConsumption);
} else { } else {
onConfirmClickListener.onConfirm(i, consumptionReasonAdapter.getSelectIndex(), edRemarks.getText().toString().trim()); onConfirmClickListener.onConfirm(i, consumptionReasonAdapter.getSelectIndex(), TextUtil.getNotNullStrAndTrim(edRemarks.getText().toString()));
} }
} else { } else {
ToastUtils.show(getContext(), "請輸入消耗庫存數"); ToastUtils.show(getContext(), "請輸入消耗庫存數");
...@@ -121,6 +122,14 @@ public class InventoryConsumptionView extends FrameLayout { ...@@ -121,6 +122,14 @@ public class InventoryConsumptionView extends FrameLayout {
}); });
} }
public InventoryConsumptionView setEdit(boolean enabled) {
edInput.setEnabled(enabled);
return this;
}
public InventoryConsumptionView setHint(String hint) {
edInput.setHint(hint);
return this;
}
public InventoryConsumptionView setOnConfirmClickListener(OnConfirmClickListener onConfirmClickListener) { public InventoryConsumptionView setOnConfirmClickListener(OnConfirmClickListener onConfirmClickListener) {
this.onConfirmClickListener = onConfirmClickListener; this.onConfirmClickListener = onConfirmClickListener;
return this; return this;
......
...@@ -38,13 +38,17 @@ public class ViewUtils { ...@@ -38,13 +38,17 @@ public class ViewUtils {
return; return;
} }
//取得中間位置的item //取得中間位置的item
Log.e("eee", "需要選中:" + sectionPosition + "顯示的:" + layoutManager.findFirstVisibleItemPosition() + "子數量:" + recyclerView.getChildCount());
View childAt = recyclerView.getChildAt(sectionPosition - layoutManager.findFirstVisibleItemPosition()); View childAt = recyclerView.getChildAt(sectionPosition - layoutManager.findFirstVisibleItemPosition());
//拿到列表一半的寬度 //拿到列表一半的寬度
int halfLeftRvWidth = recyclerView.getWidth() / 2; int halfLeftRvWidth = recyclerView.getWidth() / 2;
Log.e("eee", childAt + "一半寬度:" + halfLeftRvWidth + "第一個:" + recyclerView.getChildAt(0));
if (childAt != null) { if (childAt != null) {
//中間位置那個item減去一半的高度等於中間item一半顯示在列表中間 //中間位置那個item減去一半的高度等於中間item一半顯示在列表中間
int x = childAt.getLeft() - halfLeftRvWidth; int x = childAt.getLeft() - halfLeftRvWidth;
recyclerView.smoothScrollBy(x, 0); recyclerView.smoothScrollBy(x, 0);
} else {
layoutManager.scrollToPositionWithOffset(sectionPosition, 0);
} }
} }
} }
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
android:id="@+id/iv_order_state" android:id="@+id/iv_order_state"
android:layout_width="@dimen/dp_52" android:layout_width="@dimen/dp_52"
android:layout_height="@dimen/dp_46" android:layout_height="@dimen/dp_46"
android:layout_gravity="bottom" android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dp_25" /> android:layout_marginLeft="@dimen/dp_25" />
</LinearLayout> </LinearLayout>
......
...@@ -62,7 +62,6 @@ ...@@ -62,7 +62,6 @@
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="@dimen/dp_14" /> android:textSize="@dimen/dp_14" />
</LinearLayout> </LinearLayout>
<com.scwang.smartrefresh.layout.SmartRefreshLayout <com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/srl_supplier" android:id="@+id/srl_supplier"
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -150,26 +150,17 @@ ...@@ -150,26 +150,17 @@
app:srlEnablePreviewInEditMode="true" app:srlEnablePreviewInEditMode="true"
app:srlPrimaryColor="@color/trans"> app:srlPrimaryColor="@color/trans">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:clipChildren="true"
android:fillViewport="true"
android:layout_height="match_parent">
<LinearLayout <LinearLayout
android:id="@+id/layout_warehousing_root" android:id="@+id/layout_warehousing_root"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical">
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.viewpager2.widget.ViewPager2 <androidx.viewpager2.widget.ViewPager2
android:id="@+id/vp_warehouse_viewpager" android:id="@+id/vp_warehouse_viewpager"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginTop="@dimen/dp_10" android:layout_marginTop="@dimen/dp_10" />
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout> </LinearLayout>
</androidx.core.widget.NestedScrollView>
</com.scwang.smartrefresh.layout.SmartRefreshLayout> </com.scwang.smartrefresh.layout.SmartRefreshLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>
...@@ -7,9 +7,10 @@ ...@@ -7,9 +7,10 @@
android:id="@+id/iv_img" android:id="@+id/iv_img"
android:layout_width="@dimen/dp_58" android:layout_width="@dimen/dp_58"
android:layout_height="@dimen/dp_58" android:layout_height="@dimen/dp_58"
android:src="@drawable/img_search_keyboard_bg"
android:layout_marginTop="@dimen/dp_8" android:layout_marginTop="@dimen/dp_8"
android:layout_marginRight="@dimen/dp_8"/> android:layout_marginRight="@dimen/dp_8"
android:scaleType="fitXY"
android:src="@drawable/awe" />
<ImageView <ImageView
android:id="@+id/iv_img_delete" android:id="@+id/iv_img_delete"
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
android:paddingTop="@dimen/dp_5" android:paddingTop="@dimen/dp_5"
android:paddingRight="@dimen/dp_10" android:paddingRight="@dimen/dp_10"
android:paddingBottom="@dimen/dp_5" android:paddingBottom="@dimen/dp_5"
android:textSize="@dimen/dp_14"
tools:text="品名" /> tools:text="品名" />
<View <View
...@@ -38,6 +39,7 @@ ...@@ -38,6 +39,7 @@
android:paddingTop="@dimen/dp_5" android:paddingTop="@dimen/dp_5"
android:paddingRight="@dimen/dp_10" android:paddingRight="@dimen/dp_10"
android:paddingBottom="@dimen/dp_5" android:paddingBottom="@dimen/dp_5"
android:textSize="@dimen/dp_14"
tools:text="巴西肥牛" /> tools:text="巴西肥牛" />
</LinearLayout> </LinearLayout>
......
...@@ -77,7 +77,8 @@ ...@@ -77,7 +77,8 @@
style="@style/Supplier_Info_text_Style" style="@style/Supplier_Info_text_Style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="地\u3000\u3000址:" /> android:text="地\u3000\u3000址:"
android:visibility="gone" />
<TextView <TextView
android:id="@+id/tv_supplier_address" android:id="@+id/tv_supplier_address"
...@@ -100,7 +101,9 @@ ...@@ -100,7 +101,9 @@
style="@style/Supplier_Info_text_Style" style="@style/Supplier_Info_text_Style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="聯繫方式:" /> android:text="聯繫方式:"
android:visibility="gone" />
<TextView <TextView
android:id="@+id/tv_supplier_phone" android:id="@+id/tv_supplier_phone"
...@@ -109,38 +112,50 @@ ...@@ -109,38 +112,50 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="3" android:layout_weight="3"
tools:text="12893798276" /> tools:text="12893798276" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_7"
android:layout_marginTop="@dimen/dp_2"
android:layout_marginRight="@dimen/dp_7"
android:orientation="horizontal">
<TextView
style="@style/Supplier_Info_text_Style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="聯&#160;&#160;繫&#160;&#160;人:" />
<TextView <TextView
android:id="@+id/tv_supplier_contact" android:id="@+id/tv_supplier_contact"
style="@style/Supplier_Info_text_Style" style="@style/Supplier_Info_text_Style"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_marginLeft="@dimen/dp_5"
android:gravity="right"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="3" android:layout_weight="3"
tools:text="雷鋒" /> tools:text="雷鋒" />
</LinearLayout> </LinearLayout>
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginLeft="@dimen/dp_7"-->
<!-- android:layout_marginTop="@dimen/dp_2"-->
<!-- android:layout_marginRight="@dimen/dp_7"-->
<!-- android:orientation="horizontal">-->
<!-- <TextView-->
<!-- style="@style/Supplier_Info_text_Style"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:visibility="gone"-->
<!-- android:text="聯&#160;&#160;繫&#160;&#160;人:" />-->
<!-- <TextView-->
<!-- android:id="@+id/tv_supplier_contact"-->
<!-- style="@style/Supplier_Info_text_Style"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_weight="3"-->
<!-- tools:text="雷鋒" />-->
<!-- </LinearLayout>-->
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_7" android:layout_marginLeft="@dimen/dp_7"
android:layout_marginTop="@dimen/dp_2" android:layout_marginTop="@dimen/dp_2"
android:layout_marginRight="@dimen/dp_7" android:layout_marginRight="@dimen/dp_7"
android:orientation="horizontal"> android:orientation="horizontal"
android:visibility="gone">
<TextView <TextView
style="@style/Supplier_Info_text_Style" style="@style/Supplier_Info_text_Style"
......
<?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:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape_white_eight_corners_bg"
android:orientation="vertical">
<FrameLayout
android:layout_width="@dimen/dp_269"
android:layout_height="@dimen/dp_269">
<com.gingersoft.gsa.cloud.ui.view.imageview.mask.PorterShapeImageView
android:id="@+id/iv_goods_details"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:siShape="@drawable/shape_top_radius" />
<TextView
android:id="@+id/tv_goods_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/alpha_60_black"
android:padding="@dimen/dp_5"
android:textColor="@color/white"
android:textSize="@dimen/dp_15"
tools:text="巴西费缪" />
</FrameLayout>
<LinearLayout
android:layout_width="@dimen/dp_269"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/dp_9">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_supplier_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_17"
android:textStyle="bold"
tools:text="海鮮天地" />
<TextView
android:id="@+id/tv_goods_no"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:layout_weight="1"
android:gravity="right"
android:text="SP001"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_17" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_9"
android:orientation="horizontal">
<com.qmuiteam.qmui.widget.textview.QMUISpanTouchFixTextView
android:id="@+id/tv_goods_price"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:includeFontPadding="false"
android:text="單價:$100.0"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15" />
<TextView
android:id="@+id/tv_goods_specification"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:layout_weight="0.5"
android:gravity="right"
android:includeFontPadding="false"
android:text="1KG/盒"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<requestFocus />
<TextView
android:id="@+id/tv_goods_stock"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="庫存:15/60"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15" />
<LinearLayout
android:id="@+id/layout_operation_food_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:descendantFocusability="beforeDescendants"
android:divider="@color/color_3c"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center_vertical"
android:orientation="horizontal">
<com.qmuiteam.qmui.layout.QMUIButton
android:id="@+id/btn_food_operation_sub"
android:layout_width="@dimen/dp_24"
android:layout_height="@dimen/dp_24"
android:background="@drawable/ic_circle_gray_sub" />
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/ed_food_ingredient_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_4"
android:layout_marginRight="@dimen/dp_4"
android:background="@null"
android:gravity="center"
android:inputType="number"
android:maxLength="4"
android:maxLines="1"
android:minWidth="@dimen/dp_30"
android:textColor="@color/black"
android:textCursorDrawable="@drawable/cursor_theme"
android:textSize="@dimen/dp_22"
tools:text="10" />
<com.qmuiteam.qmui.layout.QMUIButton
android:id="@+id/btn_food_operation_add"
android:layout_width="@dimen/dp_24"
android:layout_height="@dimen/dp_24"
android:background="@drawable/ic_circle_theme_add" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/iv_popup_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_19"
android:layout_marginBottom="@dimen/dp_10"
android:src="@drawable/dialog_close" />
</LinearLayout>
\ No newline at end of file
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
android:text="" android:text=""
android:textColor="@color/color_3c" android:textColor="@color/color_3c"
android:textCursorDrawable="@drawable/cursor_theme" android:textCursorDrawable="@drawable/cursor_theme"
android:textSize="@dimen/sp_16" /> android:textSize="@dimen/sp_14" />
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
......
...@@ -47,8 +47,8 @@ ...@@ -47,8 +47,8 @@
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_marginTop="@dimen/dp_5"
android:layout_height="@dimen/dp_1" android:layout_height="@dimen/dp_1"
android:layout_marginTop="@dimen/dp_5"
android:background="@color/theme_333_color" /> android:background="@color/theme_333_color" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
...@@ -57,12 +57,21 @@ ...@@ -57,12 +57,21 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<LinearLayout
android:id="@+id/layout_sn_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:orientation="vertical"
android:paddingLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_10" />
<TextView <TextView
android:id="@+id/tv_print_consume_user_name" android:id="@+id/tv_print_consume_user_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginLeft="@dimen/dp_5" android:layout_marginLeft="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_10"
android:text="製單人:" android:text="製單人:"
android:textColor="@color/theme_333_color" android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14" /> android:textSize="@dimen/dp_14" />
...@@ -71,10 +80,11 @@ ...@@ -71,10 +80,11 @@
android:id="@+id/tv_print_sn" android:id="@+id/tv_print_sn"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginLeft="@dimen/dp_5" android:layout_marginLeft="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_10"
android:text="@string/str_sn_codes" android:text="@string/str_sn_codes"
android:textColor="@color/theme_333_color" android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14" /> android:textSize="@dimen/dp_14"
android:visibility="gone" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
android:text="0" android:text="0"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="@dimen/dp_6" android:textSize="@dimen/dp_6"
android:visibility="gone"
app:layout_constraintRight_toRightOf="@id/iv_shopping_cart" app:layout_constraintRight_toRightOf="@id/iv_shopping_cart"
app:layout_constraintTop_toTopOf="@id/iv_shopping_cart" /> app:layout_constraintTop_toTopOf="@id/iv_shopping_cart" />
</com.qmuiteam.qmui.alpha.QMUIAlphaConstraintLayout> </com.qmuiteam.qmui.alpha.QMUIAlphaConstraintLayout>
\ No newline at end of file
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
<string name="str_format_positive_int">+%1$d</string> <string name="str_format_positive_int">+%1$d</string>
<string name="str_format_less">-%1$s</string> <string name="str_format_less">-%1$s</string>
<string name="str_unit_price_colon">單價:$%1$.2f</string> <string name="str_unit_price_colon">單價:$%1$.2f</string>
<string name="str_unit_price_colon_s">單價:$%1$s</string>
<string name="str_latest_unit_price_colon">最新單價:$%1$.2f</string> <string name="str_latest_unit_price_colon">最新單價:$%1$.2f</string>
<string name="str_total_amount_colon">總價:$%1$.2f</string> <string name="str_total_amount_colon">總價:$%1$.2f</string>
<string name="str_delete_category_tip">是否確認刪除該類別【%1$s】,子類和食材將一同刪除?</string> <string name="str_delete_category_tip">是否確認刪除該類別【%1$s】,子類和食材將一同刪除?</string>
...@@ -41,4 +43,13 @@ ...@@ -41,4 +43,13 @@
<string name="str_sn_codes">SN碼:%1$s</string> <string name="str_sn_codes">SN碼:%1$s</string>
<string name="str_en_num_digits">ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789</string> <string name="str_en_num_digits">ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789</string>
<string name="str_purchase_loading">飛速加載中</string> <string name="str_purchase_loading">飛速加載中</string>
<string name="str_sn_not_edit">SN食材不可手動輸入</string>
<string name="str_serial_number">序號</string>
<string name="str_unit">單位</string>
<string name="str_unit_prices">單價</string>
<string name="str_product_name">品名</string>
<string name="str_number">數量</string>
<string name="str_amount">金額</string>
<string name="str_inventory_reason">消耗原因</string>
</resources> </resources>
\ No newline at end of file
...@@ -29,9 +29,7 @@ import com.gingersoft.gsa.cloud.common.utils.okhttpUtils.OkHttp3Utils ...@@ -29,9 +29,7 @@ import com.gingersoft.gsa.cloud.common.utils.okhttpUtils.OkHttp3Utils
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils
import com.gingersoft.gsa.cloud.component.ComponentName import com.gingersoft.gsa.cloud.component.ComponentName
import com.google.gson.Gson import com.google.gson.Gson
import io.reactivex.Observable import com.xuexiang.rxutil2.rxjava.RxJavaUtils
import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import okhttp3.* import okhttp3.*
...@@ -41,29 +39,60 @@ import java.util.* ...@@ -41,29 +39,60 @@ import java.util.*
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
class ICommandService : Service() { class ICommandService : Service() {
private val TAG = "heart" private val TAG = "heart"
/** /**
* 心跳检测时间 * 心跳检测时间
*/ */
private val HEART_BEAT_RATE = (30 * 1000).toLong()//每隔30秒进行一次对长连接的心跳检测 private val heartBeatRate = (30 * 1000).toLong()//每隔30秒进行一次对长连接的心跳检测
private val WEBSOCKET_HOST_AND_PORT = "${HttpsConstans.ROOT_URL}/ricepon-websocket/android/webSocketServer"//可替换为自己的主机名和端口号
/**
* 可替换为自己的主机名和端口号
*/
private val webSocketHostPort = "${HttpsConstans.ROOT_URL}/ricepon-websocket/android/webSocketServer"
/**
* 長連接
*/
private var mWebSocket: WebSocket? = null private var mWebSocket: WebSocket? = null
var client: OkHttpClient? = null
/**
* 長連接客戶端
*/
private var client: OkHttpClient? = null
/**
* 回調接口
*/
var postCallBack: PostCallBack? = null var postCallBack: PostCallBack? = null
/**
* 關閉心跳的廣播,收到廣播註銷掉Service
*/
private var mReceiver: ClearHeartBroadcastReceiver? = null private var mReceiver: ClearHeartBroadcastReceiver? = null
/**
* 電源喚醒
*/
private var newWakeLock: PowerManager.WakeLock? = null private var newWakeLock: PowerManager.WakeLock? = null
private var myBind: MyBind? = null private var myBind: MyBind? = null
/**
* 通知渠道id
*/
private val CHANNEL_ID = "cloud_gsa" private val CHANNEL_ID = "cloud_gsa"
private var isCreate = false private var isCreate = false
/**
* 報警定時,超過一分鐘長連接未連接上,就會發送推送警報
*/
var warningDelay: Disposable? = null
/**
* 心跳輪詢
*/
var heartPolling: Disposable? = null
/** /**
* prj數據 * prj數據
...@@ -71,10 +100,15 @@ class ICommandService : Service() { ...@@ -71,10 +100,15 @@ class ICommandService : Service() {
private val PRJ_DATA = 10 private val PRJ_DATA = 10
/** /**
* prj數據 * 餐檯數據
*/ */
private val TABLE_DATA = 11 private val TABLE_DATA = 11
/**
* 上次播報的時間
*/
private var lastSoundTime: Long = 0L
private val NOMAL_NOTIFITY_ID = 456 private val NOMAL_NOTIFITY_ID = 456
private val DELIVETY_NOTIFITY_ID = 123 private val DELIVETY_NOTIFITY_ID = 123
...@@ -127,14 +161,11 @@ class ICommandService : Service() { ...@@ -127,14 +161,11 @@ class ICommandService : Service() {
intent?.let { intent?.let {
mCurrConnectionType = it.getIntExtra(CONNECTION_TYPE, OPEN_DELIVET_ORDER_CONNECTION) mCurrConnectionType = it.getIntExtra(CONNECTION_TYPE, OPEN_DELIVET_ORDER_CONNECTION)
} }
initNotification() initNotification()
if (isCreate) { if (isCreate) {
send(mCurrConnectionType) send(mCurrConnectionType)
} }
isCreate = true isCreate = true
putTimeLog("啟動服務onStartCommand") putTimeLog("啟動服務onStartCommand")
return super.onStartCommand(intent, flags, startId) return super.onStartCommand(intent, flags, startId)
} }
...@@ -258,8 +289,8 @@ class ICommandService : Service() { ...@@ -258,8 +289,8 @@ class ICommandService : Service() {
// 初始化socket // 初始化socket
private fun initSocket() { private fun initSocket() {
putTimeLog("取消心跳") putTimeLog("取消心跳")
cancelInterval() heartPolling = RxJavaUtils.polling(0, heartBeatRate) {
interval({ run {
//保持設備喚醒 //保持設備喚醒
newWakeLock?.acquire(10 * 60 * 1000L /*10 minutes*/) newWakeLock?.acquire(10 * 60 * 1000L /*10 minutes*/)
putTimeLog("開啟心跳") putTimeLog("開啟心跳")
...@@ -275,7 +306,7 @@ class ICommandService : Service() { ...@@ -275,7 +306,7 @@ class ICommandService : Service() {
client = OkHttpClient.Builder().readTimeout(9 * 10, TimeUnit.SECONDS).build() client = OkHttpClient.Builder().readTimeout(9 * 10, TimeUnit.SECONDS).build()
client?.let { client?.let {
val request = Request.Builder() val request = Request.Builder()
.url(WEBSOCKET_HOST_AND_PORT) .url(webSocketHostPort)
.build() .build()
it.newWebSocket(request, object : WebSocketListener() { it.newWebSocket(request, object : WebSocketListener() {
override fun onOpen(webSocket: WebSocket, response: Response) {//开启长连接成功的回调 override fun onOpen(webSocket: WebSocket, response: Response) {//开启长连接成功的回调
...@@ -284,7 +315,7 @@ class ICommandService : Service() { ...@@ -284,7 +315,7 @@ class ICommandService : Service() {
mWebSocket = webSocket mWebSocket = webSocket
send(mCurrConnectionType) send(mCurrConnectionType)
putTimeLog("連接成功") putTimeLog("連接成功")
cancelTimerDisposable() warningDelay?.dispose()
myBind?.block?.invoke(false) myBind?.block?.invoke(false)
} }
} }
...@@ -354,12 +385,12 @@ class ICommandService : Service() { ...@@ -354,12 +385,12 @@ class ICommandService : Service() {
Log.e(TAG, "onFailure " + t.message) Log.e(TAG, "onFailure " + t.message)
if (!this@ICommandService.isDestroy) { if (!this@ICommandService.isDestroy) {
//連接斷開,定時五秒,如果未重連,播放提示音 //連接斷開,定時五秒,如果未重連,播放提示音
delayFun({ warningDelay = RxJavaUtils.delay(60) {
initSoundPool(R.raw.raw_disconnect) initSoundPool(R.raw.raw_disconnect)
myBind?.block?.invoke(true) myBind?.block?.invoke(true)
//推送給相關人員 //推送給相關人員
OkHttp3Utils.noticePersonnel(AppConstans.RP_HEART_ERROR, "心跳斷開十秒以上未連接成功:" + t.message) OkHttp3Utils.noticePersonnel(AppConstans.RP_HEART_ERROR, "心跳斷開十秒以上未連接成功:" + t.message)
}, 60) }
putTimeLog("onFailure連接失敗,等待一分鐘後重新連接") putTimeLog("onFailure連接失敗,等待一分鐘後重新連接")
} else { } else {
webSocket.cancel() webSocket.cancel()
...@@ -369,7 +400,8 @@ class ICommandService : Service() { ...@@ -369,7 +400,8 @@ class ICommandService : Service() {
}) })
it.dispatcher().executorService().shutdown() it.dispatcher().executorService().shutdown()
} }
}, HEART_BEAT_RATE) }
}
} }
fun send(currConnectionType: Int) { fun send(currConnectionType: Int) {
...@@ -389,7 +421,9 @@ class ICommandService : Service() { ...@@ -389,7 +421,9 @@ class ICommandService : Service() {
return connectiontype return connectiontype
} }
private var lastSoundTime: Long = 0L /**
* 初始化SoundPool
*/
fun initSoundPool(resId: Int) { fun initSoundPool(resId: Int) {
val nowTime = System.currentTimeMillis()//當前時間減去上次播放的時間,如果超過五秒,那麼才會再次播放提示聲 val nowTime = System.currentTimeMillis()//當前時間減去上次播放的時間,如果超過五秒,那麼才會再次播放提示聲
if (nowTime - lastSoundTime > 5000) { if (nowTime - lastSoundTime > 5000) {
...@@ -400,8 +434,11 @@ class ICommandService : Service() { ...@@ -400,8 +434,11 @@ class ICommandService : Service() {
} }
} }
/*获取一条随机字符串*/ /**
fun getRandomString(length: Int): String { //length表示生成字符串的长度 * 获取一条随机字符串
* @param length 表示生成字符串的长度
*/
private fun getRandomString(length: Int): String {
val base = "abcdefghijklmnopqrstuvwxyz0123456789" val base = "abcdefghijklmnopqrstuvwxyz0123456789"
val random = Random() val random = Random()
val sb = StringBuffer() val sb = StringBuffer()
...@@ -439,9 +476,9 @@ class ICommandService : Service() { ...@@ -439,9 +476,9 @@ class ICommandService : Service() {
mWebSocket!!.close(1000, null) mWebSocket!!.close(1000, null)
} }
//停止定時心跳 //停止定時心跳
cancelInterval() heartPolling?.dispose()
//停止延遲執行任務 //停止延遲執行任務
cancelTimerDisposable() warningDelay?.dispose()
//停止前台服務 //停止前台服務
stopForeground(true) stopForeground(true)
//清除保持喚醒 //清除保持喚醒
...@@ -474,65 +511,7 @@ class ICommandService : Service() { ...@@ -474,65 +511,7 @@ class ICommandService : Service() {
loginfo.append(":") loginfo.append(":")
loginfo.append(content) loginfo.append(content)
loginfo.append("\n") loginfo.append("\n")
LoganManager.w_network(TAG + " -> " + content) LoganManager.w_network("$TAG -> $content")
}
var mIntervalDisposable: Disposable? = null
var timerDisposable: Disposable? = null
/**
* 执行定时任务
*/
fun interval(block: () -> Unit, milliseconds: Long) {
Observable.interval(0, milliseconds, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(AndroidSchedulers.mainThread())
.subscribe(object : Observer<Long> {
override fun onError(e: Throwable) {}
override fun onComplete() {}
override fun onNext(t: Long) {
block()
}
override fun onSubscribe(d: Disposable) {
mIntervalDisposable = d
}
})
}
/**
* 取消定时器
*/
fun cancelInterval() {
if (mIntervalDisposable != null && !mIntervalDisposable!!.isDisposed) {
mIntervalDisposable!!.dispose()
}
}
fun cancelTimerDisposable() {
if (timerDisposable != null && !timerDisposable!!.isDisposed) {
timerDisposable!!.dispose()
}
}
fun delayFun(block: () -> Unit, milliseconds: Long) {
Observable.timer(milliseconds, TimeUnit.SECONDS)
.subscribe(object : Observer<Long> {
override fun onSubscribe(d: Disposable) {
timerDisposable = d
}
override fun onNext(t: Long) {
block()
}
override fun onError(e: Throwable) {
}
override fun onComplete() {
}
})
} }
class MsgBean(var type: Int, var data: String, var token: String) class MsgBean(var type: Int, var data: String, var token: String)
......
...@@ -49,7 +49,9 @@ public class GlideUtils { ...@@ -49,7 +49,9 @@ public class GlideUtils {
} }
public static void display(Context context, ImageView imageView, String url, int placeholder) { public static void display(Context context, ImageView imageView, String url, int placeholder) {
if (url == null) {
return;
}
if (imageView == null) { if (imageView == null) {
throw new IllegalArgumentException("argument error"); throw new IllegalArgumentException("argument error");
} }
...@@ -153,7 +155,7 @@ public class GlideUtils { ...@@ -153,7 +155,7 @@ public class GlideUtils {
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
if (callBack != null && resource != null) { if (callBack != null && resource != null) {
callBack.onObtainBitmapSuccess(resource); callBack.onObtainBitmapSuccess(resource);
}else { } else {
callBack.onObtainBitmapFailed(); callBack.onObtainBitmapFailed();
} }
} }
......
package com.gingersoft.gsa.cloud.common.utils.other; package com.gingersoft.gsa.cloud.common.utils.other;
import android.graphics.Typeface;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.widget.EditText; import android.widget.EditText;
import androidx.annotation.ColorInt;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -52,6 +59,20 @@ public class TextUtil { ...@@ -52,6 +59,20 @@ public class TextUtil {
} }
} }
public static String getNotNullStr(String str) {
if (isEmptyOrNullOrUndefined(str)) {
return "";
}
return str;
}
public static String getNotNullStrAndTrim(String str) {
if (isEmptyOrNullOrUndefined(str)) {
return "";
}
return str.trim();
}
public static String isEmptyReturnString(String str) { public static String isEmptyReturnString(String str) {
if (str == null || str.length() == 0 || if (str == null || str.length() == 0 ||
str.equals("null") || str.equals("undefined")) { str.equals("null") || str.equals("undefined")) {
...@@ -140,4 +161,44 @@ public class TextUtil { ...@@ -140,4 +161,44 @@ public class TextUtil {
} }
return length; return length;
} }
public static SpannableString getSpannableString(CharSequence source, @ColorInt int color, int startIndex, int endIndex) {
if (source != null) {
if (endIndex > source.length()) {
endIndex = source.length();
}
SpannableString spannableString = new SpannableString(source);
ForegroundColorSpan colorSpan = new ForegroundColorSpan(color);
spannableString.setSpan(colorSpan, startIndex, endIndex, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
return spannableString;
}
return null;
}
public static SpannableString getBoldSpannableString(CharSequence source, @ColorInt int color, int startIndex, int endIndex) {
if (source != null) {
if (endIndex > source.length()) {
endIndex = source.length();
}
//AbsoluteSizeSpan(int size) ---- 设置字体大小,参数是绝对数值,相当于Word中的字体大小
//RelativeSizeSpan(float proportion) ---- 设置字体大小,参数是相对于默认字体大小的倍数,比如默认字体大小是x, 那么设置后的字体大小就是x*proportion,这个用起来比较灵活,proportion>1就是放大(zoom in), proportion<1就是缩小(zoom out)
//ScaleXSpan(float proportion) ---- 缩放字体,与上面的类似,默认为1,设置后就是原来的乘以proportion,大于1时放大(zoon in),小于时缩小(zoom out)
//BackgroundColorSpan(int color) ----背景着色,参数是颜色数值,可以直接使用android.graphics.Color里面定义的常量,或是用Color.rgb(int, int, int)
//ForegroundColorSpan(int color) ----前景着色,也就是字的着色,参数与背景着色一致
//TypefaceSpan(String family) ----字体,参数是字体的名字比如“sans", "sans-serif"等
//StyleSpan(Typeface style) -----字体风格,比如粗体,斜体,参数是android.graphics.Typeface里面定义的常量,如Typeface.BOLD,Typeface.ITALIC等等。
//StrikethroughSpan----如果设置了此风格,会有一条线从中间穿过所有的字,就像被划掉一样
SpannableString spannableString = new SpannableString(source);
ForegroundColorSpan colorSpan = new ForegroundColorSpan(color);
StyleSpan styleSpan = new StyleSpan(Typeface.BOLD);
//Spanned.SPAN_EXCLUSIVE_EXCLUSIVE --- 不包含两端start和end所在的端点
//Spanned.SPAN_EXCLUSIVE_INCLUSIVE --- 不包含端start,但包含end所在的端点
//Spanned.SPAN_INCLUSIVE_EXCLUSIVE --- 包含两端start,但不包含end所在的端点
//Spanned.SPAN_INCLUSIVE_INCLUSIVE--- 包含两端start和end所在的端点
spannableString.setSpan(styleSpan, startIndex, endIndex, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
spannableString.setSpan(colorSpan, startIndex, endIndex, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
return spannableString;
}
return null;
}
} }
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
<stroke <stroke
android:width="@dimen/dp_1" android:width="@dimen/dp_1"
android:color="@color/black" /> android:color="@color/black" />
<solid android:color="@color/white" /> <solid android:color="@color/white" />
<corners android:radius="@dimen/dp_4" /> <corners android:radius="@dimen/dp_4" />
</shape> </shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:topLeftRadius="@dimen/dp_8"
android:topRightRadius="@dimen/dp_8" />
<solid android:color="@color/black" />
</shape>
\ No newline at end of file
...@@ -14,8 +14,8 @@ public class CustomAnimation1 implements BaseAnimation { ...@@ -14,8 +14,8 @@ public class CustomAnimation1 implements BaseAnimation {
@NotNull @NotNull
@Override @Override
public Animator[] animators(@NotNull View view) { public Animator[] animators(@NotNull View view) {
Animator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1.3f, 1); Animator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1.1f, 1);
Animator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1.3f, 1); Animator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1.1f, 1);
Animator alpha = ObjectAnimator.ofFloat(view, "alpha", 0, 1f); Animator alpha = ObjectAnimator.ofFloat(view, "alpha", 0, 1f);
scaleY.setDuration(350); scaleY.setDuration(350);
......
...@@ -124,6 +124,7 @@ public class AppDialog { ...@@ -124,6 +124,7 @@ public class AppDialog {
} }
}); });
hepler.getView(R.id.tv_dialog_cancel).setOnClickListener(v -> { hepler.getView(R.id.tv_dialog_cancel).setOnClickListener(v -> {
dismiss();
if (onCancelListener != null) { if (onCancelListener != null) {
onCancelListener.onclick(v, dialog); onCancelListener.onclick(v, dialog);
} }
......
/*
* Copyright 2014 - 2020 Henning Dodenhof
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gingersoft.gsa.cloud.ui.view.imageview;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewOutlineProvider;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.appcompat.widget.AppCompatImageView;
import com.gingersoft.gsa.cloud.ui.R;
public class CircleImageView extends AppCompatImageView {
private static final ScaleType SCALE_TYPE = ScaleType.CENTER_CROP;
private static final Bitmap.Config BITMAP_CONFIG = Bitmap.Config.ARGB_8888;
private static final int COLORDRAWABLE_DIMENSION = 2;
private static final int DEFAULT_BORDER_WIDTH = 0;
private static final int DEFAULT_BORDER_COLOR = Color.BLACK;
private static final int DEFAULT_CIRCLE_BACKGROUND_COLOR = Color.TRANSPARENT;
private static final int DEFAULT_IMAGE_ALPHA = 255;
private static final boolean DEFAULT_BORDER_OVERLAY = false;
private final RectF mDrawableRect = new RectF();
private final RectF mBorderRect = new RectF();
private final Matrix mShaderMatrix = new Matrix();
private final Paint mBitmapPaint = new Paint();
private final Paint mBorderPaint = new Paint();
private final Paint mCircleBackgroundPaint = new Paint();
private int mBorderColor = DEFAULT_BORDER_COLOR;
private int mBorderWidth = DEFAULT_BORDER_WIDTH;
private int mCircleBackgroundColor = DEFAULT_CIRCLE_BACKGROUND_COLOR;
private int mImageAlpha = DEFAULT_IMAGE_ALPHA;
private Bitmap mBitmap;
private Canvas mBitmapCanvas;
private float mDrawableRadius;
private float mBorderRadius;
private ColorFilter mColorFilter;
private boolean mInitialized;
private boolean mRebuildShader;
private boolean mDrawableDirty;
private boolean mBorderOverlay;
private boolean mDisableCircularTransformation;
public CircleImageView(Context context) {
super(context);
init();
}
public CircleImageView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public CircleImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView, defStyle, 0);
mBorderWidth = a.getDimensionPixelSize(R.styleable.CircleImageView_civ_border_width, DEFAULT_BORDER_WIDTH);
mBorderColor = a.getColor(R.styleable.CircleImageView_civ_border_color, DEFAULT_BORDER_COLOR);
mBorderOverlay = a.getBoolean(R.styleable.CircleImageView_civ_border_overlay, DEFAULT_BORDER_OVERLAY);
mCircleBackgroundColor = a.getColor(R.styleable.CircleImageView_civ_circle_background_color, DEFAULT_CIRCLE_BACKGROUND_COLOR);
a.recycle();
init();
}
private void init() {
mInitialized = true;
super.setScaleType(SCALE_TYPE);
mBitmapPaint.setAntiAlias(true);
mBitmapPaint.setDither(true);
mBitmapPaint.setFilterBitmap(true);
mBitmapPaint.setAlpha(mImageAlpha);
mBitmapPaint.setColorFilter(mColorFilter);
mBorderPaint.setStyle(Paint.Style.STROKE);
mBorderPaint.setAntiAlias(true);
mBorderPaint.setColor(mBorderColor);
mBorderPaint.setStrokeWidth(mBorderWidth);
mCircleBackgroundPaint.setStyle(Paint.Style.FILL);
mCircleBackgroundPaint.setAntiAlias(true);
mCircleBackgroundPaint.setColor(mCircleBackgroundColor);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setOutlineProvider(new OutlineProvider());
}
}
@Override
public void setScaleType(ScaleType scaleType) {
if (scaleType != SCALE_TYPE) {
throw new IllegalArgumentException(String.format("ScaleType %s not supported.", scaleType));
}
}
@Override
public void setAdjustViewBounds(boolean adjustViewBounds) {
if (adjustViewBounds) {
throw new IllegalArgumentException("adjustViewBounds not supported.");
}
}
@SuppressLint("CanvasSize")
@Override
protected void onDraw(Canvas canvas) {
if (mDisableCircularTransformation) {
super.onDraw(canvas);
return;
}
if (mCircleBackgroundColor != Color.TRANSPARENT) {
canvas.drawCircle(mDrawableRect.centerX(), mDrawableRect.centerY(), mDrawableRadius, mCircleBackgroundPaint);
}
if (mBitmap != null) {
if (mDrawableDirty && mBitmapCanvas != null) {
mDrawableDirty = false;
Drawable drawable = getDrawable();
drawable.setBounds(0, 0, mBitmapCanvas.getWidth(), mBitmapCanvas.getHeight());
drawable.draw(mBitmapCanvas);
}
if (mRebuildShader) {
mRebuildShader = false;
BitmapShader bitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
bitmapShader.setLocalMatrix(mShaderMatrix);
mBitmapPaint.setShader(bitmapShader);
}
canvas.drawCircle(mDrawableRect.centerX(), mDrawableRect.centerY(), mDrawableRadius, mBitmapPaint);
}
if (mBorderWidth > 0) {
canvas.drawCircle(mBorderRect.centerX(), mBorderRect.centerY(), mBorderRadius, mBorderPaint);
}
}
@Override
public void invalidateDrawable(@NonNull Drawable dr) {
mDrawableDirty = true;
invalidate();
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
updateDimensions();
invalidate();
}
@Override
public void setPadding(int left, int top, int right, int bottom) {
super.setPadding(left, top, right, bottom);
updateDimensions();
invalidate();
}
@Override
public void setPaddingRelative(int start, int top, int end, int bottom) {
super.setPaddingRelative(start, top, end, bottom);
updateDimensions();
invalidate();
}
public int getBorderColor() {
return mBorderColor;
}
public void setBorderColor(@ColorInt int borderColor) {
if (borderColor == mBorderColor) {
return;
}
mBorderColor = borderColor;
mBorderPaint.setColor(borderColor);
invalidate();
}
public int getCircleBackgroundColor() {
return mCircleBackgroundColor;
}
public void setCircleBackgroundColor(@ColorInt int circleBackgroundColor) {
if (circleBackgroundColor == mCircleBackgroundColor) {
return;
}
mCircleBackgroundColor = circleBackgroundColor;
mCircleBackgroundPaint.setColor(circleBackgroundColor);
invalidate();
}
/**
* @deprecated Use {@link #setCircleBackgroundColor(int)} instead
*/
@Deprecated
public void setCircleBackgroundColorResource(@ColorRes int circleBackgroundRes) {
setCircleBackgroundColor(getContext().getResources().getColor(circleBackgroundRes));
}
public int getBorderWidth() {
return mBorderWidth;
}
public void setBorderWidth(int borderWidth) {
if (borderWidth == mBorderWidth) {
return;
}
mBorderWidth = borderWidth;
mBorderPaint.setStrokeWidth(borderWidth);
updateDimensions();
invalidate();
}
public boolean isBorderOverlay() {
return mBorderOverlay;
}
public void setBorderOverlay(boolean borderOverlay) {
if (borderOverlay == mBorderOverlay) {
return;
}
mBorderOverlay = borderOverlay;
updateDimensions();
invalidate();
}
public boolean isDisableCircularTransformation() {
return mDisableCircularTransformation;
}
public void setDisableCircularTransformation(boolean disableCircularTransformation) {
if (disableCircularTransformation == mDisableCircularTransformation) {
return;
}
mDisableCircularTransformation = disableCircularTransformation;
if (disableCircularTransformation) {
mBitmap = null;
mBitmapCanvas = null;
mBitmapPaint.setShader(null);
} else {
initializeBitmap();
}
invalidate();
}
@Override
public void setImageBitmap(Bitmap bm) {
super.setImageBitmap(bm);
initializeBitmap();
invalidate();
}
@Override
public void setImageDrawable(Drawable drawable) {
super.setImageDrawable(drawable);
initializeBitmap();
invalidate();
}
@Override
public void setImageResource(@DrawableRes int resId) {
super.setImageResource(resId);
initializeBitmap();
invalidate();
}
@Override
public void setImageURI(Uri uri) {
super.setImageURI(uri);
initializeBitmap();
invalidate();
}
@Override
public void setImageAlpha(int alpha) {
alpha &= 0xFF;
if (alpha == mImageAlpha) {
return;
}
mImageAlpha = alpha;
// This might be called during ImageView construction before
// member initialization has finished on API level >= 16.
if (mInitialized) {
mBitmapPaint.setAlpha(alpha);
invalidate();
}
}
@Override
public int getImageAlpha() {
return mImageAlpha;
}
@Override
public void setColorFilter(ColorFilter cf) {
if (cf == mColorFilter) {
return;
}
mColorFilter = cf;
// This might be called during ImageView construction before
// member initialization has finished on API level <= 19.
if (mInitialized) {
mBitmapPaint.setColorFilter(cf);
invalidate();
}
}
@Override
public ColorFilter getColorFilter() {
return mColorFilter;
}
private Bitmap getBitmapFromDrawable(Drawable drawable) {
if (drawable == null) {
return null;
}
if (drawable instanceof BitmapDrawable) {
return ((BitmapDrawable) drawable).getBitmap();
}
try {
Bitmap bitmap;
if (drawable instanceof ColorDrawable) {
bitmap = Bitmap.createBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG);
} else {
bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG);
}
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
return bitmap;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private void initializeBitmap() {
mBitmap = getBitmapFromDrawable(getDrawable());
if (mBitmap != null && mBitmap.isMutable()) {
mBitmapCanvas = new Canvas(mBitmap);
} else {
mBitmapCanvas = null;
}
if (!mInitialized) {
return;
}
if (mBitmap != null) {
updateShaderMatrix();
} else {
mBitmapPaint.setShader(null);
}
}
private void updateDimensions() {
mBorderRect.set(calculateBounds());
mBorderRadius = Math.min((mBorderRect.height() - mBorderWidth) / 2.0f, (mBorderRect.width() - mBorderWidth) / 2.0f);
mDrawableRect.set(mBorderRect);
if (!mBorderOverlay && mBorderWidth > 0) {
mDrawableRect.inset(mBorderWidth - 1.0f, mBorderWidth - 1.0f);
}
mDrawableRadius = Math.min(mDrawableRect.height() / 2.0f, mDrawableRect.width() / 2.0f);
updateShaderMatrix();
}
private RectF calculateBounds() {
int availableWidth = getWidth() - getPaddingLeft() - getPaddingRight();
int availableHeight = getHeight() - getPaddingTop() - getPaddingBottom();
int sideLength = Math.min(availableWidth, availableHeight);
float left = getPaddingLeft() + (availableWidth - sideLength) / 2f;
float top = getPaddingTop() + (availableHeight - sideLength) / 2f;
return new RectF(left, top, left + sideLength, top + sideLength);
}
private void updateShaderMatrix() {
if (mBitmap == null) {
return;
}
float scale;
float dx = 0;
float dy = 0;
mShaderMatrix.set(null);
int bitmapHeight = mBitmap.getHeight();
int bitmapWidth = mBitmap.getWidth();
if (bitmapWidth * mDrawableRect.height() > mDrawableRect.width() * bitmapHeight) {
scale = mDrawableRect.height() / (float) bitmapHeight;
dx = (mDrawableRect.width() - bitmapWidth * scale) * 0.5f;
} else {
scale = mDrawableRect.width() / (float) bitmapWidth;
dy = (mDrawableRect.height() - bitmapHeight * scale) * 0.5f;
}
mShaderMatrix.setScale(scale, scale);
mShaderMatrix.postTranslate((int) (dx + 0.5f) + mDrawableRect.left, (int) (dy + 0.5f) + mDrawableRect.top);
mRebuildShader = true;
}
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouchEvent(MotionEvent event) {
if (mDisableCircularTransformation) {
return super.onTouchEvent(event);
}
return inTouchableArea(event.getX(), event.getY()) && super.onTouchEvent(event);
}
private boolean inTouchableArea(float x, float y) {
if (mBorderRect.isEmpty()) {
return true;
}
return Math.pow(x - mBorderRect.centerX(), 2) + Math.pow(y - mBorderRect.centerY(), 2) <= Math.pow(mBorderRadius, 2);
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private class OutlineProvider extends ViewOutlineProvider {
@Override
public void getOutline(View view, Outline outline) {
if (mDisableCircularTransformation) {
ViewOutlineProvider.BACKGROUND.getOutline(view, outline);
} else {
Rect bounds = new Rect();
mBorderRect.roundOut(bounds);
outline.setRoundRect(bounds, bounds.width() / 2.0f);
}
}
}
}
package com.gingersoft.gsa.cloud.ui.view.imageview.mask;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import androidx.appcompat.widget.AppCompatImageView;
import com.gingersoft.gsa.cloud.ui.R;
@SuppressWarnings("WeakerAccess")
public abstract class PorterImageView extends AppCompatImageView {
private static final String TAG = PorterImageView.class.getSimpleName();
private static final PorterDuffXfermode PORTER_DUFF_XFERMODE = new PorterDuffXfermode(PorterDuff.Mode.DST_IN);
private Canvas maskCanvas;
private Bitmap maskBitmap;
private Paint maskPaint;
private Canvas drawableCanvas;
private Bitmap drawableBitmap;
private Paint drawablePaint;
private boolean invalidated = true;
private boolean square = false;
public PorterImageView(Context context) {
super(context);
setup(context, null, 0);
}
public PorterImageView(Context context, AttributeSet attrs) {
super(context, attrs);
setup(context, attrs, 0);
}
public PorterImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setup(context, attrs, defStyle);
}
@SuppressWarnings("SameParameterValue")
public void setSquare(boolean square) {
this.square = square;
}
private void setup(Context context, AttributeSet attrs, int defStyle) {
if (attrs != null) {
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ShaderImageView, defStyle, 0);
square = typedArray.getBoolean(R.styleable.ShaderImageView_siSquare, false);
typedArray.recycle();
}
if (getScaleType() == ScaleType.FIT_CENTER) {
setScaleType(ScaleType.CENTER_CROP);
}
maskPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
maskPaint.setColor(Color.BLACK);
}
@Override
public void invalidate() {
invalidated = true;
super.invalidate();
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
createMaskCanvas(w, h, oldw, oldh);
}
private void createMaskCanvas(int width, int height, int oldw, int oldh) {
boolean sizeChanged = width != oldw || height != oldh;
boolean isValid = width > 0 && height > 0;
if (isValid && (maskCanvas == null || sizeChanged)) {
maskCanvas = new Canvas();
maskBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
maskCanvas.setBitmap(maskBitmap);
maskPaint.reset();
paintMaskCanvas(maskCanvas, maskPaint, width, height);
drawableCanvas = new Canvas();
drawableBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
drawableCanvas.setBitmap(drawableBitmap);
drawablePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
invalidated = true;
}
}
protected abstract void paintMaskCanvas(Canvas maskCanvas, Paint maskPaint, int width, int height);
@Override
protected void onDraw(Canvas canvas) {
if (!isInEditMode()) {
int saveCount = canvas.saveLayer(0.0f, 0.0f, getWidth(), getHeight(), null, Canvas.ALL_SAVE_FLAG);
try {
if (invalidated) {
Drawable drawable = getDrawable();
if (drawable != null) {
invalidated = false;
Matrix imageMatrix = getImageMatrix();
if (imageMatrix == null) {// && mPaddingTop == 0 && mPaddingLeft == 0) {
drawable.draw(drawableCanvas);
} else {
int drawableSaveCount = drawableCanvas.getSaveCount();
drawableCanvas.save();
drawableCanvas.concat(imageMatrix);
drawable.draw(drawableCanvas);
drawableCanvas.restoreToCount(drawableSaveCount);
}
drawablePaint.reset();
drawablePaint.setFilterBitmap(false);
drawablePaint.setXfermode(PORTER_DUFF_XFERMODE);
drawableCanvas.drawBitmap(maskBitmap, 0.0f, 0.0f, drawablePaint);
}
}
if (!invalidated) {
drawablePaint.setXfermode(null);
canvas.drawBitmap(drawableBitmap, 0.0f, 0.0f, drawablePaint);
}
} catch (Exception e) {
String log = "Exception occured while drawing " + getId();
Log.e(TAG, log, e);
} finally {
canvas.restoreToCount(saveCount);
}
} else {
super.onDraw(canvas);
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (square) {
int width = getMeasuredWidth();
int height = getMeasuredHeight();
int dimen = Math.min(width, height);
setMeasuredDimension(dimen, dimen);
}
}
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.ui.view.imageview.mask;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import com.gingersoft.gsa.cloud.ui.R;
public class PorterShapeImageView extends PorterImageView {
private Drawable shape;
private Matrix matrix;
private Matrix drawMatrix;
public PorterShapeImageView(Context context) {
super(context);
setup(context, null, 0);
}
public PorterShapeImageView(Context context, AttributeSet attrs) {
super(context, attrs);
setup(context, attrs, 0);
}
public PorterShapeImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setup(context, attrs, defStyle);
}
private void setup(Context context, AttributeSet attrs, int defStyle) {
if(attrs != null){
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ShaderImageView, defStyle, 0);
shape = typedArray.getDrawable(R.styleable.ShaderImageView_siShape);
typedArray.recycle();
}
matrix = new Matrix();
}
@Override
protected void paintMaskCanvas(Canvas maskCanvas, Paint maskPaint, int width, int height) {
if(shape != null) {
if (shape instanceof BitmapDrawable) {
configureBitmapBounds(width, height);
if(drawMatrix != null) {
int drawableSaveCount = maskCanvas.getSaveCount();
maskCanvas.save();
maskCanvas.concat(matrix);
shape.draw(maskCanvas);
maskCanvas.restoreToCount(drawableSaveCount);
return;
}
}
shape.setBounds(0, 0, width, height);
shape.draw(maskCanvas);
}
}
private void configureBitmapBounds(int viewWidth, int viewHeight) {
drawMatrix = null;
int drawableWidth = shape.getIntrinsicWidth();
int drawableHeight = shape.getIntrinsicHeight();
boolean fits = viewWidth == drawableWidth && viewHeight == drawableHeight;
if (drawableWidth > 0 && drawableHeight > 0 && !fits) {
shape.setBounds(0, 0, drawableWidth, drawableHeight);
float widthRatio = (float) viewWidth / (float) drawableWidth;
float heightRatio = (float) viewHeight / (float) drawableHeight;
float scale = Math.min(widthRatio, heightRatio);
float dx = (int) ((viewWidth - drawableWidth * scale) * 0.5f + 0.5f);
float dy = (int) ((viewHeight - drawableHeight * scale) * 0.5f + 0.5f);
matrix.setScale(scale, scale);
matrix.postTranslate(dx, dy);
}
}
}
\ No newline at end of file
...@@ -12,5 +12,5 @@ ...@@ -12,5 +12,5 @@
android:paddingTop="@dimen/dp_10" android:paddingTop="@dimen/dp_10"
android:paddingBottom="@dimen/dp_10" android:paddingBottom="@dimen/dp_10"
android:text="現金結賬" android:text="現金結賬"
android:textColor="@color/color_3c" android:textColor="@color/white"
android:textSize="@dimen/dp_12" /> android:textSize="@dimen/dp_12" />
...@@ -11,28 +11,28 @@ ...@@ -11,28 +11,28 @@
<!--斜角标签--> <!--斜角标签-->
<declare-styleable name="BeveLabelView"> <declare-styleable name="BeveLabelView">
<!--背景颜色--> <!--背景颜色-->
<attr name="label_bg_color" format="color|reference"/> <attr name="label_bg_color" format="color|reference" />
<!--文字--> <!--文字-->
<attr name="label_text" format="string"/> <attr name="label_text" format="string" />
<!-- 文字颜色--> <!-- 文字颜色-->
<attr name="label_text_color" format="color|reference"/> <attr name="label_text_color" format="color|reference" />
<!--文字大小--> <!--文字大小-->
<attr name="label_text_size" format="dimension"/> <attr name="label_text_size" format="dimension" />
<attr name="label_length" format="dimension"/> <attr name="label_length" format="dimension" />
<!-- 圆角--> <!-- 圆角-->
<attr name="label_corner" format="dimension"/> <attr name="label_corner" format="dimension" />
<attr name="label_mode"> <attr name="label_mode">
<!-- fill是沾满整个,--> <!-- fill是沾满整个,-->
<enum name="left_top" value="0"/> <enum name="left_top" value="0" />
<enum name="right_top" value="1"/> <enum name="right_top" value="1" />
<enum name="left_bottom" value="2"/> <enum name="left_bottom" value="2" />
<enum name="right_bottom" value="3"/> <enum name="right_bottom" value="3" />
<enum name="left_top_fill" value="4"/> <enum name="left_top_fill" value="4" />
<enum name="right_top_fill" value="5"/> <enum name="right_top_fill" value="5" />
<enum name="left_bottom_fill" value="6"/> <enum name="left_bottom_fill" value="6" />
<enum name="right_bottom_fill" value="7"/> <enum name="right_bottom_fill" value="7" />
</attr> </attr>
</declare-styleable> </declare-styleable>
...@@ -493,26 +493,26 @@ ...@@ -493,26 +493,26 @@
</declare-styleable> </declare-styleable>
<declare-styleable name="SwitchButton"> <declare-styleable name="SwitchButton">
<attr name="kswThumbDrawable" format="reference"/> <attr name="kswThumbDrawable" format="reference" />
<attr name="kswThumbColor" format="color|reference"/> <attr name="kswThumbColor" format="color|reference" />
<attr name="kswThumbMargin" format="dimension|reference"/> <attr name="kswThumbMargin" format="dimension|reference" />
<attr name="kswThumbMarginTop" format="dimension|reference"/> <attr name="kswThumbMarginTop" format="dimension|reference" />
<attr name="kswThumbMarginBottom" format="dimension|reference"/> <attr name="kswThumbMarginBottom" format="dimension|reference" />
<attr name="kswThumbMarginLeft" format="dimension|reference"/> <attr name="kswThumbMarginLeft" format="dimension|reference" />
<attr name="kswThumbMarginRight" format="dimension|reference"/> <attr name="kswThumbMarginRight" format="dimension|reference" />
<attr name="kswThumbWidth" format="dimension|reference"/> <attr name="kswThumbWidth" format="dimension|reference" />
<attr name="kswThumbHeight" format="dimension|reference"/> <attr name="kswThumbHeight" format="dimension|reference" />
<attr name="kswThumbRadius" format="dimension|reference"/> <attr name="kswThumbRadius" format="dimension|reference" />
<attr name="kswBackRadius" format="dimension|reference"/> <attr name="kswBackRadius" format="dimension|reference" />
<attr name="kswBackDrawable" format="reference"/> <attr name="kswBackDrawable" format="reference" />
<attr name="kswBackColor" format="color|reference"/> <attr name="kswBackColor" format="color|reference" />
<attr name="kswFadeBack" format="boolean"/> <attr name="kswFadeBack" format="boolean" />
<attr name="kswBackMeasureRatio" format="float"/> <attr name="kswBackMeasureRatio" format="float" />
<attr name="kswAnimationDuration" format="integer"/> <attr name="kswAnimationDuration" format="integer" />
<attr name="kswTintColor" format="color|reference"/> <attr name="kswTintColor" format="color|reference" />
<attr name="kswTextOn" format="string"/> <attr name="kswTextOn" format="string" />
<attr name="kswTextOff" format="string"/> <attr name="kswTextOff" format="string" />
<attr name="kswTextMarginH" format="dimension"/> <attr name="kswTextMarginH" format="dimension" />
</declare-styleable> </declare-styleable>
<declare-styleable name="WaveView"> <declare-styleable name="WaveView">
...@@ -528,4 +528,47 @@ ...@@ -528,4 +528,47 @@
</attr> </attr>
<attr name="showWave" format="boolean" /> <attr name="showWave" format="boolean" />
</declare-styleable> </declare-styleable>
<declare-styleable name="CircleImageView">
<attr name="civ_border_width" format="dimension" />
<attr name="civ_border_color" format="color" />
<attr name="civ_border_overlay" format="boolean" />
<attr name="civ_circle_background_color" format="color" />
</declare-styleable>
<attr name="siArrowPosition">
<enum name="left" value="0" />
<enum name="right" value="1" />
</attr>
<attr name="siBorderType">
<enum name="stroke" value="0" />
<enum name="fill" value="1" />
</attr>
<attr name="siStrokeCap">
<enum name="butt" value="0" />
<enum name="round" value="1" />
<enum name="square" value="2" />
</attr>
<attr name="siStrokeJoin">
<enum name="bevel" value="0" />
<enum name="miter" value="1" />
<enum name="round" value="2" />
</attr>
<declare-styleable name="ShaderImageView">
<attr name="siSquare" format="boolean" />
<attr name="siBorderColor" format="color" />
<attr name="siBorderWidth" format="dimension" />
<attr name="siBorderAlpha" format="float" />
<attr name="siForeground" format="integer|reference" />
<!-- Rounded Image View -->
<attr name="siRadius" format="dimension" />
<!--BubbleImageView-->
<attr name="siArrowPosition" />
<attr name="siTriangleHeight" format="dimension" />
<!--PorterImageView-->
<attr name="siShape" format="integer|reference" />
<!--ShaderImageView-->
<attr name="siBorderType" />
<attr name="siStrokeCap" />
<attr name="siStrokeJoin" />
<attr name="siStrokeMiter" format="dimension" />
</declare-styleable>
</resources> </resources>
\ 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