Commit 9ed1d78e by Wyh

1、增加供應鏈服務器地址 2、新增多類型adapter 3、供應鏈供應商、單位管理

Signed-off-by: Wyh <1239658231>
parent aba2a0c0
......@@ -7,7 +7,9 @@ import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.os.Build;
import android.os.RemoteException;
import androidx.annotation.NonNull;
import com.billy.cc.core.component.CC;
import com.didichuxing.doraemonkit.DoraemonKit;
import com.elvishew.xlog.LogConfiguration;
......@@ -29,6 +31,9 @@ import com.gingersoft.gsa.cloud.base.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.base.utils.xlog.MyBackupStrategy;
import com.gingersoft.gsa.cloud.config.DoraemonKitConfig;
import com.gingersoft.gsa.cloud.config.expandconfig.ExpandInfoSetting;
import com.gingersoft.gsa.cloud.config.expandconfig.FunctionExtendedConfiguration;
import com.gingersoft.gsa.cloud.config.expandconfig.UIStyleExtendedConfiguration;
import com.gingersoft.gsa.cloud.constans.HttpsConstans;
import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.gingersoft.gsa.cloud.constans.UserConstans;
......@@ -46,16 +51,12 @@ import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import me.jessyan.autosize.AutoSize;
import me.jessyan.autosize.AutoSizeConfig;
import me.jessyan.autosize.onAdaptListener;
import me.jessyan.retrofiturlmanager.RetrofitUrlManager;
import com.gingersoft.gsa.cloud.config.expandconfig.UIStyleExtendedConfiguration;
import com.gingersoft.gsa.cloud.config.expandconfig.FunctionExtendedConfiguration;
import com.gingersoft.gsa.cloud.config.expandconfig.ExpandInfoSetting;
/**
* Created by Wyh on 2019/12/21.
......@@ -197,7 +198,7 @@ public class GsaCloudApplication extends BaseApplication {
.addCallback(new LoadingCallback())
.addCallback(new TimeoutCallback())
.addCallback(new CustomCallback())
.setDefaultCallback(LoadingCallback.class)//设置默认状态页
// .setDefaultCallback(LoadingCallback.class)//设置默认状态页 已有加載彈窗,加上這個會導致兩個加載
.commit();
}
......@@ -240,6 +241,10 @@ public class GsaCloudApplication extends BaseApplication {
RetrofitUrlManager.getInstance().putDomain("ricepon_member", HttpsConstans.RICEPON_MEMBER_61177);
//餐廳模塊請求地址
RetrofitUrlManager.getInstance().putDomain("ricepon_restaurant", HttpsConstans.ROOT_SERVER_ADDRESS_FORMAL_RESTAURANT);
//供應商模塊請求地址
RetrofitUrlManager.getInstance().putDomain("ricepon-purchase", HttpsConstans.ROOT_SERVER_ADDRESS_RICEPON_PURCHASE);
}
private void initPrint() {
......
package com.gingersoft.gsa.cloud.bean;
import android.view.inputmethod.EditorInfo;
import java.util.List;
import lombok.Data;
/**
* @author 宇航.
* User: admin
* Date: 2020/11/20
* Time: 10:45
* Use: 多功能列表item實體類,多功能adapter使用
*/
@Data
public class InfoMultiBean {
/**
* 顯示一條分割線
*/
public static final int ITEM_TYPE_LINE = 0;
/**
* 顯示一條字體加粗的標題
*/
public static final int ITEM_TYPE_TITLE = 1;
/**
* 顯示輸入框
*/
public static final int ITEM_TYPE_INPUT = 2;
/**
* 選中時顯示列表,如果不添加列表數據,則是單選按鈕
*/
public static final int ITEM_TYPE_SHOW_LIST = 4;
/**
* 選中時顯示彈窗
*/
public static final int ITEM_TYPE_SHOW_DIALOG = 5;
/**
* item類型
*/
public int itemType;
/**
* 用於顯示的標題
*/
private String showTitle;
/**
* 是否必填
*/
private boolean isRequired;
/**
* 提示文字
*/
private String hintText;
/**
* 顯示的值
*/
private String showValue;
/**
* 選中狀態
*/
private boolean isChecked;
/**
* 當類型為輸入框時,限制輸入的內容格式
*/
private int inputType = EditorInfo.TYPE_CLASS_TEXT;
/**
* 點擊展開有其他item
*/
private List<InfoMultiBean> infoMultiBeans;
public InfoMultiBean(int itemType) {
this.itemType = itemType;
}
public InfoMultiBean(int itemType, String showTitle, boolean isRequired, String hintText, String showValue) {
this.itemType = itemType;
this.showTitle = showTitle;
this.isRequired = isRequired;
this.hintText = hintText;
this.showValue = showValue;
}
public InfoMultiBean(int itemType, String showTitle) {
this.itemType = itemType;
this.showTitle = showTitle;
}
public InfoMultiBean(int itemType, String showTitle, boolean isRequired, String hintText) {
this.itemType = itemType;
this.showTitle = showTitle;
this.isRequired = isRequired;
this.hintText = hintText;
}
// public String getShowValue() {
// if(showValue == null){
// return "";
// }
// return showValue;
// }
public boolean isChecked() {
return isChecked;
}
public void setChecked(boolean checked) {
isChecked = checked;
}
}
package com.gingersoft.gsa.cloud.config.globalconfig.applyOptions;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.BuildConfig;
import com.gingersoft.gsa.cloud.base.utils.encryption.Aes;
import com.gingersoft.gsa.cloud.constans.AppConstans;
import com.jess.arms.http.GlobalHttpHandler;
......@@ -47,6 +48,8 @@ public class MyGlobalHttpHandler implements GlobalHttpHandler {
}
if (GsaCloudApplication.isLogin) {
builder.set("token", token);
} else if (BuildConfig.DEBUG) {
builder.set("uuid", "999");
}
// builder.set("Domain-Name", "common");
return chain.request().newBuilder()
......
......@@ -41,6 +41,7 @@ public class HttpsConstans {
public static String CLOUD_GSA_API_PATH = "/ricepon-cloud-gsa/api/";//雲端GSA路徑
public static String RESTAURANT_API_PATH = "/ricepon-restaurant/api/";//餐廳模塊路徑
public static String PURCHASE_API_PATH = "/ricepon-purchase/api/";//供應鏈路徑
public static String ROOT_SERVER_YOU_CHANG_HK = "http://192.168.1.142:9012/api/"; //友常本地
public static String ROOT_SERVER_ZHI_WANG_HK = "http://192.168.1.169:9012/api/"; //世維本地
......@@ -104,6 +105,8 @@ public class HttpsConstans {
public static String ROOT_SERVER_ADDRESS_FORMAL_RESTAURANT = HTTP_ADDRESS_URL_FORMAL + RESTAURANT_API_PATH;
public static String ROOT_SERVER_ADDRESS_RICEPON_PURCHASE = HTTP_ADDRESS_URL_FORMAL + PURCHASE_API_PATH;
public static String ROOT_SERVER = HTTP_ADDRESS_URL_FORMAL;
//修改這個值,配置外賣接單環境
......@@ -136,6 +139,7 @@ public class HttpsConstans {
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = HTTP_ADDRESS_URL_FORMAL;
ROOT_SERVER_ADDRESS_FORMAL = HTTP_ADDRESS_URL_FORMAL + CLOUD_GSA_API_PATH;
ROOT_SERVER_ADDRESS_FORMAL_RESTAURANT = HTTP_ADDRESS_URL_FORMAL + RESTAURANT_API_PATH;
ROOT_SERVER_ADDRESS_RICEPON_PURCHASE = HTTP_ADDRESS_URL_FORMAL + PURCHASE_API_PATH;
ROOT_URL = ROOT_FORMAL_URL;
REPORT_SERVER_ADDRESS = REPORT_FORMAL_ADDRESS + REPORT_PATH;
WECHAR_REPORT_SERVER_ADDRESS = WECHAR_REPORT_FORMAL_ADDRESS + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
......@@ -149,6 +153,7 @@ public class HttpsConstans {
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = REPORT_TEST_ADDRESS;
ROOT_SERVER_ADDRESS_FORMAL = HTTP_ADDRESS_URL_HK + CLOUD_GSA_API_PATH;
ROOT_SERVER_ADDRESS_FORMAL_RESTAURANT = HTTP_ADDRESS_URL_HK + RESTAURANT_API_PATH;
ROOT_SERVER_ADDRESS_RICEPON_PURCHASE = HTTP_ADDRESS_URL_HK + PURCHASE_API_PATH;
ROOT_URL = ROOT_HK_TEST_URL;
REPORT_SERVER_ADDRESS = REPORT_TEST_ADDRESS + REPORT_PATH;
WECHAR_REPORT_SERVER_ADDRESS = WECHAR_REPORT_TEST_ADDRESS + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
......@@ -162,6 +167,7 @@ public class HttpsConstans {
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = HTTP_ADDRESS_URL_PRE;
ROOT_SERVER_ADDRESS_FORMAL = HTTP_ADDRESS_URL_PRE + CLOUD_GSA_API_PATH;
ROOT_SERVER_ADDRESS_FORMAL_RESTAURANT = HTTP_ADDRESS_URL_PRE + RESTAURANT_API_PATH;
ROOT_SERVER_ADDRESS_RICEPON_PURCHASE = HTTP_ADDRESS_URL_PRE + PURCHASE_API_PATH;
ROOT_URL = HTTP_ADDRESS_URL_PRE;
REPORT_SERVER_ADDRESS = HTTP_ADDRESS_URL_PRE + REPORT_PATH;
WECHAR_REPORT_SERVER_ADDRESS = HTTP_ADDRESS_URL_PRE + WECHAR_REPORT_PATH;
......
......@@ -35,7 +35,7 @@ public class FunctionManager {
FunctionDaoUtils daoUtils = new FunctionDaoUtils(context);
List<Function> functionList = daoUtils.queryAllFunction();
return filterFunctionByResLoction(functionList, fModules, resLoction);
return filterFunctionByResLoction(functionList, fModules, resLoction);
}
private List<Function> filterFunctionByResLoction(List<Function> functionList, FModule[] fModules, String resLoction) {
......
package com.gingersoft.gsa.cloud.ui.adapter;
import android.widget.RadioButton;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.base.R;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2020/11/21
* Time: 17:41
* Use:
*/
public class RadioListAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
private int selectIndex = 0;
public RadioListAdapter(@Nullable List<String> data) {
super(R.layout.item_radio, data);
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, String s) {
RadioButton radioButton = viewHolder.getView(R.id.rb_select_dialog_list_radio);
radioButton.setChecked(viewHolder.getAdapterPosition() == selectIndex);
viewHolder.setText(R.id.tv_select_dialog_list_title, s);
radioButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
setSelectIndex(viewHolder.getAdapterPosition());
}
});
}
public void setSelectIndex(int selectIndex) {
this.selectIndex = selectIndex;
notifyDataSetChanged();
}
public int getSelectIndex() {
return selectIndex;
}
}
package com.gingersoft.gsa.cloud.ui.adapter.multi;
import android.content.Context;
import com.chad.library.adapter.base.BaseProviderMultiAdapter;
import com.gingersoft.gsa.cloud.bean.InfoMultiBean;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2020/11/20
* Time: 10:40
* Use:
*/
public class InfoMultiAdapter extends BaseProviderMultiAdapter<InfoMultiBean> {
@Override
protected int getItemType(@NotNull List<? extends InfoMultiBean> list, int i) {
return list.get(i).getItemType();
}
public InfoMultiAdapter(Context context, List<InfoMultiBean> infoMultiBeans) {
super(infoMultiBeans);
addItemProvider(new InputProvider());
addItemProvider(new ThickLineProvider());
addItemProvider(new TitleProvider());
addItemProvider(new RadioProvider(context));
addItemProvider(new SelectDialogProvider(context));
}
}
package com.gingersoft.gsa.cloud.ui.adapter.multi;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.base.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.bean.InfoMultiBean;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2020/10/29
* Time: 15:58
* Use:
*/
public class InputProvider extends MyBaseItemProvider {
@Override
public int getItemViewType() {
return InfoMultiBean.ITEM_TYPE_INPUT;
}
@Override
public int getLayoutId() {
return R.layout.multi_input;
}
@Override
public void convert(@NotNull BaseViewHolder baseViewHolder, InfoMultiBean infoMultiBean) {
super.convert(baseViewHolder, infoMultiBean);
EditText editText = baseViewHolder.getView(R.id.ed_food_menu_value);
if (TextUtil.isNotEmptyOrNullOrUndefined(infoMultiBean.getShowValue())) {
editText.setText(infoMultiBean.getShowValue());
} else {
editText.setHint(infoMultiBean.getHintText());
editText.setText("");
}
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
List<InfoMultiBean> data = getAdapter().getData();
data.get(baseViewHolder.getAdapterPosition()).setShowValue(s + "");
}
});
editText.setInputType(infoMultiBean.getInputType());
}
}
package com.gingersoft.gsa.cloud.ui.adapter.multi;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.base.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.bean.InfoMultiBean;
import org.jetbrains.annotations.NotNull;
/**
* @author 宇航.
* User: admin
* Date: 2020/11/20
* Time: 11:07
* Use:
*/
public abstract class MyBaseItemProvider extends BaseItemProvider<InfoMultiBean> {
@Override
public void convert(@NotNull BaseViewHolder baseViewHolder, InfoMultiBean infoMultiBean) {
//是否顯示必選
baseViewHolder.setGone(R.id.multi_required, !infoMultiBean.isRequired());
//設置標題
if (TextUtil.isNotEmptyOrNullOrUndefined(infoMultiBean.getShowTitle())) {
baseViewHolder.setText(R.id.tv_multi_title, infoMultiBean.getShowTitle());
} else {
baseViewHolder.setText(R.id.tv_multi_title, "");
}
}
}
package com.gingersoft.gsa.cloud.ui.adapter.multi;
import android.content.Context;
import android.view.View;
import android.widget.CheckBox;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.bean.InfoMultiBean;
import com.gingersoft.gsa.cloud.ui.recylcler.decorator.DividerItemDecoration;
import org.jetbrains.annotations.NotNull;
import static com.gingersoft.gsa.cloud.ui.recylcler.decorator.DividerItemDecoration.VERTICAL_LIST;
/**
* @author 宇航.
* User: admin
* Date: 2020/10/29
* Time: 15:58
* Use:
*/
public class RadioProvider extends MyBaseItemProvider {
private Context context;
public RadioProvider(Context context) {
this.context = context;
}
@Override
public int getItemViewType() {
return InfoMultiBean.ITEM_TYPE_SHOW_LIST;
}
@Override
public int getLayoutId() {
return R.layout.multi_radio;
}
@Override
public void convert(@NotNull BaseViewHolder baseViewHolder, InfoMultiBean infoMultiBean) {
super.convert(baseViewHolder, infoMultiBean);
baseViewHolder.setText(R.id.rb_multi, infoMultiBean.getShowValue());
if (infoMultiBean.getInfoMultiBeans() != null) {
RecyclerView rv = baseViewHolder.getView(R.id.rv_radio_multi);
CheckBox checkBox = baseViewHolder.getView(R.id.rb_multi);
rv.setVisibility(checkBox.isChecked() ? View.VISIBLE : View.GONE);
rv.addItemDecoration(new DividerItemDecoration(context, VERTICAL_LIST));
InfoMultiAdapter infoMultiAdapter = new InfoMultiAdapter(context, infoMultiBean.getInfoMultiBeans());
rv.setAdapter(infoMultiAdapter);
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
rv.setVisibility(isChecked ? View.VISIBLE : View.GONE);
});
}
}
}
package com.gingersoft.gsa.cloud.ui.adapter.multi;
import android.content.Context;
import android.view.View;
import android.widget.TextView;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.bean.InfoMultiBean;
import com.gingersoft.gsa.cloud.ui.utils.AppDialog;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2020/10/29
* Time: 15:58
* Use:
*/
public class SelectDialogProvider extends MyBaseItemProvider {
private Context context;
private List<InfoMultiBean> infoMultiBeans;
private int lastSelect = 0;
//當前佈局在adapter中的下標
private int currentPosition = -1;
public SelectDialogProvider(Context context) {
this.context = context;
}
@Override
public int getItemViewType() {
return InfoMultiBean.ITEM_TYPE_SHOW_DIALOG;
}
@Override
public int getLayoutId() {
return R.layout.multi_select_dialog;
}
@Override
public void convert(@NotNull BaseViewHolder baseViewHolder, InfoMultiBean infoMultiBean) {
super.convert(baseViewHolder, infoMultiBean);
currentPosition = baseViewHolder.getAdapterPosition();
infoMultiBeans = infoMultiBean.getInfoMultiBeans();
if (lastSelect == 0) {
for (int i = 0; i < infoMultiBeans.size(); i++) {
if (infoMultiBeans.get(i).isChecked()) {
lastSelect = i;
}
}
}
TextView tvValue = baseViewHolder.getView(R.id.tv_provider_select_text);
if (infoMultiBeans != null) {
tvValue.setText(infoMultiBeans.get(lastSelect).getShowTitle());
infoMultiBeans.get(lastSelect).setChecked(true);
}
tvValue.setOnClickListener(mOnClickListener);
baseViewHolder.getView(R.id.iv_provider_select).setOnClickListener(mOnClickListener);
}
View.OnClickListener mOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
if (infoMultiBeans != null) {
List<String> list = new ArrayList<>();
int defaultCheck = 0;
for (int i = 0; i < infoMultiBeans.size(); i++) {
list.add(infoMultiBeans.get(i).getShowTitle());
if (infoMultiBeans.get(i).isChecked()) {
defaultCheck = i;
}
}
lastSelect = defaultCheck;
new AppDialog().showSelectDialog(context, "單位種類", list, defaultCheck, (view, dialog, position) -> {
if (view.getId() == R.id.tv_delivery_confirm) {
infoMultiBeans.get(lastSelect).setChecked(false);
infoMultiBeans.get(position).setChecked(true);
lastSelect = position;
getAdapter().notifyItemChanged(currentPosition);
}
dialog.dismiss();
});
}
}
};
}
package com.gingersoft.gsa.cloud.ui.adapter.multi;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.bean.InfoMultiBean;
import org.jetbrains.annotations.NotNull;
/**
* @author 宇航.
* User: admin
* Date: 2020/10/29
* Time: 15:58
* Use:
*/
public class ThickLineProvider extends MyBaseItemProvider {
@Override
public int getItemViewType() {
return InfoMultiBean.ITEM_TYPE_LINE;
}
@Override
public int getLayoutId() {
return R.layout.item_thick_line;
}
@Override
public void convert(@NotNull BaseViewHolder baseViewHolder, InfoMultiBean infoMultiBean) {
}
}
package com.gingersoft.gsa.cloud.ui.adapter.multi;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.bean.InfoMultiBean;
import org.jetbrains.annotations.NotNull;
/**
* @author 宇航.
* User: admin
* Date: 2020/10/29
* Time: 15:58
* Use:
*/
public class TitleProvider extends MyBaseItemProvider {
@Override
public int getItemViewType() {
return InfoMultiBean.ITEM_TYPE_TITLE;
}
@Override
public int getLayoutId() {
return R.layout.multi_title;
}
@Override
public void convert(@NotNull BaseViewHolder baseViewHolder, InfoMultiBean infoMultiBean) {
baseViewHolder.setText(R.id.tv_multi_title, infoMultiBean.getShowTitle());
}
}
......@@ -11,8 +11,11 @@ import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.base.widget.DialogUtils;
import com.gingersoft.gsa.cloud.ui.adapter.RadioListAdapter;
import com.jess.arms.utils.ArmsUtils;
import java.util.List;
public class AppDialog {
public void showWaringDialog(Context context, String title, DialogOnClickListenter sureOnclickListenter) {
......@@ -56,10 +59,22 @@ public class AppDialog {
.show();
}
public void showSelectDialog(Context context, String title, List<String> list, int defaultCheck, onDialogSelectListener onDialogSelectListener) {
RadioListAdapter radioListAdapter = new RadioListAdapter(list);
radioListAdapter.setSelectIndex(defaultCheck);
showSelectDialog(context, title, 1, radioListAdapter, (view, dialog) -> {
if(onDialogSelectListener != null){
onDialogSelectListener.onclick(view, dialog, radioListAdapter.getSelectIndex());
}
});
}
public interface DialogOnClickListenter {
void onclick(View view, Dialog dialog);
}
public interface onDialogSelectListener {
void onclick(View view, Dialog dialog, int position);
}
public void showTipDialog(Context context, String title, DialogOnClickListenter sureOnclickListenter) {
new DialogUtils(context, R.layout.dialog_tip) {
......@@ -69,8 +84,8 @@ public class AppDialog {
hepler.setText(R.id.tv_warning_title, title);
}
hepler.getView(R.id.tv_dialog_cancel).setOnClickListener(v -> dialog.dismiss());
hepler.getView(R.id.tv_dialog_confirm).setOnClickListener(v->{
if(sureOnclickListenter != null){
hepler.getView(R.id.tv_dialog_confirm).setOnClickListener(v -> {
if (sureOnclickListenter != null) {
sureOnclickListenter.onclick(v, dialog);
}
});
......
......@@ -4,7 +4,8 @@ import com.gingersoft.gsa.cloud.base.R
import com.gingersoft.gsa.cloud.constans.FunctionManagerConstants
import com.gingersoft.gsa.cloud.database.bean.Function
class BtnBuilder(var functions: List<Function>) {
class BtnBuilder {
lateinit var functions: List<Function>
companion object {
const val SureBtn = 0
......@@ -21,11 +22,16 @@ class BtnBuilder(var functions: List<Function>) {
private var instance: BtnBuilder? = null
@JvmStatic
fun getInstance(functions: List<Function>) = instance
?: synchronized(this) {
instance
?: BtnBuilder(functions).also { instance = it }
}
fun getInstance(functions: List<Function>): BtnBuilder {
instance
?: synchronized(this) {
instance
?: BtnBuilder().also { instance = it }
}
instance!!.functions = functions
return instance!!
}
}
class BtnBean(val type: Int, var btnContent: String, val btnColor: Int, val btnImg: Int)
......@@ -80,4 +86,5 @@ class BtnBuilder(var functions: List<Function>) {
// return BtnBean(btnCode, btnContent, btnColor, btnImg)
}
}

525 Bytes | W: | H:

879 Bytes | W: | H:

base-module/src/main/res/drawable-xhdpi/ic_checkbox_checked.png
base-module/src/main/res/drawable-xhdpi/ic_checkbox_checked.png
base-module/src/main/res/drawable-xhdpi/ic_checkbox_checked.png
base-module/src/main/res/drawable-xhdpi/ic_checkbox_checked.png
  • 2-up
  • Swipe
  • Onion skin

166 Bytes | W: | H:

285 Bytes | W: | H:

base-module/src/main/res/drawable-xhdpi/ic_checkbox_uncheck.png
base-module/src/main/res/drawable-xhdpi/ic_checkbox_uncheck.png
base-module/src/main/res/drawable-xhdpi/ic_checkbox_uncheck.png
base-module/src/main/res/drawable-xhdpi/ic_checkbox_uncheck.png
  • 2-up
  • Swipe
  • Onion skin
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_checkbox_checked" android:state_checked="true" />
<item android:drawable="@drawable/ic_checkbox_uncheck" />
<item android:drawable="@drawable/ic_circle_radio_check" android:state_checked="true" />
<item android:drawable="@drawable/ic_circle_radio_uncheck" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<com.qmuiteam.qmui.alpha.QMUIAlphaButton xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/btn_save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_20"
android:layout_marginRight="@dimen/dp_20"
android:layout_marginBottom="@dimen/dp_10"
android:background="@drawable/shape_app_btn"
android:gravity="center"
android:textColor="@color/white"
android:textSize="@dimen/dp_16"
tools:text="保存" />
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_40"
android:gravity="center_vertical">
<TextView
android:id="@+id/tv_select_dialog_list_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:layout_weight="1"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_16"
tools:text="重量" />
<RadioButton
android:id="@+id/rb_select_dialog_list_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_10"
android:button="@drawable/selector_radio_circle_bg" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ui_shape_rect_loading"
android:gravity="center"
android:layout_gravity="center"
android:minWidth="120dp"
android:minHeight="120dp"
android:orientation="vertical"
android:padding="10dp">
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
style="@style/AppTheme.Base"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_loading_dialog_text"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="@string/ui_loading"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/load_dialog_text_size" />
android:layout_gravity="center"
android:background="@drawable/ui_shape_rect_loading"
android:gravity="center"
android:minWidth="120dp"
android:minHeight="120dp"
android:orientation="vertical"
android:padding="10dp">
<ProgressBar
style="@style/AppTheme.Base"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_loading_dialog_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="@string/ui_loading"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/load_dialog_text_size" />
</LinearLayout>
\ No newline at end of file
</LinearLayout>
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_55"
android:paddingLeft="@dimen/multi_marginLeft"
android:paddingRight="@dimen/multi_marginLeft"
xmlns:tools="http://schemas.android.com/tools">
<TextView
android:id="@+id/multi_required"
style="@style/Multi_RequiredStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="*" />
<TextView
android:id="@+id/tv_multi_title"
style="@style/Multi_Input_titleStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="供應商編號" />
<EditText
android:id="@+id/ed_food_menu_value"
style="@style/Multi_Input_editStyle"
android:layout_width="0dp"
android:layout_marginLeft="@dimen/dp_5"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@null"
tools:hint="請輸入食品組名稱" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dp_55"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="@dimen/multi_marginLeft"
android:paddingRight="@dimen/multi_marginLeft">
<TextView
android:id="@+id/multi_required"
style="@style/Multi_RequiredStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="*" />
<TextView
android:id="@+id/tv_multi_title"
style="@style/Multi_Input_titleStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:text="供應商編號" />
<CheckBox
android:id="@+id/rb_multi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@color/trans"
android:drawableLeft="@drawable/selector_radio_bg"
android:drawablePadding="@dimen/dp_5"
android:text="選擇"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_16" />
</LinearLayout>
<include layout="@layout/include_horizontal_color_eee_dividing_line" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_radio_multi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_55"
android:paddingLeft="@dimen/multi_marginLeft"
android:paddingRight="@dimen/multi_marginLeft">
<TextView
android:id="@+id/multi_required"
style="@style/Multi_RequiredStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="*" />
<TextView
android:id="@+id/tv_multi_title"
style="@style/Multi_Input_titleStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="供應商編號" />
<TextView
android:id="@+id/tv_provider_select_text"
style="@style/Multi_Input_editStyle"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_5"
android:layout_weight="1"
android:background="@null"
android:hint="請選擇" />
<ImageView
android:id="@+id/iv_provider_select"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/arrow_down_black" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_38"
xmlns:tools="http://schemas.android.com/tools"
android:gravity="center_vertical">
<TextView
android:id="@+id/tv_multi_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_18"
tools:text="基本信息"
android:textColor="@color/black"
android:textSize="@dimen/multi_marginLeft"
android:textStyle="bold" />
</LinearLayout>
\ No newline at end of file
......@@ -485,4 +485,6 @@
<dimen name="settlement_report_text_size">@dimen/sp_18</dimen>
<dimen name="switcher_elevation">4dp</dimen>
<dimen name="multi_marginLeft">@dimen/dp_18</dimen>
</resources>
\ No newline at end of file
......@@ -24,6 +24,7 @@
<item name="topbar_right_add_button" type="id"/>
<item name="topbar_right_edit_button" type="id"/>
<item name="topbar_right_screen_button" type="id"/>
<item name="topbar_right_delete_button" type="id"/>
<item name="layout_for_test" type="id"/>
<item name="topbar_heart_disconnect" type="id"/>
......
......@@ -28,7 +28,8 @@
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowAnimationStyle">@style/ui_activityAnimation</item><!-- 设置activity切换动画 -->
<item name="android:windowAnimationStyle">@style/ui_activityAnimation
</item><!-- 设置activity切换动画 -->
<item name="android:windowIsTranslucent">false</item><!-- 防止Acitivity跳转黑屏 将背景设置成透明-->
<item name="android:windowDisablePreview">true</item>
</style>
......@@ -359,7 +360,7 @@
<item name="android:layout_height">@dimen/button_height</item>
<item name="android:background">@drawable/shape_app_btn</item>
</style>
<!--————————————————————外送/自取模塊 凍鏈模塊共用樣式————————————————————-->
<!--————————————————————外送/自取模塊 凍鏈模塊共用樣式————————————————————-->
<!-- 彈窗_收貨標題字體樣式-->
<style name="otherOrderReceiving_title_textStyle">
......@@ -423,4 +424,21 @@
<item name="android:textSize">@dimen/dp_12</item>
<item name="android:textColor">@color/color_3c</item>
</style>
<style name="Multi_RequiredStyle">
<item name="android:textColor">@color/required_color</item>
<item name="android:textSize">@dimen/dp_16</item>
</style>
<style name="Multi_Input_titleStyle">
<item name="android:textColor">@color/color_3c</item>
<item name="android:textSize">@dimen/dp_16</item>
</style>
<style name="Multi_Input_editStyle">
<item name="android:textColorHint">@color/color_c9</item>
<item name="android:textSize">@dimen/dp_16</item>
<item name="android:gravity">center_vertical|right</item>
<item name="android:textColor">@color/color_3c</item>
</style>
</resources>
......@@ -51,7 +51,7 @@ android {
/**
* 版本号
*/
schemaVersion 21
schemaVersion 22
/**
* greendao输出dao的数据库操作实体类文件夹(相对路径 包名+自定义路径名称,包将创建于包名的直接路径下)
*/
......
......@@ -4,6 +4,7 @@ import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.Transient;
import java.io.Serializable;
......@@ -15,9 +16,13 @@ import lombok.Data;
@Entity
@Data
public class PrinterDeviceBean implements Serializable {
@Transient
public static final int PRINT_IP = 1;
@Transient
public static final int PRINT_LOCAL = 2;
@Transient
public static final int PRINT_USB = 3;
@Transient
public static final int PRINT_PRJ_PC = 4;
private static final long serialVersionUID = 4583366043598445115L;
......
......@@ -14,10 +14,10 @@ import org.greenrobot.greendao.identityscope.IdentityScopeType;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* Master of DAO (schema version 21): knows all DAOs.
* Master of DAO (schema version 22): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 21;
public static final int SCHEMA_VERSION = 22;
/** Creates underlying database table using DAOs. */
public static void createAllTables(Database db, boolean ifNotExists) {
......
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillColor="#008577"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/shape_id">
<!-- 正三角 -->
<rotate
android:fromDegrees="45"
android:pivotX="80%"
android:pivotY="50%">
<shape android:shape="rectangle">
<solid android:color="#C8C8C8" />
</shape>
</rotate>
</item>
</layer-list>
\ No newline at end of file
......@@ -11,7 +11,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:button="@drawable/selector_checkbox_bg"
android:button="@drawable/selector_checkbox"
tools:text="H5" />
......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gingersoft.supply_chain">
package="com.gingersoft.supply_chain" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
......@@ -10,9 +10,8 @@
<application
android:name="com.gingersoft.gsa.cloud.app.GsaCloudApplication"
android:networkSecurityConfig="@xml/network_android">
<activity android:name="com.gingersoft.supply_chain.mvp.ui.activity.SupplyChainMainActivity">
android:networkSecurityConfig="@xml/network_android" >
<activity android:name=".mvp.ui.activity.SupplyChainMainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
......
package com.gingersoft.supply_chain.di.component;
import com.gingersoft.supply_chain.di.module.MeasurementUnitModule;
import com.gingersoft.supply_chain.mvp.contract.MeasurementUnitContract;
import com.gingersoft.supply_chain.mvp.ui.fragment.MeasurementUnitFragment;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.di.scope.FragmentScope;
import dagger.BindsInstance;
import dagger.Component;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 11/21/2020 14:22
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@FragmentScope
@Component(modules = MeasurementUnitModule.class, dependencies = AppComponent.class)
public interface MeasurementUnitComponent {
void inject(MeasurementUnitFragment fragment);
@Component.Builder
interface Builder {
@BindsInstance
MeasurementUnitComponent.Builder view(MeasurementUnitContract.View view);
MeasurementUnitComponent.Builder appComponent(AppComponent appComponent);
MeasurementUnitComponent build();
}
}
\ No newline at end of file
package com.gingersoft.supply_chain.di.component;
import dagger.BindsInstance;
import dagger.Component;
import com.jess.arms.di.component.AppComponent;
import com.gingersoft.supply_chain.di.module.NewFoodUnitModule;
import com.gingersoft.supply_chain.mvp.contract.NewFoodUnitContract;
import com.jess.arms.di.scope.FragmentScope;
import com.gingersoft.supply_chain.mvp.ui.fragment.NewFoodUnitFragment;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 11/21/2020 16:52
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@FragmentScope
@Component(modules = NewFoodUnitModule.class, dependencies = AppComponent.class)
public interface NewFoodUnitComponent {
void inject(NewFoodUnitFragment fragment);
@Component.Builder
interface Builder {
@BindsInstance
NewFoodUnitComponent.Builder view(NewFoodUnitContract.View view);
NewFoodUnitComponent.Builder appComponent(AppComponent appComponent);
NewFoodUnitComponent build();
}
}
\ No newline at end of file
package com.gingersoft.supply_chain.di.module;
import com.jess.arms.di.scope.FragmentScope;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import com.gingersoft.supply_chain.mvp.contract.MeasurementUnitContract;
import com.gingersoft.supply_chain.mvp.model.MeasurementUnitModel;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 11/21/2020 14:23
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@Module
public abstract class MeasurementUnitModule {
@Binds
abstract MeasurementUnitContract.Model bindMeasurementUnitModel(MeasurementUnitModel model);
}
\ No newline at end of file
package com.gingersoft.supply_chain.di.module;
import com.jess.arms.di.scope.FragmentScope;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import com.gingersoft.supply_chain.mvp.contract.NewFoodUnitContract;
import com.gingersoft.supply_chain.mvp.model.NewFoodUnitModel;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 11/21/2020 16:52
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@Module
public abstract class NewFoodUnitModule {
@Binds
abstract NewFoodUnitContract.Model bindNewFoodUnitModel(NewFoodUnitModel model);
}
\ No newline at end of file
package com.gingersoft.supply_chain.mvp.bean;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import lombok.Data;
/**
* @author 宇航.
* User: admin
* Date: 2020/11/21
* Time: 15:54
* Use:
*/
@Data
public class MeasurementUnitBean {
private boolean success;
private long sysTime;
private DataBean data;
private String errMsg;
@Data
public static class DataBean {
private int count;
private List<Unit> list;
@Data
public static class Unit implements Serializable {
private static final long serialVersionUID = -4464228028817022515L;
private int id;
private int uid;
private int brandId;
private int restaurantId;
/**
* 1、重量
* 2、容積
* 3、體積
* 4、面積
* 5、長度
*/
private int type;
private String unitContent;
private String remarks;
private long createTime;
private long updateTime;
private int deletes;
public static List<String> measurementUnits = Arrays.asList("重量","容積","體積","面積","長度");
}
}
}
package com.gingersoft.supply_chain.mvp.bean;
import java.io.Serializable;
import java.util.List;
import lombok.Data;
/**
......@@ -10,18 +13,69 @@ import lombok.Data;
* Use: 供應商信息
*/
@Data
public class SupplierInfoBean {
private String name;
public class SupplierInfoBean implements Serializable {
private static final long serialVersionUID = 9167054021101810555L;
private int id;
private String supplierNo;
private String contactInformation;
private String supplierName;
private String address;
private String phone;
private String remarks;
private String contacts;
private String createDate;
private int restaurantId;
private int brandId;
private int uid;
private int countryId;
private long createTime;
private long updateTime;
private int deletes;
public SupplierInfoBean(String name, String address, String phone, String contacts, String createDate) {
this.name = name;
private List<SupplierContacts> supplierContacts;
public SupplierInfoBean(String supplierName, String address, String contactInformation, String contacts, String createDate) {
this.contactInformation = contactInformation;
this.supplierName = supplierName;
this.address = address;
this.phone = phone;
this.contacts = contacts;
this.createDate = createDate;
}
public SupplierInfoBean() {
}
@Data
public static class SupplierContacts implements Serializable {
private static final long serialVersionUID = -4586838211196656718L;
private String configText;
/**
* 聯繫方式
* 1、郵箱
* 2、座機
* 3、Whatsapp
* 4、wehat
* 5、line
* 6、Kakao
* 7、Talk
* 8、SMS
* 9、efax
*/
private int type;
public final static int Email = 1;
public final static int Landline = 2;
public final static int Whatsapp = 3;
public final static int WeChat = 4;
public final static int Line = 5;
public final static int Kakao = 6;
public final static int Talk = 7;
public final static int SMS = 8;
public final static int Efax = 9;
public SupplierContacts(String configText, int type) {
this.configText = configText;
this.type = type;
}
}
}
package com.gingersoft.supply_chain.mvp.bean;
import java.util.List;
import lombok.Data;
/**
* @author 宇航.
* User: admin
* Date: 2020/11/20
* Time: 16:35
* Use:
*/
@Data
public class SupplierResultBean {
private boolean success;
private long sysTime;
private DataBean data;
private String errMsg;
@Data
public static class DataBean {
private int count;
private List<SupplierInfoBean> list;
}
}
package com.gingersoft.supply_chain.mvp.contract;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.MeasurementUnitBean;
import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView;
import java.util.List;
import java.util.Map;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 11/21/2020 14:22
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public interface MeasurementUnitContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
void loadUnitList(List<MeasurementUnitBean.DataBean.Unit> list);
void deleteSuccess(int position);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {
Observable<MeasurementUnitBean> getMeasurementUnitList(Map<String, Object> map);
Observable<BaseResult> updateMeasurementUnit(RequestBody requestBody);
}
}
package com.gingersoft.supply_chain.mvp.contract;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 11/21/2020 16:52
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public interface NewFoodUnitContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
void saveSuccess();
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {
Observable<BaseResult> addFoodUnit(RequestBody requestBody);
Observable<BaseResult> updateFoodUnit(RequestBody requestBody);
}
}
package com.gingersoft.supply_chain.mvp.contract;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
* ================================================
......@@ -19,11 +23,14 @@ import com.jess.arms.mvp.IModel;
public interface NewSupplierContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
void saveSuccess();
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {
Observable<BaseResult> addSupplier(RequestBody requestBody);
Observable<BaseResult> updateSupplier(RequestBody requestBody);
}
}
package com.gingersoft.supply_chain.mvp.contract;
import com.jess.arms.mvp.IView;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean;
import com.gingersoft.supply_chain.mvp.bean.SupplierResultBean;
import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView;
import java.util.List;
import java.util.Map;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
......@@ -19,11 +28,18 @@ import com.jess.arms.mvp.IModel;
public interface SupplierListContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
void loadSupplierList(List<SupplierInfoBean> supplierBeanList);
void deleteSuccess(int position);
void loadError();
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {
Observable<SupplierResultBean> getSupplierList(Map<String, Object> map);
Observable<BaseResult> updateSupplier(RequestBody requestBody);
}
}
package com.gingersoft.supply_chain.mvp.model;
import android.app.Application;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.MeasurementUnitBean;
import com.gingersoft.supply_chain.mvp.contract.MeasurementUnitContract;
import com.gingersoft.supply_chain.mvp.server.SupplierServer;
import com.google.gson.Gson;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
import java.util.Map;
import javax.inject.Inject;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 11/21/2020 14:22
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@FragmentScope
public class MeasurementUnitModel extends BaseModel implements MeasurementUnitContract.Model {
@Inject
Gson mGson;
@Inject
Application mApplication;
@Inject
public MeasurementUnitModel(IRepositoryManager repositoryManager) {
super(repositoryManager);
}
@Override
public void onDestroy() {
super.onDestroy();
this.mGson = null;
this.mApplication = null;
}
@Override
public Observable<MeasurementUnitBean> getMeasurementUnitList(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getMeasurementUnitList(map);
}
@Override
public Observable<BaseResult> updateMeasurementUnit(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).updateFoodUnit(requestBody);
}
}
\ No newline at end of file
package com.gingersoft.supply_chain.mvp.model;
import android.app.Application;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.contract.NewFoodUnitContract;
import com.gingersoft.supply_chain.mvp.server.SupplierServer;
import com.google.gson.Gson;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
import javax.inject.Inject;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 11/21/2020 16:52
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@FragmentScope
public class NewFoodUnitModel extends BaseModel implements NewFoodUnitContract.Model {
@Inject
Gson mGson;
@Inject
Application mApplication;
@Inject
public NewFoodUnitModel(IRepositoryManager repositoryManager) {
super(repositoryManager);
}
@Override
public void onDestroy() {
super.onDestroy();
this.mGson = null;
this.mApplication = null;
}
@Override
public Observable<BaseResult> addFoodUnit(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).addFoodUnit(requestBody);
}
@Override
public Observable<BaseResult> updateFoodUnit(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).updateFoodUnit(requestBody);
}
}
\ No newline at end of file
......@@ -2,15 +2,18 @@ package com.gingersoft.supply_chain.mvp.model;
import android.app.Application;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.contract.NewSupplierContract;
import com.gingersoft.supply_chain.mvp.server.SupplierServer;
import com.google.gson.Gson;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
import com.jess.arms.di.scope.FragmentScope;
import javax.inject.Inject;
import com.gingersoft.supply_chain.mvp.contract.NewSupplierContract;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
......@@ -43,4 +46,14 @@ public class NewSupplierModel extends BaseModel implements NewSupplierContract.M
this.mGson = null;
this.mApplication = null;
}
@Override
public Observable<BaseResult> addSupplier(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).addSupplier(requestBody);
}
@Override
public Observable<BaseResult> updateSupplier(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).updateSupplier(requestBody);
}
}
\ No newline at end of file
......@@ -2,15 +2,21 @@ package com.gingersoft.supply_chain.mvp.model;
import android.app.Application;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.SupplierResultBean;
import com.gingersoft.supply_chain.mvp.contract.SupplierListContract;
import com.gingersoft.supply_chain.mvp.server.SupplierServer;
import com.google.gson.Gson;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
import com.jess.arms.di.scope.FragmentScope;
import java.util.Map;
import javax.inject.Inject;
import com.gingersoft.supply_chain.mvp.contract.SupplierListContract;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
......@@ -43,4 +49,14 @@ public class SupplierListModel extends BaseModel implements SupplierListContract
this.mGson = null;
this.mApplication = null;
}
@Override
public Observable<SupplierResultBean> getSupplierList(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getSupplierList(map);
}
@Override
public Observable<BaseResult> updateSupplier(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).updateSupplier(requestBody);
}
}
\ No newline at end of file
package com.gingersoft.supply_chain.mvp.presenter;
import android.app.Application;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.base.utils.other.TextUtil;
import com.gingersoft.supply_chain.mvp.bean.MeasurementUnitBean;
import com.gingersoft.supply_chain.mvp.contract.MeasurementUnitContract;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.RxLifecycleUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import okhttp3.MediaType;
import okhttp3.RequestBody;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 11/21/2020 14:22
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@FragmentScope
public class MeasurementUnitPresenter extends BasePresenter<MeasurementUnitContract.Model, MeasurementUnitContract.View> {
@Inject
RxErrorHandler mErrorHandler;
@Inject
Application mApplication;
@Inject
ImageLoader mImageLoader;
@Inject
AppManager mAppManager;
private List<MeasurementUnitBean.DataBean.Unit> units;
@Inject
public MeasurementUnitPresenter(MeasurementUnitContract.Model model, MeasurementUnitContract.View rootView) {
super(model, rootView);
}
@Override
public void onDestroy() {
super.onDestroy();
this.mErrorHandler = null;
this.mAppManager = null;
this.mImageLoader = null;
this.mApplication = null;
}
public void getMeasurementUnitList(String unitContent, int pageIndex) {
Map<String, Object> map = new HashMap<>();
map.put("pageSize", 10);
map.put("pageIndex", pageIndex);
if (!TextUtil.isEmptyOrNullOrUndefined(unitContent)) {
map.put("unitContent", unitContent);
}
map.put("brandId", GsaCloudApplication.getBrandId());
map.put("restaurantId", GsaCloudApplication.getRestaurantId());
map.put("pageIndex", pageIndex);
mModel.getMeasurementUnitList(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("獲取中..."))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<MeasurementUnitBean>(mErrorHandler) {
@Override
public void onNext(@NonNull MeasurementUnitBean info) {
if (info != null) {
if (info.isSuccess()) {
if(units == null){
units = new ArrayList<>();
}
if(pageIndex == 0){
units.clear();
}
units.addAll(info.getData().getList());
mRootView.loadUnitList(units);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
} else {
mRootView.showMessage("保存失敗");
}
}
}
});
}
public void deleteMeasurementUnit(MeasurementUnitBean.DataBean.Unit unit, int position) {
unit.setDeletes(1);
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), GsonUtils.GsonString(unit));
mModel.updateMeasurementUnit(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("刪除中..."))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(@NonNull BaseResult info) {
if (info != null) {
if (info.isSuccess()) {
mRootView.deleteSuccess(position);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
} else {
mRootView.showMessage("保存失敗");
}
}
}
});
}
}
package com.gingersoft.supply_chain.mvp.presenter;
import android.app.Application;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.base.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.bean.InfoMultiBean;
import com.gingersoft.supply_chain.mvp.bean.MeasurementUnitBean;
import com.gingersoft.supply_chain.mvp.contract.NewFoodUnitContract;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.RxLifecycleUtils;
import java.util.List;
import javax.inject.Inject;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import okhttp3.MediaType;
import okhttp3.RequestBody;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 11/21/2020 16:52
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
@FragmentScope
public class NewFoodUnitPresenter extends BasePresenter<NewFoodUnitContract.Model, NewFoodUnitContract.View> {
@Inject
RxErrorHandler mErrorHandler;
@Inject
Application mApplication;
@Inject
ImageLoader mImageLoader;
@Inject
AppManager mAppManager;
@Inject
public NewFoodUnitPresenter(NewFoodUnitContract.Model model, NewFoodUnitContract.View rootView) {
super(model, rootView);
}
@Override
public void onDestroy() {
super.onDestroy();
this.mErrorHandler = null;
this.mAppManager = null;
this.mImageLoader = null;
this.mApplication = null;
}
public void addFoodUnit(MeasurementUnitBean.DataBean.Unit foodUnit) {
if (foodUnit == null) {
return;
}
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), GsonUtils.GsonString(foodUnit));
mModel.addFoodUnit(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("保存中..."))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(@NonNull BaseResult info) {
if (info != null) {
if (info.isSuccess()) {
mRootView.saveSuccess();
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
} else {
mRootView.showMessage("保存失敗");
}
}
}
});
}
public void updateFoodUnit(MeasurementUnitBean.DataBean.Unit foodUnit) {
if (foodUnit == null) {
return;
}
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), GsonUtils.GsonString(foodUnit));
mModel.updateFoodUnit(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("保存中..."))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(@NonNull BaseResult info) {
if (info != null) {
if (info.isSuccess()) {
mRootView.saveSuccess();
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
} else {
mRootView.showMessage("保存失敗");
}
}
}
});
}
public MeasurementUnitBean.DataBean.Unit getFoodUnit(List<InfoMultiBean> infoMultiBeans, MeasurementUnitBean.DataBean.Unit foodUnit) {
if (foodUnit == null) {
foodUnit = new MeasurementUnitBean.DataBean.Unit();
}
foodUnit.setBrandId(GsaCloudApplication.getBrandId());
foodUnit.setRestaurantId(GsaCloudApplication.getRestaurantId());
List<InfoMultiBean> units = infoMultiBeans.get(0).getInfoMultiBeans();
for (int i = 0; i < units.size(); i++) {
if (units.get(i).isChecked()) {
foodUnit.setType(i);
}
}
foodUnit.setUnitContent(infoMultiBeans.get(1).getShowValue());
foodUnit.setRemarks(infoMultiBeans.get(2).getShowValue());
return foodUnit;
}
}
......@@ -2,15 +2,31 @@ package com.gingersoft.supply_chain.mvp.presenter;
import android.app.Application;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.base.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.bean.InfoMultiBean;
import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean;
import com.gingersoft.supply_chain.mvp.contract.NewSupplierContract;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.RxLifecycleUtils;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import okhttp3.MediaType;
import okhttp3.RequestBody;
/**
......@@ -49,4 +65,131 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
this.mImageLoader = null;
this.mApplication = null;
}
public void updateSupplier(SupplierInfoBean supplierInfoBean) {
if (supplierInfoBean == null) {
return;
}
supplierInfoBean.setSupplierNo(null);
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), GsonUtils.GsonString(supplierInfoBean));
mModel.updateSupplier(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("保存中..."))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(@NonNull BaseResult info) {
if (info != null) {
if (info.isSuccess()) {
mRootView.saveSuccess();
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
} else {
mRootView.showMessage("保存失敗");
}
}
}
});
}
public void addSupplier(SupplierInfoBean supplierInfoBean) {
if (supplierInfoBean == null) {
return;
}
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), GsonUtils.GsonString(supplierInfoBean));
mModel.addSupplier(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("保存中..."))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(@NonNull BaseResult info) {
if (info != null) {
if (info.isSuccess()) {
mRootView.saveSuccess();
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
} else {
mRootView.showMessage("保存失敗");
}
}
}
});
}
public SupplierInfoBean getSupplierInfo(List<InfoMultiBean> infoMultiBeans, SupplierInfoBean supplierInfoBean) {
if(supplierInfoBean == null){
supplierInfoBean = new SupplierInfoBean();
}
supplierInfoBean.setSupplierNo(infoMultiBeans.get(2).getShowValue());
supplierInfoBean.setSupplierName(infoMultiBeans.get(3).getShowValue());
supplierInfoBean.setContacts(infoMultiBeans.get(4).getShowValue());
supplierInfoBean.setContactInformation(infoMultiBeans.get(5).getShowValue());
supplierInfoBean.setAddress(infoMultiBeans.get(6).getShowValue());
supplierInfoBean.setRestaurantId(GsaCloudApplication.getRestaurantId());
supplierInfoBean.setBrandId(GsaCloudApplication.getBrandId());
if (TextUtil.isEmptyOrNullOrUndefined(supplierInfoBean.getSupplierNo())) {
supplierInfoBean.setSupplierNo("GYS001");
}
if (TextUtil.isEmptyOrNullOrUndefined(supplierInfoBean.getSupplierName())) {
mRootView.showMessage("請輸入供應商名稱");
return null;
} else if (TextUtil.isEmptyOrNullOrUndefined(supplierInfoBean.getContacts())) {
mRootView.showMessage("請輸入聯繫人");
return null;
} else if (TextUtil.isEmptyOrNullOrUndefined(supplierInfoBean.getContactInformation())) {
mRootView.showMessage("請輸入聯繫人電話");
return null;
} else if (TextUtil.isEmptyOrNullOrUndefined(supplierInfoBean.getAddress())) {
mRootView.showMessage("請輸入聯繫人地址");
return null;
}
List<SupplierInfoBean.SupplierContacts> contacts = new ArrayList<>();
String email = infoMultiBeans.get(9).getShowValue();
isAddContact(contacts, email, SupplierInfoBean.SupplierContacts.Email);
String landline = infoMultiBeans.get(10).getShowValue();
isAddContact(contacts, landline, SupplierInfoBean.SupplierContacts.Landline);
List<InfoMultiBean> childContacts = infoMultiBeans.get(11).getInfoMultiBeans();
String whatsApp = childContacts.get(0).getShowValue();
isAddContact(contacts, whatsApp, SupplierInfoBean.SupplierContacts.Whatsapp);
String weChat = childContacts.get(1).getShowValue();
isAddContact(contacts, weChat, SupplierInfoBean.SupplierContacts.WeChat);
String line = childContacts.get(2).getShowValue();
isAddContact(contacts, line, SupplierInfoBean.SupplierContacts.Line);
String kakao = childContacts.get(3).getShowValue();
isAddContact(contacts, kakao, SupplierInfoBean.SupplierContacts.Kakao);
String sms = childContacts.get(4).getShowValue();
isAddContact(contacts, sms, SupplierInfoBean.SupplierContacts.SMS);
String efax = childContacts.get(5).getShowValue();
isAddContact(contacts, efax, SupplierInfoBean.SupplierContacts.Efax);
supplierInfoBean.setSupplierContacts(contacts);
supplierInfoBean.setRemarks(infoMultiBeans.get(14).getShowValue());
return supplierInfoBean;
}
private void isAddContact(List<SupplierInfoBean.SupplierContacts> contacts, String whatsApp, int whatsapp) {
if (TextUtil.isNotEmptyOrNullOrUndefined(whatsApp)) {
contacts.add(new SupplierInfoBean.SupplierContacts(whatsApp, whatsapp));
}
}
}
......@@ -2,15 +2,33 @@ package com.gingersoft.supply_chain.mvp.presenter;
import android.app.Application;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.base.utils.other.TextUtil;
import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean;
import com.gingersoft.supply_chain.mvp.bean.SupplierResultBean;
import com.gingersoft.supply_chain.mvp.contract.SupplierListContract;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.RxLifecycleUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import okhttp3.MediaType;
import okhttp3.RequestBody;
/**
......@@ -36,6 +54,7 @@ public class SupplierListPresenter extends BasePresenter<SupplierListContract.Mo
@Inject
AppManager mAppManager;
private List<SupplierInfoBean> supplierBeanList;
@Inject
public SupplierListPresenter(SupplierListContract.Model model, SupplierListContract.View rootView) {
super(model, rootView);
......@@ -49,4 +68,79 @@ public class SupplierListPresenter extends BasePresenter<SupplierListContract.Mo
this.mImageLoader = null;
this.mApplication = null;
}
public void getSupplierList(String content, int pageIndex) {
Map<String, Object> map = new HashMap<>();
map.put("pageSize", 10);
map.put("pageIndex", pageIndex);
map.put("restaurantId", GsaCloudApplication.getRestaurantId());
map.put("brandId", GsaCloudApplication.getBrandId());
if (!TextUtil.isEmptyOrNullOrUndefined(content)) {
map.put("content", content);
}
mModel.getSupplierList(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("獲取中..."))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<SupplierResultBean>(mErrorHandler) {
@Override
public void onNext(@NonNull SupplierResultBean info) {
if (info != null) {
if (info.isSuccess()) {
if(supplierBeanList == null){
supplierBeanList = new ArrayList<>();
}
if(pageIndex == 0){
supplierBeanList.clear();
}
supplierBeanList.addAll(info.getData().getList());
mRootView.loadSupplierList(supplierBeanList);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
} else {
mRootView.loadError();
}
}
}
@Override
public void onError(Throwable t) {
super.onError(t);
mRootView.loadError();
}
});
}
public void deleteSupplier(SupplierInfoBean supplierBean, int position) {
supplierBean.setDeletes(1);
supplierBean.setSupplierNo(null);
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), GsonUtils.GsonString(supplierBean));
mModel.updateSupplier(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("刪除中..."))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(@NonNull BaseResult info) {
if (info != null) {
if (info.isSuccess()) {
mRootView.deleteSuccess(position);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
} else {
mRootView.showMessage("保存失敗");
}
}
}
});
}
}
package com.gingersoft.supply_chain.mvp.server;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.MeasurementUnitBean;
import com.gingersoft.supply_chain.mvp.bean.SupplierResultBean;
import java.util.Map;
import io.reactivex.Observable;
import me.jessyan.retrofiturlmanager.RetrofitUrlManager;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.QueryMap;
/**
* @author 宇航.
* User: admin
* Date: 2020/11/20
* Time: 15:29
* Use:
*/
public interface SupplierServer {
@Headers({"Domain-Name: ricepon-purchase"})
@POST("supplier/add" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> addSupplier(@Body RequestBody requestBody);
@Headers({"Domain-Name: ricepon-purchase"})
@GET("supplier/list" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<SupplierResultBean> getSupplierList(@QueryMap Map<String, Object> map);
@Headers({"Domain-Name: ricepon-purchase"})
@POST("supplier/update" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> updateSupplier(@Body RequestBody requestBody);
@Headers({"Domain-Name: ricepon-purchase"})
@GET("foodUnit/list" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<MeasurementUnitBean> getMeasurementUnitList(@QueryMap Map<String, Object> map);
@Headers({"Domain-Name: ricepon-purchase"})
@POST("foodUnit/update" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> updateFoodUnit(@Body RequestBody requestBody);
@Headers({"Domain-Name: ricepon-purchase"})
@POST("foodUnit/add" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> addFoodUnit(@Body RequestBody requestBody);
}
package com.gingersoft.supply_chain.mvp.ui.adapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.MeasurementUnitBean;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2020/11/21
* Time: 16:04
* Use:
*/
public class MeasurementUnitAdapter extends BaseQuickAdapter<MeasurementUnitBean.DataBean.Unit, BaseViewHolder> {
public MeasurementUnitAdapter(@Nullable List<MeasurementUnitBean.DataBean.Unit> data) {
super(R.layout.item_unit, data);
addChildClickViewIds(R.id.iv_measurement_unit_delete);
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, MeasurementUnitBean.DataBean.Unit unit) {
viewHolder.setText(R.id.tv_measurement_unit_type, MeasurementUnitBean.DataBean.Unit.measurementUnits.get(unit.getType()));
viewHolder.setText(R.id.tv_measurement_unit, unit.getUnitContent());
viewHolder.setText(R.id.tv_measurement_unit_remakes, unit.getRemarks());
}
}
......@@ -2,6 +2,7 @@ package com.gingersoft.supply_chain.mvp.ui.adapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean;
......@@ -25,11 +26,11 @@ public class SupplierAdapter extends BaseQuickAdapter<SupplierInfoBean, BaseView
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, SupplierInfoBean supplierInfoBean) {
viewHolder.setText(R.id.tv_supplier_name, supplierInfoBean.getName());
viewHolder.setText(R.id.tv_supplier_address, supplierInfoBean.getAddress());
viewHolder.setText(R.id.tv_supplier_phone, supplierInfoBean.getPhone());
viewHolder.setText(R.id.tv_supplier_contact, supplierInfoBean.getContacts());
viewHolder.setText(R.id.tv_supplier_create_date, supplierInfoBean.getCreateDate());
protected void convert(@NotNull BaseViewHolder viewHolder, SupplierInfoBean supplierBean) {
viewHolder.setText(R.id.tv_supplier_name, supplierBean.getSupplierName());
viewHolder.setText(R.id.tv_supplier_address, supplierBean.getAddress());
viewHolder.setText(R.id.tv_supplier_phone, supplierBean.getContactInformation());
viewHolder.setText(R.id.tv_supplier_contact, supplierBean.getContacts());
viewHolder.setText(R.id.tv_supplier_create_date, TimeUtils.getTime(supplierBean.getCreateTime(), TimeUtils.DEFAULT_DATE_FORMAT) + "");
}
}
......@@ -9,10 +9,12 @@ import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.gingersoft.supply_chain.mvp.contract.BaseSupplyChainContract;
import com.jess.arms.base.BaseFragment;
import com.jess.arms.mvp.IPresenter;
import com.jess.arms.utils.ArmsUtils;
import com.kingja.loadsir.core.LoadService;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......@@ -30,6 +32,8 @@ import static com.jess.arms.utils.Preconditions.checkNotNull;
* ================================================
*/
public abstract class BaseSupplyChainFragment<P extends IPresenter> extends BaseFragment<P> implements BaseSupplyChainContract.View {
protected LoadService loadService;
/**
* 通过此方法可以使 Fragment 能够与外界做一些交互和通信, 比如说外部的 Activity 想让自己持有的某个 Fragment 对象执行一些方法,
* 建议在有多个需要与外界交互的方法时, 统一传 {@link Message}, 通过 what 字段来区分不同的方法, 在 {@link #setData(Object)}
......@@ -73,18 +77,21 @@ public abstract class BaseSupplyChainFragment<P extends IPresenter> extends Base
@Override
public void showLoading(String message) {
if (message != null) {
LoadingDialog.showDialogForLoading(mContext, message, true);
} else {
LoadingDialog.showDialogForLoading(mContext);
}
}
@Override
public void hideLoading() {
LoadingDialog.cancelDialogForLoading();
}
@Override
public void showMessage(@NonNull String message) {
checkNotNull(message);
ArmsUtils.snackbarText(message);
ArmsUtils.makeText(mContext, message);
}
@Override
......
......@@ -13,6 +13,7 @@ import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerFunctionListComponent;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFunctionBean;
import com.gingersoft.supply_chain.mvp.contract.FunctionListContract;
......@@ -42,9 +43,9 @@ import butterknife.BindView;
*/
public class FunctionListFragment extends BaseSupplyChainFragment<FunctionListPresenter> implements FunctionListContract.View {
@BindView(R.id.topbar_supply_chain)
@BindView(R2.id.topbar_supply_chain)
QMUITopBar mTopBar;
@BindView(R.id.rv_supply_chain_function_list)
@BindView(R2.id.rv_supply_chain_function_list)
RecyclerView rvSupplyChainFunctionList;
public static FunctionListFragment newInstance() {
......@@ -89,8 +90,16 @@ public class FunctionListFragment extends BaseSupplyChainFragment<FunctionListPr
public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
FunctionChildAdapter functionChildAdapter = (FunctionChildAdapter) adapter;
List<Function> data = functionChildAdapter.getData();
if(data.get(position).getResName().equals("供應商")){
start(SupplierListFragment.newInstance());
switch (data.get(position).getResName()) {
case "供應商":
start(SupplierListFragment.newInstance());
break;
case "包裝":
start(MeasurementUnitFragment.newInstance());
break;
default:
break;
}
}
});
......
package com.gingersoft.supply_chain.mvp.ui.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.ui.loadsir.EmptyCallback;
import com.gingersoft.gsa.cloud.ui.utils.AppDialog;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerMeasurementUnitComponent;
import com.gingersoft.supply_chain.mvp.bean.MeasurementUnitBean;
import com.gingersoft.supply_chain.mvp.contract.MeasurementUnitContract;
import com.gingersoft.supply_chain.mvp.presenter.MeasurementUnitPresenter;
import com.gingersoft.supply_chain.mvp.ui.adapter.MeasurementUnitAdapter;
import com.jess.arms.di.component.AppComponent;
import com.kingja.loadsir.callback.Callback;
import com.kingja.loadsir.core.LoadSir;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import java.util.List;
import butterknife.BindView;
import butterknife.OnClick;
/**
* ================================================
* Description: 食材單位列表頁面
* <p>
* Created by MVPArmsTemplate on 11/21/2020 14:22
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public class MeasurementUnitFragment extends BaseSupplyChainFragment<MeasurementUnitPresenter> implements MeasurementUnitContract.View, View.OnClickListener {
@BindView(R2.id.topbar_measurement_unit_list)
QMUITopBar topbarMeasurementUnitList;
@BindView(R2.id.ed_measurement_unit_search)
EditText edMeasurementUnitSearch;
@BindView(R2.id.btn_measurement_unit_search)
QMUIAlphaButton btnMeasurementUnitSearch;
@BindView(R2.id.layout_measurement_unit_search)
LinearLayout layoutMeasurementUnitSearch;
@BindView(R2.id.rv_measurement_unit_list)
RecyclerView rvMeasurementUnitList;
@BindView(R2.id.btn_new_measurement_unit)
QMUIAlphaButton btnNewMeasurementUnit;
@BindView(R2.id.srl_measurement)
SmartRefreshLayout smartRefreshLayout;
private MeasurementUnitAdapter measurementUnitAdapter;
public final static int EDIT_FOOD_UNIT_REQUEST_CODE = 1100;
private int pageIndex = 0;
public static MeasurementUnitFragment newInstance() {
MeasurementUnitFragment fragment = new MeasurementUnitFragment();
return fragment;
}
@Override
public void setupFragmentComponent(@NonNull AppComponent appComponent) {
DaggerMeasurementUnitComponent //如找不到该类,请编译一下项目
.builder()
.appComponent(appComponent)
.view(this)
.build()
.inject(this);
}
@Override
public View initView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_measurement_unit, container, false);
}
@Override
public void initData(@Nullable Bundle savedInstanceState) {
initTopBar();
loadInfo("");
// 重新加载逻辑
loadService = LoadSir.getDefault().register(smartRefreshLayout, (Callback.OnReloadListener) v -> {
pageIndex = 0;
loadInfo("");
});
smartRefreshLayout.setOnRefreshListener(refreshLayout -> {
pageIndex = 0;
loadInfo("");
});
smartRefreshLayout.setOnLoadMoreListener(refreshLayout -> {
pageIndex++;
loadInfo("");
});
}
private void loadInfo(String unitContent) {
mPresenter.getMeasurementUnitList(unitContent, pageIndex);
}
private void initTopBar() {
topbarMeasurementUnitList.setTitle("計量單位");
topbarMeasurementUnitList.addLeftBackImageButton().setOnClickListener(v -> killMyself());
}
@OnClick({R2.id.btn_measurement_unit_search, R2.id.btn_new_measurement_unit})
@Override
public void onClick(View v) {
int viewId = v.getId();
if (viewId == R.id.btn_new_measurement_unit) {
//新增計量單位
startForResult(NewFoodUnitFragment.newInstance(null), EDIT_FOOD_UNIT_REQUEST_CODE);
} else if (viewId == R.id.btn_measurement_unit_search) {
//搜索計量單位
loadInfo(edMeasurementUnitSearch.getText() + "");
}
}
@Override
public void loadUnitList(List<MeasurementUnitBean.DataBean.Unit> list) {
smartRefreshLayout.finishRefresh();
smartRefreshLayout.finishLoadMore();
if (list != null && list.size() > 0) {
loadService.showSuccess();
smartRefreshLayout.setEnableLoadMore(true);
} else {
smartRefreshLayout.setEnableLoadMore(false);
loadService.showCallback(EmptyCallback.class);
return;
}
if (measurementUnitAdapter == null) {
measurementUnitAdapter = new MeasurementUnitAdapter(list);
measurementUnitAdapter.setOnItemChildClickListener((adapter, view, position) -> {
List<MeasurementUnitBean.DataBean.Unit> data = measurementUnitAdapter.getData();
MeasurementUnitBean.DataBean.Unit unit = data.get(position);
new AppDialog().showWaringDialog(mContext, "是否確認刪除?", (view1, dialog) -> {
dialog.dismiss();
mPresenter.deleteMeasurementUnit(unit, position);
});
});
measurementUnitAdapter.setOnItemClickListener((adapter, view, position) -> {
List<MeasurementUnitBean.DataBean.Unit> data = measurementUnitAdapter.getData();
MeasurementUnitBean.DataBean.Unit unit = data.get(position);
startForResult(NewFoodUnitFragment.newInstance(unit), EDIT_FOOD_UNIT_REQUEST_CODE);
});
rvMeasurementUnitList.setAdapter(measurementUnitAdapter);
} else {
measurementUnitAdapter.setList(list);
}
}
@Override
public void deleteSuccess(int position) {
measurementUnitAdapter.removeAt(position);
if (measurementUnitAdapter.getData().size() == 0) {
loadService.showCallback(EmptyCallback.class);
}
}
@Override
public void onFragmentResult(int requestCode, int resultCode, Bundle data) {
super.onFragmentResult(requestCode, resultCode, data);
loadInfo("");
}
}
package com.gingersoft.supply_chain.mvp.ui.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.bean.InfoMultiBean;
import com.gingersoft.gsa.cloud.ui.adapter.multi.InfoMultiAdapter;
import com.gingersoft.gsa.cloud.ui.recylcler.decorator.DividerItemDecoration;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerNewFoodUnitComponent;
import com.gingersoft.supply_chain.mvp.bean.MeasurementUnitBean;
import com.gingersoft.supply_chain.mvp.contract.NewFoodUnitContract;
import com.gingersoft.supply_chain.mvp.presenter.NewFoodUnitPresenter;
import com.jess.arms.di.component.AppComponent;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import com.qmuiteam.qmui.widget.QMUITopBar;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.OnClick;
import static com.gingersoft.gsa.cloud.ui.recylcler.decorator.DividerItemDecoration.VERTICAL_LIST;
import static com.gingersoft.supply_chain.mvp.ui.fragment.MeasurementUnitFragment.EDIT_FOOD_UNIT_REQUEST_CODE;
/**
* ================================================
* Description: 新增計量單位
* <p>
* Created by MVPArmsTemplate on 11/21/2020 16:52
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
* <a href="https://github.com/JessYanCoding">Follow me</a>
* <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
* <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public class NewFoodUnitFragment extends BaseSupplyChainFragment<NewFoodUnitPresenter> implements NewFoodUnitContract.View, View.OnClickListener {
public static final String FOOD_UNIT_KEY = "measurement_unit";
@BindView(R2.id.topbar_food_unit_info)
QMUITopBar topbarFoodUnitInfo;
@BindView(R2.id.btn_save_food_unit)
QMUIAlphaButton btnSaveFoodUnit;
@BindView(R2.id.rv_food_unit_info)
RecyclerView rvFoodUnitInfo;
private MeasurementUnitBean.DataBean.Unit foodUnit;
private boolean isUpdate = false;
private InfoMultiAdapter infoMultiAdapter;
public static NewFoodUnitFragment newInstance(MeasurementUnitBean.DataBean.Unit unit) {
NewFoodUnitFragment fragment = new NewFoodUnitFragment();
if (unit != null) {
Bundle bundle = new Bundle();
bundle.putSerializable(FOOD_UNIT_KEY, unit);
fragment.setArguments(bundle);
}
return fragment;
}
@Override
public void setupFragmentComponent(@NonNull AppComponent appComponent) {
DaggerNewFoodUnitComponent //如找不到该类,请编译一下项目
.builder()
.appComponent(appComponent)
.view(this)
.build()
.inject(this);
}
@Override
public View initView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_new_food_unit, container, false);
}
@Override
public void initData(@Nullable Bundle savedInstanceState) {
Bundle arguments = getArguments();
if (arguments != null) {
foodUnit = (MeasurementUnitBean.DataBean.Unit) arguments.getSerializable(FOOD_UNIT_KEY);
}
initTopBar();
List<InfoMultiBean> infoMultiBeans = new ArrayList<>();
InfoMultiBean unitType = new InfoMultiBean(InfoMultiBean.ITEM_TYPE_SHOW_DIALOG, "單位種類", false, "請選擇");
List<InfoMultiBean> units = new ArrayList<>();
for (int i = 0; i < MeasurementUnitBean.DataBean.Unit.measurementUnits.size(); i++) {
units.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_SHOW_DIALOG, MeasurementUnitBean.DataBean.Unit.measurementUnits.get(i)));
}
unitType.setInfoMultiBeans(units);
infoMultiBeans.add(unitType);
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_INPUT, "計量單位", false, "請輸入計量單位"));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_INPUT, "備註", false, "請輸入備註"));
if(foodUnit != null){
units.get(foodUnit.getType()).setChecked(true);
infoMultiBeans.get(1).setShowValue(foodUnit.getUnitContent());
infoMultiBeans.get(2).setShowValue(foodUnit.getRemarks());
}
infoMultiAdapter = new InfoMultiAdapter(mContext, infoMultiBeans);
rvFoodUnitInfo.addItemDecoration(new DividerItemDecoration(mContext, VERTICAL_LIST));
rvFoodUnitInfo.setAdapter(infoMultiAdapter);
}
private void initTopBar() {
if (foodUnit != null) {
isUpdate = true;
topbarFoodUnitInfo.setTitle("編輯計量單位");
} else {
topbarFoodUnitInfo.setTitle("新增計量單位");
}
topbarFoodUnitInfo.addLeftBackImageButton().setOnClickListener(v -> killMyself());
}
@OnClick({R2.id.btn_save_food_unit})
@Override
public void onClick(View v) {
int viewId = v.getId();
if (viewId == R.id.btn_save_food_unit) {
//保存
if (isUpdate) {
mPresenter.updateFoodUnit(mPresenter.getFoodUnit(infoMultiAdapter.getData(), foodUnit));
} else {
mPresenter.addFoodUnit(mPresenter.getFoodUnit(infoMultiAdapter.getData(), foodUnit));
}
}
}
@Override
public void saveSuccess() {
setFragmentResult(EDIT_FOOD_UNIT_REQUEST_CODE, null);
killMyself();
}
}
......@@ -4,15 +4,34 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.bean.InfoMultiBean;
import com.gingersoft.gsa.cloud.ui.adapter.multi.InfoMultiAdapter;
import com.gingersoft.gsa.cloud.ui.recylcler.decorator.DividerItemDecoration;
import com.gingersoft.gsa.cloud.ui.utils.AppDialog;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerNewSupplierComponent;
import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean;
import com.gingersoft.supply_chain.mvp.contract.NewSupplierContract;
import com.gingersoft.supply_chain.mvp.presenter.NewSupplierPresenter;
import com.jess.arms.di.component.AppComponent;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import com.qmuiteam.qmui.widget.QMUITopBar;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.OnClick;
import static com.gingersoft.gsa.cloud.ui.recylcler.decorator.DividerItemDecoration.VERTICAL_LIST;
import static com.gingersoft.supply_chain.mvp.ui.fragment.SupplierListFragment.SUPPLIER_LIST;
/**
......@@ -27,10 +46,28 @@ import com.jess.arms.di.component.AppComponent;
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public class NewSupplierFragment extends BaseSupplyChainFragment<NewSupplierPresenter> implements NewSupplierContract.View {
public class NewSupplierFragment extends BaseSupplyChainFragment<NewSupplierPresenter> implements NewSupplierContract.View, View.OnClickListener {
@BindView(R2.id.topbar_supplier_info)
QMUITopBar topbarSupplierInfo;
@BindView(R2.id.rv_supplier_info)
RecyclerView rvSupplierInfo;
@BindView(R2.id.btn_save_supplier)
QMUIAlphaButton btnSaveSupplier;
public static NewSupplierFragment newInstance() {
private SupplierInfoBean supplierBean;
private boolean isUpdate = false;
private final static String SUPPLIER_INFO_KEY = "supplier_info_key";
private InfoMultiAdapter infoMultiAdapter;
public static NewSupplierFragment newInstance(SupplierInfoBean supplierBean) {
NewSupplierFragment fragment = new NewSupplierFragment();
if (supplierBean != null) {
Bundle bundle = new Bundle();
bundle.putSerializable(SUPPLIER_INFO_KEY, supplierBean);
fragment.setArguments(bundle);
}
return fragment;
}
......@@ -51,7 +88,88 @@ public class NewSupplierFragment extends BaseSupplyChainFragment<NewSupplierPres
@Override
public void initData(@Nullable Bundle savedInstanceState) {
Bundle arguments = getArguments();
if (arguments != null) {
supplierBean = (SupplierInfoBean) arguments.getSerializable(SUPPLIER_INFO_KEY);
}
initTopBar();
List<InfoMultiBean> infoMultiBeans = new ArrayList<>();
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_LINE));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_TITLE, "基本信息"));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_INPUT, "供應商編號", false, "請輸入編號-默認GYS001"));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_INPUT, "名稱", true, "請輸入名稱"));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_INPUT, "聯繫人", true, "請輸入聯繫人"));
InfoMultiBean phoneBean = new InfoMultiBean(InfoMultiBean.ITEM_TYPE_INPUT, "聯繫人電話", true, "請輸入聯繫人電話");
phoneBean.setInputType(EditorInfo.TYPE_CLASS_PHONE);
infoMultiBeans.add(phoneBean);
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_INPUT, "詳細地址", true, "請輸入詳細地址"));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_LINE));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_TITLE, "接收方式"));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_INPUT, "Email", false, "請輸入Email"));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_INPUT, "座機", false, "請輸入座機"));
InfoMultiBean receivingMode = new InfoMultiBean(InfoMultiBean.ITEM_TYPE_SHOW_LIST, "接收軟件", false, "", "選擇");
List<InfoMultiBean> childInfoMulti = new ArrayList<>();
childInfoMulti.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_INPUT, "WhatsApp", false, "請輸入WhatsApp"));
childInfoMulti.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_INPUT, "WeChat", false, "請輸入WeChat"));
childInfoMulti.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_INPUT, "Line", false, "請輸入Line"));
childInfoMulti.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_INPUT, "Kakao Talk", false, "請輸入Kakao Talk"));
childInfoMulti.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_INPUT, "SMS", false, "請輸入SMS"));
childInfoMulti.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_INPUT, "Efax", false, "請輸入Efax"));
receivingMode.setInfoMultiBeans(childInfoMulti);
infoMultiBeans.add(receivingMode);
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_LINE));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_TITLE, "備註"));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_INPUT, null, false, "請輸入備註"));
if (supplierBean != null) {
infoMultiBeans.get(2).setShowValue(supplierBean.getSupplierNo());
infoMultiBeans.get(3).setShowValue(supplierBean.getSupplierName());
infoMultiBeans.get(4).setShowValue(supplierBean.getContacts());
infoMultiBeans.get(5).setShowValue(supplierBean.getContactInformation());
infoMultiBeans.get(6).setShowValue(supplierBean.getAddress());
infoMultiBeans.get(14).setShowValue(supplierBean.getRemarks());
}
infoMultiAdapter = new InfoMultiAdapter(mContext, infoMultiBeans);
rvSupplierInfo.addItemDecoration(new DividerItemDecoration(mContext, VERTICAL_LIST));
rvSupplierInfo.setAdapter(infoMultiAdapter);
}
private void initTopBar() {
if (supplierBean != null) {
isUpdate = true;
topbarSupplierInfo.addRightImageButton(R.drawable.ic_white_delete, R.id.topbar_right_delete_button).setOnClickListener(this);
topbarSupplierInfo.setTitle("編輯供應商");
} else {
topbarSupplierInfo.setTitle("新增供應商");
}
topbarSupplierInfo.addLeftBackImageButton().setOnClickListener(v -> killMyself());
}
@OnClick({R2.id.btn_save_supplier})
@Override
public void onClick(View v) {
int viewId = v.getId();
if (viewId == R.id.topbar_right_delete_button) {
//刪除供應商
new AppDialog().showWaringDialog(mContext, "刪除供應商", (view1, dialog) -> {
dialog.dismiss();
supplierBean.setDeletes(1);
mPresenter.updateSupplier(supplierBean);
});
} else if (viewId == R.id.btn_save_supplier) {
//保存
if (isUpdate) {
mPresenter.updateSupplier(mPresenter.getSupplierInfo(infoMultiAdapter.getData(), supplierBean));
} else {
mPresenter.addSupplier(mPresenter.getSupplierInfo(infoMultiAdapter.getData(), supplierBean));
}
}
}
@Override
public void saveSuccess() {
setFragmentResult(SUPPLIER_LIST, null);
killMyself();
}
}
......@@ -4,23 +4,29 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.ui.loadsir.EmptyCallback;
import com.gingersoft.gsa.cloud.ui.loadsir.ErrorCallback;
import com.gingersoft.gsa.cloud.ui.utils.AppDialog;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerSupplierListComponent;
import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean;
import com.gingersoft.supply_chain.mvp.contract.SupplierListContract;
import com.gingersoft.supply_chain.mvp.presenter.SupplierListPresenter;
import com.gingersoft.supply_chain.mvp.ui.adapter.SupplierAdapter;
import com.jess.arms.di.component.AppComponent;
import com.kingja.loadsir.callback.Callback;
import com.kingja.loadsir.core.LoadSir;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
......@@ -29,7 +35,7 @@ import butterknife.OnClick;
/**
* ================================================
* Description:
* Description: 供應商列表
* <p>
* Created by MVPArmsTemplate on 11/19/2020 17:41
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
......@@ -41,14 +47,20 @@ import butterknife.OnClick;
*/
public class SupplierListFragment extends BaseSupplyChainFragment<SupplierListPresenter> implements SupplierListContract.View, View.OnClickListener {
@BindView(R.id.topbar_supplier_list)
@BindView(R2.id.topbar_supplier_list)
QMUITopBar mTopBarSupplierList;
@BindView(R.id.rv_supplier_list)
@BindView(R2.id.rv_supplier_list)
RecyclerView rvSupplierList;
@BindView(R.id.btn_new_supplier)
@BindView(R2.id.btn_new_supplier)
QMUIAlphaButton btnNewSupplier;
@BindView(R2.id.ed_supplier_search)
EditText edSupplier;
public final static int SUPPLIER_LIST = 101;
private SupplierAdapter supplierAdapter;
@BindView(R2.id.srl_supplier)
SmartRefreshLayout smartRefreshLayout;
private int pageIndex = 0;
public static SupplierListFragment newInstance() {
SupplierListFragment fragment = new SupplierListFragment();
......@@ -72,33 +84,35 @@ public class SupplierListFragment extends BaseSupplyChainFragment<SupplierListPr
@Override
public void initData(@Nullable Bundle savedInstanceState) {
loadService = LoadSir.getDefault().register(smartRefreshLayout, (Callback.OnReloadListener) v -> {
// 重新加载逻辑
pageIndex = 0;
getSupplierList("");
});
initTopBar();
getSupplierList("");
List<SupplierInfoBean> supplierInfoBeans = new ArrayList<>();
supplierInfoBeans.add(new SupplierInfoBean("海鮮天地", "香港長沙灣青山道479A麗昌大廈", "23719831", "李先生", "2020-11-19"));
supplierInfoBeans.add(new SupplierInfoBean("海鮮天地", "香港長沙灣青山道479A麗昌大廈", "23719831", "李先生", "2020-11-19"));
supplierInfoBeans.add(new SupplierInfoBean("海鮮天地", "香港長沙灣青山道479A麗昌大廈", "23719831", "李先生", "2020-11-19"));
SupplierAdapter supplierAdapter = new SupplierAdapter(supplierInfoBeans);
rvSupplierList.setAdapter(supplierAdapter);
supplierAdapter.setOnItemClickListener((adapter, view, position) -> startForResult(NewSupplierFragment.newInstance(), SUPPLIER_LIST));
supplierAdapter.setOnItemChildClickListener((adapter, view, position) -> {
if (view.getId() == R.id.iv_supplier_delete) {
new AppDialog().showWaringDialog(mContext, "刪除供應商", (view1, dialog) -> {
dialog.dismiss();
supplierAdapter.removeAt(position);
});
}
smartRefreshLayout.setOnRefreshListener(refreshLayout -> {
pageIndex = 0;
getSupplierList("");
});
smartRefreshLayout.setOnLoadMoreListener(refreshLayout -> {
pageIndex++;
getSupplierList("");
});
}
private void getSupplierList(String content) {
mPresenter.getSupplierList(content, pageIndex);
}
private void initTopBar() {
mTopBarSupplierList.setTitle("供應商");
mTopBarSupplierList.addLeftBackImageButton().setOnClickListener(v -> killMyself());
mTopBarSupplierList.addRightImageButton(R.drawable.ic_screen, R.id.topbar_right_screen_button).setOnClickListener(this);
}
@OnClick({R.id.btn_new_supplier})
@OnClick({R2.id.btn_new_supplier, R2.id.btn_supplier_search})
@Override
public void onClick(View v) {
int viewId = v.getId();
......@@ -106,7 +120,9 @@ public class SupplierListFragment extends BaseSupplyChainFragment<SupplierListPr
//篩選
} else if (viewId == R.id.btn_new_supplier) {
//新增供應商
startForResult(NewSupplierFragment.newInstance(), SUPPLIER_LIST);
startForResult(NewSupplierFragment.newInstance(null), SUPPLIER_LIST);
} else if (viewId == R.id.btn_supplier_search) {
getSupplierList(edSupplier.getText() + "");
}
}
......@@ -115,7 +131,54 @@ public class SupplierListFragment extends BaseSupplyChainFragment<SupplierListPr
super.onFragmentResult(requestCode, resultCode, data);
if (requestCode == SUPPLIER_LIST) {
//新增或編輯了供應商,重新獲取所有供應商數據
getSupplierList("");
}
}
@Override
public void loadSupplierList(List<SupplierInfoBean> supplierBeanList) {
smartRefreshLayout.finishRefresh();
smartRefreshLayout.finishLoadMore();
if (supplierBeanList.size() == 0) {
loadService.showCallback(EmptyCallback.class);
smartRefreshLayout.setEnableLoadMore(false);
return;
} else {
loadService.showSuccess();
smartRefreshLayout.setEnableLoadMore(true);
}
if (supplierAdapter == null) {
supplierAdapter = new SupplierAdapter(supplierBeanList);
rvSupplierList.setAdapter(supplierAdapter);
supplierAdapter.setOnItemClickListener((adapter, view, position) -> {
List<SupplierInfoBean> data = supplierAdapter.getData();
startForResult(NewSupplierFragment.newInstance(data.get(position)), SUPPLIER_LIST);
});
supplierAdapter.setOnItemChildClickListener((adapter, view, position) -> {
if (view.getId() == R.id.iv_supplier_delete) {
new AppDialog().showWaringDialog(mContext, "刪除供應商", (view1, dialog) -> {
dialog.dismiss();
List<SupplierInfoBean> data = supplierAdapter.getData();
mPresenter.deleteSupplier(data.get(position), position);
});
}
});
} else {
supplierAdapter.setList(supplierBeanList);
}
}
@Override
public void deleteSuccess(int position) {
supplierAdapter.removeAt(position);
if (supplierAdapter.getData().size() == 0) {
loadService.showCallback(EmptyCallback.class);
}
}
@Override
public void loadError() {
loadService.showCallback(ErrorCallback.class);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/supply_chain_bg_color"
android:orientation="vertical">
<com.qmuiteam.qmui.widget.QMUITopBar
android:id="@+id/topbar_measurement_unit_list"
android:layout_width="match_parent"
android:layout_height="@dimen/head_height"
android:background="@color/theme_color"
android:fitsSystemWindows="true"
app:qmui_topbar_title_color="@color/theme_white_color" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/dp_10">
<LinearLayout
android:id="@+id/layout_measurement_unit_search"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_40"
android:background="@drawable/shape_white_eight_corners_bg"
android:orientation="horizontal">
<ImageView
android:layout_width="@dimen/dp_20"
android:layout_height="@dimen/dp_20"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dp_10"
android:src="@drawable/ic_search" />
<EditText
android:id="@+id/ed_measurement_unit_search"
android:layout_width="265dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginRight="@dimen/dp_5"
android:layout_weight="1"
android:background="@null"
android:hint="搜索計量單位"
android:textColor="@color/theme_333_color"
android:textColorHint="@color/hint_color"
android:textSize="@dimen/dp_16" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_measurement_unit_search"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/dp_1"
android:layout_marginBottom="@dimen/dp_1"
android:background="@drawable/shape_app_btn"
android:text="搜索"
android:textColor="@color/white"
android:textSize="@dimen/dp_14" />
</LinearLayout>
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/srl_measurement"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/btn_new_measurement_unit"
android:layout_below="@id/layout_measurement_unit_search">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_measurement_unit_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_new_measurement_unit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:layout_marginBottom="@dimen/dp_10"
android:background="@drawable/shape_app_btn"
android:gravity="center"
android:text="+新增計量單位"
android:textColor="@color/white"
android:textSize="@dimen/dp_16" />
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/supply_chain_bg_color"
android:orientation="vertical">
<com.qmuiteam.qmui.widget.QMUITopBar
android:id="@+id/topbar_food_unit_info"
android:layout_width="match_parent"
android:layout_height="@dimen/head_height"
android:background="@color/theme_color"
android:fitsSystemWindows="true"
app:qmui_topbar_title_color="@color/theme_white_color" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_save_food_unit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_20"
android:layout_marginRight="@dimen/dp_20"
android:layout_marginBottom="@dimen/dp_10"
android:background="@drawable/shape_app_btn"
android:gravity="center"
android:text="保存"
android:textColor="@color/white"
android:textSize="@dimen/dp_16" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_food_unit_info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/btn_save_food_unit"
android:background="@color/white"
android:layout_below="@id/topbar_food_unit_info"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout 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:background="@color/supply_chain_bg_color"
......@@ -15,17 +14,29 @@
android:fitsSystemWindows="true"
app:qmui_topbar_title_color="@color/theme_white_color" />
<TextView
android:layout_width="wrap_content"
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_save_supplier"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/new_supplier_info_item_marginLeft"
android:layout_marginTop="@dimen/new_supplier_info_item_marginTop"
android:layout_marginBottom="@dimen/new_supplier_info_item_marginBottom"
android:text="基本信息"
android:textColor="@color/black"
android:textSize="@dimen/dp_14" />
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_20"
android:layout_marginRight="@dimen/dp_20"
android:layout_marginBottom="@dimen/dp_10"
android:background="@drawable/shape_app_btn"
android:gravity="center"
android:text="保存"
android:textColor="@color/white"
android:textSize="@dimen/dp_16" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_supplier_info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/btn_save_supplier"
android:background="@color/white"
android:layout_below="@id/topbar_supplier_info"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</LinearLayout>
\ No newline at end of file
</RelativeLayout>
\ No newline at end of file
......@@ -34,6 +34,7 @@
android:src="@drawable/ic_search" />
<EditText
android:id="@+id/ed_supplier_search"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_5"
......@@ -46,6 +47,7 @@
android:textSize="@dimen/dp_16" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_supplier_search"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/dp_1"
......@@ -56,13 +58,19 @@
android:textSize="@dimen/dp_14" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_supplier_list"
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/srl_supplier"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/btn_new_supplier"
android:layout_below="@id/layout_supplier_search"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
android:layout_below="@id/layout_supplier_search">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_supplier_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_new_supplier"
......
......@@ -62,10 +62,9 @@
<TextView
style="@style/Supplier_Info_text_Style"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="地 址:" />
android:text="地\u3000\u3000址:" />
<TextView
android:id="@+id/tv_supplier_address"
......@@ -84,9 +83,8 @@
<TextView
style="@style/Supplier_Info_text_Style"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="聯繫方式:" />
<TextView
......@@ -106,10 +104,9 @@
<TextView
style="@style/Supplier_Info_text_Style"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="聯繫人:" />
android:text="聯&#160;&#160;繫&#160;&#160;人:" />
<TextView
android:id="@+id/tv_supplier_contact"
......@@ -128,9 +125,8 @@
<TextView
style="@style/Supplier_Info_text_Style"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="添加日期:" />
<TextView
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:background="@drawable/shape_white_eight_corners_bg"
android:orientation="vertical"
android:padding="@dimen/dp_10">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
style="@style/Supplier_Info_text_Style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="單位種類:" />
<TextView
android:id="@+id/tv_measurement_unit_type"
style="@style/Supplier_Info_title_Style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:text="重量" />
<ImageView
android:id="@+id/iv_measurement_unit_edit"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/ic_blue_edit" />
<ImageView
android:id="@+id/iv_measurement_unit_delete"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_15"
android:src="@drawable/ic_red_delete" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:orientation="horizontal">
<TextView
style="@style/Supplier_Info_text_Style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="計量單位:" />
<TextView
android:id="@+id/tv_measurement_unit"
style="@style/Supplier_Info_title_Style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:text="KG" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:orientation="horizontal">
<TextView
style="@style/Supplier_Info_text_Style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="備\u3000\u3000註:" />
<TextView
android:id="@+id/tv_measurement_unit_remakes"
style="@style/Supplier_Info_title_Style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:text="備註" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
\ No newline at end of file
......@@ -5,4 +5,10 @@
<item name="android:textColor">@color/color_3c</item>
<item name="android:textSize">@dimen/dp_14</item>
</style>
<style name="Supplier_Info_title_Style">
<item name="android:textColor">@color/black</item>
<item name="android:textSize">@dimen/dp_14</item>
<item name="android:textStyle">bold</item>
</style>
</resources>
\ No newline at end of file
......@@ -7,8 +7,8 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.order.billItem.BillOrderMoney;
import com.gingersoft.gsa.cloud.base.order.billItem.BillItem;
import com.gingersoft.gsa.cloud.base.order.billItem.BillOrderMoney;
import com.gingersoft.gsa.cloud.table.R;
import com.gingersoft.gsa.cloud.table.R2;
import com.gingersoft.gsa.cloud.table.mvp.ui.activity.OrderContentActivity;
......
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