Commit 0eb5f0e1 by 宁斌

1、解決butterknife R2 問題導致項目整合編譯不過問題

2、增加食品點選送單流程
parent e82b2c21
...@@ -18,6 +18,8 @@ buildscript { ...@@ -18,6 +18,8 @@ buildscript {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath'com.jakewharton:butterknife-gradle-plugin:10.2.1'
classpath 'com.novoda:bintray-release:0.9.2' classpath 'com.novoda:bintray-release:0.9.2'
classpath 'com.billy.android:cc-register:1.1.2' classpath 'com.billy.android:cc-register:1.1.2'
......
package com.billy.android.register.cc package com.billy.android.register.cc
import com.billy.android.register.RegisterPlugin import com.billy.android.register.RegisterPlugin
import groovy.util.logging.Log
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.util.GradleVersion import org.gradle.util.GradleVersion
import java.util.logging.Logger
import java.util.regex.Pattern import java.util.regex.Pattern
/** /**
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
// 完成组件、拦截器及跨进程json解释器等CC库自身需要的自动注册功能 // 完成组件、拦截器及跨进程json解释器等CC库自身需要的自动注册功能
// 支持新增自定义的其它自动注册功能,参考AutoRegister,用法参考cc-settings-demo.gradle // 支持新增自定义的其它自动注册功能,参考AutoRegister,用法参考cc-settings-demo.gradle
project.apply plugin: 'cc-register' project.apply plugin: 'cc-register'
project.dependencies.add('api', "com.billy.android:cc:2.1.6") //用最新版 project.dependencies.add('api', project(':cc')) //用最新版
//project.dependencies.add('api', "com.billy.android:cc:2.1.6") //用最新版
dependencies { dependencies {
if (project.name != 'public-base' && project.name != 'arms' && project.name !='public-database') { if (project.name != 'public-base' && project.name != 'arms' && project.name !='public-database') {
...@@ -32,6 +33,7 @@ dependencies { ...@@ -32,6 +33,7 @@ dependencies {
implementation rootProject.ext.dependencies["multidex"] implementation rootProject.ext.dependencies["multidex"]
implementation rootProject.ext.dependencies["constraintlayout"] implementation rootProject.ext.dependencies["constraintlayout"]
implementation 'org.jetbrains:annotations:15.0' implementation 'org.jetbrains:annotations:15.0'
} }
//此文件是作为组件化配置的公共gradle脚本文件,在每个组件中都apply此文件,下载到工程根目录后,可以在下方添加一些自己工程中通用的配置 //此文件是作为组件化配置的公共gradle脚本文件,在每个组件中都apply此文件,下载到工程根目录后,可以在下方添加一些自己工程中通用的配置
......
...@@ -34,7 +34,8 @@ android { ...@@ -34,7 +34,8 @@ android {
dependencies { dependencies {
//发布到bintray时,要写成compile才行 //发布到bintray时,要写成compile才行
implementation "com.billy.android:pools:0.0.6" compile "com.billy.android:pools:0.0.6"
// compileOnly project(':pools')
compileOnly rootProject.ext.dependencies["appcompat-v7"] compileOnly rootProject.ext.dependencies["appcompat-v7"]
compileOnly project(':android_internal') compileOnly project(':android_internal')
} }
......
...@@ -12,9 +12,9 @@ ext { ...@@ -12,9 +12,9 @@ ext {
version = [ version = [
androidSupportSdkVersion: "28+", androidSupportSdkVersion: "28+",
retrofitSdkVersion : '2.3.0', retrofitSdkVersion : '2.3.0',
dagger2SdkVersion : "2.14.1", dagger2SdkVersion : "2.19",
glideSdkVersion : "4.9.0", glideSdkVersion : "4.9.0",
butterknifeSdkVersion : "10.1.0", butterknifeSdkVersion : "10.2.1",
rxlifecycleSdkVersion : "1.0", rxlifecycleSdkVersion : "1.0",
rxlifecycle2SdkVersion : "2.2.1", rxlifecycle2SdkVersion : "2.2.1",
espressoSdkVersion : "3.0.1", espressoSdkVersion : "3.0.1",
......
apply from: rootProject.file('cc-settings.gradle') apply from: rootProject.file('cc-settings.gradle')
apply plugin: 'com.jakewharton.butterknife'
android { android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"] compileSdkVersion rootProject.ext.android["compileSdkVersion"]
...@@ -35,16 +36,26 @@ android { ...@@ -35,16 +36,26 @@ android {
} }
} }
} }
lintOptions {
disable 'InvalidPackage'
disable "ResourceType"
abortOnError false
}
} }
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
// if (project.ext.runAsApp) {
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"] annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
// test debugImplementation rootProject.ext.dependencies["canary-debug"]
releaseImplementation rootProject.ext.dependencies["canary-release"]
testImplementation rootProject.ext.dependencies["canary-release"]
// }else {
// compileOnly rootProject.ext.dependencies["dagger2-compiler"]
// compileOnly rootProject.ext.dependencies["canary-debug"]
// compileOnly rootProject.ext.dependencies["canary-release"]
// compileOnly rootProject.ext.dependencies["canary-release"]
// }
testImplementation rootProject.ext.dependencies["junit"] testImplementation rootProject.ext.dependencies["junit"]
debugImplementation rootProject.ext.dependencies["canary-debug"]
releaseImplementation rootProject.ext.dependencies["canary-release"]
testImplementation rootProject.ext.dependencies["canary-release"]
} }
...@@ -58,7 +58,6 @@ ...@@ -58,7 +58,6 @@
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_LOGS" /> <uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.GET_TASKS" /> <uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest> </manifest>
\ No newline at end of file
package com.gingersoft.gsa.cloud.download; package com.gingersoft.gsa.cloud.download;
import android.content.Context;
import android.text.TextUtils;
import com.billy.cc.core.component.CC; import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult; import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil; import com.billy.cc.core.component.CCUtil;
import com.billy.cc.core.component.IComponent; import com.billy.cc.core.component.IComponent;
import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.utils.FoodDaoUtils;
import com.gingersoft.gsa.cloud.download.mvp.ui.activity.DownloadActivity; import com.gingersoft.gsa.cloud.download.mvp.ui.activity.DownloadActivity;
import java.util.List;
public class ComponentDownload implements IComponent { public class ComponentDownload implements IComponent {
...@@ -21,23 +29,28 @@ public class ComponentDownload implements IComponent { ...@@ -21,23 +29,28 @@ public class ComponentDownload implements IComponent {
* 组件被调用时的入口 * 组件被调用时的入口
* 要确保每个逻辑分支都会调用到CC.sendCCResult, * 要确保每个逻辑分支都会调用到CC.sendCCResult,
* 包括try-catch,if-else,switch-case-default,startActivity * 包括try-catch,if-else,switch-case-default,startActivity
*
* @param cc 组件调用对象,可从此对象中获取相关信息 * @param cc 组件调用对象,可从此对象中获取相关信息
* @return true:将异步调用CC.sendCCResult(...),用于异步实现相关功能,例如:文件加载、网络请求等 * @return true:将异步调用CC.sendCCResult(...),用于异步实现相关功能,例如:文件加载、网络请求等
* false:会同步调用CC.sendCCResult(...),即在onCall方法return之前调用,否则将被视为不合法的实现 * false:会同步调用CC.sendCCResult(...),即在onCall方法return之前调用,否则将被视为不合法的实现
*/ */
@Override @Override
public boolean onCall(CC cc) { public boolean onCall(CC cc) {
String actionName = cc.getActionName(); String actionName = cc.getActionName();
Context context = cc.getContext();
switch (actionName) { switch (actionName) {
case "showDownloadActivity": case "showDownloadActivity":
openActivity(cc); openActivity(cc);
break; break;
case "getLifecycleFragment": case "getFunctionlist":
//demo for provide fragment object to other component //demo for provide fragment object to other component
getLifecycleFragment(cc); getFunctionlist(cc);
break; break;
case "lifecycleFragment.addText": case "getFoodGroupList":
lifecycleFragmentDoubleText(cc); getFoodGroupList(cc);
break;
case "getFoodListByParentId":
getFoodListByParentId(cc);
break; break;
case "getInfo": case "getInfo":
getInfo(cc); getInfo(cc);
...@@ -51,19 +64,45 @@ public class ComponentDownload implements IComponent { ...@@ -51,19 +64,45 @@ public class ComponentDownload implements IComponent {
return false; return false;
} }
private void lifecycleFragmentDoubleText(CC cc) { private void getFunctionlist(CC cc) {
// LifecycleFragment lifecycleFragment = cc.getParamItem("fragment");
// if (lifecycleFragment != null) { String parentId = cc.getParamItem("parentId");
// String text = cc.getParamItem("text", "");
// lifecycleFragment.addText(text); if (TextUtils.isEmpty(parentId)) {
// CC.sendCCResult(cc.getCallId(), CCResult.success());
// } else { } else {
// CC.sendCCResult(cc.getCallId(), CCResult.error("no fragment params"));
// } }
}
private void getFoodGroupList(CC cc) {
List<Food> foodGroupList = queryDB_FoodGroupList(cc.getContext());
if (foodGroupList != null) {
CCResult ccResult = CCResult.success("foodGroupList", GsonUtils.GsonString(foodGroupList));
CC.sendCCResult(cc.getCallId(), ccResult);
} else {
CC.sendCCResult(cc.getCallId(), CCResult.error("foodGroupList is null"));
}
}
private void getFoodListByParentId(CC cc) {
int parentId = cc.getParamItem("parentId");
List<Food> foodList = queryDB_FoodList(cc.getContext(), parentId);
if (foodList != null) {
CC.sendCCResult(cc.getCallId(), CCResult.success("foodList", GsonUtils.GsonString(foodList)));
} else {
CC.sendCCResult(cc.getCallId(), CCResult.error("foodList is null"));
}
}
public List<Food> queryDB_FoodGroupList(Context context) {
FoodDaoUtils foodDaoUtils = new FoodDaoUtils(context);
return foodDaoUtils.queryFoodGroupByQueryBuilder();
} }
private void getLifecycleFragment(CC cc) { public List<Food> queryDB_FoodList(Context context, int parentId) {
// CC.sendCCResult(cc.getCallId(), CCResult.successWithNoKey(new LifecycleFragment())); FoodDaoUtils foodDaoUtils = new FoodDaoUtils(context);
return foodDaoUtils.queryFoodByQueryBuilder(parentId);
} }
private void getInfo(CC cc) { private void getInfo(CC cc) {
......
package com.gingersoft.gsa.cloud.download.mvp.contract; package com.gingersoft.gsa.cloud.download.mvp.contract;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodBean; import android.content.Context;
import com.gingersoft.gsa.cloud.base.bean.FoodBean;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FunctionBean; import com.gingersoft.gsa.cloud.download.mvp.model.bean.FunctionBean;
import com.jess.arms.base.DefaultAdapter; import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.mvp.IView; import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel; import com.jess.arms.mvp.IModel;
import java.util.HashMap;
import java.util.List;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import io.reactivex.Observable; import io.reactivex.Observable;
...@@ -35,6 +40,10 @@ public interface DownloadContract { ...@@ -35,6 +40,10 @@ public interface DownloadContract {
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存 //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel { interface Model extends IModel {
List<Food> queryDB_FoodGroupList(Context context);
List<Food> queryDB_FoodList(Context context, int parentId);
Observable<FunctionBean> downFunctionList(); Observable<FunctionBean> downFunctionList();
Observable<FoodBean> downFoodList(String restaurantId); Observable<FoodBean> downFoodList(String restaurantId);
......
package com.gingersoft.gsa.cloud.download.mvp.model; package com.gingersoft.gsa.cloud.download.mvp.model;
import android.app.Application; import android.app.Application;
import android.content.Context;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodBean; import com.gingersoft.gsa.cloud.base.bean.FoodBean;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.utils.FoodDaoUtils;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FunctionBean; import com.gingersoft.gsa.cloud.download.mvp.model.bean.FunctionBean;
import com.gingersoft.gsa.cloud.download.mvp.model.service.DownloadService; import com.gingersoft.gsa.cloud.download.mvp.model.service.DownloadService;
import com.google.gson.Gson; import com.google.gson.Gson;
...@@ -11,6 +14,9 @@ import com.jess.arms.mvp.BaseModel; ...@@ -11,6 +14,9 @@ import com.jess.arms.mvp.BaseModel;
import com.jess.arms.di.scope.ActivityScope; import com.jess.arms.di.scope.ActivityScope;
import javax.inject.Inject; import javax.inject.Inject;
import com.gingersoft.gsa.cloud.download.mvp.contract.DownloadContract; import com.gingersoft.gsa.cloud.download.mvp.contract.DownloadContract;
import java.util.List;
import io.reactivex.Observable; import io.reactivex.Observable;
...@@ -46,6 +52,18 @@ public class DownloadModel extends BaseModel implements DownloadContract.Model { ...@@ -46,6 +52,18 @@ public class DownloadModel extends BaseModel implements DownloadContract.Model {
} }
@Override @Override
public List<Food> queryDB_FoodGroupList(Context context) {
FoodDaoUtils foodDaoUtils = new FoodDaoUtils(context);
return foodDaoUtils.queryFoodGroupByQueryBuilder();
}
@Override
public List<Food> queryDB_FoodList(Context context, int parentId) {
FoodDaoUtils foodDaoUtils = new FoodDaoUtils(context);
return foodDaoUtils.queryFoodByQueryBuilder(parentId);
}
@Override
public Observable<FunctionBean> downFunctionList() { public Observable<FunctionBean> downFunctionList() {
return mRepositoryManager.obtainRetrofitService(DownloadService.class) return mRepositoryManager.obtainRetrofitService(DownloadService.class)
.downFunctionList(); .downFunctionList();
...@@ -56,4 +74,7 @@ public class DownloadModel extends BaseModel implements DownloadContract.Model { ...@@ -56,4 +74,7 @@ public class DownloadModel extends BaseModel implements DownloadContract.Model {
return mRepositoryManager.obtainRetrofitService(DownloadService.class) return mRepositoryManager.obtainRetrofitService(DownloadService.class)
.downFoodList(restaurantId); .downFoodList(restaurantId);
} }
} }
\ No newline at end of file
...@@ -21,6 +21,7 @@ public class FunctionBean { ...@@ -21,6 +21,7 @@ public class FunctionBean {
*/ */
private boolean success; private boolean success;
private String errMsg;
private double sysTime; private double sysTime;
private List<Function> data; private List<Function> data;
...@@ -32,6 +33,14 @@ public class FunctionBean { ...@@ -32,6 +33,14 @@ public class FunctionBean {
this.success = success; this.success = success;
} }
public String getErrMsg() {
return errMsg;
}
public void setErrMsg(String errMsg) {
this.errMsg = errMsg;
}
public double getSysTime() { public double getSysTime() {
return sysTime; return sysTime;
} }
......
package com.gingersoft.gsa.cloud.download.mvp.model.service; package com.gingersoft.gsa.cloud.download.mvp.model.service;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodBean; import com.gingersoft.gsa.cloud.base.bean.FoodBean;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FunctionBean; import com.gingersoft.gsa.cloud.download.mvp.model.bean.FunctionBean;
import io.reactivex.Observable; import io.reactivex.Observable;
import me.jessyan.retrofiturlmanager.RetrofitUrlManager; import me.jessyan.retrofiturlmanager.RetrofitUrlManager;
import retrofit2.http.GET; import retrofit2.http.GET;
import retrofit2.http.Query; import retrofit2.http.Query;
import retrofit2.http.Url;
/** /**
* Created by Wyh on 2019/12/20. * Created by Wyh on 2019/12/20.
......
package com.gingersoft.gsa.cloud.download.mvp.presenter; package com.gingersoft.gsa.cloud.download.mvp.presenter;
import android.app.Application; import android.app.Application;
import android.util.Log;
import com.billy.cc.core.component.CC; import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.base.Api; import com.gingersoft.gsa.cloud.base.Api;
import com.gingersoft.gsa.cloud.base.bean.FoodBean;
import com.gingersoft.gsa.cloud.base.utils.constans.HttpsConstans; import com.gingersoft.gsa.cloud.base.utils.constans.HttpsConstans;
import com.gingersoft.gsa.cloud.database.bean.Food; import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.gsa.cloud.database.greendao.FoodDao;
import com.gingersoft.gsa.cloud.database.utils.FoodDaoUtils; import com.gingersoft.gsa.cloud.database.utils.FoodDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.FunctionDaoUtils; import com.gingersoft.gsa.cloud.database.utils.FunctionDaoUtils;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.DataDownLoadState; import com.gingersoft.gsa.cloud.download.mvp.model.bean.DataDownLoadState;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FoodBean;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.FunctionBean; import com.gingersoft.gsa.cloud.download.mvp.model.bean.FunctionBean;
import com.gingersoft.gsa.cloud.download.mvp.ui.activity.DownloadActivity; import com.gingersoft.gsa.cloud.download.mvp.ui.activity.DownloadActivity;
import com.gingersoft.gsa.cloud.download.mvp.ui.adapter.DataDownLoadAdapter; import com.gingersoft.gsa.cloud.download.mvp.ui.adapter.DataDownLoadAdapter;
...@@ -23,7 +20,6 @@ import com.jess.arms.http.imageloader.ImageLoader; ...@@ -23,7 +20,6 @@ import com.jess.arms.http.imageloader.ImageLoader;
import io.reactivex.Observable; import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler; import me.jessyan.rxerrorhandler.core.RxErrorHandler;
...@@ -32,14 +28,12 @@ import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber; ...@@ -32,14 +28,12 @@ import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import javax.inject.Inject; import javax.inject.Inject;
import com.gingersoft.gsa.cloud.download.mvp.contract.DownloadContract; import com.gingersoft.gsa.cloud.download.mvp.contract.DownloadContract;
import com.jess.arms.mvp.IView;
import com.jess.arms.utils.DeviceUtils; import com.jess.arms.utils.DeviceUtils;
import com.jess.arms.utils.RxLifecycleUtils; import com.jess.arms.utils.RxLifecycleUtils;
import java.net.URLEncoder; import org.simple.eventbus.EventBus;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -219,12 +213,14 @@ public class DownloadPresenter extends BasePresenter<DownloadContract.Model, Dow ...@@ -219,12 +213,14 @@ public class DownloadPresenter extends BasePresenter<DownloadContract.Model, Dow
} }
private void endDownReturn() { private void endDownReturn() {
CC.obtainBuilder("Component.Main") CC.obtainBuilder("Component.Main")
.setActionName("showMainActivity") .setActionName("showMainActivity")
.build() .build()
.call(); .call();
mRootView.killMyself(); mRootView.killMyself();
} }
public void initDataDownItem() { public void initDataDownItem() {
......
...@@ -4,6 +4,7 @@ import android.content.Intent; ...@@ -4,6 +4,7 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import com.gingersoft.gsa.cloud.download.R; import com.gingersoft.gsa.cloud.download.R;
import com.gingersoft.gsa.cloud.download.R2;
import com.gingersoft.gsa.cloud.download.di.component.DaggerDownloadComponent; import com.gingersoft.gsa.cloud.download.di.component.DaggerDownloadComponent;
import com.gingersoft.gsa.cloud.ui.dialog.LoadingDialog; import com.gingersoft.gsa.cloud.ui.dialog.LoadingDialog;
import com.jess.arms.base.BaseActivity; import com.jess.arms.base.BaseActivity;
...@@ -13,6 +14,9 @@ import com.jess.arms.utils.ArmsUtils; ...@@ -13,6 +14,9 @@ import com.jess.arms.utils.ArmsUtils;
import com.gingersoft.gsa.cloud.download.mvp.contract.DownloadContract; import com.gingersoft.gsa.cloud.download.mvp.contract.DownloadContract;
import com.gingersoft.gsa.cloud.download.mvp.presenter.DownloadPresenter; import com.gingersoft.gsa.cloud.download.mvp.presenter.DownloadPresenter;
import com.qmuiteam.qmui.widget.QMUITopBar; import com.qmuiteam.qmui.widget.QMUITopBar;
import org.simple.eventbus.EventBus;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
...@@ -36,9 +40,9 @@ import static com.jess.arms.utils.Preconditions.checkNotNull; ...@@ -36,9 +40,9 @@ import static com.jess.arms.utils.Preconditions.checkNotNull;
*/ */
public class DownloadActivity extends BaseActivity<DownloadPresenter> implements DownloadContract.View { public class DownloadActivity extends BaseActivity<DownloadPresenter> implements DownloadContract.View {
@BindView(R.id.topbar) @BindView(R2.id.topbar)
QMUITopBar mTopBar; QMUITopBar mTopBar;
@BindView(R.id.recycle_download) @BindView(R2.id.recycle_download)
RecyclerView recycle_download; RecyclerView recycle_download;
...@@ -53,6 +57,11 @@ public class DownloadActivity extends BaseActivity<DownloadPresenter> implements ...@@ -53,6 +57,11 @@ public class DownloadActivity extends BaseActivity<DownloadPresenter> implements
} }
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public int initView(@Nullable Bundle savedInstanceState) { public int initView(@Nullable Bundle savedInstanceState) {
return R.layout.download_data_activity_download; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0 return R.layout.download_data_activity_download; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
} }
......
...@@ -6,6 +6,7 @@ import android.widget.ImageView; ...@@ -6,6 +6,7 @@ import android.widget.ImageView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import com.gingersoft.gsa.cloud.download.R; import com.gingersoft.gsa.cloud.download.R;
import com.gingersoft.gsa.cloud.download.R2;
import com.gingersoft.gsa.cloud.download.mvp.model.bean.DataDownLoadState; import com.gingersoft.gsa.cloud.download.mvp.model.bean.DataDownLoadState;
import com.jess.arms.base.BaseHolder; import com.jess.arms.base.BaseHolder;
import com.jess.arms.base.DefaultAdapter; import com.jess.arms.base.DefaultAdapter;
...@@ -46,11 +47,11 @@ public class DataDownLoadAdapter extends DefaultAdapter<DataDownLoadState> { ...@@ -46,11 +47,11 @@ public class DataDownLoadAdapter extends DefaultAdapter<DataDownLoadState> {
class DataDownLoadItemHolder extends BaseHolder<DataDownLoadState> { class DataDownLoadItemHolder extends BaseHolder<DataDownLoadState> {
@BindView(R.id.iv_state) @BindView(R2.id.iv_state)
ImageView iv_state; ImageView iv_state;
@BindView(R.id.tv_title) @BindView(R2.id.tv_title)
TextView tv_title; TextView tv_title;
@BindView(R.id.pb_progress) @BindView(R2.id.pb_progress)
ProgressBar pb_progress; ProgressBar pb_progress;
public DataDownLoadItemHolder(View itemView) { public DataDownLoadItemHolder(View itemView) {
......
apply from: rootProject.file('cc-settings.gradle') apply from: rootProject.file('cc-settings.gradle')
apply plugin: 'com.jakewharton.butterknife'
android { android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"] compileSdkVersion rootProject.ext.android["compileSdkVersion"]
...@@ -19,6 +20,7 @@ android { ...@@ -19,6 +20,7 @@ android {
targetSdkVersion rootProject.ext.android["targetSdkVersion"] targetSdkVersion rootProject.ext.android["targetSdkVersion"]
versionCode rootProject.ext.android["versionCode"] versionCode rootProject.ext.android["versionCode"]
versionName rootProject.ext.android["versionName"] versionName rootProject.ext.android["versionName"]
multiDexEnabled true
} }
resourcePrefix "main" resourcePrefix "main"
...@@ -38,14 +40,16 @@ android { ...@@ -38,14 +40,16 @@ android {
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
// if (project.ext.runAsApp) {
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"] annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
// test
testImplementation rootProject.ext.dependencies["junit"]
debugImplementation rootProject.ext.dependencies["canary-debug"] debugImplementation rootProject.ext.dependencies["canary-debug"]
releaseImplementation rootProject.ext.dependencies["canary-release"] releaseImplementation rootProject.ext.dependencies["canary-release"]
testImplementation rootProject.ext.dependencies["canary-release"] testImplementation rootProject.ext.dependencies["canary-release"]
// }else {
// compileOnly rootProject.ext.dependencies["dagger2-compiler"]
// compileOnly rootProject.ext.dependencies["canary-debug"]
// compileOnly rootProject.ext.dependencies["canary-release"]
// compileOnly rootProject.ext.dependencies["canary-release"]
// }
testImplementation rootProject.ext.dependencies["junit"]
} }
...@@ -75,15 +75,16 @@ public class MainPresenter extends BasePresenter<MainContract.Model, MainContrac ...@@ -75,15 +75,16 @@ public class MainPresenter extends BasePresenter<MainContract.Model, MainContrac
public void initItemClickListener(Context context) { public void initItemClickListener(Context context) {
mAdapter.setOnItemClickListener(new FunctionAdapter.OnItemClickListener() { mAdapter.setOnItemClickListener(new FunctionAdapter.OnItemClickListener() {
@Override @Override
public void onItemClick(int position) { public void onItemClick(int position) {
String clas = mList.get(position).getResUrl(); String clas = mList.get(position).getResUrl();
if (TextUtils.isEmpty(clas)) { if (TextUtils.isEmpty(clas)) {
Intent intent = null;
try { try {
intent = new Intent(context, Class.forName(clas)); Intent intent = new Intent(context, Class.forName(clas));
context.startActivity(intent); context.startActivity(intent);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
......
...@@ -6,9 +6,12 @@ import android.view.KeyEvent; ...@@ -6,9 +6,12 @@ import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.GridView; import android.widget.GridView;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.database.bean.Function; import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.gsa.cloud.database.utils.FunctionDaoUtils; import com.gingersoft.gsa.cloud.database.utils.FunctionDaoUtils;
import com.gingersoft.gsa.cloud.main.R; import com.gingersoft.gsa.cloud.main.R;
import com.gingersoft.gsa.cloud.main.R2;
import com.gingersoft.gsa.cloud.main.di.component.DaggerMainComponent; import com.gingersoft.gsa.cloud.main.di.component.DaggerMainComponent;
import com.gingersoft.gsa.cloud.main.mvp.contract.MainContract; import com.gingersoft.gsa.cloud.main.mvp.contract.MainContract;
import com.gingersoft.gsa.cloud.main.mvp.presenter.MainPresenter; import com.gingersoft.gsa.cloud.main.mvp.presenter.MainPresenter;
...@@ -39,9 +42,9 @@ import static com.jess.arms.utils.Preconditions.checkNotNull; ...@@ -39,9 +42,9 @@ import static com.jess.arms.utils.Preconditions.checkNotNull;
*/ */
public class MainActivity extends BaseActivity<MainPresenter> implements MainContract.View { public class MainActivity extends BaseActivity<MainPresenter> implements MainContract.View {
@BindView(R.id.topbar) @BindView(R2.id.topbar)
QMUITopBar mTopBar; QMUITopBar mTopBar;
@BindView(R.id.gv_function) @BindView(R2.id.gv_function)
GridView gv_function; GridView gv_function;
...@@ -65,16 +68,8 @@ public class MainActivity extends BaseActivity<MainPresenter> implements MainCon ...@@ -65,16 +68,8 @@ public class MainActivity extends BaseActivity<MainPresenter> implements MainCon
mPresenter.initAdapter(this); mPresenter.initAdapter(this);
mPresenter.initItemClickListener(this); mPresenter.initItemClickListener(this);
initFunction();
} }
private void initFunction() {
FunctionDaoUtils functionDao = new FunctionDaoUtils(this);
List<Function> functionList = functionDao.queryAllFunction();
}
@Override @Override
public void initIntent() { public void initIntent() {
...@@ -86,6 +81,15 @@ public class MainActivity extends BaseActivity<MainPresenter> implements MainCon ...@@ -86,6 +81,15 @@ public class MainActivity extends BaseActivity<MainPresenter> implements MainCon
mTopBar.setBackgroundColor(ContextCompat.getColor(this, R.color.theme_color)); mTopBar.setBackgroundColor(ContextCompat.getColor(this, R.color.theme_color));
mTopBar.addLeftBackImageButton().setVisibility(View.INVISIBLE); mTopBar.addLeftBackImageButton().setVisibility(View.INVISIBLE);
mTopBar.setTitle("首頁"); mTopBar.setTitle("首頁");
mTopBar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CC.obtainBuilder("Component.Table")
.setActionName("showTableActivity")
.build()
.call();
}
});
} }
@Override @Override
......
...@@ -2,6 +2,8 @@ package com.gingersoft.cloud.gsa; ...@@ -2,6 +2,8 @@ package com.gingersoft.cloud.gsa;
import org.junit.Test; import org.junit.Test;
import java.math.BigDecimal;
import static org.junit.Assert.*; import static org.junit.Assert.*;
/** /**
...@@ -10,8 +12,16 @@ import static org.junit.Assert.*; ...@@ -10,8 +12,16 @@ import static org.junit.Assert.*;
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/ */
public class ExampleUnitTest { public class ExampleUnitTest {
@Test @Test
public void addition_isCorrect() { public void addition_isCorrect() {
assertEquals(4, 2 + 2); assertEquals(4, 2 + 2);
BigDecimal bigDecimal = new BigDecimal(13.456);
// BigDecimal bigDecimal2 = new BigDecimal(1.56);
System.out.println("bigDecimal: "+bigDecimal.setScale(2, BigDecimal.ROUND_DOWN).doubleValue());
} }
} }
\ No newline at end of file
apply from: rootProject.file('cc-settings.gradle') apply from: rootProject.file('cc-settings.gradle')
apply plugin: 'com.jakewharton.butterknife'
android { android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"] compileSdkVersion rootProject.ext.android["compileSdkVersion"]
...@@ -19,6 +20,12 @@ android { ...@@ -19,6 +20,12 @@ android {
targetSdkVersion rootProject.ext.android["targetSdkVersion"] targetSdkVersion rootProject.ext.android["targetSdkVersion"]
versionCode rootProject.ext.android["versionCode"] versionCode rootProject.ext.android["versionCode"]
versionName rootProject.ext.android["versionName"] versionName rootProject.ext.android["versionName"]
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
includeCompileClasspath true
}
}
} }
resourcePrefix "meal" resourcePrefix "meal"
...@@ -38,12 +45,21 @@ android { ...@@ -38,12 +45,21 @@ android {
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
// if (project.ext.runAsApp) {
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"] annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
debugImplementation rootProject.ext.dependencies["canary-debug"]
releaseImplementation rootProject.ext.dependencies["canary-release"]
testImplementation rootProject.ext.dependencies["canary-release"]
// }else {
// compileOnly rootProject.ext.dependencies["dagger2-compiler"]
// compileOnly rootProject.ext.dependencies["canary-debug"]
// compileOnly rootProject.ext.dependencies["canary-release"]
// compileOnly rootProject.ext.dependencies["canary-release"]
// }
// test // test
testImplementation rootProject.ext.dependencies["junit"] testImplementation rootProject.ext.dependencies["junit"]
debugImplementation rootProject.ext.dependencies["canary-debug"] // debugImplementation rootProject.ext.dependencies["canary-debug"]
releaseImplementation rootProject.ext.dependencies["canary-release"] // releaseImplementation rootProject.ext.dependencies["canary-release"]
testImplementation rootProject.ext.dependencies["canary-release"] // testImplementation rootProject.ext.dependencies["canary-release"]
} }
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gingersoft.gsa.cloud.mealstand"> package="com.gingersoft.gsa.cloud.meal">
<application> <application>
<activity android:name=".mvp.ui.activity.MealStandActivity"> <activity android:name=".mvp.ui.activity.MealStandActivity">
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gingersoft.gsa.cloud.mealstand"> package="com.gingersoft.gsa.cloud.meal">
<application <application
android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication" android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication"
...@@ -9,9 +9,12 @@ ...@@ -9,9 +9,12 @@
android:label="@string/meal_app_name" android:label="@string/meal_app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme.Base"> android:theme="@style/AppTheme">
<activity android:name=".mvp.ui.activity.MealStandActivity"> <activity
android:name="com.gingersoft.gsa.cloud.meal.mvp.ui.activity.MealStandActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
...@@ -31,6 +34,7 @@ ...@@ -31,6 +34,7 @@
android:name="design_height_in_dp" android:name="design_height_in_dp"
android:value="540" /> android:value="540" />
</application> </application>
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
......
package com.gingersoft.gsa.cloud.mealstand; package com.gingersoft.gsa.cloud.meal;
import com.billy.cc.core.component.CC; import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult; import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil; import com.billy.cc.core.component.CCUtil;
import com.billy.cc.core.component.IComponent; import com.billy.cc.core.component.IComponent;
import com.gingersoft.gsa.cloud.mealstand.mvp.ui.activity.MealStandActivity; import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.meal.mvp.ui.activity.MealStandActivity;
import java.util.List;
public class ComponentMealStand implements IComponent { public class ComponentMealStand implements IComponent {
...@@ -20,9 +23,10 @@ public class ComponentMealStand implements IComponent { ...@@ -20,9 +23,10 @@ public class ComponentMealStand implements IComponent {
* 组件被调用时的入口 * 组件被调用时的入口
* 要确保每个逻辑分支都会调用到CC.sendCCResult, * 要确保每个逻辑分支都会调用到CC.sendCCResult,
* 包括try-catch,if-else,switch-case-default,startActivity * 包括try-catch,if-else,switch-case-default,startActivity
*
* @param cc 组件调用对象,可从此对象中获取相关信息 * @param cc 组件调用对象,可从此对象中获取相关信息
* @return true:将异步调用CC.sendCCResult(...),用于异步实现相关功能,例如:文件加载、网络请求等 * @return true:将异步调用CC.sendCCResult(...),用于异步实现相关功能,例如:文件加载、网络请求等
* false:会同步调用CC.sendCCResult(...),即在onCall方法return之前调用,否则将被视为不合法的实现 * false:会同步调用CC.sendCCResult(...),即在onCall方法return之前调用,否则将被视为不合法的实现
*/ */
@Override @Override
public boolean onCall(CC cc) { public boolean onCall(CC cc) {
......
package com.gingersoft.gsa.cloud.meal.app;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-01-08
* 修订历史:2020-01-08
* 描述:
*/
public interface GoldConstants {
int DetailColCount = 5;
}
package com.gingersoft.gsa.cloud.meal.app;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-01-09
* 修订历史:2020-01-09
* 描述:
*/
public class OpenTableContract {
private String TAG = getClass().getSimpleName();
private static OpenTableContract sDefaultOpenTableManage;
public OpenTableContract() {
}
public static OpenTableContract getDefault() {
if (sDefaultOpenTableManage == null) {
sDefaultOpenTableManage = new OpenTableContract();
}
return sDefaultOpenTableManage;
}
}
package com.gingersoft.gsa.cloud.mealstand.di.component; package com.gingersoft.gsa.cloud.meal.di.component;
import dagger.BindsInstance; import dagger.BindsInstance;
import dagger.Component; import dagger.Component;
import com.jess.arms.di.component.AppComponent; import com.jess.arms.di.component.AppComponent;
import com.gingersoft.gsa.cloud.mealstand.di.module.MealStandModule; import com.gingersoft.gsa.cloud.meal.di.module.MealStandModule;
import com.gingersoft.gsa.cloud.mealstand.mvp.contract.MealStandContract; import com.gingersoft.gsa.cloud.meal.mvp.contract.MealStandContract;
import com.jess.arms.di.scope.ActivityScope; import com.jess.arms.di.scope.ActivityScope;
import com.gingersoft.gsa.cloud.mealstand.mvp.ui.activity.MealStandActivity; import com.gingersoft.gsa.cloud.meal.mvp.ui.activity.MealStandActivity;
/** /**
......
package com.gingersoft.gsa.cloud.mealstand.di.module; package com.gingersoft.gsa.cloud.meal.di.module;
import com.jess.arms.di.scope.ActivityScope;
import dagger.Binds; import dagger.Binds;
import dagger.Module; import dagger.Module;
import dagger.Provides;
import com.gingersoft.gsa.cloud.mealstand.mvp.contract.MealStandContract; import com.gingersoft.gsa.cloud.meal.mvp.contract.MealStandContract;
import com.gingersoft.gsa.cloud.mealstand.mvp.model.MealStandModel; import com.gingersoft.gsa.cloud.meal.mvp.model.MealStandModel;
/** /**
......
package com.gingersoft.gsa.cloud.mealstand.mvp.contract; package com.gingersoft.gsa.cloud.meal.mvp.contract;
import android.app.Activity;
import android.widget.BaseAdapter;
import com.gingersoft.gsa.cloud.base.bean.BaseRespose;
import com.gingersoft.gsa.cloud.base.bean.FoodBean;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.meal.mvp.model.bean.request.SendOrderRequest;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.mvp.IView; import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel; import com.jess.arms.mvp.IModel;
import java.util.List;
import androidx.recyclerview.widget.RecyclerView;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/** /**
* ================================================ * ================================================
...@@ -20,10 +34,73 @@ public interface MealStandContract { ...@@ -20,10 +34,73 @@ public interface MealStandContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息 //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView { interface View extends IView {
boolean isInitFineItemLayout();
void initFineItemTabBarViewPage();
void showFinePage();
void setPluMode();
void resetPluMode();
void recordOperat(boolean isPressButtonSound);
void showChoosePeopleNumDialog(boolean isNeedCancel);
void setPrinterLocalmachine(boolean isPrint);
void setTableInfoDialogAdapter(BaseAdapter adapter);
void setSelectFoodAdapter(RecyclerView.Adapter adapter);
void setFoodGroupAdapter(DefaultAdapter adapter);
void setFoodAdapter(DefaultAdapter adapter);
void setComboAdapter(DefaultAdapter adapter);
void setDiscountAdapter(DefaultAdapter adapter);
void setSelectFoodRecycleLayoutManager();
void setFoodGroupRecycleLayoutManager(int orientation);
void setFoodRecycleLayoutManager(int orientation);
void setComboRecycleLayoutManager(int orientation);
void setDiscountRecycleLayoutManager(int orientation);
void setFoodGroupRecycleSpanCount(int size);
void setFoodRecycleSpanCount(int size);
void setComboRecycleSpanCount(int size);
void setDiscountRecycleSpanCount(int size);
void showViewModeVisibility(int... viewMode);
void showModifyLayoutVisibility(boolean show);
Activity getActivity();
} }
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存 //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel { interface Model extends IModel {
Observable<BaseRespose> loadOrder(RequestBody requestBody);
Observable<BaseRespose> sendOrder(List<SendOrderRequest> foods);
Observable<BaseRespose> addFood(RequestBody requestBody);
Observable<BaseRespose> deleteFood(RequestBody requestBody);
List<Food> queryDB_FoodGroupList();
List<Food> queryDB_FoodList(long parentId);
} }
} }
package com.gingersoft.gsa.cloud.mealstand.mvp.model; package com.gingersoft.gsa.cloud.meal.mvp.model;
import android.app.Application; import android.app.Application;
import com.gingersoft.gsa.cloud.base.bean.BaseRespose;
import com.gingersoft.gsa.cloud.base.bean.FoodBean;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.utils.FoodDaoUtils;
import com.gingersoft.gsa.cloud.meal.mvp.model.bean.request.SendOrderRequest;
import com.gingersoft.gsa.cloud.meal.mvp.model.service.MealService;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager; import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel; import com.jess.arms.mvp.BaseModel;
...@@ -10,7 +16,12 @@ import com.jess.arms.di.scope.ActivityScope; ...@@ -10,7 +16,12 @@ import com.jess.arms.di.scope.ActivityScope;
import javax.inject.Inject; import javax.inject.Inject;
import com.gingersoft.gsa.cloud.mealstand.mvp.contract.MealStandContract; import com.gingersoft.gsa.cloud.meal.mvp.contract.MealStandContract;
import java.util.List;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/** /**
...@@ -43,4 +54,40 @@ public class MealStandModel extends BaseModel implements MealStandContract.Model ...@@ -43,4 +54,40 @@ public class MealStandModel extends BaseModel implements MealStandContract.Model
this.mGson = null; this.mGson = null;
this.mApplication = null; this.mApplication = null;
} }
@Override
public Observable<BaseRespose> loadOrder(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(MealService.class)
.loadOrder(requestBody);
}
@Override
public Observable<BaseRespose> sendOrder(List<SendOrderRequest> foods) {
return mRepositoryManager.obtainRetrofitService(MealService.class)
.sendOrder(foods);
}
@Override
public Observable<BaseRespose> addFood(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(MealService.class)
.addFood(requestBody);
}
@Override
public Observable<BaseRespose> deleteFood(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(MealService.class)
.deleteFood(requestBody);
}
@Override
public List<Food> queryDB_FoodGroupList() {
FoodDaoUtils foodDaoUtils = new FoodDaoUtils(mApplication);
return foodDaoUtils.queryFoodGroupByQueryBuilder();
}
@Override
public List<Food> queryDB_FoodList(long parentId) {
FoodDaoUtils foodDaoUtils = new FoodDaoUtils(mApplication);
return foodDaoUtils.queryFoodByQueryBuilder(parentId);
}
} }
\ No newline at end of file
package com.gingersoft.gsa.cloud.meal.mvp.model.bean;
import android.text.TextUtils;
import com.gingersoft.gsa.cloud.meal.mvp.model.constant.MealConstant;
import java.util.List;
public class OrderDetail {
/**
* code : 0
* message :
* datas : []
*/
private int code;
private String message;
private List<DatasBean> datas;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public List<DatasBean> getDatas() {
return datas;
}
public void setDatas(List<DatasBean> datas) {
this.datas = datas;
}
public static class DatasBean {
/*******自定义字段*******/
public boolean RealDiscountNew = false;//
//新点后是否自动展开
public int automod = 0;
//作用于套餐下子食品的限制数量
public int limitQty = 0;
/**
* 是否选择
* 0 未选中
* 1 被选中但不是主体
* 2 作为主体被选中
* 3 由三级菜单进入选中全部
*/
public int selected = 0;
//最后的金额平均数(Famount_price/number)
public double Famount_price_sign = 0;
//是否组合商品 1-组合商品 2-组合商品的子商品
public int ComboLevel = 0;
//是否显示,当
public boolean visible = true;
public String itemNo = "";
public int index = -1;
public int parent_index = 0;
public int my_index = 0;
//折扣后还应该收多少钱
public double discount_Main_money = 0.00;
public double PERCENTAGE = 0.00;
public int advprice = 0;
//是否已经折扣过
public boolean sc_able2 = true;
//"food" or "discount" or "modifiy"
public String Prop = "food";
//false时加 D标
public boolean discount_double1 = true;
//fix=6时加S标
public int discount_Fixed = 0;
//当作为discount时,记录下值
public boolean double1_as_discount = true;
public int fixed_as_discount = 0;
//手动金额
public boolean isManualMoney = false;
public double manualMoney = 0.00;
public boolean isComboAuto = false;
//当作为套餐内时的编號
public String comid = "";
//是否新的数据
public boolean isnew = false;
public int newnumber = 0;
//修改数量前的数量
private int changeBeforeQty = 0;
//是否自定义价格
private boolean isFuncmoney = false;
//当前食品是否有子项
private boolean hasChild = false;
private String name;
// private DiscountTypeAndOrderPay.DatasBean discountBean;
/**
* ��Ա���ּ����ֶ�
*/
private double pointsadd;
private double pointsrote;
private double PointsRedeem;
//该食品是否修改过
private boolean isModify = false;
//修改食品前的数量
private int modifyBeforeNumber = 0;
//取消食品备注
private String cancelInfo;
//取消食品id
private int cancelId;
//取消食品数量
private int cancelNumber;
/*******接口字段*******/
private int order_detail_id = -1;
private int parent_order_detail_id = -1;
private String itemno;
private String desc1;
private String desc2;
private String desc3;
private int itemtype = 0;
private boolean isfood;
//一级序 /二级序 /三级序
private int seqno = 0;
private int sseq = 0;
private int mseq = 0;
private int qty = 0;
private double unitprice = 0;//單價
private double amount_price = 0;//總價格
private String modid = "";
private int cancelid = 0;
private double discount = 0.00;
private int unit_id = -1;
private String discount_code;
private int discount_id = 0;
private int discount_type = 0;
private boolean sc_able = false;
private boolean d_able = true;
private String User_Qty;
private int foodTableMode = MealConstant.hall_food_mode;
/**
* 以下是碰餐信息
*/
private int MixGroupID = -1;
private double MixGroupDiscPrice = 0.00;
private int MixQty = -1;
private int Mix_DETAIL_ID;
private String MixDesc1;
private String MixDesc2;
private String MixDesc3;
private String FTID = "";
//1=沒有碰餐 2=已碰餐 3=從碰餐到沒有碰餐(需要更新價格數據)
private int hasMix = 1;
public DatasBean() {
}
/**
* �ϲ�ʳƷ��Ҫ��д�˷���
*
* @param obj
* @return
*/
@Override
public boolean equals(Object obj) {
if (obj == null)
return false;
if (this == obj) {//ͬһ�����󣬱ض���һ�µ�
return true;
}
if (obj instanceof DatasBean) {
DatasBean datasBean = (DatasBean) obj;
if (isnew && itemno.equals(datasBean.getItemno())) {
return true;
} else {
return false;
}
}
return false;//anObject����DatasBeanʵ������ô����false
}
/**
* ��дhashcode ���������ص�hashCode��һ������ȥ�Ƚ�ÿ�����Ե�ֵ
*/
@Override
public int hashCode() {
return itemno.hashCode() * desc1.hashCode();
}
public String getName() {
if (!TextUtils.isEmpty(name)) {
return name;
}
// return AndroidSettingUtils.getDataLanguage(desc1, desc2, desc3);
return desc1;
}
public void setName(String name) {
this.name = name;
}
public int getHasMix() {
return hasMix;
}
public void setHasMix(int hasMix) {
if (this.hasMix == 2 && hasMix == 1) {
hasMix = 3;
}
this.hasMix = hasMix;
}
public int getFoodTableMode() {
return foodTableMode;
}
public void setFoodTableMode(int foodTableMode) {
this.foodTableMode = foodTableMode;
}
public void setModify(boolean modify) {
isModify = modify;
}
public boolean isSc_able2() {
return sc_able2;
}
public void setSc_able2(boolean sc_able2) {
this.sc_able2 = sc_able2;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public boolean isRealDiscountNew() {
return RealDiscountNew;
}
public void setRealDiscountNew(boolean realDiscountNew) {
RealDiscountNew = realDiscountNew;
}
public int getAutomod() {
return automod;
}
public void setAutomod(int automod) {
this.automod = automod;
}
public int getLimitQty() {
return limitQty;
}
public void setLimitQty(int limitQty) {
this.limitQty = limitQty;
}
public int getSelected() {
return selected;
}
public void setSelected(int selected) {
this.selected = selected;
}
public double getFamount_price_sign() {
return Famount_price_sign;
}
public void setFamount_price_sign(double famount_price_sign) {
Famount_price_sign = famount_price_sign;
}
public int getComboLevel() {
return ComboLevel;
}
public void setComboLevel(int comboLevel) {
ComboLevel = comboLevel;
}
public boolean isVisible() {
return visible;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
public String getItemNo() {
return itemNo;
}
public void setItemNo(String itemNo) {
this.itemNo = itemNo;
}
public int getParent_index() {
return parent_index;
}
public void setParent_index(int parent_index) {
this.parent_index = parent_index;
}
public int getMy_index() {
return my_index;
}
public void setMy_index(int my_index) {
this.my_index = my_index;
}
public double getDiscount_Main_money() {
return discount_Main_money;
}
public void setDiscount_Main_money(double discount_Main_money) {
this.discount_Main_money = discount_Main_money;
}
public double getPERCENTAGE() {
return PERCENTAGE;
}
public void setPERCENTAGE(double PERCENTAGE) {
this.PERCENTAGE = PERCENTAGE;
}
public int getAdvprice() {
return advprice;
}
public void setAdvprice(int advprice) {
this.advprice = advprice;
}
public String getProp() {
return Prop;
}
public void setProp(String prop) {
Prop = prop;
}
public boolean isDiscount_double1() {
return discount_double1;
}
public void setDiscount_double1(boolean discount_double1) {
this.discount_double1 = discount_double1;
}
public int getDiscount_Fixed() {
return discount_Fixed;
}
public void setDiscount_Fixed(int discount_Fixed) {
this.discount_Fixed = discount_Fixed;
}
public boolean isDouble1_as_discount() {
return double1_as_discount;
}
public void setDouble1_as_discount(boolean double1_as_discount) {
this.double1_as_discount = double1_as_discount;
}
public int getFixed_as_discount() {
return fixed_as_discount;
}
public void setFixed_as_discount(int fixed_as_discount) {
this.fixed_as_discount = fixed_as_discount;
}
public boolean isManualMoney() {
return isManualMoney;
}
public void setManualMoney(boolean manualMoney) {
isManualMoney = manualMoney;
}
public double getManualMoney() {
return manualMoney;
}
public void setManualMoney(double manualMoney) {
this.manualMoney = manualMoney;
}
public int getChangeBeforeQty() {
return changeBeforeQty;
}
public void setChangeBeforeQty(int changeBeforeQty) {
this.changeBeforeQty = changeBeforeQty;
}
public boolean isComboAuto() {
return isComboAuto;
}
public void setComboAuto(boolean comboAuto) {
isComboAuto = comboAuto;
}
public String getComid() {
return comid;
}
public void setComid(String comid) {
this.comid = comid;
}
public boolean isIsnew() {
return isnew;
}
public void setIsnew(boolean isnew) {
this.isnew = isnew;
}
public int getNewnumber() {
return newnumber;
}
public void setNewnumber(int newnumber) {
this.newnumber = newnumber;
}
public int getOrder_detail_id() {
return order_detail_id;
}
public void setOrder_detail_id(int order_detail_id) {
this.order_detail_id = order_detail_id;
}
public int getParent_order_detail_id() {
return parent_order_detail_id;
}
public void setParent_order_detail_id(int parent_order_detail_id) {
this.parent_order_detail_id = parent_order_detail_id;
}
public boolean isFuncmoney() {
return isFuncmoney;
}
public void setFuncmoney(boolean funcmoney) {
isFuncmoney = funcmoney;
}
public String getItemno() {
return itemno;
}
public void setItemno(String itemno) {
this.itemno = itemno;
}
public String getDesc1() {
return desc1;
}
public void setDesc1(String desc1) {
this.desc1 = desc1;
}
public String getDesc2() {
return desc2;
}
public void setDesc2(String desc2) {
this.desc2 = desc2;
}
public String getDesc3() {
return desc3;
}
public void setDesc3(String desc3) {
this.desc3 = desc3;
}
public int getItemtype() {
return itemtype;
}
public void setItemtype(int itemtype) {
this.itemtype = itemtype;
}
public boolean isIsfood() {
return isfood;
}
public void setIsfood(boolean isfood) {
this.isfood = isfood;
}
public int getSeqno() {
return seqno;
}
public void setSeqno(int seqno) {
this.seqno = seqno;
}
public int getSseq() {
return sseq;
}
public void setSseq(int sseq) {
this.sseq = sseq;
}
public int getMseq() {
return mseq;
}
public void setMseq(int mseq) {
this.mseq = mseq;
}
public int getQty() {
return qty;
}
public void setQty(int qty) {
this.qty = qty;
}
public double getUnitprice() {
return unitprice;
}
public void setUnitprice(double unitprice) {
this.unitprice = unitprice;
}
public double getAmount_price() {
return amount_price;
}
public void setAmount_price(double amount_price) {
this.amount_price = amount_price;
}
public String getModid() {
return modid;
}
public void setModid(String modid) {
this.modid = modid;
}
public int getCancelid() {
return cancelid;
}
public void setCancelid(int cancelid) {
this.cancelid = cancelid;
}
public double getDiscount() {
return discount;
}
public void setDiscount(double discount) {
this.discount = discount;
}
public int getUnit_id() {
return unit_id;
}
public void setUnit_id(int unit_id) {
this.unit_id = unit_id;
}
public String getDiscount_code() {
return discount_code;
}
public void setDiscount_code(String discount_code) {
this.discount_code = discount_code;
}
public int getDiscount_id() {
return discount_id;
}
public void setDiscount_id(int discount_id) {
this.discount_id = discount_id;
}
public int getDiscount_type() {
return discount_type;
}
public void setDiscount_type(int discount_type) {
this.discount_type = discount_type;
}
public boolean isSc_able() {
return sc_able;
}
public void setSc_able(boolean sc_able) {
this.sc_able = sc_able;
}
public boolean isD_able() {
return d_able;
}
public void setD_able(boolean d_able) {
this.d_able = d_able;
}
public String getUser_Qty() {
return User_Qty;
}
public void setUser_Qty(String user_Qty) {
User_Qty = user_Qty;
}
public int getMixGroupID() {
return MixGroupID;
}
public void setMixGroupID(int mixGroupID) {
MixGroupID = mixGroupID;
}
public double getMixGroupDiscPrice() {
return MixGroupDiscPrice;
}
public void setMixGroupDiscPrice(double mixGroupDiscPrice) {
MixGroupDiscPrice = mixGroupDiscPrice;
}
public int getMixQty() {
return MixQty;
}
public void setMixQty(int mixQty) {
MixQty = mixQty;
}
public int getMix_DETAIL_ID() {
return Mix_DETAIL_ID;
}
public void setMix_DETAIL_ID(int mix_DETAIL_ID) {
Mix_DETAIL_ID = mix_DETAIL_ID;
}
public String getMixDesc1() {
return MixDesc1;
}
public void setMixDesc1(String mixDesc1) {
MixDesc1 = mixDesc1;
}
public String getMixDesc2() {
return MixDesc2;
}
public void setMixDesc2(String mixDesc2) {
MixDesc2 = mixDesc2;
}
public String getMixDesc3() {
return MixDesc3;
}
public void setMixDesc3(String mixDesc3) {
MixDesc3 = mixDesc3;
}
public String getFTID() {
return FTID;
}
public void setFTID(String FTID) {
this.FTID = FTID;
}
// public DiscountTypeAndOrderPay.DatasBean getDiscountTypeAndOrderPayBean() {
// return discountBean;
// }
//
// public void setDiscountTypeAndOrderPayBean(DiscountTypeAndOrderPay.DatasBean discountBean) {
// this.discountBean = discountBean;
// }
public double getPointsadd() {
return pointsadd;
}
public void setPointsadd(double pointsadd) {
this.pointsadd = pointsadd;
}
public double getPointsrote() {
return pointsrote;
}
public void setPointsrote(double pointsrote) {
this.pointsrote = pointsrote;
}
public double getPointsRedeem() {
return PointsRedeem;
}
public void setPointsRedeem(double pointsRedeem) {
PointsRedeem = pointsRedeem;
}
public boolean isModify() {
if (!isnew && qty != modifyBeforeNumber) {
isModify = true;
} else {
isModify = false;
}
return isModify;
}
public int getModifyBeforeNumber() {
return modifyBeforeNumber;
}
public void setModifyBeforeNumber(int modifyBeforeNumber) {
this.modifyBeforeNumber = modifyBeforeNumber;
}
public String getCancelInfo() {
return cancelInfo;
}
public void setCancelInfo(String cancelInfo) {
this.cancelInfo = cancelInfo;
}
public int getCancelId() {
return cancelId;
}
public void setCancelId(int cancelId) {
this.cancelId = cancelId;
}
public int getCancelNumber() {
return cancelNumber;
}
public void setCancelNumber(int cancelNumber) {
this.cancelNumber = cancelNumber;
}
public boolean isHasChild() {
return hasChild;
}
public void setHasChild(boolean hasChild) {
this.hasChild = hasChild;
}
}
}
package com.gingersoft.gsa.cloud.meal.mvp.model.bean.request;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-01-06
* 修订历史:2020-01-06
* 描述:
*/
public class SendOrderRequest {
private long productId;
private String productName;
private double price;
private double lunchboxPrice;
private int number;
public SendOrderRequest(long productId, String productName, double price, double lunchboxPrice, int number) {
this.productId = productId;
this.productName = productName;
this.price = price;
this.lunchboxPrice = lunchboxPrice;
this.number = number;
}
public long getProductId() {
return productId;
}
public void setProductId(long productId) {
this.productId = productId;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public double getLunchboxPrice() {
return lunchboxPrice;
}
public void setLunchboxPrice(double lunchboxPrice) {
this.lunchboxPrice = lunchboxPrice;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
}
package com.gingersoft.gsa.cloud.meal.mvp.model.constant;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-01-04
* 修订历史:2020-01-04
* 描述:
*/
public interface MealConstant {
int food_group_ViewMode = 100;
int food_ViewMode = 101;
int combo_ViewMode = 102;
int discount_ViewMode = 104;
int fine_ViewMode = 105;
int fine_tabs_ViewMode = 106;
int ViewMode_keys = 503;
//堂食
int hall_food_mode = 1;
//外賣
int takeaway_food_mode = 2;
String ADD_FOOD_MODIFIER = "add_food_modifier";
String UPDATE_MODIFIER_MAX_QTY = "update_modifier_max_qty";
String EXIT_IS_PLU_MODE = "ExitIsPluMode";
}
package com.gingersoft.gsa.cloud.meal.mvp.model.manage;
import android.app.Activity;
import com.gingersoft.gsa.cloud.base.bean.FoodBean;
import com.gingersoft.gsa.cloud.base.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.meal.mvp.model.bean.OrderDetail;
import com.gingersoft.gsa.cloud.meal.mvp.ui.adapter.meal.SelectMealAdapter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019/9/17
* 修订历史:2019/9/17
* 描述:
*/
public class MyOrderManage {
private static MyOrderManage myOrderManage;
public static MyOrderManage getInstance() {
if (myOrderManage == null) {
myOrderManage = new MyOrderManage();
}
return myOrderManage;
}
private Activity context;
// private MealStandPresenter presenter;
private SelectMealAdapter selectMealAdapter;
private boolean overMaxQty = false;
private int Languageindex;
private boolean Edit_Send = false;
private int selpostion = 0;
private int selstartpostion = 0;
private int selendpostion = 0;
private int selmainstartpositon = 0;
private int selmainendpostion = 0;
private int select_Full_start_position = 0;
private int select_Full_end_position = 0;
private int seqno = 1; //一级序
private int sseq = 0;//二级序
private int mseq = 0;//三级序
private List<Food> orderFoodList = new ArrayList<>();
// private List<DatasBean> comboOrders = new ArrayList<>();
// private List<MixOldOrder> MixOldOrders = new ArrayList<>();
// private List<MixComboGroupDiscount.DatasBean> mixComboGroup_Discounts;
// private List<MixComboGroup.DatasBean> MixComboGroups;
private int lastTimeChangeNumber = 1;
private boolean allowAddAutoDiscount = false;
public static final int ADD_OPERAT = 1;
public static final int DELETE_OPERAT = 2;
// public void changeNumber(int number) {
//
// if (orderFoodList.size() <= 0) {
// return;
// }
// if (this.selmainstartpositon > orderFoodList.size()) {
// return;
// }
//
// OrderDetail.DatasBean orderFood = orderFoodList.get(this.selmainstartpositon);
//
// CurrentSoldoutFood.DatasBean scClass;
// Db_SoldoutCtrl db = new Db_SoldoutCtrl(GSAApplication.getAppContext());
// if (orderFood.isIsfood()) {
// scClass = db.getSoldoutCtrl("F", orderFood.getItemno());
// } else {
// scClass = db.getSoldoutCtrl("M", orderFood.getItemno());
// }
// db.closeDb();
//
// int OR_Qty = scClass.getOR_Qty();
// int Used_Qty = scClass.getUsed_Qty();
// if (OR_Qty == -999999999 && Used_Qty == -999999999) {
//
// } else {
// int countNumber = getCountNumber(orderFood.getItemno());
// if (OR_Qty - Used_Qty - countNumber - number < 0) {
// return;
// }
// }
//
// int qty = orderFood.getQty();
//
// boolean intQty = number == 1 || qty == 1 || number < qty;
//// boolean isChangeChildNumberSuccess = orderFood.isChangeChildNumberSuccess() && number < qty;
//
// change_food_number(orderFood, number);
//
// if (intQty) {
// if (number != 1 && number < qty) {
// //從大到小直接抹掉細項
// removeFoodModifify(orderFood);
// }
// change_child_number(orderFood, number);
// }
//
// boolean isCalcMix;
//
// if (number == 0) {
// isCalcMix = calc_Mix(DELETE_OPERAT);
// } else {
// isCalcMix = calc_Mix(ADD_OPERAT);
// }
//
// if (!isCalcMix) {
// //TODO 需要重新計算折扣
// for (int i = selstartpostion; i <= selendpostion; i++) {
// if (orderFoodList.size() > i) {
// OrderDetail.DatasBean order = orderFoodList.get(i);
// if (order.getDiscount_id() != 0) {
// MyOrderManage.getInstance().updateDiscoutMoney(order);
// }
// }
// }
// }
//
// Re_Discount();
//
//
// selectMealAdapter.setIndexAndSqeno(false);
// selectMealAdapter.setSelectPosition(selpostion);
//
// selectMealAdapter.notifyDataSetChanged();
// }
// private void change_food_number(OrderDetail.DatasBean orderFood, int number) {
//
// orderFood.setQty(number);
// orderFood.newnumber = number;
//
// setCalculatePrice(orderFood, orderFood.isFuncmoney(), orderFood.getUnitprice());
// }
// private void change_child_number(OrderDetail.DatasBean orderFood, int number) {
//
// //每个组子项最大选择数量
// Map<String, String> maxNumberArray = new HashMap<>();
//
// for (int i = 0; i < orderFoodList.size(); i++) {
// OrderDetail.DatasBean datasBean = orderFoodList.get(i);
// if (datasBean.getParent_index() == orderFood.getMy_index() && datasBean.getItemtype() == 2) {
//
// String comId = datasBean.getComid();
//
// if (!datasBean.getComid().equals("discount")) {
//
// //当前主食品组子项最大选择数
// int comboMaxQty = selectMealAdapter.queryComboMaxQty(datasBean.getItemNo(), datasBean.getComid());
// int comboGroupMaxQty = selectMealAdapter.queryComboMaxQty(datasBean.getItemNo(), datasBean.getComid()) * number;
//
// maxNumberArray.put(comId, comboMaxQty + "_" + comboGroupMaxQty);
// } else {
// maxNumberArray.put(comId, "-1_-1");
// }
//// int comIdIndex = maxNumberArray.indexOfKey(comId);
//// if (comIdIndex != -1) {
//// int totalQty;
//// if (!TextUtils.isEmpty(maxNumberArray.get(comId))) {
//// totalQty = Integer.parseInt(maxNumberArray.get(comId).split("_")[0]) + datasBean.getQty();
//// } else {
//// totalQty = datasBean.getQty();
//// }
//// } else {
//// maxNumberArray.put(comId, datasBean.getQty() + "");
//// }
// }
// }
//
// Iterator<String> iterator = maxNumberArray.keySet().iterator();
// while (iterator.hasNext()) {
// String key = iterator.next();
// String totalQty = maxNumberArray.get(key);
// int combNumber = 0;
// for (int j = 0; j < orderFoodList.size(); j++) {
// OrderDetail.DatasBean datasBean = orderFoodList.get(j);
// if (datasBean.getParent_index() == orderFood.getMy_index() && datasBean.getItemtype() == 2) {
// String comId = datasBean.getComid();
// if (key.equals(comId)) {
// combNumber += datasBean.getQty();
// }
// }
// }
// String value = totalQty + "_" + combNumber;
// maxNumberArray.put(key, value);
// }
//
//// for (int i = 0; i < maxNumberArray.size(); i++) {
//// String key = maxNumberArray.get(i);
//// String totalQty = maxNumberArray.get(key);
//// int combNumber = 0;
//// for (int j = 0; j < orderFoodList.size(); j++) {
//// OrderDetail.DatasBean datasBean = orderFoodList.get(j);
//// if (datasBean.getParent_index() == orderFood.getMy_index() && datasBean.getItemtype() == 2) {
//// String comId = datasBean.getComid();
//// if (key.equals(comId)) {
//// combNumber += datasBean.getQty();
//// }
//// }
//// }
//// String value = totalQty + "_" + combNumber;
//// maxNumberArray.put(key, value);
//// }
//
// for (int i = orderFoodList.size() - 1; i >= 0; i--) {
// OrderDetail.DatasBean datasBean = orderFoodList.get(i);
// if (datasBean.getParent_index() == orderFood.getMy_index()) {
// if (datasBean.getItemtype() == 3) {
// datasBean.setQty(number);
// datasBean.newnumber = number;
// setCalculatePrice(datasBean, datasBean.isFuncmoney(), datasBean.getUnitprice());
// } else {
//
// if (datasBean.getComid().equals("discount")) {
// datasBean.setQty(number);
// datasBean.newnumber = number;
// continue;
// }
//
// int comboQty = datasBean.getQty();
//
// //当前主食品子项最大选择数
//// int comboMaxQty = selectMealAdapter.queryComboMaxQty(datasBean.getItemNo(), datasBean.getComid()) * orderFood.getQty();
//
// int currentNumber = datasBean.getChangeBeforeQty();
////
// String key = datasBean.getComid();
// String vaule = maxNumberArray.get(key);
//
// String[] totalQty_combNumber = vaule.split("_");
// int comboMaxQty = Integer.parseInt(totalQty_combNumber[0]);
// int comboGroupMaxQty = Integer.parseInt(totalQty_combNumber[1]);
//// int combNumber = Integer.parseInt(totalQty_combNumber[2]);
//
// if (number == 1) {
// currentNumber = datasBean.getChangeBeforeQty();
// } else {
// if (number < datasBean.getQty()) {
// //从大到小
// if (comboMaxQty == 1) {
// //这一组最大选择数为1
// currentNumber = number;
// } else {
// if (comboGroupMaxQty > 0) {
// currentNumber = number;
// //最大选择数减去当前子项的数量
// comboGroupMaxQty -= currentNumber;
// maxNumberArray.put(key, comboMaxQty + "_" + comboGroupMaxQty);
// } else {
// //已达到最大选择数,后面还有食品直接删除
// currentNumber = 0;
// }
// }
// } else {
// currentNumber = number * datasBean.getChangeBeforeQty();
// }
// }
//
// if (currentNumber == 0) {
// orderFoodList.remove(i);
// } else {
// datasBean.setQty(currentNumber);
// datasBean.newnumber = currentNumber;
// setCalculatePrice(datasBean, datasBean.isFuncmoney(), datasBean.getUnitprice());
// }
// }
// }
// }
//
// lastTimeChangeNumber = number;
//
// maxNumberArray.clear();
// }
// private void removeFoodModifify(OrderDetail.DatasBean myorder) {
// int endIndex = myorder.getMy_index() - 1;
// for (int i = orderFoodList.size() - 1; i > endIndex; i--) {
// OrderDetail.DatasBean foodBean = orderFoodList.get(i);
// if (foodBean.getProp().equalsIgnoreCase("modifify_modalkeyboard") && foodBean.getParent_index() == myorder.getMy_index()) {
// //删除当前食品下的所有子项
// orderFoodList.remove(i);
// }
// }
// }
// public void Re_Discount() {
// if (orderFoodList.size() == 0) {
// return;
// }
// try {
// //计算数呈
// if (this.selstartpostion > orderFoodList.size()) {
// return;
// }
//
// OrderDetail.DatasBean mainorder = orderFoodList.get(this.selstartpostion);
// for (int i = selstartpostion; i < orderFoodList.size(); i++) {
// OrderDetail.DatasBean childOrder = orderFoodList.get(i);
// if (childOrder.getItemtype() == 0) {
// break;
// }
// if (childOrder.comid.equals("discount")) {
// childOrder.setAmount_price(childOrder.getUnitprice());
// childOrder.Famount_price_sign = childOrder.getUnitprice() / childOrder.newnumber;
// }
// }
// //从selstartpostion开始向下查找到全部的归属于本茶品的最后位置
// DiscountTypeAndOrderPay.DatasBean dt = new DiscountTypeAndOrderPay.DatasBean();
// dt.setSelStartPostion(this.selstartpostion);
// dt.setSelEndPostion(this.selendpostion);
// dt.recalc_doubleandfixed6(orderFoodList);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
/**
* 检查当前食品有没有超过数量或者已经沽清
*
* @param fid
* @param isfood
* @param number
* @return
*/
// public boolean checkOverSoldoutNumber(String fid, boolean isfood, int number) {
// int newNumber = 0;
// //检查是否需要改变估清
// CurrentSoldoutFood.DatasBean scClass;
// Db_SoldoutCtrl db = new Db_SoldoutCtrl(context);
// if (isfood) {
// scClass = db.getSoldoutCtrl("F", fid);
// } else {
// scClass = db.getSoldoutCtrl("M", fid);
// }
// db.closeDb();
// db = null;
//
// if (scClass.OR_Qty == -999999999 && scClass.Used_Qty == -999999999) {
// //不需要判读数量
// return true;
// } else {
// newNumber = getCountNumber(fid);
// //需要判读数量,如果当前数量超过,直接返回估清
// if (scClass.OR_Qty - scClass.Used_Qty - newNumber - number < 0) {
// return false;
// } else {
// return true;
// }
// }
// }
/*查找并计算碰餐,计算出的结果:如果是已经存在的,则需要记录此单新金额*/
/*得到当前的碰餐折扣表,从高到低的折扣金额排列*/
/*获取食品细项,把该食品与其它任意食品B依金额碰,如果B尚未碰过,则两者相碰成功*/
/*检查到B食品时,向下碰C食品,如果C食品碰的金额大于*/
// public boolean calc_Mix(int operatType) {
// int max_mixIndex = 0;
// MixOldOrders.clear();
//
// //获得碰餐有效数据(已经数据库中对status=false和日期不在起始日期内 或者不在假期内的数据进行了屏蔽并且已经是取到了最优的碰餐结果了)
// Db_MixComboGroup_Discount db_md = new Db_MixComboGroup_Discount(context);// this.activity);
// mixComboGroup_Discounts = db_md.get_valid_discount();
// db_md.closeDb();
//
// if (mixComboGroup_Discounts.size() == 0) {
// return false;
// }
//
// int n = 0;
// for (OrderDetail.DatasBean order : orderFoodList) {
// if (order.getItemtype() == 1) {
//// n = n + order.newnumber;
// n = n + 1;
// order.setMix_DETAIL_ID(0);
// order.setMixGroupDiscPrice(0);
// order.setMixDesc1("");
// order.setMixDesc2("");
// order.setMixDesc3("");
// order.setMixQty(0);
// order.setMixGroupID(0);
// }
// }
// /*只有一个食品,则退出*/
//// if (operatType == ADD_OPERAT && n <= 1) {
//// return false;
//// }
//
// /*删除后食品必须大于一,否则则退出*/
// boolean allowDelete = operatType == DELETE_OPERAT && n > 1;
//
// if (operatType == ADD_OPERAT || allowDelete) {
// Db_MixComboGroup db_maxgroup = new Db_MixComboGroup(GSAApplication.getAppContext());
// for (MixComboGroupDiscount.DatasBean mcgd : mixComboGroup_Discounts) {
//
// boolean findgroup1;
// boolean findgroup2;
//
// OrderDetail.DatasBean findorder1;
// OrderDetail.DatasBean findorder2;
//
// List<MixComboGroup.DatasBean> mcgroups1 = db_maxgroup.query_byFood(mcgd.getGROUPID1());
// List<MixComboGroup.DatasBean> mcgroups2 = db_maxgroup.query_byFood(mcgd.getGROUPID2());// + " and status=1 order by ISNULL(SEQ,-1),f.Price desc,g.ID,id ");
//
// for (int i = 0; i < mcgroups1.size(); i++) {
// MixComboGroup.DatasBean mcgroup1 = mcgroups1.get(i);
// //加个循环,保证找完所有的order
// for (OrderDetail.DatasBean morder : orderFoodList) {
// findgroup1 = false;
// findgroup2 = false;
// findorder1 = null;
// findorder2 = null;
// int recordIndex = -1;
// for (int k = 0; k < orderFoodList.size(); k++) {
// OrderDetail.DatasBean order = orderFoodList.get(k);
// String desc1 = order.getDesc1();
// if (order.getItemtype() != 1 || !order.isIsfood()) {
// continue;
// }
// //非食品则不操作
// int qty = order.getQty();
// int mixQty = order.getMixQty();
// if (qty <= 0 || qty <= mixQty) {
// continue;
// }
// String fid1 = order.getItemno();
// String fid2 = mcgroup1.getFID();
// if (fid1.equals(fid2)) {
// findgroup1 = true;
// findorder1 = order;
// recordIndex = k;
// break;
// }
// }
// if (findgroup1 == false) {
// continue;
// } //没有找到就跳下一个
//
// for (int k = 0; k < mcgroups2.size(); k++) {
// MixComboGroup.DatasBean mcgroup2 = mcgroups2.get(k);
// for (int o = 0; o < orderFoodList.size(); o++) {
// OrderDetail.DatasBean order = orderFoodList.get(o);
// String desc1 = order.getDesc1();
// if (order.getItemtype() != 1 || !order.isIsfood()) {
// continue;
// } //非食品则不操作
// int qty = order.getQty();
// int mixQty = order.getMixQty();
// if (qty <= 0 || qty <= mixQty) {
// continue;
// }
// if (recordIndex == o) {
// //该食品已经碰餐了
// continue;
// }
// String fid1 = order.getItemno();
// String fid2 = mcgroup2.getFID();
// if (fid1.equals(fid2)) {
// findgroup2 = true;
// findorder2 = order;
// break;
// }
// }
// if (findgroup2 == true) {
// break;
// }
// }
// if (findgroup2 == false) {
// continue;
// }
//
// max_mixIndex = max_mixIndex + 1;
//
// int Mix_DETAIL_ID1 = findorder1.getMix_DETAIL_ID() + max_mixIndex;
// int Mix_DETAIL_ID2 = findorder2.getMix_DETAIL_ID() + max_mixIndex;
// findorder1.setMix_DETAIL_ID(Mix_DETAIL_ID1);
// findorder2.setMix_DETAIL_ID(Mix_DETAIL_ID2);
// /*开始设置这两个食品的碰餐属性*/
// /*数量算法,如果限制了数量,则最高为限制数量,如果没有限制,则使用最小的可以折扣的数量*/
// int findorder1MixNumber = db_maxgroup.get_mixqty(findorder1.getItemno(), mcgd.getGROUPID1());
// int findorder2MixNumber = db_maxgroup.get_mixqty(findorder2.getItemno(), mcgd.getGROUPID2());
// //最后需要更新的数量
// int nowMixQty = 0;
// //得到最小的剩余数量
// int mixqty = findorder1.getQty() - findorder1.getMixQty() > findorder2.getQty() - findorder2.getMixQty() ?
// findorder2.getQty() - findorder2.getMixQty() : findorder1.getQty() - findorder1.getMixQty();
//
// if (findorder1MixNumber < 1 || findorder2MixNumber < 1) {
// //有一个有无限数量或者两个都是无限数量的情况
// if (findorder1MixNumber + findorder2MixNumber <= 0) {
// //两个都是无限数量,此时取最小的数量
// nowMixQty = mixqty;
// } else if (findorder1MixNumber > 1) { //表明2号食品无限制,1号食品有限制
// //食品1有限制数量:
// // 食品1总数量-碰餐1数量即剩下的数量大于MixNumber,取最小的剩余数量。
// // 小于
// nowMixQty = mixqty > findorder1MixNumber ? findorder1MixNumber : mixqty;
// } else { //2号食品有限制 1号食品无限制
// nowMixQty = mixqty > findorder2MixNumber ? findorder2MixNumber : mixqty;
// }
//
// } else {
// //两个都有限制,取最小值
// if (findorder1MixNumber > findorder2MixNumber) {
// nowMixQty = mixqty > findorder2MixNumber ? findorder2MixNumber : mixqty;
// } else {
// nowMixQty = mixqty > findorder1MixNumber ? findorder1MixNumber : mixqty;
// }
// }
//
// int mixQty1 = findorder1.getMixQty();
// findorder1.setMixQty(mixQty1 + nowMixQty);
//
// double GROUP1Price = mcgd.getGROUP1Price();
// if (GROUP1Price > findorder1.getFamount_price_sign()) {
// //碰餐金額大於 食品總金額,直接減去原因金額
// GROUP1Price = findorder1.getFamount_price_sign();
// }
// findorder1.setMixGroupDiscPrice(findorder1.getMixGroupDiscPrice() + GROUP1Price * nowMixQty);
// findorder1.setMixGroupID(mcgd.getGROUPID1());
// findorder1.setMixDesc1(mcgd.getDesc1());
// findorder1.setMixDesc2(mcgd.getDesc2());
// findorder1.setMixDesc3(mcgd.getDesc3());
//
// double GROUP2Price = mcgd.getGROUP2Price();
// if (GROUP2Price > findorder2.getFamount_price_sign()) {
// //碰餐金額大於 食品總金額,直接減去原因金額
// GROUP2Price = findorder2.getFamount_price_sign();
// }
//
// int mixQty2 = findorder2.getMixQty();
// findorder2.setMixQty(mixQty2 + nowMixQty);
//// findorder2.setMixGroupDiscPrice(findorder2.getMixGroupDiscPrice() + mcgd.getGROUP2Price() * nowMixQty);
// findorder2.setMixGroupDiscPrice(findorder2.getMixGroupDiscPrice() + GROUP2Price * nowMixQty);
// findorder2.setMixGroupID(mcgd.getGROUPID2());
// findorder2.setMixDesc1(mcgd.getDesc1());
// findorder2.setMixDesc2(mcgd.getDesc2());
// findorder2.setMixDesc3(mcgd.getDesc3());
// }
// }
// }
// db_maxgroup.closeDb();
// }
//
// //2:更新各项数据
// for (OrderDetail.DatasBean order : orderFoodList) {
// if (order.getItemtype() != 1) {
// continue;
// }
// if (!order.isIsfood()) {
// continue;
// }
// if (order.getQty() <= 0) {
// continue;
// }
// if (order.getOrder_detail_id() > -1) {//是已经保存过的
// MixOldOrder moo = new MixOldOrder();
// moo.Mix_DETAIL_ID = order.getMix_DETAIL_ID();
// moo.Mixqty = order.getMixQty();
// moo.ORDER_DETAIL_ID = order.getOrder_detail_id();
// moo.MixDesc1 = order.getMixDesc1();
// moo.MixDesc2 = order.getMixDesc2();
// moo.MixDesc3 = order.getMixDesc3();
// moo.MixGroupDiscPrice = order.getMixGroupDiscPrice();
// moo.MixGroupID = order.getMixGroupID();
// MixOldOrders.add(moo);
// }
// }
// for (OrderDetail.DatasBean order : orderFoodList) {
// int fnumber = order.getQty();
// double famount_price_sign = 0.0;
// if (!order.isnew) {
// famount_price_sign = order.Famount_price_sign / fnumber;
// } else {
// famount_price_sign = order.Famount_price_sign;
// }
// double mixGroupDiscPrice = order.getMixGroupDiscPrice();
// double amount_price = famount_price_sign * fnumber - Math.abs(mixGroupDiscPrice);
// if (amount_price < 0 && order.getDiscount_id() == 0) {
// //排除掉折扣,食品金额不能为负数
// order.setAmount_price(0);
// } else {
// if (order.getDiscount_id() != 0) {
// updateDiscoutMoney(order);
// } else {
// order.setAmount_price(amount_price);
// }
// }
//
// LogUtil.d("mix_detail_id: " + order.getMix_DETAIL_ID() + " amount_price: " + order.getAmount_price());
// }
// return true;
// }
// /**
// * 更新折扣金額
// *
// * @param order
// */
// public void updateDiscoutMoney(OrderDetail.DatasBean order) {
// DiscountTypeAndOrderPay.DatasBean discountBean = order.getDiscountTypeAndOrderPayBean();
// if (discountBean != null) {
// discountBean.setSelPostion(selectMealAdapter.getSelect_position());
// discountBean.setSelEndPostion(selectMealAdapter.getSelect_end_position());
// discountBean.setSelStartPostion(selectMealAdapter.getSelect_start_position());
// discountBean.setSelMainStartPositon(selectMealAdapter.getMainStartPos());
// discountBean.setSelMainEnnPostion(selectMealAdapter.getMainEndPos());
// discountBean.setSelect_Full_start_position(selectMealAdapter.getSelect_full_start_position());
// discountBean.setSelect_Full_end_position(selectMealAdapter.getSelect_full_end_position());
// discountBean.setUpdateDiscoutMoney(true);
// double discountMoney = discountBean.Add_menu_postion(orderFoodList, context);
// order.setAmount_price(discountMoney);
// }
// }
// public boolean hasMixFood() {
// for (int i = 0; i < orderFoodList.size(); i++) {
// OrderDetail.DatasBean datasBean = orderFoodList.get(i);
// if (datasBean.getMixGroupID() > 0) {
// return true;
// }
// }
// return false;
// }
// public void get_max_seqno() {
// int i = 1;
// for (OrderDetail.DatasBean myorder : orderFoodList) {
// if (myorder.getItemtype() == 1) {
// i = i + 1;
// }
// }
// seqno = i;
// }
//
// private int get_sseq() {
// int i = 0;
// if (orderFoodList == null) {
// return i;
// }
// for (OrderDetail.DatasBean myorder : orderFoodList) {
// if (myorder.getSeqno() == seqno && myorder.getItemtype() == 2) {
// i = i + 1;
// }
// }
// return i;
// }
//
// private int get_mseq(int isseq) {
// int i = 0;
// if (orderFoodList == null) {
// return i;
// }
// for (OrderDetail.DatasBean myorder : orderFoodList) {
// if (myorder.getSeqno() == seqno && myorder.getSseq() == isseq && myorder.getItemtype() == 3) {
// i = i + 1;
// }
// }
// return i;
// }
//
// public void no_select() {
// for (int i = 0; i < orderFoodList.size(); i++) {
// orderFoodList.get(i).selected = 0;
// }
// }
//
// public DatasBean getCurrentOrderFood() {
// if (getSize() == 0) {
// return null;
// }
// if (selpostion < orderFoodList.size()) {
// return orderFoodList.get(selpostion);
// } else {
// return orderFoodList.get(orderFoodList.size() - 1);
// }
// }
//
// private int getCountNumber(String fid) {
// int number = 0;
// for (OrderDetail.DatasBean or : orderFoodList) {
// if (or.getItemno().equals(fid)) {
// number = number + or.newnumber;
// }
// }
// return number;
// }
//
/**
* 设置所有价格相关字段数据
* Qty、Itemtype、Itemno、Advprice、MixGroupDiscPrice字段需提前设置值
*
* @param datasBean
* @param isFuncmoney
* @param Money
*/
public void setCalculatePrice(OrderDetail.DatasBean datasBean, boolean isFuncmoney, double Money) {
double money = 0.00;
if (datasBean.getItemtype() == 1 && isFuncmoney == false && datasBean.getAdvprice() != 2) {
// money = getMoney(datasBean.getItemno(), datasBean.getQty(), 0, new Date());
} else {
money = Money;
datasBean.manualMoney = money;
datasBean.isManualMoney = true;
}
datasBean.setUnitprice(MoneyUtil.get_ItemDecimals_money(money));
datasBean.setAmount_price(money * datasBean.getQty() - Math.abs(datasBean.getMixGroupDiscPrice()));
datasBean.setFamount_price_sign(money);
}
// /**
// * 主食品转换
// *
// * @param datasBean
// * @return
// */
// public OrderDetail.DatasBean orderConvertOrderDetail(Food datasBean, int Qty, boolean isFuncmoney) {
// OrderDetail.DatasBean orderDetail = new OrderDetail.DatasBean();
// orderDetail.setDesc1(datasBean.getFoodName());
// orderDetail.setDesc2(datasBean.getFoodName());
// orderDetail.setDesc3(datasBean.getFoodName());
// orderDetail.setName(datasBean.getFoodName());
// orderDetail.setItemno(datasBean.getId()+"");
// orderDetail.setFTID(datasBean.getTopID());
// orderDetail.setIsfood(true);
// orderDetail.setIsnew(true);
// orderDetail.setQty(Qty);
// orderDetail.setNewnumber(Qty);
// orderDetail.setItemtype(1);
// orderDetail.setProp("food");
// orderDetail.setModid("");
// orderDetail.setUser_Qty(datasBean.getOR_Qty());
// orderDetail.setPointsadd(datasBean.getPointsAdd());
// orderDetail.setPointsRedeem(datasBean.getPointsRedeem());
// orderDetail.setPointsrote(datasBean.getPointsRatio());
// orderDetail.setD_able(datasBean.isAblediscount());
// orderDetail.setSc_able(datasBean.isServercharge());
// orderDetail.setAutomod(datasBean.isAutoMod() ? 1 : 0);
// orderDetail.setAdvprice(datasBean.getAdvPrice());
// orderDetail.setUnit_id(datasBean.getUnit_id());
// orderDetail.setFuncmoney(isFuncmoney);
//
// setCalculatePrice(orderDetail, isFuncmoney, datasBean.getPrice());
//
// //设置seq
// sseq = get_sseq();
// mseq = get_mseq(sseq);
// orderDetail.setSeqno(seqno);
// orderDetail.setSseq(sseq);
// orderDetail.setMseq(mseq);
//
// int comboLevel = datasBean.isComboFood() ? 1 : 0;
// orderDetail.setComboLevel(comboLevel);
// orderDetail.setSelected(2);
// return orderDetail;
// }
//
// /**
// * 子食品转换
// *
// * @param datasBean
// * @param prop
// * @return
// */
// public OrderDetail.DatasBean comboConvertOrderDetail(ComboItem.DatasBean datasBean, String prop) {
// OrderDetail.DatasBean orderDetail = new OrderDetail.DatasBean();
// orderDetail.setDesc1(datasBean.getDesc1());
// orderDetail.setDesc2(datasBean.getDesc2());
// orderDetail.setDesc3(datasBean.getDesc3());
// orderDetail.setItemno(datasBean.getFID());
// orderDetail.setFTID(datasBean.getFID());
// orderDetail.setComid(datasBean.getComID());
// orderDetail.setIsfood(true);
// orderDetail.setIsnew(true);
// orderDetail.setQty(datasBean.getQty());
// orderDetail.setNewnumber(datasBean.getQty());
// orderDetail.setItemtype(2);
// orderDetail.setD_able(datasBean.isAblediscount());
// orderDetail.setComboAuto(datasBean.isAutomode());
// if (prop.equals("comboitem_auto")) {
// orderDetail.isComboAuto = true;
// }
// orderDetail.ComboLevel = 2;
// orderDetail.limitQty = datasBean.getQty();
// orderDetail.setProp(prop);
//
// int order_detail_id = -1;
// if (MyOrderManage.getInstance().getCurrentOrderFood() != null) {
// order_detail_id = MyOrderManage.getInstance().getCurrentOrderFood().getOrder_detail_id();
// }
// orderDetail.setOrder_detail_id(order_detail_id);
//
// setCalculatePrice(orderDetail, false, datasBean.getDiffAmt());
//
// //设置seq
// sseq = get_sseq();
// mseq = get_mseq(sseq);
// orderDetail.setSeqno(seqno);
// orderDetail.setSseq(sseq);
// orderDetail.setMseq(mseq);
//
// if (presenter.isRvMealClicked()) {
// //手动点击细项 才将子食品作为主体被选中
// orderDetail.setSelected(2);
// } else {
// orderDetail.setSelected(1);
// }
// return orderDetail;
// }
//
// public OrderDetail.DatasBean modifierConvertOrderDetail(Modifier.DatasBean datasBean) {
// OrderDetail.DatasBean orderDetail = new OrderDetail.DatasBean();
// orderDetail.setDesc1(datasBean.getDesc1());
// orderDetail.setDesc2(datasBean.getDesc2());
// orderDetail.setDesc3(datasBean.getDesc3());
// orderDetail.setName(datasBean.getName());
//// orderDetail.setItemno(datasBean.getFid());
// orderDetail.setItemno(datasBean.getMID());
// orderDetail.setFTID(datasBean.getTopID());
// orderDetail.setIsfood(false);
// orderDetail.setIsnew(true);
// orderDetail.setQty(1);
// orderDetail.setNewnumber(1);
// orderDetail.setItemtype(3);
// orderDetail.setProp("modifify");
// orderDetail.setModid(datasBean.getMID());
// orderDetail.setUser_Qty(datasBean.getOR_Qty());
// orderDetail.setD_able(datasBean.isAblediscount());
//
// int order_detail_id = -1;
// if (MyOrderManage.getInstance().getCurrentOrderFood() != null) {
// order_detail_id = MyOrderManage.getInstance().getCurrentOrderFood().getOrder_detail_id();
// }
// orderDetail.setOrder_detail_id(order_detail_id);
//
// setCalculatePrice(orderDetail, false, datasBean.getPrice());
//
// //手动点击细项 才将子食品作为主体被选中
// orderDetail.setSelected(2);
//
// return orderDetail;
// }
//
// public OrderDetail.DatasBean MyButtonMealModifDetailConvertOrderDetail(MyButtonMealModifDetail datasBean) {
// OrderDetail.DatasBean orderDetail = new OrderDetail.DatasBean();
// orderDetail.setDesc1(datasBean.name1);
// orderDetail.setDesc2(datasBean.name2);
// orderDetail.setDesc3(datasBean.name3);
// orderDetail.setItemno(datasBean.mid);
// orderDetail.setItemNo(datasBean.parentid);
// orderDetail.setFTID(datasBean.topid);
// orderDetail.setIsfood(false);
// orderDetail.setIsnew(true);
// orderDetail.setQty(1);
// orderDetail.setNewnumber(1);
// orderDetail.setItemtype(3);
// orderDetail.setProp("modifify_modalkeyboard");
// orderDetail.setModid(datasBean.mid);
// orderDetail.setD_able(datasBean.ablediscount);
//
// int order_detail_id = -1;
// if (MyOrderManage.getInstance().getCurrentOrderFood() != null) {
// order_detail_id = MyOrderManage.getInstance().getCurrentOrderFood().getOrder_detail_id();
// }
// orderDetail.setOrder_detail_id(order_detail_id);
//
//// orderDetail.setOrder_detail_id(datasBean.order_detail_id);
//
// setCalculatePrice(orderDetail, false, datasBean.money);
//
// //设置seq
// sseq = get_sseq();
// mseq = get_mseq(sseq);
// orderDetail.setSeqno(seqno);
// orderDetail.setSseq(sseq);
// orderDetail.setMseq(mseq);
//
//// if (datasBean.name1.length() > 0) {
//// orderDetail.setUnit_id(datasBean.order_detail_id);
//// add_menu_bmd(bmd_advpriceIs2, bmd_advpriceIs2.get_Fname() + "(" + Title.trim() + ")", money, unitid);
//// }
// return orderDetail;
// }
//
// public MyButtonMealModifDetail modifierConvertMyButtonMealModifDetail(Modifier.DatasBean datasBean) {
// MyButtonMealModifDetail buttonMealModifDetail = new MyButtonMealModifDetail(context, GSAApplication.androidSetting.getOrderNumberChildShowSize(), GSAApplication.androidSetting.getOrderNumberChildFontSize());
// buttonMealModifDetail.name1 = datasBean.getDesc1();
// buttonMealModifDetail.name2 = datasBean.getDesc2();
// buttonMealModifDetail.name3 = datasBean.getDesc3();
// buttonMealModifDetail.maxQty = datasBean.getMaxqty();
// buttonMealModifDetail.minQty = datasBean.getMinqty();
// buttonMealModifDetail.mid = datasBean.getMID();
// buttonMealModifDetail.money = datasBean.getPrice();
//
// buttonMealModifDetail.set_Fname(AndroidSettingUtils.getDataLanguage(datasBean.getDesc1(), datasBean.getDesc2(), datasBean.getDesc3()));
// buttonMealModifDetail.topid = datasBean.getTopID();
// buttonMealModifDetail.isParent = datasBean.isParent() ? 1 : 0;
// buttonMealModifDetail.parentid = datasBean.getFid();
// buttonMealModifDetail.mod_Comm = datasBean.isMod_comm() ? 1 : 0;
// buttonMealModifDetail.mod_msg = datasBean.isMod_msg() ? 1 : 0;
// buttonMealModifDetail.multiple = datasBean.isMod_taste() ? 1 : 0;
// buttonMealModifDetail.visible = datasBean.isVisible() ? 1 : 0;
// buttonMealModifDetail.ModKeyboard = datasBean.isModKeyboard();
// buttonMealModifDetail.ablediscount = datasBean.isAblediscount();
// int order_detail_id = -1;
// if (MyOrderManage.getInstance().getCurrentOrderFood() != null) {
// order_detail_id = MyOrderManage.getInstance().getCurrentOrderFood().getOrder_detail_id();
// }
// buttonMealModifDetail.order_detail_id = order_detail_id;
//
// return buttonMealModifDetail;
// }
//
// public Modifier.DatasBean MyButtonMealModifDetailConvertModifier(MyButtonMealModifDetail datasBean) {
//
// Modifier.DatasBean modifier = new Modifier.DatasBean();
// modifier.setDesc1(datasBean.name1);
// modifier.setDesc2(datasBean.name2);
// modifier.setDesc3(datasBean.name3);
// modifier.setMaxqty(datasBean.maxQty);
// modifier.setMinqty(datasBean.minQty);
// modifier.setMID(datasBean.mid);
// modifier.setPrice(datasBean.money);
//
// modifier.setTopID(datasBean.topid);
// modifier.setIsParent(datasBean.isParent == 1 ? true : false);
// modifier.setFid(datasBean.parentid);
// modifier.setMod_comm(datasBean.mod_Comm == 1 ? true : false);
// modifier.setMod_msg(datasBean.mod_msg == 1 ? true : false);
//
// modifier.setMultiple(datasBean.multiple);
// modifier.setVisible(datasBean.visible == 1 ? true : false);
// modifier.setModKeyboard(datasBean.ModKeyboard);
// modifier.setAblediscount(datasBean.ablediscount);
//
// return modifier;
// }
//
// public double getMoney(String fid, int number, int unit, Date needCalcdate) {
// double money = 0.00;
// Db_Food_Price dfp = new Db_Food_Price(context);
// money = dfp.getMoney(fid, unit, number, needCalcdate);
// dfp.closeDb();
// return money;
// }
public int getSize() {
return orderFoodList != null ? orderFoodList.size() : 0;
}
public void close() {
if (orderFoodList != null) {
orderFoodList.clear();
}
// if (comboOrders != null) {
// comboOrders.clear();
// }
// if (MixOldOrders != null) {
// MixOldOrders.clear();
// }
// if (mixComboGroup_Discounts != null) {
// mixComboGroup_Discounts.clear();
// }
//
// if (MixComboGroups != null) {
// MixComboGroups.clear();
// }
// allowAddAutoDiscount = false;
// MixComboGroups = null;
}
public void clear() {
if (orderFoodList != null) {
orderFoodList.clear();
}
}
public boolean isOverMaxQty() {
return overMaxQty;
}
public void setOverMaxQty(boolean overMaxQty) {
this.overMaxQty = overMaxQty;
}
public int getLanguageindex() {
return Languageindex;
}
public void setLanguageindex(int languageindex) {
Languageindex = languageindex;
}
public boolean isEdit_Send() {
return Edit_Send;
}
public void setEdit_Send(boolean edit_Send) {
Edit_Send = edit_Send;
}
public int getSelpostion() {
return selpostion;
}
public void setSelpostion(int selpostion) {
this.selpostion = selpostion;
}
public int getSelstartpostion() {
return selstartpostion;
}
public void setSelstartpostion(int selstartpostion) {
this.selstartpostion = selstartpostion;
}
public int getSelendpostion() {
return selendpostion;
}
public void setSelendpostion(int selendpostion) {
this.selendpostion = selendpostion;
}
public int getSelmainstartpositon() {
return selmainstartpositon;
}
public void setSelmainstartpositon(int selmainstartpositon) {
this.selmainstartpositon = selmainstartpositon;
}
public int getSelmainendpostion() {
return selmainendpostion;
}
public void setSelmainendpostion(int selmainendpostion) {
this.selmainendpostion = selmainendpostion;
}
public int getSelect_Full_start_position() {
return select_Full_start_position;
}
public void setSelect_Full_start_position(int select_Full_start_position) {
this.select_Full_start_position = select_Full_start_position;
}
public int getSelect_Full_end_position() {
return select_Full_end_position;
}
public void setSelect_Full_end_position(int select_Full_end_position) {
this.select_Full_end_position = select_Full_end_position;
}
public int getSeqno() {
return seqno;
}
public void setSeqno(int seqno) {
this.seqno = seqno;
}
public int getSseq() {
return sseq;
}
public void setSseq(int sseq) {
this.sseq = sseq;
}
public int getMseq() {
return mseq;
}
public void setMseq(int mseq) {
this.mseq = mseq;
}
public List<Food> getOrderFoodList() {
return orderFoodList;
}
public void setOrderFoodList(List<Food> orderFoodList) {
this.orderFoodList = orderFoodList;
}
//
// public List<DatasBean> getComboOrders() {
// return comboOrders;
// }
//
// public void setComboOrders(List<DatasBean> comboOrders) {
// this.comboOrders = comboOrders;
// }
//
// public List<MixOldOrder> getMixOldOrders() {
// return MixOldOrders;
// }
//
// public void setMixOldOrders(List<MixOldOrder> mixOldOrders) {
// MixOldOrders = mixOldOrders;
// }
//
// public List<MixComboGroupDiscount.DatasBean> getMixComboGroup_Discounts() {
// return mixComboGroup_Discounts;
// }
//
// public void setMixComboGroup_Discounts(List<MixComboGroupDiscount.DatasBean> mixComboGroup_Discounts) {
// this.mixComboGroup_Discounts = mixComboGroup_Discounts;
// }
//
// public List<MixComboGroup.DatasBean> getMixComboGroups() {
// return MixComboGroups;
// }
//
// public void setMixComboGroups(List<MixComboGroup.DatasBean> mixComboGroups) {
// MixComboGroups = mixComboGroups;
// }
//
// public void setContext(Activity context) {
// this.context = context;
// }
//
// public void setPresenter(MealStandPresenter presenter) {
// this.presenter = presenter;
// }
//
public void setSelectMealAdapter(SelectMealAdapter selectMealAdapter) {
this.selectMealAdapter = selectMealAdapter;
}
public boolean isAllowAddAutoDiscount() {
return allowAddAutoDiscount;
}
public void setAllowAddAutoDiscount(boolean allowAddAutoDiscount) {
this.allowAddAutoDiscount = allowAddAutoDiscount;
}
}
package com.gingersoft.gsa.cloud.meal.mvp.model.service;
import com.gingersoft.gsa.cloud.base.bean.BaseRespose;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.meal.mvp.model.bean.request.SendOrderRequest;
import java.util.List;
import io.reactivex.Observable;
import me.jessyan.retrofiturlmanager.RetrofitUrlManager;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.POST;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-01-06
* 修订历史:2020-01-06
* 描述:
*/
public interface MealService {
@POST("order/send" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseRespose> sendOrder(@Body List<SendOrderRequest> foods);
@POST("orderDetails/add" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseRespose> addFood(@Body RequestBody requestBody);
@POST("orderDetails/add" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseRespose> loadOrder(@Body RequestBody requestBody);
@POST("orderDetails/delete" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseRespose> deleteFood(@Body RequestBody requestBody);
}
package com.gingersoft.gsa.cloud.meal.mvp.presenter;
import android.app.Application;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.IComponentCallback;
import com.gingersoft.gsa.cloud.base.bean.BaseRespose;
import com.gingersoft.gsa.cloud.base.bean.FoodBean;
import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.utils.FoodDaoUtils;
import com.gingersoft.gsa.cloud.meal.R;
import com.gingersoft.gsa.cloud.meal.mvp.model.bean.request.SendOrderRequest;
import com.gingersoft.gsa.cloud.meal.mvp.model.constant.MealConstant;
import com.gingersoft.gsa.cloud.meal.mvp.model.manage.MyOrderManage;
import com.gingersoft.gsa.cloud.base.utils.ViewUtils;
import com.gingersoft.gsa.cloud.meal.mvp.model.bean.OrderDetail;
import com.gingersoft.gsa.cloud.meal.mvp.ui.activity.MealStandActivity;
import com.gingersoft.gsa.cloud.meal.mvp.ui.adapter.meal.FoodAdapter;
import com.gingersoft.gsa.cloud.meal.mvp.ui.adapter.meal.FoodGroupAdapter;
import com.gingersoft.gsa.cloud.meal.mvp.ui.adapter.meal.SelectMealAdapter;
import com.jess.arms.integration.AppManager;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.http.imageloader.ImageLoader;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import okhttp3.FormBody;
import okhttp3.Request;
import okhttp3.RequestBody;
import javax.inject.Inject;
import com.gingersoft.gsa.cloud.meal.mvp.contract.MealStandContract;
import com.jess.arms.utils.RxLifecycleUtils;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 12/27/2019 19:17
* <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>
* ================================================
*/
@ActivityScope
public class MealStandPresenter extends BasePresenter<MealStandContract.Model, MealStandContract.View> {
@Inject
RxErrorHandler mErrorHandler;
@Inject
Application mApplication;
@Inject
ImageLoader mImageLoader;
@Inject
AppManager mAppManager;
private MealStandActivity IActivity;
//订单数据管理类
private MyOrderManage myOrderManage;
private SelectMealAdapter mSelectMealAdapter;
private FoodAdapter mFoodAdapter;
//当前选择的食品数据
// private SparseArray<OrderDetail.DatasBean> getOrderFoodLists() = new SparseArray<>();
//食品种类数据
private List<Food> mFoodGroupList = new ArrayList<>();
//食品数据
private List<Food> mFoodList = new ArrayList<>();
private boolean RvMealClicked;
@Inject
public MealStandPresenter(MealStandContract.Model model, MealStandContract.View rootView) {
super(model, rootView);
this.IActivity = (MealStandActivity) rootView;
myOrderManage = MyOrderManage.getInstance();
}
@Override
public void onDestroy() {
super.onDestroy();
this.mErrorHandler = null;
this.mAppManager = null;
this.mImageLoader = null;
this.mApplication = null;
}
public void initOrderBefore() {
// 无帐单号
// if (GSAApplication.tableContract.getOrderid() == -1) {
// if (GSAApplication.androidSetting.isOrder_InputPax()) {
// // 选择人数
// mRootView.showChoosePeopleNumDialog(false);
// }
// //设置开台时间
// GSAApplication.tableContract.setDt_createtime(new Date());
// }
// if (GSAApplication.tableContract.getMember() != null) {
// GSAApplication.tableContract.setMember(null);
// }
//获取订单数据
// loadOrderList(GSAApplication.tableContract.getOrderid(), false);
}
public void initMealData() {
List<Food> foodGroupList = mModel.queryDB_FoodGroupList();
if (foodGroupList != null && foodGroupList.size() > 0) {
IActivity.initFoodGroupView(foodGroupList);
changedMealByParentId(foodGroupList.get(0).getId());
}
}
public void initAdapter() {
if (mSelectMealAdapter == null) {
mSelectMealAdapter = new SelectMealAdapter(IActivity, myOrderManage.getOrderFoodList(), this);
mRootView.setSelectFoodAdapter(mSelectMealAdapter);
}
myOrderManage.setSelectMealAdapter(mSelectMealAdapter);
if (mFoodAdapter == null) {
mFoodAdapter = new FoodAdapter(IActivity, mFoodList);
mRootView.setFoodAdapter(mFoodAdapter);
}
}
public void initItemClickListener() {
mSelectMealAdapter.setOnItemClickListener(new SelectMealAdapter.OnItemClickListener() {
@Override
public void onItemClick(Food datasBean, int position) {
mRootView.recordOperat(true);
RvMealClicked = true;
}
});
mFoodAdapter.setOnItemClickListener(new FoodAdapter.OnItemClickListener() {
@Override
public void onItemClick(Food datasBean, int position) {
mRootView.recordOperat(true);
if (!foodConditionFilter(datasBean)) {
return;
}
RvMealClicked = false;
datasBean.setNumber(1);
mSelectMealAdapter.addFoodItem(datasBean);
}
});
}
public void loadOrder(String account, String pwd) {
RequestBody requestBody = new FormBody.Builder()
.add("userName", account.trim() + "")
.add("passWord", pwd.trim() + "")
.build();
mModel.loadOrder(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(""))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseRespose>(mErrorHandler) {
@Override
public void onNext(@NonNull BaseRespose info) {
if (info != null && info.isSuccess()) {
} else {
}
}
});
}
public void sendOrder() {
List<SendOrderRequest> foods = getSendOrderRequest(getOrderFoodLists());
mModel.sendOrder(foods)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(""))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseRespose>(mErrorHandler) {
@Override
public void onNext(@NonNull BaseRespose info) {
if (info != null && info.isSuccess()) {
mRootView.showMessage("送單成功");
} else {
mRootView.showMessage("送單失敗");
}
}
});
}
public void addOrderFood(String account, String pwd) {
RequestBody requestBody = new FormBody.Builder()
.add("userName", account.trim() + "")
.add("passWord", pwd.trim() + "")
.build();
mModel.addFood(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(""))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseRespose>(mErrorHandler) {
@Override
public void onNext(@NonNull BaseRespose info) {
if (info != null && info.isSuccess()) {
mRootView.showMessage("送單成功");
} else {
mRootView.showMessage("送單失敗");
}
}
});
}
public void deleteFood(long id) {
RequestBody requestBody = new FormBody.Builder()
.add("id", id + "")
.build();
mModel.deleteFood(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(""))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseRespose>(mErrorHandler) {
@Override
public void onNext(@NonNull BaseRespose info) {
if (info != null && info.isSuccess()) {
mRootView.showMessage("刪除成功");
} else {
mRootView.showMessage("刪除失敗");
}
}
});
}
private void deleteWithOrderedFoodById(Long id) {
QMUIDialog.MessageDialogBuilder dialogBuilder = new QMUIDialog.MessageDialogBuilder(IActivity);
dialogBuilder.setTitle("溫馨提示");
dialogBuilder.setMessage("是否確認刪除該食品?");
dialogBuilder.addAction("取消", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
dialog.dismiss();
deleteFood(id);
}
});
dialogBuilder.addAction(0, "確認", QMUIDialogAction.ACTION_PROP_NEGATIVE, new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
dialog.dismiss();
}
});
dialogBuilder.create(R.style.QMUI_Dialog).show();
}
/**
* 刪除食品
*
* @param deleteStyle 1=點擊刪除、2=長按刪除
*/
public void deleteFoodItem(int deleteStyle) {
Food deleteFood = getOrderFoodLists().get(mSelectMealAdapter.getSelect_position());
if (!deleteFood.isNew()) {
//TODO 刪除已下單食品
deleteWithOrderedFoodById(deleteFood.getId());
} else {
if (deleteStyle == 2) {
mSelectMealAdapter.removeAllNewFoodItem();
} else {
mSelectMealAdapter.removeFoodItem();
}
}
}
public void changedMealByParentId(long parentId) {
List<Food> foodList = mModel.queryDB_FoodList(parentId);
if (foodList != null) {
mFoodList.clear();
mFoodList.addAll(foodList);
//根据Item个数显示每一行的个数
mRootView.setFoodRecycleSpanCount(mFoodList.size());
mFoodAdapter.notifyDataSetChanged();
}
mRootView.showViewModeVisibility(MealConstant.food_ViewMode, MealConstant.food_group_ViewMode);
}
/**
* 设置当前食品还可最多选几份
*
* @param foodBean
*/
public boolean setUserMaxQty(Food foodBean) {
int currentSelectNumber = 0;
for (int i = 0; i < getOrderFoodLists().size(); i++) {
Food orderFood = getOrderFoodLists().get(i);
if (orderFood.getId() == foodBean.getId()) {
currentSelectNumber += orderFood.getNumber();
}
}
// String User_Qty = foodBean.getOR_Qty();
// if (!User_Qty.equals("") && !User_Qty.equals("售罄") && !User_Qty.equals("暫停")) {
// int maxQty = Integer.parseInt(User_Qty);
// if (maxQty > 0) {
// int Currrent_OR__Qty = maxQty - currentSelectNumber;
// if (Currrent_OR__Qty < 1) {
// foodBean.setCurrrent_OR_Qty("售罄");
// return false;
// } else {
// foodBean.setCurrrent_OR_Qty(Currrent_OR__Qty + "");
// }
// }
// }
return true;
}
/**
* 添加食品条件过滤
* 1:售罄、最大选择数
* 2:是否需要会员积分
* 3:
*/
public boolean foodGroupConditionFilter(Food foodBean, boolean init) {
if (init) {
return true;
}
// String User_Qty = foodBean.getOR_Qty();
// if (!TextUtils.isEmpty(User_Qty)) {
// TitleDialog.showTitledialog(IActivity, foodBean.getName()
// + LanguageUtils.get_language_system(IActivity, "Comm.pause", "已暫停(Comm.pause)"),
// "", LanguageUtils.get_language_system(IActivity, "comm.ok", "ok(comm.ok)"), "", null);
// return false;
// }
return true;
}
private boolean foodConditionFilter(Food foodBean) {
int isSold = foodBean.getIsSold();
if (isSold == 1) {
new QMUITipDialog.Builder(IActivity)
.setTipWord("已售罄(Comm.sold)")
.create(true);
return false;
}
// String User_Qty = foodBean.getCurrrent_OR_Qty();
//
// if (!TextUtils.isEmpty(User_Qty)) {
// if (User_Qty.equals("售罄") || User_Qty.equals("暫停")) {
// TitleDialog.showTitledialog(IActivity, foodBean.getName()
// + LanguageUtils.get_language_system(IActivity, "Comm.pause", "已暫停(Comm.pause)"),
// "", LanguageUtils.get_language_system(IActivity, "comm.ok", "ok(comm.ok)"), "", null);
// return false;
// }
// }
//
// if (GSAApplication.tableContract.getMember() == null) {
// //当前食品需要会员积分
// if (foodBean.getPointsRedeem() > 0) {
// mRootView.showMessage(LanguageUtils.get_language_system(mApplication, "unused_members_can.not.order.food", "積分食品,未使用會員,不可點選") + "\"" + foodBean.getName() + "\"");
// return false;
// }
// } else {
// if (GSAApplication.tableContract.getMember().getDatas() != null) {
// //如果没有会员,则pointsadd=5是加5分 pointsredeem=5是減5分
// //當一張臺號沒有會員登錄時判定積分為0 不能為負數
// // 此時call pointsredeem=5 的食物 不給過
// //點選pointsadd=5的食物 0+5 是正數 這個給過
// if (foodBean.getPointsRedeem() > 0 && GSAApplication.tableContract.getMember().getDatas().getData().getMemberPoint() < foodBean.getPointsRedeem()) {
// mRootView.showMessage(LanguageUtils.get_language_system(mApplication, "insufficient.points.can.not.selected", "積分食品,會員積分不足,不可點選") + "\"" + foodBean.getName() + "\"");
// return false;
// }
// }
// }
return true;
}
/**
* @return
*/
private boolean isCreateOrder() {
for (int i = 0; i < getOrderFoodLists().size(); i++) {
Food orderFood = getOrderFoodLists().get(i);
if (!orderFood.isNew())
return false;
}
return true;
}
private List<SendOrderRequest> getSendOrderRequest(List<Food> foodList) {
List<SendOrderRequest> sendOrderRequestList = new ArrayList<>();
for (int i = 0; i < foodList.size(); i++) {
Food food = foodList.get(i);
SendOrderRequest request = new SendOrderRequest(food.getId(), food.getFoodName(), food.getPrice(), 0, food.getNumber());
sendOrderRequestList.add(request);
}
return sendOrderRequestList;
}
public Food getOrderFoodById(long id) {
for (int i = 0; i < mFoodList.size(); i++) {
Food foodBean = mFoodList.get(i);
if (id == foodBean.getId()) {
return foodBean;
}
}
return null;
}
public List<Food> getOrderFoodLists() {
return myOrderManage.getOrderFoodList();
}
public boolean isRvMealClicked() {
return RvMealClicked;
}
public void setRvMealClicked(boolean rvMealClicked) {
RvMealClicked = rvMealClicked;
}
}
package com.gingersoft.gsa.cloud.meal.mvp.ui.activity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.SparseArray;
import android.view.View;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.Chronometer;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.utils.VibratorUtils;
import com.gingersoft.gsa.cloud.base.utils.ViewUtils;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.meal.R2;
import com.gingersoft.gsa.cloud.meal.app.GoldConstants;
import com.gingersoft.gsa.cloud.meal.mvp.ui.adapter.meal.MyViewPagerAdapter;
import com.gingersoft.gsa.cloud.meal.di.component.DaggerMealStandComponent;
import com.gingersoft.gsa.cloud.meal.mvp.model.constant.MealConstant;
import com.gingersoft.gsa.cloud.meal.mvp.ui.adapter.HorizontalGridViewAdpter;
import com.gingersoft.gsa.cloud.meal.mvp.ui.widget.ChooseNumberDialog;
import com.gingersoft.gsa.cloud.ui.view.LineGridView;
import com.gingersoft.gsa.cloud.ui.view.PagerSlidingTabStrip;
import com.gingersoft.gsa.cloud.ui.view.RecyclerViewNoBugLinearLayoutManager;
import com.gingersoft.gsa.cloud.ui.view.SearchKeyBoardView;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.gingersoft.gsa.cloud.meal.mvp.contract.MealStandContract;
import com.gingersoft.gsa.cloud.meal.mvp.presenter.MealStandPresenter;
import com.gingersoft.gsa.cloud.meal.R;
import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;
import butterknife.OnClick;
import butterknife.OnLongClick;
import static com.jess.arms.utils.Preconditions.checkNotNull;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 12/27/2019 19:17
* <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 MealStandActivity extends BaseActivity<MealStandPresenter> implements MealStandContract.View {
private SparseArray<View> map = new SparseArray<>();
@BindView(R2.id.ctime)
Chronometer chronometer;
@BindView(R2.id.rv_select_meal)
RecyclerView rv_select_meal;
@BindView(R2.id.ll_food_group)
LinearLayout ll_food_group;
@BindView(R2.id.vp_food_group)
ViewPager vp_food_group;
@BindView(R2.id.ll_food_group_point)
LinearLayout ll_food_group_point;
// @BindView(R2.id.rv_food_group)
// RecyclerView rv_food_group;
@BindView(R2.id.rv_food)
RecyclerView rv_food;
@BindView(R2.id.rv_combo)
RecyclerView rv_combo;
@BindView(R2.id.rv_discount)
RecyclerView rv_discount;
@BindView(R2.id.rl_fine_tabs)
RelativeLayout rl_fine_tabs;
@BindView(R2.id.iv_fine_back)
ImageView iv_fine_back;
@BindView(R2.id.tabs_fine)
PagerSlidingTabStrip tabs_fine;
@BindView(R2.id.pager_fine)
ViewPager pager_fine;
@BindView(R2.id.meal_stand_search_keyboard_view)
SearchKeyBoardView keyView;
@BindView(R2.id.rl_stand_oper)
RelativeLayout rl_stand_oper;
@BindView(R2.id.tv_no_save_return)
TextView tv_no_save_return;
// @BindView(R2.id.tv_send_order)
// TextView tv_send_order;
@BindView(R2.id.fl_order_content)
FrameLayout fl_order_content;
@BindView(R2.id.tv_order_content)
TextView tv_order_content;
@BindView(R2.id.btn_order_count)
Button btn_order_count;
//送单
@BindView(R2.id.fl_send_order)
FrameLayout fl_send_order;
@BindView(R2.id.btn_send_order)
Button btn_send_order;
// @BindView(R2.id.btn_send_order_machine_name)
// TextView btn_send_order_machine_name;
//印单
@BindView(R2.id.fl_printer_order)
FrameLayout fl_printer_order;
@BindView(R2.id.btn_order_printer)
Button btn_order_printer;
@BindView(R2.id.btn_printer_machine_name)
TextView btn_printer_machine_name;
@BindView(R2.id.ll_meals)
LinearLayout ll_meals;
@BindView(R2.id.ll_meals_main)
LinearLayout ll_meals_main;
@BindView(R2.id.ll_mm)
LinearLayout ll_mm;
@BindView(R2.id.btn_table)
Button btn_table;
@BindView(R2.id.btn_numberman)
Button btn_numberman;
@BindView(R2.id.btn_fid)
TextView btn_fid;
// @BindView(R2.id.btn_temporary)
// TextView btn_temporary;
// @BindView(R2.id.btn_meal_discount)
// TextView btn_meal_discount;
@BindView(R2.id.btn_meal_delete)
TextView btn_meal_delete;
// @BindView(R2.id.btn_meal_modify_restore)
// ImageButton btn_meal_modify_restore;
// @BindView(R2.id.btn_change_Language)
// ImageButton btn_change_Language;
// @BindView(R2.id.btn_food_merge)
// ImageButton btn_food_merge;
// @BindView(R2.id.btn_food_mode)
// TextView btn_food_mode;
@BindView(R2.id.ll_Keys)
LinearLayout ll_Keys;
@BindView(R2.id.btn_key0)
Button btn_key0;
@BindView(R2.id.btn_key1)
Button btn_key1;
@BindView(R2.id.btn_key2)
Button btn_key2;
@BindView(R2.id.btn_key3)
Button btn_key3;
@BindView(R2.id.btn_key4)
Button btn_key4;
@BindView(R2.id.btn_keys)
Button btn_keys;
@BindView(R2.id.ll_modify)
LinearLayout ll_modify;
@BindView(R2.id.btn_add_delete)
Button btn_add_delete;
@BindView(R2.id.btn_msg)
Button btn_msg;
@BindView(R2.id.btn_delete)
Button btn_delete;
@BindView(R2.id.btn_end)
Button btn_end;
private ChooseNumberDialog chooseNumberDialog;
private int mCurrentViewMode;
private boolean isPluMode = false;
//小圆点图片的集合
private ImageView[] ivPoints;
//总的页数
private int totalPage;
//每页显示的最大的数量
private int mPageSize = 12;
//GridView作为一个View对象添加到ViewPager集合中
private List<View> viewPagerList;
private int currentSelectPosition;
@Override
public void setupActivityComponent(@NonNull AppComponent appComponent) {
DaggerMealStandComponent //如找不到该类,请编译一下项目
.builder()
.appComponent(appComponent)
.view(this)
.build()
.inject(this);
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public int initView(@Nullable Bundle savedInstanceState) {
return R.layout.meal_activity_meal_stand; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
}
@Override
public void initData(@Nullable Bundle savedInstanceState) {
initViewMap();
//初始化Plu模式
setPluMode();
mPresenter.initAdapter();
mPresenter.initItemClickListener();
//初始化默认食品组
mPresenter.initMealData();
}
public void initFoodGroupView(List<Food> foodGroupList) {
//默認選中第一組
foodGroupList.get(0).setIsSelected(true);
//总的页数向上取整
totalPage = (int) Math.ceil(foodGroupList.size() * 1.0 / mPageSize);
viewPagerList = new ArrayList<>();
for (int i = 0; i < totalPage; i++) {
//每个页面都是inflate出一个新实例
LineGridView gridView = (LineGridView) View.inflate(this, R.layout.meal_food_group_grid, null);
gridView.setNumColumns(6);
HorizontalGridViewAdpter horizontalGridViewAdpter = new HorizontalGridViewAdpter(this, foodGroupList, i, mPageSize);
gridView.setAdapter(horizontalGridViewAdpter);
//添加item点击监听
horizontalGridViewAdpter.setOnItemClickListener(new HorizontalGridViewAdpter.OnItemClickListener() {
@Override
public void onItemClick(Food food, int position) {
recordOperat(true);
if (!ViewUtils.isFastClick2()) {
return;
}
if (!foodGroupConditionFilter(food, false)) {
return;
}
mPresenter.setRvMealClicked(false);
mPresenter.changedMealByParentId(food.getId());
}
});
//每一个GridView作为一个View对象添加到ViewPager集合中
viewPagerList.add(gridView);
}
//设置ViewPager适配器
vp_food_group.setAdapter(new MyViewPagerAdapter(viewPagerList));
//添加小圆点
ivPoints = new ImageView[totalPage];
for (int i = 0; i < totalPage; i++) {
//循坏加入点点图片组
ivPoints[i] = new ImageView(this);
if (i == 0) {
ivPoints[i].setImageResource(R.drawable.meal_food_group_point_focuese);
} else {
ivPoints[i].setImageResource(R.drawable.meal_food_group_point_unfocused);
}
ivPoints[i].setPadding(0, 0, 0, 0);
ll_food_group_point.addView(ivPoints[i]);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) ivPoints[i].getLayoutParams();
layoutParams.height = ll_food_group_point.getLayoutParams().height;
layoutParams.width = ArmsUtils.getScreenWidth(this) / totalPage;
ivPoints[i].setLayoutParams(layoutParams);
}
//设置ViewPager的滑动监听,主要是设置点点的背景颜色的改变
vp_food_group.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
//currentPage = position;
for (int i = 0; i < totalPage; i++) {
if (i == position) {
ivPoints[i].setImageResource(R.drawable.meal_food_group_point_focuese);
} else {
ivPoints[i].setImageResource(R.drawable.meal_food_group_point_unfocused);
}
}
}
});
}
/**
* 添加食品条件过滤
* 1:售罄、最大选择数
*/
public boolean foodGroupConditionFilter(Food foodBean, boolean init) {
if (init) {
return true;
}
int isSold = foodBean.getIsSold();
if (isSold == 1) {
new QMUITipDialog.Builder(this)
.setTipWord("已售罄(Comm.sold)")
.create(true);
return false;
}
return true;
}
@Override
public boolean isInitFineItemLayout() {
return false;
}
@Override
public void initFineItemTabBarViewPage() {
}
@Override
public void showFinePage() {
}
@Override
public void setPluMode() {
isPluMode = (boolean) SPUtils.get(this, MealConstant.EXIT_IS_PLU_MODE, false);
if (isPluMode) {
btn_fid.setBackgroundColor(ArmsUtils.getColor(this, R.color.theme_grey_color));
showViewModeVisibility(MealConstant.ViewMode_keys);
}
}
@Override
public void resetPluMode() {
isPluMode = false;
SPUtils.put(this, MealConstant.EXIT_IS_PLU_MODE, false);
btn_fid.setBackground(ArmsUtils.getDrawablebyResource(this, R.drawable.ui_selector_item_background));
}
@OnLongClick({R2.id.btn_meal_delete,R2.id.btn_order_printer})
public boolean onLongClick1(View view) {
//记录操作 并且震动
recordOperat(true);
switch (view.getId()) {
case R2.id.btn_meal_delete:
mPresenter.deleteFoodItem(3);
break;
case R2.id.btn_order_printer:
break;
}
return false;
}
@OnClick({R2.id.btn_fid, R2.id.btn_meal_delete, R2.id.btn_send_order, R2.id.tv_no_save_return, R2.id.fl_order_content})
public void onClick(View v) {
recordOperat(true);
if (!ViewUtils.isFastClick5()) {
return;
}
switch (v.getId()) {
case R2.id.btn_numberman:
showChoosePeopleNumDialog(true);
break;
case R2.id.btn_fid:
//搜索
if (mCurrentViewMode == MealConstant.ViewMode_keys) {
showViewModeVisibility(MealConstant.food_group_ViewMode, MealConstant.food_ViewMode);
} else {
showViewModeVisibility(MealConstant.ViewMode_keys);
}
break;
case R2.id.btn_meal_delete:
break;
case R2.id.btn_send_order:
mPresenter.sendOrder();
break;
case R2.id.fl_order_content:
break;
case R2.id.tv_no_save_return:
break;
}
}
@Override
public void recordOperat(boolean isPressButtonSound) {
if (isPressButtonSound)
VibratorUtils.pressButtonSound(this);
//关闭倒计时
if (chronometer != null) {
chronometer.stop();
}
//重新开启倒计时
if (chronometer != null) {
chronometer.setBase(SystemClock.elapsedRealtime());
chronometer.start();
}
}
@Override
public void showChoosePeopleNumDialog(boolean isNeedCancel) {
if (chooseNumberDialog == null) {
chooseNumberDialog = new ChooseNumberDialog(this);
chooseNumberDialog.builder();
chooseNumberDialog.setValueHint("請輸入人數");
// mInputNumberDialog2.setTitle(LanguageUtils.get_language_system(this, "Meal.Mannumber", "Number"));
// mInputNumberDialog2.setHeadLayoutVisibility(View.VISIBLE);
if (!isNeedCancel)
chooseNumberDialog.setOnBackClickListener(new ChooseNumberDialog.OnBackClickListener() {
@Override
public void OnBackClick() {
recordOperat(true);
// returnTableOrOrderManagementActivity();
}
});
int backPageBtnVisibility;
if (isNeedCancel) {
backPageBtnVisibility = View.GONE;
} else {
backPageBtnVisibility = View.VISIBLE;
}
// mInputNumberDialog2.setBackPageBtnVisibility(backPageBtnVisibility);
chooseNumberDialog.setOnClickListener(new ChooseNumberDialog.OnClickListener() {
@Override
public void onComfirmClick(String number) {
recordOperat(true);
//选择的人数大于0
if (Integer.parseInt(number) > 0) {
// GSAApplication.tableContract.setMans(Integer.parseInt(number));
// setBtnNumbermanText(LanguageUtils.get_language_system(MealStandActivity.this, "Meal.Mannumber", "Number") + number + "");
}
}
@Override
public void onBackPage() {
// returnTableOrOrderManagementActivity();
}
});
chooseNumberDialog.setCancelable(isNeedCancel);
}
}
@Override
public void setPrinterLocalmachine(boolean isPrint) {
}
@Override
public void setTableInfoDialogAdapter(BaseAdapter adapter) {
}
@Override
public void setSelectFoodAdapter(RecyclerView.Adapter adapter) {
setSelectFoodRecycleLayoutManager();
rv_select_meal.setAdapter(adapter);
}
@Override
public void setFoodGroupAdapter(DefaultAdapter adapter) {
}
@Override
public void setFoodAdapter(DefaultAdapter adapter) {
setFoodRecycleLayoutManager(LinearLayoutManager.VERTICAL);
rv_food.setAdapter(adapter);
}
@Override
public void setComboAdapter(DefaultAdapter adapter) {
}
@Override
public void setDiscountAdapter(DefaultAdapter adapter) {
}
private GridLayoutManager foodRecycleLayoutManager;
@Override
public void setSelectFoodRecycleLayoutManager() {
RecyclerViewNoBugLinearLayoutManager selectFoodRecycleLayoutManager = new RecyclerViewNoBugLinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
rv_select_meal.setLayoutManager(selectFoodRecycleLayoutManager);
rv_select_meal.setItemAnimator(new DefaultItemAnimator());
}
@Override
public void setFoodGroupRecycleLayoutManager(int orientation) {
}
@Override
public void setFoodRecycleLayoutManager(int orientation) {
foodRecycleLayoutManager = new GridLayoutManager(this, 1, orientation, false);
rv_food.setLayoutManager(foodRecycleLayoutManager);
rv_food.setItemAnimator(new DefaultItemAnimator());
}
@Override
public void setComboRecycleLayoutManager(int orientation) {
}
@Override
public void setDiscountRecycleLayoutManager(int orientation) {
}
@Override
public void setFoodGroupRecycleSpanCount(int size) {
}
@Override
public void setFoodRecycleSpanCount(int size) {
if (size > 0) {
if (size > GoldConstants.DetailColCount) {
setFoodRecycleLayoutManager(LinearLayoutManager.VERTICAL);
foodRecycleLayoutManager.setSpanCount(GoldConstants.DetailColCount);
} else {
//只有一行就使用水平显示以免不能占满
setFoodRecycleLayoutManager(LinearLayoutManager.HORIZONTAL);
}
}
}
@Override
public void setComboRecycleSpanCount(int size) {
}
@Override
public void setDiscountRecycleSpanCount(int size) {
}
@Override
public void showViewModeVisibility(int... viewMode) {
//將所有的view隱藏
for (int i = 0; i < map.size(); i++) {
map.valueAt(i).setVisibility(View.INVISIBLE);
}
//設置當前mode為第一個傳入的mode
for (int mode : viewMode) {
this.mCurrentViewMode = mode;
break;
}
//顯示所有傳入的需要顯示的view
for (int mode : viewMode) {
map.get(mode).setVisibility(View.VISIBLE);
}
//設置當前模式為輸入Plu模式
if (viewMode != null && viewMode[0] == MealConstant.ViewMode_keys) {
isPluMode = true;
} else {
isPluMode = false;
}
switch (mCurrentViewMode) {
case MealConstant.food_group_ViewMode:
case MealConstant.food_ViewMode:
showModifyLayoutVisibility(false);
break;
case MealConstant.combo_ViewMode:
case MealConstant.discount_ViewMode:
showModifyLayoutVisibility(true);
break;
}
}
@Override
public void showModifyLayoutVisibility(boolean show) {
if (show) {
ll_modify.setVisibility(View.VISIBLE);
rl_stand_oper.setVisibility(View.INVISIBLE);
} else {
ll_modify.setVisibility(View.INVISIBLE);
rl_stand_oper.setVisibility(View.VISIBLE);
}
}
@Override
public void initIntent() {
}
@Override
public void initTopBar() {
}
@Override
public void initLanguage() {
}
@Override
public void initLayoutParams() {
}
@Override
public void initLayoutVisible() {
}
@Override
public void showLoading(String message) {
}
@Override
public void hideLoading() {
}
@Override
public void showMessage(@NonNull String message) {
checkNotNull(message);
ArmsUtils.snackbarText(message);
}
@Override
public void launchActivity(@NonNull Intent intent) {
checkNotNull(intent);
ArmsUtils.startActivity(intent);
}
@Override
public void killMyself() {
finish();
}
@Override
public Activity getActivity() {
return this;
}
private void initViewMap() {
map.put(MealConstant.food_group_ViewMode, ll_food_group);
map.put(MealConstant.food_ViewMode, rv_food);
map.put(MealConstant.combo_ViewMode, rv_combo);
map.put(MealConstant.discount_ViewMode, rv_discount);
map.put(MealConstant.fine_ViewMode, pager_fine);
map.put(MealConstant.fine_tabs_ViewMode, rl_fine_tabs);
map.put(MealConstant.ViewMode_keys, keyView);
}
}
package com.gingersoft.gsa.cloud.meal.mvp.ui.adapter;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.meal.R;
import com.jess.arms.utils.ArmsUtils;
import java.util.List;
import androidx.recyclerview.widget.GridLayoutManager;
public class HorizontalGridViewAdpter extends BaseAdapter {
private Context context;
private List<Food> lists;//数据源
private int mIndex; // 页数下标,标示第几页,从0开始
private int mPargerSize;// 每页显示的最大的数量
private int currentSelectPosition;
public HorizontalGridViewAdpter(Context context, List<Food> lists, int mIndex, int mPargerSize) {
this.context = context;
this.lists = lists;
this.mIndex = mIndex;
this.mPargerSize = mPargerSize;
}
/**
* 先判断数据及的大小是否显示满本页lists.size() > (mIndex + 1)*mPagerSize
* 如果满足,则此页就显示最大数量lists的个数
* 如果不够显示每页的最大数量,那么剩下几个就显示几个
*/
@Override
public int getCount() {
return lists.size() > (mIndex + 1) * mPargerSize ?
mPargerSize : (lists.size() - mIndex * mPargerSize);
}
@Override
public Food getItem(int arg0) {
return lists.get(arg0 + mIndex * mPargerSize);
}
@Override
public long getItemId(int arg0) {
return arg0 + mIndex * mPargerSize;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
//重新确定position因为拿到的总是数据源,数据源是分页加载到每页的GridView上的
final int pos = position + mIndex * mPargerSize;//假设mPageSiez
Food food = lists.get(pos);
final ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
convertView = View.inflate(context, R.layout.meal_item_name, null);
holder.tv_name = (TextView) convertView.findViewById(R.id.tv_text);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
//假设mPagerSize=8,假如点击的是第二页(即mIndex=1)上的第二个位置item(position=1),那么这个item的实际位置就是pos=9
holder.tv_name.setText(lists.get(pos).getFoodName());
if (food.isSelected()){
holder.tv_name.setBackgroundColor(context.getResources().getColor(R.color.orange_500));
}else {
holder.tv_name.setBackgroundColor(ArmsUtils.getColor(context, R.color.Grass_green));
}
holder.tv_name.setMaxHeight(100);
holder.tv_name.setHeight(ArmsUtils.dip2px(context, 40));
// ViewGroup.LayoutParams layoutParams = (ViewGroup.LayoutParams) holder.tv_name.getLayoutParams();
// layoutParams.height = 40;
// holder.tv_name.setLayoutParams(layoutParams);
holder.tv_name.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Food food = lists.get(pos);
if (currentSelectPosition != pos) {
//设置当前选中item颜色
food.setSelected(true);
if (currentSelectPosition < lists.size()) {
//重置上次选中item的颜色
lists.get(currentSelectPosition).setSelected(false);
}
notifyDataSetChanged();
//保存上次操作的position
currentSelectPosition = pos;
if (mOnItemClickListener != null)
mOnItemClickListener.onItemClick(food, pos);
}
}
});
return convertView;
}
static class ViewHolder {
private TextView tv_name;
}
private OnItemClickListener mOnItemClickListener;
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
mOnItemClickListener = onItemClickListener;
}
public interface OnItemClickListener {
void onItemClick(Food food, int position);
}
}
package com.gingersoft.gsa.cloud.meal.mvp.ui.adapter.meal;
import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.bean.FoodBean;
import com.gingersoft.gsa.cloud.base.utils.ViewUtils;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.meal.R;
import com.gingersoft.gsa.cloud.meal.R2;
import com.jess.arms.base.BaseHolder;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.utils.DeviceUtils;
import java.util.List;
import androidx.recyclerview.widget.GridLayoutManager;
import butterknife.BindView;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2018/6/27
* 修订历史:2018/6/27
* 描述:
*/
public class FoodAdapter extends DefaultAdapter<Food> {
private Context mContext;
private int mOrderNumberShowSize;
private int mOrderNumberFontSize;
private int mFoodFontSize;
private int mColwidth;
private int mColHeight;
private int mLayoutQtyHeight;
private int currentSelectPosition = 0;
private int user_qty;//在进入的的数量
public boolean check_qty = false;//是否检查数理
public FoodAdapter(Context context, List<Food> infos) {
super(infos);
this.mContext = context;
this.mOrderNumberShowSize = 10;
this.mOrderNumberFontSize = 7;
this.mFoodFontSize = 14;
this.mColwidth = (int) ((DeviceUtils.getScreenWidth(context) / 5));
this.mColHeight = 80;
this.mLayoutQtyHeight = 10;
}
@Override
public int getItemCount() {
return mInfos.size();
}
@Override
public BaseHolder<Food> getHolder(View v, int viewType) {
return new FoodItemHolder(v);
}
@Override
public int getLayoutId(int viewType) {
return R.layout.meal_item_food;
}
class FoodItemHolder extends BaseHolder<Food> {
@BindView(R2.id.rl_container)
RelativeLayout rl_container;
@BindView(R2.id.tv_food_name)
TextView tv_food_name;
@BindView(R2.id.tv_number)
TextView tv_number;
@BindView(R2.id.tv_soldout)
TextView tv_soldout;
@BindView(R2.id.iv_qtySold)
ImageView iv_qtySold;
public FoodItemHolder(View itemView) {
super(itemView);
}
@Override
public void setData(Food datasBean, int position) {
setFood(datasBean);
setNumber(datasBean);
setColor(datasBean);
setStatus(datasBean);
setOnItemClickListener(new OnViewClickListener() {
@Override
public void onViewClick(View view, int position) {
if (ViewUtils.isFastClick2()) {
if (currentSelectPosition == 0 || currentSelectPosition != position) {
if (currentSelectPosition < mInfos.size()) {
//重置上次选中item的颜色
mInfos.get(currentSelectPosition).setSelected(false);
notifyItemChanged(currentSelectPosition);
}
//设置当前选中item颜色
datasBean.setSelected(true);
notifyItemChanged(position);
//保存上次操作的position
currentSelectPosition = position;
}
if (mOnItemClickListener != null)
mOnItemClickListener.onItemClick(datasBean, position);
}
}
});
}
public void setFood(Food datasBean) {
// String desc = "";
// switch (GSAApplication.androidSetting.getDataLanguage()) {
// case 1:
// desc = datasBean.getDesc1();
// break;
// case 2:
// desc = datasBean.getDesc2();
// break;
// case 3:
// desc = datasBean.getDesc3();
// break;
// }
// if (desc == null || desc.trim().length() == 0) {
// desc = datasBean.getDesc1();
// }
tv_food_name.setMaxWidth(mColwidth);
tv_food_name.setMinWidth(mColwidth);
tv_food_name.setWidth(mColwidth);
tv_food_name.setText(datasBean.getFoodName());
tv_food_name.setTextSize(mFoodFontSize);
tv_food_name.setHeight(mColHeight);
tv_food_name.setGravity(Gravity.CENTER);
tv_food_name.setSingleLine(false);
GridLayoutManager.LayoutParams lp = (GridLayoutManager.LayoutParams) rl_container.getLayoutParams();
lp.height = mColHeight;
lp.width = mColwidth;
rl_container.setLayoutParams(lp);
}
public void setNumber(Food datasBean) {
ViewGroup.MarginLayoutParams mp = new ViewGroup.MarginLayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); //item的宽高
mp.setMargins(0, 0, 0, 0);//分别是margin_top那四个属性
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(mp);
lp.width = ArmsUtils.dip2px(mContext, 16);
lp.height = ArmsUtils.dip2px(mContext, 16);
tv_number.setLayoutParams(lp);
tv_number.setTextSize(10);
// if (datasBean.getNumber() == 0) {
// tv_number.setVisibility(View.INVISIBLE);
// } else {
// tv_number.setVisibility(View.VISIBLE);
tv_number.setText(datasBean.getNumber() + "");
// }
}
private void setStatus(Food datasBean) {
tv_soldout.setMaxHeight(mOrderNumberShowSize);
tv_soldout.setMinHeight(mOrderNumberShowSize);
tv_soldout.setTextSize(mOrderNumberShowSize);
tv_soldout.setTextColor(android.graphics.Color.parseColor("#000000"));
tv_soldout.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.ui_selector_white_rect));
tv_soldout.setMinWidth(20);
tv_soldout.setTextSize(10);
tv_soldout.setGravity(Gravity.CENTER);
RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(new ViewGroup.MarginLayoutParams(60, 40));
lp2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
lp2.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
tv_soldout.setLayoutParams(lp2);
tv_soldout.setVisibility(View.INVISIBLE);
iv_qtySold.setVisibility(View.INVISIBLE);
int isSold = datasBean.getIsSold();
if (isSold == 1) {
iv_qtySold.setVisibility(View.VISIBLE);
} else {
iv_qtySold.setVisibility(View.INVISIBLE);
}
}
private void setColor(Food datasBean) {
if (datasBean.isSelected()) {
tv_food_name.setBackgroundColor(ArmsUtils.getColor(mContext, R.color.orange_500));
tv_food_name.setTextColor(ArmsUtils.getColor(mContext, R.color.theme_white_color));
} else {
tv_food_name.setBackgroundColor(ArmsUtils.getColor(mContext, R.color.light_blue_500));
tv_food_name.setTextColor(ArmsUtils.getColor(mContext, R.color.theme_white_color));
}
}
}
public int getCurrentSelectPosition() {
return currentSelectPosition;
}
public void setCurrentSelectPosition(int currentSelectPosition) {
this.currentSelectPosition = currentSelectPosition;
}
public int getUser_qty() {
return user_qty;
}
public void setUser_qty(int user_qty) {
this.user_qty = user_qty;
}
public boolean isCheck_qty() {
return check_qty;
}
public void setCheck_qty(boolean check_qty) {
this.check_qty = check_qty;
}
private OnItemClickListener mOnItemClickListener;
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
mOnItemClickListener = onItemClickListener;
}
public interface OnItemClickListener {
void onItemClick(Food datasBean, int position);
}
}
package com.gingersoft.gsa.cloud.meal.mvp.ui.adapter.meal;
import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.bean.FoodBean;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.meal.R;
import com.gingersoft.gsa.cloud.meal.R2;
import com.jess.arms.base.BaseHolder;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.utils.DeviceUtils;
import java.util.List;
import androidx.recyclerview.widget.GridLayoutManager;
import butterknife.BindView;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2018/6/27
* 修订历史:2018/6/27
* 描述:
*/
public class FoodGroupAdapter extends DefaultAdapter<Food> {
private Context mContext;
// private List<Color.DatasBean> mColorList;
private int mOrderNumberShowSize;
private int mOrderNumberFontSize;
private int FoodTypeFontSize;
private int mParentRowCount;
private int mParentColWidth;
private int mParentColHeight;
private int mLayoutQtyHeight;
private int currentSelectPosition = 0;
public FoodGroupAdapter(Context context, List<Food> infos) {
super(infos);
this.mContext = context;
// this.mOrderNumberShowSize = GSAApplication.androidSetting.getOrderNumberShowSize();
// this.mOrderNumberFontSize = GSAApplication.androidSetting.getOrderNumberFontSize();
// this.FoodTypeFontSize = GSAApplication.androidSetting.getFoodTypeFontSize();
// int foodCol = GSAApplication.androidSetting.getFoodTypeCol();
// this.mParentColWidth = (int) (DeviceUtils.getScreenWidth(context) / foodCol);
//
// this.mParentColHeight = GSAApplication.androidSetting.getLayoutFoodTypeHeight() / GSAApplication.androidSetting.getFoodTypeRow();
// this.mLayoutQtyHeight = GSAApplication.androidSetting.getLayoutQtyHeight();
//
// Db_Color dc = new Db_Color(context);
// mColorList = dc.query("");
// dc.closeDb();
}
@Override
public int getItemCount() {
return mInfos.size();
}
@Override
public BaseHolder<Food> getHolder(View v, int viewType) {
return new FoodlKindItemHolder(v);
}
@Override
public int getLayoutId(int viewType) {
return R.layout.meal_item_food_group;
}
class FoodlKindItemHolder extends BaseHolder<Food> {
@BindView(R2.id.rl_container)
RelativeLayout rl_container;
@BindView(R2.id.tv_name)
TextView tv_name;
@BindView(R2.id.tv_number)
TextView tv_number;
@BindView(R2.id.tv_soldout)
TextView tv_soldout;
public FoodlKindItemHolder(View itemView) {
super(itemView);
}
@Override
public void setData(Food datasBean, int position) {
setFoodGroup(datasBean);
setNumber(datasBean);
setSoldoutStatus(datasBean);
setOnItemClickListener(new OnViewClickListener() {
@Override
public void onViewClick(View view, int position) {
if (mOnItemClickListener != null) {
if (currentSelectPosition != position) {
//设置当前选中item颜色
datasBean.setSelected(true);
tv_name.setBackgroundColor(mContext.getResources().getColor(R.color.colorAccent));
//重置上次选中item的颜色
mInfos.get(currentSelectPosition).setSelected(false);
notifyItemChanged(currentSelectPosition, 1);
//保存上次操作的position
currentSelectPosition = position;
}
mOnItemClickListener.onItemClick(datasBean, position);
}
}
});
}
public void setFoodGroup(Food datasBean) {
// String desc = "";
// switch (GSAApplication.androidSetting.getDataLanguage()) {
// case 1:
// desc = datasBean.getDesc1();
// break;
// case 2:
// desc = datasBean.getDesc2();
// break;
// case 3:
// desc = datasBean.getDesc3();
// break;
// }
// if (desc == null || desc.trim().length() == 0) {
// desc = datasBean.getDesc1();
// }
tv_name.setMaxHeight(50);
tv_name.setMinHeight(50);
tv_name.setHeight(50);
tv_name.setMaxWidth(mParentColWidth);
tv_name.setMinWidth(mParentColWidth);
tv_name.setWidth(mParentColWidth);
tv_name.setText(datasBean.getFoodName());
tv_name.setTextSize(FoodTypeFontSize);
tv_name.setHeight(mParentColHeight);
tv_name.setGravity(Gravity.CENTER);
GridLayoutManager.LayoutParams lp = (GridLayoutManager.LayoutParams) rl_container.getLayoutParams();
lp.height = mParentColHeight;
lp.width = mParentColWidth;
rl_container.setLayoutParams(lp);
/**
* 设置字体颜色以及块颜色
*/
// if (mColorList != null) {
// //后台有设置颜色当前选中高亮色,没有选中默认使用后台配置的颜色
// if (datasBean.isSelected()) {
// tv_name.setBackgroundColor(ArmsUtils.getColor(mContext, R.color.colorAccent));
// tv_name.setTextColor(ArmsUtils.getColor(mContext, R.color.theme_white_color));
// } else {
// for (Color.DatasBean cs : mColorList) {
// String color = cs.getAndroidColor();
// String fontcolor = cs.getAndroidfontcolor();
// if (cs.getColorid() == datasBean.getColorID()) {
// if (!TextUtils.isEmpty(color)) {
// tv_name.setBackgroundColor(android.graphics.Color.parseColor(color));
// } else {
// tv_name.setBackgroundColor(ArmsUtils.getColor(mContext, R.color.Grass_green));
// }
// if (!TextUtils.isEmpty(fontcolor)) {
// tv_name.setTextColor(android.graphics.Color.parseColor(fontcolor));
// } else {
// tv_name.setTextColor(ArmsUtils.getColor(mContext, R.color.theme_white_color));
// }
// break;
// }
// }
// }
// } else {
// //后台没有设置颜色当前选中高亮色,没有选中默认使用绿色
// if (datasBean.isSelected()) {
// tv_name.setBackgroundColor(ArmsUtils.getColor(mContext, R.color.colorAccent));
// tv_name.setTextColor(ArmsUtils.getColor(mContext, R.color.theme_white_color));
// } else {
// tv_name.setBackgroundColor(ArmsUtils.getColor(mContext, R.color.Grass_green));
// tv_name.setTextColor(ArmsUtils.getColor(mContext, R.color.theme_white_color));
// }
// }
}
public void setNumber(Food datasBean) {
tv_number.setTextSize(10);
tv_number.setHeight(mLayoutQtyHeight);
ViewGroup.MarginLayoutParams mp = new ViewGroup.MarginLayoutParams(mOrderNumberShowSize, mOrderNumberShowSize); //item�Ŀ��
mp.setMargins(0, 0, 0, 0);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(mp);
lp.width = ArmsUtils.dip2px(mContext, 16);
lp.height = ArmsUtils.dip2px(mContext, 16);
tv_number.setLayoutParams(lp);
// if (datasBean.getQty() == 0) {
// tv_number.setVisibility(View.INVISIBLE);
// } else {
// tv_number.setVisibility(View.VISIBLE);
// tv_number.setText(datasBean.getQty() + "");
// }
}
public void setSoldoutStatus(Food datasBean) {
tv_soldout.setMaxHeight(mOrderNumberShowSize);
tv_soldout.setMinHeight(mOrderNumberShowSize);
tv_soldout.setTextSize(mOrderNumberFontSize);
// String qty = datasBean.getOR_Qty();
// if (TextUtils.isEmpty(qty)) {
// tv_soldout.setVisibility(View.INVISIBLE);
// } else {
// tv_soldout.setVisibility(View.VISIBLE);
tv_soldout.setText(datasBean.getNumber());
// }
/**
* 设置当前状态
*/
// if (mCurrentSlodoutFoodList_Full != null) {
// for (CurrentSoldoutFood.DatasBean sc : mCurrentSlodoutFoodList_Full) {
// if (sc.getItemID().equals(datasBean.getFID()) && sc.getType().equals("G")) {
// if (sc.get_QtyName().equals("")) {
// tv_soldout.setVisibility(View.INVISIBLE);
// } else {
// tv_soldout.setVisibility(View.VISIBLE);
// tv_soldout.setText(sc.get_QtyName());
// }
// }
// }
// }
}
}
private OnItemClickListener mOnItemClickListener;
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
mOnItemClickListener = onItemClickListener;
}
public interface OnItemClickListener {
void onItemClick(Food datasBean, int position);
}
}
package com.gingersoft.gsa.cloud.meal.mvp.ui.adapter.meal;
import android.view.View;
import android.view.ViewGroup;
import java.util.List;
import androidx.viewpager.widget.PagerAdapter;
public class MyViewPagerAdapter extends PagerAdapter {
private List<View> viewList;//View就二十GridView
public MyViewPagerAdapter(List<View> viewList) {
this.viewList = viewList;
}
@Override
public int getCount() {
return viewList != null ? viewList.size() : 0;
}
@Override
public boolean isViewFromObject(View arg0, Object arg1) {
return arg0 == arg1;
}
/**
* 将当前的View添加到ViewGroup容器中
* 这个方法,return一个对象,这个对象表明了PagerAdapter适配器选择哪个对象放在当前的ViewPage上
*/
@Override
public Object instantiateItem(ViewGroup container, int position) {
container.addView(viewList.get(position));
return viewList.get(position);
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
}
package com.gingersoft.gsa.cloud.meal.mvp.ui.adapter.meal;
import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.bean.FoodBean;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.meal.R2;
import com.gingersoft.gsa.cloud.meal.mvp.model.manage.MyOrderManage;
import com.gingersoft.gsa.cloud.base.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.meal.R;
import com.gingersoft.gsa.cloud.meal.mvp.model.bean.OrderDetail;
import com.gingersoft.gsa.cloud.meal.mvp.model.constant.MealConstant;
import com.gingersoft.gsa.cloud.meal.mvp.presenter.MealStandPresenter;
import com.gingersoft.gsa.cloud.meal.mvp.ui.activity.MealStandActivity;
import com.jess.arms.base.BaseHolder;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.utils.ThirdViewUtil;
import com.zhy.autolayout.utils.AutoUtils;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2018/9/16
* 修订历史:2018/9/17
* 描述:
*/
public class SelectMealAdapter extends DefaultAdapter<Food> {
private MealStandActivity mContext;
private MealStandPresenter mPresenter;
private int BillListFontSize = 18;
private String carshStr = "$";
private int mOrderNumberShowSize;
private int mOrderNumberFontSize;
private int mFoodFontSize;
private int mColwidth;
private int mColHeight;
private int mLayoutQtyHeight;
private int mainStartPos = 0;
private int mainEndPos = 0;
private int select_position = -1;
private int select_start_position = 0;
private int select_end_position = 0;
public int select_full_start_position = 0;
public int select_full_end_position = 0;
private boolean isRemove = false;
public SelectMealAdapter(Context context, List<Food> data, MealStandPresenter presenter) {
super(data);
this.mContext = (MealStandActivity) context;
this.mPresenter = presenter;
// this.mOrderNumberShowSize = GSAApplication.androidSetting.getOrderNumberChildShowSize();
// this.mOrderNumberFontSize = GSAApplication.androidSetting.getOrderNumberChildFontSize();
// this.mFoodFontSize = GSAApplication.androidSetting.getFoodFontSize();
// this.mColwidth = (int) ((DeviceUtils.getScreenWidth(context) / GSAApplication.androidSetting.getFoodCol()) - 4);
// this.mColHeight = GSAApplication.androidSetting.getFoodBtnHeight();
// this.mLayoutQtyHeight = GSAApplication.androidSetting.getLayoutQtyHeight();
//
// this.BillListFontSize = GSAApplication.androidSetting.getFoodlListFontSize();
// this.carshStr = LanguageUtils.get_language_system(context, "order.cashstr", "$");
}
@Override
public int getItemCount() {
return mInfos.size();
}
@Override
public SelectMealItemHolder getHolder(View v, int viewType) {
return new SelectMealItemHolder(v);
}
@Override
public int getLayoutId(int viewType) {
return R.layout.meal_item_select_meal_stand;
}
class SelectMealItemHolder extends BaseHolder<Food> implements View.OnClickListener {
@BindView(R2.id.rl_container)
RelativeLayout rl_container;
@BindView(R2.id.rl_select)
RelativeLayout rl_select;
@BindView(R2.id.ll_tvname)
LinearLayout ll_tvname;
@BindView(R2.id.tv_number)
TextView tv_number;
@BindView(R2.id.tv_food_table_mode)
TextView tv_food_table_mode;
@BindView(R2.id.tv_modify_before_number)
TextView tv_modify_before_number;
@BindView(R2.id.tv_name)
TextView tv_name;
@BindView(R2.id.tv_money)
TextView tv_money;
@BindView(R2.id.tv_D)
TextView tv_D;
@BindView(R2.id.tv_S)
TextView tv_S;
@BindView(R2.id.tv_D_1)
TextView tv_D_1;
@BindView(R2.id.tv_S_1)
TextView tv_S_1;
@BindView(R2.id.img_lock)
ImageView iv_lock;
@BindView(R2.id.tv_discount_money)
TextView tv_discount_money;
@BindView(R2.id.tv_mix)
TextView tv_mix;
public SelectMealItemHolder(View itemView) {
super(itemView);
}
@Override
public void onClick(View view) {
if (mOnItemClickListener != null) {
int position = this.getPosition();
if (position < mInfos.size()) {
setSelectPosition(position);
//设置当前选中的食品或食品组
mOnItemClickListener.onItemClick(mInfos.get(position), position);
}
}
}
@Override
public void setData(Food datasBean, int position) {
setViewVisibility(datasBean);
setDSMark(datasBean);
if (datasBean.isVisible()) {
rl_container.setVisibility(View.VISIBLE);
setName(datasBean);
setNumber(datasBean);
setFoodMode(datasBean);
setMoney(datasBean);
setColor(datasBean);
setTextSize();
} else {
rl_container.setVisibility(View.INVISIBLE);
}
}
private void setFoodMode(Food datasBean) {
// if (GSAApplication.tableContract.getTableType() == MealConstant.takeaway_food_mode) {
// //外賣檯
// if (datasBean.getItemtype() == 1 && datasBean.getFoodTableMode() == MealConstant.hall_food_mode) {
// tv_food_table_mode.setText(LanguageUtils.get_language_system(mContext, "food.table.mode.hall", "堂"));
// tv_food_table_mode.setVisibility(View.VISIBLE);
// } else {
// tv_food_table_mode.setText("");
// tv_food_table_mode.setVisibility(View.GONE);
// }
// } else {
// //堂食檯
// if (datasBean.getItemtype() == 1 && datasBean.getFoodTableMode() == MealConstant.takeaway_food_mode) {
// tv_food_table_mode.setText(LanguageUtils.get_language_system(mContext, "food.table.mode.takeaway", "外"));
// tv_food_table_mode.setVisibility(View.VISIBLE);
// } else {
// tv_food_table_mode.setText("");
// tv_food_table_mode.setVisibility(View.GONE);
// }
// }
}
private void setViewVisibility(Food datasBean) {
tv_D.setVisibility(View.INVISIBLE);
tv_D_1.setVisibility(View.INVISIBLE);
tv_discount_money.setVisibility(View.INVISIBLE);
// if (datasBean.isModify()) {
// tv_modify_before_number.setText(String.valueOf(datasBean.getModifyBeforeNumber()));
// tv_modify_before_number.setVisibility(View.VISIBLE);
// } else {
// tv_modify_before_number.setVisibility(View.INVISIBLE);
// }
//
// if (datasBean.getMix_DETAIL_ID() > 0) {
// tv_mix.setText(String.valueOf(datasBean.getMix_DETAIL_ID()));
// tv_mix.setVisibility(View.VISIBLE);
// } else {
// tv_mix.setVisibility(View.INVISIBLE);
// }
}
private void setDSMark(Food datasBean) {
// if (datasBean.isD_able() == false && !datasBean.getProp().equals("discount")) {
// tv_D.setVisibility(View.VISIBLE);
// } else {
// tv_D.setVisibility(View.INVISIBLE);
// }
// if (datasBean.isDiscount_double1() == false && !datasBean.getProp().equals("discount")) {
// tv_D_1.setVisibility(View.VISIBLE);
// } else {
// tv_D_1.setVisibility(View.INVISIBLE);
// }
// if (datasBean.isIsfood() == true && datasBean.getItemtype() <= 1) {
// if (datasBean.isSc_able() == false) {
// tv_S.setVisibility(View.VISIBLE);
// } else {
// tv_S.setVisibility(View.INVISIBLE);
// }
// if (datasBean.getDiscount_Fixed() == 6) {
// tv_S_1.setVisibility(View.VISIBLE);
// } else {
// tv_S_1.setVisibility(View.INVISIBLE);
// }
// } else {
tv_S.setVisibility(View.INVISIBLE);
tv_S_1.setVisibility(View.INVISIBLE);
// }
}
private void setName(Food datasBean) {
// int flevel = datasBean.getItemtype();
String name = datasBean.getFoodName();
// switch (flevel) {
// case 1:
// tv_number.setGravity(Gravity.LEFT);
// break;
// case 2:
// name = " " + name;
// tv_number.setGravity(Gravity.CENTER);
// break;
// case 3:
// name = " " + name;
// tv_number.setGravity(Gravity.RIGHT);
// break;
// }
tv_name.setText(name);
boolean selected = datasBean.isSelected();
if (selected) {
//作为主体被选中 开启跑马灯效果
tv_name.setFocusable(true);
tv_name.setEllipsize(TextUtils.TruncateAt.MARQUEE);//设置旋转
tv_name.setMarqueeRepeatLimit(-1);//-1为死循环,1为1次
tv_name.setSelected(true);//设置不获取焦点就可以转
tv_name.setFocusableInTouchMode(true);
} else {
//关闭跑马灯效果
tv_name.setFocusable(false);
tv_name.setMarqueeRepeatLimit(0);
tv_name.setSelected(false);
tv_name.setFocusableInTouchMode(false);
}
}
private void setNumber(Food datasBean) {
int number = datasBean.getNumber();
if (number == 0) {
//细项、折扣不需要显示数量
tv_number.setText("");
} else {
tv_number.setText(String.valueOf(number));
}
}
private void setMoney(Food datasBean) {
double price = datasBean.getPrice();
if (price != 0) {
tv_money.setText(carshStr + MoneyUtil.get_ItemDecimals_money(price));
} else {
tv_money.setText("");
}
}
private void setColor(Food datasBean) {
boolean selected = datasBean.isSelected();
//设置Item选中颜色
if (!datasBean.isNew()) {
iv_lock.setVisibility(View.INVISIBLE);
rl_container.setBackgroundColor(ArmsUtils.getColor(mContext, R.color.theme_background_color));
tv_name.setTextColor(ArmsUtils.getColor(mContext, R.color.Grass_green));
tv_number.setTextColor(ArmsUtils.getColor(mContext, R.color.Grass_green));
tv_money.setTextColor(ArmsUtils.getColor(mContext, R.color.Grass_green));
if (selected) {
rl_container.setBackgroundColor(ArmsUtils.getColor(mContext, R.color.itemSelected));
rl_select.setBackgroundColor(ArmsUtils.getColor(mContext, R.color.itemSelected));// Color.YELLOW);
ll_tvname.setBackgroundResource(R.color.mainSelected);
} else {
rl_container.setBackgroundColor(ArmsUtils.getColor(mContext, R.color.theme_white_color));
rl_select.setBackgroundColor(ArmsUtils.getColor(mContext, R.color.theme_white_color));
ll_tvname.setBackgroundColor(ArmsUtils.getColor(mContext, R.color.theme_white_color));
}
} else {
iv_lock.setVisibility(View.INVISIBLE);
rl_container.setBackgroundColor(ArmsUtils.getColor(mContext, R.color.theme_background_color));
tv_name.setTextColor(ArmsUtils.getColor(mContext, R.color.theme_black));
tv_number.setTextColor(ArmsUtils.getColor(mContext, R.color.theme_black));
tv_money.setTextColor(ArmsUtils.getColor(mContext, R.color.theme_black));
if (selected) {
rl_container.setBackgroundColor(ArmsUtils.getColor(mContext, R.color.itemSelected));
rl_select.setBackgroundColor(ArmsUtils.getColor(mContext, R.color.itemSelected));// Color.YELLOW);
ll_tvname.setBackgroundResource(R.color.mainSelected);
} else {
rl_container.setBackgroundColor(ArmsUtils.getColor(mContext, R.color.theme_white_color));
rl_select.setBackgroundColor(ArmsUtils.getColor(mContext, R.color.theme_white_color));
ll_tvname.setBackgroundColor(ArmsUtils.getColor(mContext, R.color.theme_white_color));
}
}
}
public void setTextSize() {
tv_money.setTextSize(BillListFontSize);
tv_name.setTextSize(BillListFontSize);
tv_number.setTextSize(BillListFontSize);
}
}
private void setSelectPosition(int position) {
resetSelected();
select_position = position;
mInfos.get(select_position).setIsSelected(true);
notifyDataSetChanged();
}
public int addFoodItem(Food food) {
select_position += 1;
mInfos.add(food);
setSelectPosition(select_position);
return select_position;
}
/**
* 長按刪除食品
*/
public void removeAllNewFoodItem() {
for (int i = mInfos.size() - 1; i >= 0; i--) {
Food orderItem = mInfos.get(i);
if (orderItem.isNew()) {
mInfos.remove(i);
notifyItemChanged(i);
if (orderItem != null) {
Food orderBean = mPresenter.getOrderFoodById(orderItem.getId());
if (orderBean != null) {
mPresenter.setUserMaxQty(orderBean);
}
}
}
}
if (mInfos.size() == 0)
//全部刪除
return;
mContext.showViewModeVisibility(MealConstant.food_group_ViewMode, MealConstant.food_ViewMode);
}
/**
* 删除食品
*/
public void removeFoodItem() {
mInfos.remove(select_position);
notifyItemChanged(select_position);
if (mInfos.size() == 0) {
//全部删除重置选中下标
select_position = -1;
} else {
if (select_position == mInfos.size()) {
select_position -= 1;
}
}
mContext.showViewModeVisibility(MealConstant.food_group_ViewMode, MealConstant.food_ViewMode);
}
private void removeIntactFoodItem() {
int start_position = select_full_start_position + 1;
int end_position = select_full_end_position + 1;
for (int i = mInfos.size() - 1; i >= 0; i--) {
int my_index = mInfos.get(i).getMyIndex();
if (start_position <= my_index && my_index <= end_position) {
if (mInfos.get(i).isNew()) {
mInfos.remove(i);
notifyItemChanged(i);
}
}
}
}
private void resetSelected() {
for (int i = 0; i < mInfos.size(); i++) {
Food food = mInfos.get(i);
food.setIsSelected(false);
}
}
public List<Food> getInfos() {
return mInfos;
}
public int getSelect_position() {
return select_position;
}
public void setSelect_position(int select_position) {
this.select_position = select_position;
}
public void setSelect_end_position(int select_end_position) {
this.select_end_position = select_end_position;
}
public int getSelect_start_position() {
return select_start_position;
}
public int getSelect_end_position() {
return select_end_position;
}
public int getSelect_full_start_position() {
return select_full_start_position;
}
public int getSelect_full_end_position() {
return select_full_end_position;
}
public int getMainStartPos() {
return mainStartPos;
}
public int getMainEndPos() {
return mainEndPos;
}
public Food getCurrentOrderDetail() {
if (select_position != -1) {
return mInfos.get(select_position);
} else {
return null;
}
}
public Food getCurrentMainOrderDetail() {
if (select_start_position != -1) {
return mInfos.get(select_start_position);
} else {
return null;
}
}
private OnItemClickListener mOnItemClickListener;
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
mOnItemClickListener = onItemClickListener;
}
public interface OnItemClickListener {
void onItemClick(Food datasBean, int position);
}
}
package com.gingersoft.gsa.cloud.meal.mvp.ui.widget;
import android.app.Dialog;
import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import com.gingersoft.gsa.cloud.meal.R;
import com.gingersoft.gsa.cloud.meal.R2;
import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.utils.ThirdViewUtil;
import butterknife.BindView;
import butterknife.OnClick;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2018/8/17
* 修订历史:2018/8/17
* 描述:输入数字Dialog
*/
public class ChooseNumberDialog {
private Context mContext;
private Dialog dialog;
@BindView(R2.id.ll_container)
LinearLayout ll_container;
// @BindView(R2.id.rl_head)
// RelativeLayout rl_head;
// @BindView(R2.id.ib_back_page)
// ImageButton ib_back_page;
// @BindView(R2.id.tv_title)
// TextView tv_title;
@BindView(R2.id.ed_value)
EditText ed_value;
@BindView(R2.id.btn_0)
Button btn_0;
@BindView(R2.id.btn_1)
Button btn_1;
@BindView(R2.id.btn_2)
Button btn_2;
@BindView(R2.id.btn_3)
Button btn_3;
@BindView(R2.id.btn_4)
Button btn_4;
@BindView(R2.id.btn_5)
Button btn_5;
@BindView(R2.id.btn_6)
Button btn_6;
@BindView(R2.id.btn_7)
Button btn_7;
@BindView(R2.id.btn_8)
Button btn_8;
@BindView(R2.id.btn_9)
Button btn_9;
@BindView(R2.id.btn_back)
Button btn_back;
@BindView(R2.id.btn_ten_plus)
Button btn_ten_plus;
//没有输入点击确认的提示
private String emptyInputTip;
//1、選擇人數、2、選擇食品數量
private int type = 1;
//选中10+的次数
private int currentTenPlus = 0;
public ChooseNumberDialog(Context context) {
this.mContext = context;
initView();
}
private void initView() {
// 获取Dialog布局
View view = LayoutInflater.from(mContext).inflate(R.layout.ui_dialog_input_number, null);
ThirdViewUtil.bindTarget(this, view);//绑定
// 定义Dialog布局和参数
dialog = new Dialog(mContext, R.style.QMUI_Dialog);
dialog.setContentView(view);
dialog.setCancelable(false);
// 调整dialog背景大小
ll_container.setLayoutParams(
new FrameLayout.LayoutParams((int) (ArmsUtils.getScreenWidth(mContext) * 0.92), ViewGroup.LayoutParams.WRAP_CONTENT));
}
public ChooseNumberDialog builder() {
initLanguage();
return this;
}
private void initLanguage() {
btn_back.setText("返回");
ed_value.setHint( "請按鍵錄入數量");
}
public void setValueHint(String hint) {
ed_value.setHint(hint);
}
@OnClick({R2.id.btn_0, R2.id.btn_1, R2.id.btn_2, R2.id.btn_3, R2.id.btn_4, R2.id.btn_5, R2.id.btn_6, R2.id.btn_7, R2.id.btn_8, R2.id.btn_9, R2.id.btn_back, R2.id.btn_ten_plus})
public void onClick(View v) {
switch (v.getId()) {
case R2.id.btn_0:
case R2.id.btn_1:
case R2.id.btn_2:
case R2.id.btn_3:
case R2.id.btn_4:
case R2.id.btn_5:
case R2.id.btn_6:
case R2.id.btn_7:
case R2.id.btn_8:
case R2.id.btn_9:
int i = Integer.parseInt(v.getTag().toString());
String values = String.valueOf(i);
if (currentTenPlus > 0) {
//有选择十整位
values = (currentTenPlus * 10) + "_" + values;
}
if (values.length() > 0 && Integer.parseInt(split_value(values)) > 99) {
//最大选择数99
values = "99";
ed_value.setText(values);
} else {
ed_value.setText(values);
}
if (!TextUtils.isEmpty(getInputNumber())) {
if (onClickListener != null) {
onClickListener.onComfirmClick(getInputNumber());
clearValueText();
}
cancel();
}
break;
case R2.id.btn_back:
if (onBackClickListener != null) {
onBackClickListener.OnBackClick();
}
cancel();
break;
// case R.id.ib_back_page:
// if (onClickListener != null) {
// onClickListener.onBackPage();
// }
// break;
case R2.id.btn_ten_plus:
currentTenPlus++;
ed_value.setText(currentTenPlus + "_");
break;
}
}
public void clearValueText() {
currentTenPlus = 0;
ed_value.setText("");
}
public String getInputNumber() {
return split_value(ed_value.getText().toString().trim());
}
private String split_value(String value) {
if (value.contains("_")) {
String[] values = value.split("_");
int tenBit = Integer.parseInt(values[0]);
value = (tenBit + Integer.parseInt(values[1])) + "";
}
return value;
}
public String getEmptyInputTip() {
return emptyInputTip;
}
public void setEmptyInputTip(String emptyInputTip) {
this.emptyInputTip = emptyInputTip;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
// public void setTitle(String title) {
// tv_title.setText(title);
// }
//
// public void setHeadLayoutVisibility(int visibility) {
// rl_head.setVisibility(visibility);
// }
//
// public void setBackPageBtnVisibility(int visibility) {
// ib_back_page.setVisibility(visibility);
// }
public ChooseNumberDialog setCancelable(boolean cancelable) {
dialog.setCancelable(cancelable);
return this;
}
public void show() {
dialog.show();
}
public void cancel() {
dialog.cancel();
}
private OnBackClickListener onBackClickListener;
private OnClickListener onClickListener;
public void setOnBackClickListener(OnBackClickListener clickListener) {
onBackClickListener = clickListener;
}
public void setOnClickListener(OnClickListener clickListener) {
onClickListener = clickListener;
}
public interface OnBackClickListener {
void OnBackClick();
}
public interface OnClickListener {
void onComfirmClick(String number);
void onBackPage();
}
}
package com.gingersoft.gsa.cloud.mealstand.mvp.presenter;
import android.app.Application;
import com.jess.arms.integration.AppManager;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.http.imageloader.ImageLoader;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import javax.inject.Inject;
import com.gingersoft.gsa.cloud.mealstand.mvp.contract.MealStandContract;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 12/27/2019 19:17
* <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>
* ================================================
*/
@ActivityScope
public class MealStandPresenter extends BasePresenter<MealStandContract.Model, MealStandContract.View> {
@Inject
RxErrorHandler mErrorHandler;
@Inject
Application mApplication;
@Inject
ImageLoader mImageLoader;
@Inject
AppManager mAppManager;
@Inject
public MealStandPresenter(MealStandContract.Model model, MealStandContract.View rootView) {
super(model, rootView);
}
@Override
public void onDestroy() {
super.onDestroy();
this.mErrorHandler = null;
this.mAppManager = null;
this.mImageLoader = null;
this.mApplication = null;
}
}
package com.gingersoft.gsa.cloud.mealstand.mvp.ui.activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.Chronometer;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.mealstand.di.component.DaggerMealStandComponent;
import com.gingersoft.gsa.cloud.ui.view.PagerSlidingTabStrip;
import com.gingersoft.gsa.cloud.ui.view.SearchKeyBoardView;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.gingersoft.gsa.cloud.mealstand.mvp.contract.MealStandContract;
import com.gingersoft.gsa.cloud.mealstand.mvp.presenter.MealStandPresenter;
import com.gingersoft.gsa.cloud.mealstand.R;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;
import static com.jess.arms.utils.Preconditions.checkNotNull;
/**
* ================================================
* Description:
* <p>
* Created by MVPArmsTemplate on 12/27/2019 19:17
* <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 MealStandActivity extends BaseActivity<MealStandPresenter> implements MealStandContract.View {
@BindView(R.id.ctime)
Chronometer chronometer;
@BindView(R.id.rv_select_meal)
RecyclerView rv_select_meal;
@BindView(R.id.rv_food_group)
RecyclerView rv_food_group;
@BindView(R.id.rv_food)
RecyclerView rv_food;
@BindView(R.id.rv_combo)
RecyclerView rv_combo;
@BindView(R.id.rv_discount)
RecyclerView rv_discount;
@BindView(R.id.rl_fine_tabs)
RelativeLayout rl_fine_tabs;
@BindView(R.id.iv_fine_back)
ImageView iv_fine_back;
@BindView(R.id.tabs_fine)
PagerSlidingTabStrip tabs_fine;
@BindView(R.id.pager_fine)
ViewPager pager_fine;
@BindView(R.id.meal_stand_search_keyboard_view)
SearchKeyBoardView keyView;
@BindView(R.id.rl_stand_oper)
RelativeLayout rl_stand_oper;
@BindView(R.id.tv_no_save_return)
TextView tv_no_save_return;
// @BindView(R.id.tv_send_order)
// TextView tv_send_order;
@BindView(R.id.fl_order_content)
FrameLayout fl_order_content;
@BindView(R.id.tv_order_content)
TextView tv_order_content;
@BindView(R.id.btn_order_count)
Button btn_order_count;
//送单
@BindView(R.id.fl_send_order)
FrameLayout fl_send_order;
@BindView(R.id.btn_send_order)
Button btn_send_order;
// @BindView(R.id.btn_send_order_machine_name)
// TextView btn_send_order_machine_name;
//印单
@BindView(R.id.fl_printer_order)
FrameLayout fl_printer_order;
@BindView(R.id.btn_order_printer)
Button btn_order_printer;
@BindView(R.id.btn_printer_machine_name)
TextView btn_printer_machine_name;
@BindView(R.id.ll_meals)
LinearLayout ll_meals;
@BindView(R.id.ll_meals_main)
LinearLayout ll_meals_main;
@BindView(R.id.ll_mm)
LinearLayout ll_mm;
@BindView(R.id.btn_table)
Button btn_table;
@BindView(R.id.btn_numberman)
Button btn_numberman;
@BindView(R.id.btn_fid)
TextView btn_fid;
@BindView(R.id.btn_temporary)
TextView btn_temporary;
@BindView(R.id.btn_meal_discount)
TextView btn_meal_discount;
@BindView(R.id.btn_meal_delete)
TextView btn_meal_delete;
@BindView(R.id.btn_meal_modify_restore)
ImageButton btn_meal_modify_restore;
@BindView(R.id.btn_change_Language)
ImageButton btn_change_Language;
@BindView(R.id.btn_food_merge)
ImageButton btn_food_merge;
@BindView(R.id.btn_food_mode)
TextView btn_food_mode;
@BindView(R.id.ll_Keys)
LinearLayout ll_Keys;
@BindView(R.id.btn_key0)
Button btn_key0;
@BindView(R.id.btn_key1)
Button btn_key1;
@BindView(R.id.btn_key2)
Button btn_key2;
@BindView(R.id.btn_key3)
Button btn_key3;
@BindView(R.id.btn_key4)
Button btn_key4;
@BindView(R.id.btn_keys)
Button btn_keys;
@BindView(R.id.ll_modify)
LinearLayout ll_modify;
@BindView(R.id.btn_add_delete)
Button btn_add_delete;
@BindView(R.id.btn_msg)
Button btn_msg;
@BindView(R.id.btn_delete)
Button btn_delete;
@BindView(R.id.btn_end)
Button btn_end;
@Override
public void setupActivityComponent(@NonNull AppComponent appComponent) {
DaggerMealStandComponent //如找不到该类,请编译一下项目
.builder()
.appComponent(appComponent)
.view(this)
.build()
.inject(this);
}
@Override
public int initView(@Nullable Bundle savedInstanceState) {
return R.layout.meal_activity_meal_stand; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
}
@Override
public void initData(@Nullable Bundle savedInstanceState) {
}
@Override
public void initIntent() {
}
@Override
public void initTopBar() {
}
@Override
public void initLanguage() {
}
@Override
public void initLayoutParams() {
}
@Override
public void initLayoutVisible() {
}
@Override
public void showLoading(String message) {
}
@Override
public void hideLoading() {
}
@Override
public void showMessage(@NonNull String message) {
checkNotNull(message);
ArmsUtils.snackbarText(message);
}
@Override
public void launchActivity(@NonNull Intent intent) {
checkNotNull(intent);
ArmsUtils.startActivity(intent);
}
@Override
public void killMyself() {
finish();
}
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/theme_color" />
<size
android:width="15dp"
android:height="2dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/theme_grey_color" />
<size
android:width="15dp"
android:height="2dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true" android:state_focused="false"
android:state_pressed="false" android:color="@color/theme_white_color"/>
<item android:state_pressed="true" android:color="@color/colorAccent"/>
</selector>
\ No newline at end of file
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
<RelativeLayout 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:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content">
android:background="@color/theme_black">
<Chronometer <Chronometer
android:id="@+id/ctime" android:id="@+id/ctime"
...@@ -64,7 +63,7 @@ ...@@ -64,7 +63,7 @@
<TextView <TextView
android:id="@+id/btn_fid" android:id="@+id/btn_fid"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:background="@drawable/ui_selector_item_background" android:background="@drawable/ui_selector_item_background"
android:text="PLU" android:text="PLU"
android:drawablePadding="@dimen/dp_1" android:drawablePadding="@dimen/dp_1"
...@@ -78,7 +77,7 @@ ...@@ -78,7 +77,7 @@
<TextView <TextView
android:id="@+id/btn_meal_delete" android:id="@+id/btn_meal_delete"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:text="刪除" android:text="刪除"
android:drawablePadding="@dimen/dp_1" android:drawablePadding="@dimen/dp_1"
android:background="@drawable/ui_selector_item_background" android:background="@drawable/ui_selector_item_background"
...@@ -89,33 +88,33 @@ ...@@ -89,33 +88,33 @@
android:textColor="@color/theme_black" android:textColor="@color/theme_black"
android:textSize="@dimen/sp_12" /> android:textSize="@dimen/sp_12" />
<TextView <!-- <TextView-->
android:id="@+id/btn_food_mode" <!-- android:id="@+id/btn_food_mode"-->
android:layout_width="match_parent" <!-- android:layout_width="match_parent"-->
android:layout_height="match_parent" <!-- android:layout_height="wrap_content"-->
android:text="堂食" <!-- android:text="堂食"-->
android:background="@drawable/ui_selector_item_background" <!-- android:background="@drawable/ui_selector_item_background"-->
android:drawablePadding="@dimen/dp_1" <!-- android:drawablePadding="@dimen/dp_1"-->
android:textAllCaps="false" <!-- android:textAllCaps="false"-->
android:gravity="center" <!-- android:gravity="center"-->
android:layout_marginTop="@dimen/dp_8" <!-- android:layout_marginTop="@dimen/dp_8"-->
android:drawableTop="@drawable/meal_hall_mode" <!-- android:drawableTop="@drawable/meal_hall_mode"-->
android:textColor="@color/theme_black" <!-- android:textColor="@color/theme_black"-->
android:textSize="@dimen/sp_12"/> <!-- android:textSize="@dimen/sp_12"/>-->
<TextView <!-- <TextView-->
android:id="@+id/btn_meal_discount" <!-- android:id="@+id/btn_meal_discount"-->
android:layout_width="match_parent" <!-- android:layout_width="match_parent"-->
android:layout_height="match_parent" <!-- android:layout_height="wrap_content"-->
android:text="折扣" <!-- android:text="折扣"-->
android:drawablePadding="@dimen/dp_1" <!-- android:drawablePadding="@dimen/dp_1"-->
android:layout_marginTop="@dimen/dp_8" <!-- android:layout_marginTop="@dimen/dp_8"-->
android:background="@drawable/ui_selector_item_background" <!-- android:background="@drawable/ui_selector_item_background"-->
android:textAllCaps="false" <!-- android:textAllCaps="false"-->
android:gravity="center" <!-- android:gravity="center"-->
android:drawableTop="@drawable/meal_discount" <!-- android:drawableTop="@drawable/meal_discount"-->
android:textColor="@color/theme_black" <!-- android:textColor="@color/theme_black"-->
android:textSize="@dimen/sp_12"/> <!-- android:textSize="@dimen/sp_12"/>-->
<!-- <ImageButton--> <!-- <ImageButton-->
<!-- android:id="@+id/btn_meal_discount"--> <!-- android:id="@+id/btn_meal_discount"-->
...@@ -125,40 +124,40 @@ ...@@ -125,40 +124,40 @@
<!-- android:layout_weight="1"--> <!-- android:layout_weight="1"-->
<!-- android:src="@drawable/meal_discount" />--> <!-- android:src="@drawable/meal_discount" />-->
<TextView <!-- <TextView-->
android:id="@+id/btn_temporary" <!-- android:id="@+id/btn_temporary"-->
android:layout_width="match_parent" <!-- android:layout_width="match_parent"-->
android:layout_height="match_parent" <!-- android:layout_height="wrap_content"-->
android:background="@drawable/ui_selector_item_background" <!-- android:background="@drawable/ui_selector_item_background"-->
android:text="暫存" <!-- android:text="暫存"-->
android:layout_marginTop="@dimen/dp_8" <!-- android:layout_marginTop="@dimen/dp_8"-->
android:gravity="center" <!-- android:gravity="center"-->
android:textAllCaps="false" <!-- android:textAllCaps="false"-->
android:textColor="@color/theme_black" <!-- android:textColor="@color/theme_black"-->
android:visibility="visible" <!-- android:visibility="visible"-->
android:drawableTop="@drawable/meal_temporary" <!-- android:drawableTop="@drawable/meal_temporary"-->
android:textSize="@dimen/sp_12"/> <!-- android:textSize="@dimen/sp_12"/>-->
<ImageButton <!-- <ImageButton-->
android:id="@+id/btn_meal_modify_restore" <!-- android:id="@+id/btn_meal_modify_restore"-->
style="@style/ButtonBorderless" <!-- style="@style/ButtonBorderless"-->
android:layout_width="match_parent" <!-- android:layout_width="match_parent"-->
android:layout_height="match_parent" <!-- android:layout_height="wrap_content"-->
android:src="@drawable/meal_modify_restore" /> <!-- android:src="@drawable/meal_modify_restore" />-->
<ImageButton <!-- <ImageButton-->
android:id="@+id/btn_change_Language" <!-- android:id="@+id/btn_change_Language"-->
style="@style/ButtonBorderless" <!-- style="@style/ButtonBorderless"-->
android:layout_width="match_parent" <!-- android:layout_width="match_parent"-->
android:layout_height="match_parent" <!-- android:layout_height="wrap_content"-->
android:src="@drawable/meal_change_language_index_1" /> <!-- android:src="@drawable/meal_change_language_index_1" />-->
<ImageButton <!-- <ImageButton-->
android:id="@+id/btn_food_merge" <!-- android:id="@+id/btn_food_merge"-->
style="@style/ButtonBorderless" <!-- style="@style/ButtonBorderless"-->
android:layout_width="match_parent" <!-- android:layout_width="match_parent"-->
android:layout_height="match_parent" <!-- android:layout_height="wrap_content"-->
android:src="@drawable/meal_food_merge" /> <!-- android:src="@drawable/meal_food_merge" />-->
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</LinearLayout> </LinearLayout>
...@@ -343,7 +342,7 @@ ...@@ -343,7 +342,7 @@
android:background="@drawable/ui_shape_red_oval" android:background="@drawable/ui_shape_red_oval"
android:singleLine="true" android:singleLine="true"
android:layout_margin="@dimen/dp_2" android:layout_margin="@dimen/dp_2"
android:textColor="@color/white" /> android:textColor="@color/theme_white_color" />
</FrameLayout> </FrameLayout>
<!-- <TextView--> <!-- <TextView-->
...@@ -471,21 +470,43 @@ ...@@ -471,21 +470,43 @@
android:orientation="vertical" android:orientation="vertical"
android:visibility="gone" /> android:visibility="gone" />
<androidx.recyclerview.widget.RecyclerView <!-- <androidx.recyclerview.widget.RecyclerView-->
android:id="@+id/rv_food_group" <!-- android:id="@+id/rv_food_group"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_below="@+id/ll_meals"-->
<!-- android:divider="@null"-->
<!-- android:fadeScrollbars="false"-->
<!-- android:orientation="vertical" />-->
<LinearLayout
android:id="@+id/ll_food_group"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/ll_meals" android:orientation="vertical"
android:divider="@null" android:layout_below="@+id/ll_meals">
android:fadeScrollbars="false"
android:orientation="vertical" /> <androidx.viewpager.widget.ViewPager
android:id="@+id/vp_food_group"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_80"
android:layout_weight="1"/>
<LinearLayout
android:id="@+id/ll_food_group_point"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_5"
android:background="@color/theme_grey_color"
android:orientation="horizontal" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_food" android:id="@+id/rv_food"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_above="@+id/rl_stand_oper" android:layout_above="@+id/rl_stand_oper"
android:layout_below="@+id/rv_food_group" android:layout_below="@+id/ll_food_group"
android:divider="@null" android:divider="@null"
android:fadeScrollbars="false" android:fadeScrollbars="false"
android:orientation="vertical" /> android:orientation="vertical" />
......
<?xml version="1.0" encoding="utf-8"?>
<com.gingersoft.gsa.cloud.ui.view.LineGridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gv_food_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="6">
</com.gingersoft.gsa.cloud.ui.view.LineGridView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rl_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_food_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="1px"
android:layout_marginTop="1px"
android:text="food"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@drawable/meal_selector_food_backgroup" />
<TextView
android:id="@+id/tv_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ui_shape_red_oval"
android:gravity="center"
android:text="number"
android:visibility="gone"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/theme_white_color" />
<TextView
android:id="@+id/tv_soldout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:layout_marginRight="2px"
android:layout_marginTop="2px"
android:visibility="gone"
android:background="@drawable/ui_selector_white_rect"
android:text="sold" />
<!--<TextView-->
<!--android:id="@+id/tv_status"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_alignParentRight="true"-->
<!--android:layout_gravity="right"-->
<!--android:layout_marginRight="3px"-->
<!--android:layout_marginTop="2px"-->
<!--android:background="@drawable/selector_white_rect"-->
<!--android:text="sold" />-->
<ImageView
android:id="@+id/iv_qtySold"
android:layout_width="40dp"
android:layout_height="20dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:layout_marginRight="1px"
android:layout_marginTop="1px"
android:src="@drawable/sold"
android:text="sold" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rl_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="2px"
android:layout_marginTop="2px"
android:text="food"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@drawable/meal_selector_food_backgroup" />
<TextView
android:id="@+id/tv_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ui_shape_red_oval"
android:gravity="center"
android:text="number"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/theme_white_color" />
<TextView
android:id="@+id/tv_soldout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:layout_marginRight="2px"
android:layout_marginTop="2px"
android:background="@drawable/ui_selector_white_rect"
android:text="sold" />
<View
android:id="@+id/right_line"
android:layout_width="2px"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:background="@color/theme_black" />
<View
android:id="@+id/top_line"
android:layout_width="match_parent"
android:layout_height="2px"
android:layout_alignParentTop="true"
android:background="@color/theme_black" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tv_text"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_40"
android:gravity="center"
android:text="和風牛肉"
android:maxLines="2"
android:background="@color/green_400"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/font_normal"/>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rl_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/img_lock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/tv_number"
android:src="@drawable/lock" />
<RelativeLayout
android:id="@+id/rl_select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/img_lock">
<LinearLayout
android:id="@+id/ll_tvname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_90">
<com.gingersoft.gsa.cloud.ui.view.MarqueeTextView
android:id="@+id/tv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="true"
android:text="TextView"
android:textColor="@color/theme_black"
android:textSize="@dimen/sp_20" />
</LinearLayout>
<TextView
android:id="@+id/tv_money"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="$20"
android:layout_marginRight="@dimen/dp_5"
android:textColor="@color/theme_black"
android:textSize="@dimen/sp_20" />
<TextView
android:id="@+id/tv_mix"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignWithParentIfMissing="true"
android:layout_marginBottom="@dimen/dp_1"
android:layout_marginRight="@dimen/dp_1"
android:layout_marginTop="@dimen/dp_1"
android:layout_toLeftOf="@+id/tv_discount_money"
android:background="@color/red"
android:text="1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/green"
android:textSize="@dimen/sp_20"
android:visibility="invisible" />
<TextView
android:id="@+id/tv_discount_money"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/tv_money"
android:layout_marginRight="@dimen/dp_5"
android:layout_toLeftOf="@+id/tv_D"
android:text="D"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/red"
android:visibility="invisible" />
<TextView
android:id="@+id/tv_D"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignWithParentIfMissing="true"
android:layout_marginRight="@dimen/dp_1"
android:layout_toLeftOf="@+id/tv_D_1"
android:background="@color/white"
android:text="D"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/red"
android:textSize="@dimen/sp_10"
android:visibility="invisible" />
<TextView
android:id="@+id/tv_S"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/tv_money"
android:layout_alignWithParentIfMissing="true"
android:layout_below="@+id/tv_D"
android:layout_marginRight="1dp"
android:layout_toLeftOf="@+id/tv_D_1"
android:background="@color/white"
android:text="S"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/red"
android:textSize="@dimen/sp_10"
android:visibility="invisible" />
<TextView
android:id="@+id/tv_D_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignWithParentIfMissing="true"
android:layout_marginRight="@dimen/dp_90"
android:layout_toLeftOf="@+id/tv_money"
android:background="@color/blue"
android:text="D"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/white"
android:textSize="@dimen/sp_10"
android:visibility="invisible" />
<TextView
android:id="@+id/tv_S_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/tv_money"
android:layout_alignParentRight="true"
android:layout_below="@+id/tv_D_1"
android:layout_marginRight="@dimen/dp_90"
android:background="@color/blue"
android:text="S"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/white"
android:textSize="@dimen/sp_10"
android:visibility="invisible" />
</RelativeLayout>
<TextView
android:id="@+id/tv_number"
android:layout_width="@dimen/dp_35"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="20"
android:gravity="center"
android:textColor="@color/theme_black"
android:textSize="@dimen/sp_20" />
<TextView
android:id="@+id/tv_food_table_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_28"
android:background="@color/red_400"
android:gravity="center"
android:padding="@dimen/dp_3"
android:text="外"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_14"
android:textStyle="bold"
android:visibility="invisible"/>
<TextView
android:id="@+id/tv_modify_before_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/tv_number"
android:text="30"
android:visibility="invisible"
android:textColor="@color/orange_200"
android:textSize="@dimen/sp_14" />
</RelativeLayout>
\ No newline at end of file
apply from: rootProject.file("cc-settings.gradle")
android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"]
if (project.ext.runAsApp) {
applicationId 'com.gingersoft.cloud.gsa.order.detail'
}
versionCode rootProject.ext.android["versionCode"]
versionName rootProject.ext.android["versionName"]
}
resourcePrefix "order_detail"
buildTypes {
release {
postprocessing {
removeUnusedCode false
removeUnusedResources false
obfuscate false
optimizeCode false
proguardFiles 'proguard.cfg'
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
}
package com.gingersoft.cloud.gsa.component.order.list;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.gingersoft.cloud.gsa.component.order.list", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gingersoft.gsa.cloud.order.detail">
<application>
<activity android:name=".OrderDetailActivity"></activity>
</application>
</manifest>
\ No newline at end of file
package com.gingersoft.gsa.cloud.order.detail;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
/**
* @author billy.qi
*/
public class OrderDetailActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.order_detail_activity_main);
TextView textView = new TextView(this);
textView.setGravity(Gravity.CENTER);
textView.setText("ActivityA\nClick to finish this activity");
setContentView(textView);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>
<?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"?>
<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:orientation="vertical"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/login_user_state_observer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
/>
<TextView
android:id="@+id/login_user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
/>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
>
</ScrollView>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:background="#cccccc"
android:scrollbars="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/console"
android:padding="10dp"
/>
</ScrollView>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- <color name="colorPrimary">#008577</color>-->
<!-- <color name="colorPrimaryDark">#00574B</color>-->
<!-- <color name="colorAccent">#D81B60</color>-->
</resources>
<resources>
<string name="order_detail_app_name">component-order-detail</string>
</resources>
package com.gingersoft.cloud.gsa.component.order.list;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
apply from: rootProject.file("cc-settings.gradle")
android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"]
if (project.ext.runAsApp) {
applicationId 'com.gingersoft.cloud.gsa.order.list'
}
versionCode rootProject.ext.android["versionCode"]
versionName rootProject.ext.android["versionName"]
}
resourcePrefix "gsa_order_detail"
buildTypes {
release {
postprocessing {
removeUnusedCode false
removeUnusedResources false
obfuscate false
optimizeCode false
proguardFiles 'proguard.cfg'
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package com.gingersoft.cloud.gsa.component.order.list;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.gingersoft.cloud.gsa.component.order.list", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gingersoft.gsa.cloud.order.list">
</manifest>
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>
<?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"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>
<resources>
<string name="app_name">component-order-list</string>
</resources>
package com.gingersoft.cloud.gsa.component.order.list;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
apply plugin: 'com.android.library'
android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"]
}
}
ext {
bintrayRepo = 'android'
bintrayName = 'objpool'
publishedGroupId = 'com.billy.android'
libraryName = 'ObjPool'
artifact = 'pools'
libraryDescription = '线程安全的对象池'
siteUrl = 'https://github.com/luckybilly/CC'
gitUrl = 'git@github.com:luckybilly/CC.git'
libraryVersion = '0.0.6' //要发布到 jcenter 上的版本号
developerId = 'billy'
developerName = 'billy'
developerEmail = 'okkanan@hotmail.com'
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
apply from: rootProject.file('bintray.gradle')
\ No newline at end of file
# Add project specific ProGuard rules here. # Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the # By default, the flags in this file are appended to flags specified
# proguardFiles setting in build.gradle. # in /Users/billy/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
# #
# For more details, see # For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html # http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following # If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface # and specify the fully qualified class name to the JavaScript interface
# class: # class:
......
<manifest package="com.billy.android.pools">
<application />
</manifest>
package com.billy.android.pools;
import java.util.concurrent.ConcurrentLinkedQueue;
/**
* 线程安全的对象池
*
* 使用方法:
* <pre>
* //创建一个新对象池
* ObjPool&lt;ImageView, Context&gt; pool = new ObjPool&lt;&gt;(){
* protected ImageView newInstance(Context r) {
* return new ImageView(r);
* }
* };
* pool.get(context); //获取一个实例
* pool.put(imageView); //回收一个实例到对象池
* pool.clear(); //清空对象池
* </pre>
*
* @param <T> 要创建的对象
* @param <R> 创建对象所需的参数
*/
public abstract class ObjPool<T, R> {
protected ConcurrentLinkedQueue<T> list;
/**
* 创建一个对象池,不限制缓存数量
*/
public ObjPool() {
list = new ConcurrentLinkedQueue<>();
}
/**
* 从对象池中获取一个实例
* 优先从缓存中获取,如果缓存中没有实例,则创建一个实例并返回
* @param r 创建一个新实例需要的参数
* @return 获取的实例
*/
public T get(R r) {
T t = list.poll();
if (t == null) {
t = newInstance(r);
}
if (t != null && t instanceof Initable) {
((Initable<R>) t).init(r);
}
return t;
}
/**
* 接收一个实例放到对象池中
* @param t 要放入对象池的实例
*/
public void put(T t) {
if (t != null) {
if (t instanceof Resetable) {
((Resetable) t).reset();
}
list.offer(t);
}
}
/**
* 清空对象池
* 推荐在确定不再需要此对象池的时候调用此方法来清空缓存的实例
*/
public void clear() {
list.clear();
}
/**
* 创建新的实例
* @param r 创建对象所需的参数
* @return 新的实例
*/
protected abstract T newInstance(R r);
public interface Resetable {
void reset();
}
public interface Initable<R> {
void init(R r);
}
}
...@@ -62,8 +62,6 @@ public class PrintActivity extends Activity implements PrintSocketHolder.OnState ...@@ -62,8 +62,6 @@ public class PrintActivity extends Activity implements PrintSocketHolder.OnState
rvBill.setLayoutManager(new LinearLayoutManager(this)); rvBill.setLayoutManager(new LinearLayoutManager(this));
rvBill.setAdapter(billAdapter); rvBill.setAdapter(billAdapter);
// findViewById(R.id.btn_print).setOnClickListener(v -> { // findViewById(R.id.btn_print).setOnClickListener(v -> {
// if (executor == null) { // if (executor == null) {
// executor = new PrintExecutor("192.168.1.217", 9100, PrinterWriter58mm.TYPE_58); // executor = new PrintExecutor("192.168.1.217", 9100, PrinterWriter58mm.TYPE_58);
......
...@@ -35,8 +35,11 @@ dependencies { ...@@ -35,8 +35,11 @@ dependencies {
implementation files('libs/javabase64-1.2.jar') implementation files('libs/javabase64-1.2.jar')
implementation files('libs/sun.misc.BASE64Decoder.jar') implementation files('libs/sun.misc.BASE64Decoder.jar')
implementation 'androidx.appcompat:appcompat:1.1.0' // implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//日誌管理
implementation 'com.elvishew:xlog:1.6.1'
} }
...@@ -19,6 +19,7 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -19,6 +19,7 @@ public class GsaCloudApplication extends BaseApplication {
*/ */
private static Context mAppContext; private static Context mAppContext;
public static boolean isLogin = false;
@Override @Override
public void onCreate() { public void onCreate() {
...@@ -35,8 +36,7 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -35,8 +36,7 @@ public class GsaCloudApplication extends BaseApplication {
} }
private void initGreenDao() private void initGreenDao() {
{
DaoManager mManager = DaoManager.getInstance(); DaoManager mManager = DaoManager.getInstance();
mManager.init(this); mManager.init(this);
} }
...@@ -58,25 +58,25 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -58,25 +58,25 @@ public class GsaCloudApplication extends BaseApplication {
//获取登陆token //获取登陆token
public static String getLoginToken(Context context) { public static String getLoginToken(Context context) {
return (String) SPUtils.get(context, UserConstans.token, "0"); return (String) SPUtils.get(context, UserConstans.token, "");
} }
public static String getMemberId(Context context) { public static int getMemberId(Context context) {
return (String) SPUtils.get(context, UserConstans.memberId, "0"); return (int) SPUtils.get(context, UserConstans.memberId, 0);
} }
public static String getRestaurantId(Context context) { public static int getRestaurantId(Context context) {
return (String) SPUtils.get(context, UserConstans.restaurantId, ""); return (int) SPUtils.get(context, UserConstans.restaurantId, 0);
}
public static void setMemberId(Context context, int memberId) {
SPUtils.put(context, UserConstans.memberId, memberId);
} }
public static void setLoginToken(Context context, String token) { public static void setLoginToken(Context context, String token) {
SPUtils.put(context, UserConstans.token, token); SPUtils.put(context, UserConstans.token, token);
} }
public static void setMemberId(Context context, int memberId) {
SPUtils.put(context, UserConstans.memberId, memberId);
}
public static void setRestaurantId(Context context, int restaurantId) { public static void setRestaurantId(Context context, int restaurantId) {
SPUtils.put(context, UserConstans.restaurantId, restaurantId); SPUtils.put(context, UserConstans.restaurantId, restaurantId);
} }
......
...@@ -16,6 +16,7 @@ public class BaseRespose { ...@@ -16,6 +16,7 @@ public class BaseRespose {
*/ */
private boolean success; private boolean success;
private String errMsg;
private long sysTime; private long sysTime;
public boolean isSuccess() { public boolean isSuccess() {
...@@ -26,6 +27,14 @@ public class BaseRespose { ...@@ -26,6 +27,14 @@ public class BaseRespose {
this.success = success; this.success = success;
} }
public String getErrMsg() {
return errMsg;
}
public void setErrMsg(String errMsg) {
this.errMsg = errMsg;
}
public long getSysTime() { public long getSysTime() {
return sysTime; return sysTime;
} }
......
package com.gingersoft.gsa.cloud.download.mvp.model.bean; package com.gingersoft.gsa.cloud.base.bean;
import com.gingersoft.gsa.cloud.database.bean.Food; import com.gingersoft.gsa.cloud.database.bean.Food;
...@@ -69,6 +69,32 @@ public class FoodBean { ...@@ -69,6 +69,32 @@ public class FoodBean {
private int isSold; private int isSold;
private String plu; private String plu;
/**
* 自定義字段
*/
//是否被選中
private boolean isSelected = false;
//选择的数据
private int number = 0;
public boolean isSelected() {
return isSelected;
}
public void setSelected(boolean selected) {
isSelected = selected;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public int getId() { public int getId() {
return id; return id;
} }
......
package com.gingersoft.gsa.cloud.base.utils;
import com.elvishew.xlog.XLog;
import java.math.BigDecimal;
import java.text.DecimalFormat;
/**
* Created by Administrator on 2018/9/10 0010.
*/
public class MoneyUtil {
// 總金額小數位
public static int rounding,RoundingDecimal;
// (直接截取) : 食品 細項 折扣 會員折扣 合計 服務費
public static int ItemDecimals;
public static double get_ItemDecimals_money(double money) {
double rMoney = money;
//返回指定的小数位:
//e.g Coke $13.456
//ItemDecimals=0 $13.00
//ItemDecimals=1 $13.40
//ItemDecimals=2 $13.45
rMoney = new BigDecimal(String.valueOf(money)).setScale(ItemDecimals, BigDecimal.ROUND_DOWN).doubleValue();
return rMoney;
}
public static double get_Count_money(double countmoney) {
//计算并返回最后的符合规定的取值
XLog.tag("MoneyUtil").d("计算账单小数前金额get_Count_money: " + countmoney);
//帐单小数
//Sys_AndroidSetting \Rounding 帳單小數算法
//例如: e.g
//Rounding=0 0.1-0.9=0.0 /
//Rounding=1 0.1-0.9=1.0 /
//Rounding=2 0.1-0.4=0.0 and 0.5-0.9=1.0 即 4 捨 5 入
//Rounding=3 0.1-0.5=0.5 and 0.6-0.9=1.0
//Sys_AndroidSetting \RoundingDecimal 整單的小數位
//例如:帳單總金額 13.456
//RoundingDecimal=1 小數後1個位進行四捨五入, 總金額結果= 13.00
//RoundingDecimal=2 小數後2個位進行四捨五入, 總金額結果= 13.50
//12.25 RoundingDecimal=1 RoundingDecimal=2 RoundingDecimal=3
//Rounding=0(0.1-0.9=0.0) 12.00 12.20 12.25
//Rounding=1(0.1-0.9=1.0) 13.00 12.30 12.25
//Rounding=2(0.1-0.4=0.0 and 0.5-0.9=1.0) 12.00 12.30 12.25
//Rounding=3(0.1-0.5=0.0 and 0.6-0.9=1.0) 12.00 12.20 12.25
double dMoney = 0.00;
//Locale.setDefault(Locale.GERMAN);
// countmoney=round(countmoney, RoundingDecimal+1);//首先产生包含了正确的数值
DecimalFormat df = new DecimalFormat("#.000000000");
if (countmoney < 1) {
countmoney = Math.round(countmoney);
}
String cm = df.format(countmoney);
String[] stringarray = cm.split("[.]");
String Int_v = stringarray[0]; //整数部分
String litt_v = stringarray[1];//小数部分
if (Int_v.length() == 0) {
return 0.00;
}
int endIndex = RoundingDecimal - 1;
if (litt_v.length() <= endIndex) {
return countmoney;
}
String midd = litt_v.substring(0, RoundingDecimal - 1);
String mid = litt_v.substring(RoundingDecimal - 1, RoundingDecimal);
switch (rounding) {
case 0:
//计算出countmoney的值
mid = "0";
mid = Int_v + "." + midd + mid;
dMoney = Double.parseDouble(mid);
break;
case 1://取出来的位置如果大于0,则需要在前面加1
if (!mid.equals("0")) {
if (RoundingDecimal == 1) {
Int_v = String.valueOf(Integer.parseInt(Int_v) + 1);
mid = "0";
} else {
midd = String.valueOf(Integer.parseInt(midd) + 1);
mid = "0";
}
}
mid = Int_v + "." + midd + mid;
dMoney = Double.parseDouble(mid);
break;
case 2:
if (!mid.equals("0")) {
if (Integer.parseInt(mid) > 4) {
if (RoundingDecimal == 1) {
Int_v = String.valueOf(Integer.parseInt(Int_v) + 1);
mid = "0";
} else {
midd = String.valueOf(Integer.parseInt(midd) + 1);
mid = "0";
}
} else {
//小于4不进位
mid = "0";
}
}
mid = Int_v + "." + midd + mid;
dMoney = Double.parseDouble(mid);
break;
case 3:
if (!mid.equals("0")) {
if (Integer.parseInt(mid) > 5) {
if (RoundingDecimal == 1) {
Int_v = String.valueOf(Integer.parseInt(Int_v) + 1);
mid = "0";
} else {
midd = String.valueOf(Integer.parseInt(midd) + 1);
mid = "0";
}
} else {
//小于5不进位
mid = "5";
}
}
mid = Int_v + "." + midd + mid;
dMoney = Double.parseDouble(mid);
break;
default:
dMoney = Double.parseDouble(new DecimalFormat("#.00").format(countmoney));
break;
}
XLog.tag("MoneyUtil").d("计算账单小数后金额get_Count_money: " + dMoney);
return dMoney;
}
public static double get_Count_money2(double countmoney) {
//计算并返回最后的符合规定的取值
XLog.tag("MoneyUtil").d("计算账单小数前金额get_Count_money: " + countmoney);
double dMoney = 0.00;
DecimalFormat df = new DecimalFormat("#.000000000");
if (countmoney < 1) {
countmoney = Math.round(countmoney);
}
String cm = df.format(countmoney);
String[] stringarray = cm.split("[.]");
String Int_v = stringarray[0]; //整数部分
String litt_v = stringarray[1];//小数部分
if (Int_v.length() == 0) {
return 0.00;
}
int endIndex = RoundingDecimal - 1;
if (litt_v.length() <= endIndex) {
return countmoney;
}
String midd = litt_v.substring(0, RoundingDecimal - 1);
String mid = litt_v.substring(RoundingDecimal - 1, RoundingDecimal);
switch (rounding) {
case 0:
//计算出countmoney的值
mid = "0";
mid = Int_v + "." + midd + mid;
dMoney = Double.parseDouble(mid);
break;
case 1://取出来的位置如果大于0,则需要在前面加1
if (!mid.equals("0")) {
if (RoundingDecimal == 1) {
Int_v = String.valueOf(Integer.parseInt(Int_v) + 1);
mid = "0";
} else {
midd = String.valueOf(Integer.parseInt(midd) + 1);
mid = "0";
}
}
mid = Int_v + "." + midd + mid;
dMoney = Double.parseDouble(mid);
break;
case 2:
if (!mid.equals("0")) {
if (Integer.parseInt(mid) > 4) {
if (RoundingDecimal == 1) {
Int_v = String.valueOf(Integer.parseInt(Int_v) + 1);
mid = "0";
} else {
midd = String.valueOf(Integer.parseInt(midd) + 1);
mid = "0";
}
} else {
//小于4不进位
mid = "0";
}
}
mid = Int_v + "." + midd + mid;
dMoney = Double.parseDouble(mid);
break;
case 3:
if (!mid.equals("0")) {
if (Integer.parseInt(mid) > 5) {
if (RoundingDecimal == 1) {
Int_v = String.valueOf(Integer.parseInt(Int_v) + 1);
mid = "0";
} else {
midd = String.valueOf(Integer.parseInt(midd) + 1);
mid = "0";
}
} else {
//小于5不进位
mid = "5";
}
}
mid = Int_v + "." + midd + mid;
dMoney = Double.parseDouble(mid);
break;
}
XLog.tag("MoneyUtil").d("计算账单小数后金额get_Count_money: " + dMoney);
return dMoney;
}
public static double getDecimalMoney(double money, int decimal) {
return new BigDecimal(String.valueOf(money)).setScale(decimal, BigDecimal.ROUND_HALF_UP).doubleValue();
}
/**
* 计算总价
*
* @param price
* @param number
* @return
*/
public static double priceCalculation(double price, int number) {
BigDecimal b1 = new BigDecimal(price);
BigDecimal b2 = new BigDecimal(number);
return (b1.multiply(b2)).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
}
}
...@@ -5,7 +5,8 @@ package com.gingersoft.gsa.cloud.base.utils.constans; ...@@ -5,7 +5,8 @@ package com.gingersoft.gsa.cloud.base.utils.constans;
*/ */
public class HttpsConstans { public class HttpsConstans {
public static String ROOT_SERVER_ADDRESS_FORMAL = "http://gingersoft.tpddns.cn:58201/ricepon-cloud-gsa/api/";// 正式服務器 // public static String ROOT_SERVER_ADDRESS_FORMAL = "http://gingersoft.tpddns.cn:58201/ricepon-cloud-gsa/api/";// 正式服務器
public static String ROOT_SERVER_ADDRESS_FORMAL = "http://192.168.1.74:8201/ricepon-cloud-gsa/api/";// 正式服務器
public static String ROOT_SERVER_ADDRESS_FORMAL2 = "http://gingersoft.tpddns.cn:53000/mock/49/ricepon-cloud-gsa/api/";//測試服務器 public static String ROOT_SERVER_ADDRESS_FORMAL2 = "http://gingersoft.tpddns.cn:53000/mock/49/ricepon-cloud-gsa/api/";//測試服務器
......
...@@ -65,8 +65,7 @@ public class GsonUtils { ...@@ -65,8 +65,7 @@ public class GsonUtils {
public static <T> List<T> GsonToList(String gsonString, Class<T> cls) { public static <T> List<T> GsonToList(String gsonString, Class<T> cls) {
List<T> list = null; List<T> list = null;
if (gson != null) { if (gson != null) {
list = gson.fromJson(gsonString, new TypeToken<List<T>>() { list = gson.fromJson(gsonString, new TypeToken<List<T>>() {}.getType());
}.getType());
} }
return list; return list;
} }
......
ext.alwaysLib = true //虽然apply了cc-settings-2.gradle,但一直作为library编译,否则别的组件依赖此module时会报错 ext.alwaysLib = true //虽然apply了cc-settings-2.gradle,但一直作为library编译,否则别的组件依赖此module时会报错
apply from: rootProject.file("cc-settings.gradle") apply from: rootProject.file("cc-settings.gradle")
apply plugin: 'org.greenrobot.greendao' apply plugin: 'org.greenrobot.greendao'
android { android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"] compileSdkVersion rootProject.ext.android["compileSdkVersion"]
......
...@@ -4,6 +4,7 @@ import org.greenrobot.greendao.annotation.Entity; ...@@ -4,6 +4,7 @@ import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated; import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id; import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.NotNull; import org.greenrobot.greendao.annotation.NotNull;
import org.greenrobot.greendao.annotation.Transient;
/** /**
* 作者:ELEGANT_BIN * 作者:ELEGANT_BIN
...@@ -20,7 +21,6 @@ public class Food { ...@@ -20,7 +21,6 @@ public class Food {
private Long id; private Long id;
@NotNull @NotNull
private int foodId;
private int parentId; private int parentId;
private String foodName; private String foodName;
private int restaurantId; private int restaurantId;
...@@ -29,14 +29,33 @@ public class Food { ...@@ -29,14 +29,33 @@ public class Food {
private int isSold; private int isSold;
private String plu; private String plu;
/**
* 自定義字段
*/
@Transient
private boolean isSelected = false;
@Transient
private int number = 0;
@Transient
private int parentIndex = 0;
@Transient
private int myIndex = 0;
@Transient
private boolean isNew = true;
@Transient
private boolean visible = true;
@Generated(hash = 1605097359) @Generated(hash = 866324199)
public Food(Long id, int foodId, int parentId, String foodName, public Food() {
int restaurantId, double price, int totalSold, int isSold, String plu) { }
@Generated(hash = 278629678)
public Food(Long id, int parentId, String foodName, int restaurantId,
double price, int totalSold, int isSold, String plu) {
this.id = id; this.id = id;
this.foodId = foodId;
this.parentId = parentId; this.parentId = parentId;
this.foodName = foodName; this.foodName = foodName;
this.restaurantId = restaurantId; this.restaurantId = restaurantId;
...@@ -46,12 +65,22 @@ public class Food { ...@@ -46,12 +65,22 @@ public class Food {
this.plu = plu; this.plu = plu;
} }
@Generated(hash = 866324199)
public Food() { public boolean isSelected() {
return isSelected;
} }
public void setSelected(boolean selected) {
isSelected = selected;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public Long getId() { public Long getId() {
return id; return id;
...@@ -61,14 +90,6 @@ public class Food { ...@@ -61,14 +90,6 @@ public class Food {
this.id = id; this.id = id;
} }
public int getFoodId() {
return foodId;
}
public void setFoodId(int foodId) {
this.foodId = foodId;
}
public int getParentId() { public int getParentId() {
return parentId; return parentId;
} }
...@@ -124,4 +145,76 @@ public class Food { ...@@ -124,4 +145,76 @@ public class Food {
public void setPlu(String plu) { public void setPlu(String plu) {
this.plu = plu; this.plu = plu;
} }
public boolean getIsSelected() {
return this.isSelected;
}
public void setIsSelected(boolean isSelected) {
this.isSelected = isSelected;
}
public int getParentIndex() {
return parentIndex;
}
public void setParentIndex(int parentIndex) {
this.parentIndex = parentIndex;
}
public int getMyIndex() {
return myIndex;
}
public void setMyIndex(int myIndex) {
this.myIndex = myIndex;
}
public boolean isNew() {
return isNew;
}
public void setNew(boolean aNew) {
isNew = aNew;
}
public boolean isVisible() {
return visible;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
public boolean getIsNew() {
return this.isNew;
}
public void setIsNew(boolean isNew) {
this.isNew = isNew;
}
public boolean getVisible() {
return this.visible;
}
@Override
public String toString() {
return "Food{" +
"id=" + id +
", parentId=" + parentId +
", foodName='" + foodName + '\'' +
", restaurantId=" + restaurantId +
", price=" + price +
", totalSold=" + totalSold +
", isSold=" + isSold +
", plu='" + plu + '\'' +
", isSelected=" + isSelected +
", number=" + number +
", parentIndex=" + parentIndex +
", myIndex=" + myIndex +
", isNew=" + isNew +
", visible=" + visible +
'}';
}
} }
package com.gingersoft.gsa.cloud.database.bean; package com.gingersoft.gsa.cloud.database.bean;
import org.greenrobot.greendao.annotation.Entity; import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated; import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id; import org.greenrobot.greendao.annotation.Id;
...@@ -21,7 +22,6 @@ public class Function { ...@@ -21,7 +22,6 @@ public class Function {
private Long id; private Long id;
@NotNull @NotNull
private int functionId;
private int status; private int status;
private long effectiveTime; private long effectiveTime;
private String resName; private String resName;
...@@ -29,11 +29,10 @@ public class Function { ...@@ -29,11 +29,10 @@ public class Function {
private String imageURL; private String imageURL;
@Generated(hash = 1658242544) @Generated(hash = 291948792)
public Function(Long id, int functionId, int status, long effectiveTime, public Function(Long id, int status, long effectiveTime, String resName,
String resName, String resUrl, String imageURL) { String resUrl, String imageURL) {
this.id = id; this.id = id;
this.functionId = functionId;
this.status = status; this.status = status;
this.effectiveTime = effectiveTime; this.effectiveTime = effectiveTime;
this.resName = resName; this.resName = resName;
...@@ -54,14 +53,6 @@ public class Function { ...@@ -54,14 +53,6 @@ public class Function {
this.id = id; this.id = id;
} }
public int getFunctionId() {
return functionId;
}
public void setFunctionId(int functionId) {
this.functionId = functionId;
}
public int getStatus() { public int getStatus() {
return status; return status;
} }
...@@ -101,4 +92,16 @@ public class Function { ...@@ -101,4 +92,16 @@ public class Function {
public void setImageURL(String imageURL) { public void setImageURL(String imageURL) {
this.imageURL = imageURL; this.imageURL = imageURL;
} }
@Override
public String toString() {
return "Function{" +
"id=" + id +
", status=" + status +
", effectiveTime=" + effectiveTime +
", resName='" + resName + '\'' +
", resUrl='" + resUrl + '\'' +
", imageURL='" + imageURL + '\'' +
'}';
}
} }
...@@ -25,14 +25,13 @@ public class FoodDao extends AbstractDao<Food, Long> { ...@@ -25,14 +25,13 @@ public class FoodDao extends AbstractDao<Food, Long> {
*/ */
public static class Properties { public static class Properties {
public final static Property Id = new Property(0, Long.class, "id", true, "_id"); public final static Property Id = new Property(0, Long.class, "id", true, "_id");
public final static Property FoodId = new Property(1, int.class, "foodId", false, "FOOD_ID"); public final static Property ParentId = new Property(1, int.class, "parentId", false, "PARENT_ID");
public final static Property ParentId = new Property(2, int.class, "parentId", false, "PARENT_ID"); public final static Property FoodName = new Property(2, String.class, "foodName", false, "FOOD_NAME");
public final static Property FoodName = new Property(3, String.class, "foodName", false, "FOOD_NAME"); public final static Property RestaurantId = new Property(3, int.class, "restaurantId", false, "RESTAURANT_ID");
public final static Property RestaurantId = new Property(4, int.class, "restaurantId", false, "RESTAURANT_ID"); public final static Property Price = new Property(4, double.class, "price", false, "PRICE");
public final static Property Price = new Property(5, double.class, "price", false, "PRICE"); public final static Property TotalSold = new Property(5, int.class, "totalSold", false, "TOTAL_SOLD");
public final static Property TotalSold = new Property(6, int.class, "totalSold", false, "TOTAL_SOLD"); public final static Property IsSold = new Property(6, int.class, "isSold", false, "IS_SOLD");
public final static Property IsSold = new Property(7, int.class, "isSold", false, "IS_SOLD"); public final static Property Plu = new Property(7, String.class, "plu", false, "PLU");
public final static Property Plu = new Property(8, String.class, "plu", false, "PLU");
} }
...@@ -49,14 +48,13 @@ public class FoodDao extends AbstractDao<Food, Long> { ...@@ -49,14 +48,13 @@ public class FoodDao extends AbstractDao<Food, Long> {
String constraint = ifNotExists? "IF NOT EXISTS ": ""; String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"FOOD\" (" + // db.execSQL("CREATE TABLE " + constraint + "\"FOOD\" (" + //
"\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
"\"FOOD_ID\" INTEGER NOT NULL ," + // 1: foodId "\"PARENT_ID\" INTEGER NOT NULL ," + // 1: parentId
"\"PARENT_ID\" INTEGER NOT NULL ," + // 2: parentId "\"FOOD_NAME\" TEXT," + // 2: foodName
"\"FOOD_NAME\" TEXT," + // 3: foodName "\"RESTAURANT_ID\" INTEGER NOT NULL ," + // 3: restaurantId
"\"RESTAURANT_ID\" INTEGER NOT NULL ," + // 4: restaurantId "\"PRICE\" REAL NOT NULL ," + // 4: price
"\"PRICE\" REAL NOT NULL ," + // 5: price "\"TOTAL_SOLD\" INTEGER NOT NULL ," + // 5: totalSold
"\"TOTAL_SOLD\" INTEGER NOT NULL ," + // 6: totalSold "\"IS_SOLD\" INTEGER NOT NULL ," + // 6: isSold
"\"IS_SOLD\" INTEGER NOT NULL ," + // 7: isSold "\"PLU\" TEXT);"); // 7: plu
"\"PLU\" TEXT);"); // 8: plu
} }
/** Drops the underlying database table. */ /** Drops the underlying database table. */
...@@ -73,21 +71,20 @@ public class FoodDao extends AbstractDao<Food, Long> { ...@@ -73,21 +71,20 @@ public class FoodDao extends AbstractDao<Food, Long> {
if (id != null) { if (id != null) {
stmt.bindLong(1, id); stmt.bindLong(1, id);
} }
stmt.bindLong(2, entity.getFoodId()); stmt.bindLong(2, entity.getParentId());
stmt.bindLong(3, entity.getParentId());
String foodName = entity.getFoodName(); String foodName = entity.getFoodName();
if (foodName != null) { if (foodName != null) {
stmt.bindString(4, foodName); stmt.bindString(3, foodName);
} }
stmt.bindLong(5, entity.getRestaurantId()); stmt.bindLong(4, entity.getRestaurantId());
stmt.bindDouble(6, entity.getPrice()); stmt.bindDouble(5, entity.getPrice());
stmt.bindLong(7, entity.getTotalSold()); stmt.bindLong(6, entity.getTotalSold());
stmt.bindLong(8, entity.getIsSold()); stmt.bindLong(7, entity.getIsSold());
String plu = entity.getPlu(); String plu = entity.getPlu();
if (plu != null) { if (plu != null) {
stmt.bindString(9, plu); stmt.bindString(8, plu);
} }
} }
...@@ -99,21 +96,20 @@ public class FoodDao extends AbstractDao<Food, Long> { ...@@ -99,21 +96,20 @@ public class FoodDao extends AbstractDao<Food, Long> {
if (id != null) { if (id != null) {
stmt.bindLong(1, id); stmt.bindLong(1, id);
} }
stmt.bindLong(2, entity.getFoodId()); stmt.bindLong(2, entity.getParentId());
stmt.bindLong(3, entity.getParentId());
String foodName = entity.getFoodName(); String foodName = entity.getFoodName();
if (foodName != null) { if (foodName != null) {
stmt.bindString(4, foodName); stmt.bindString(3, foodName);
} }
stmt.bindLong(5, entity.getRestaurantId()); stmt.bindLong(4, entity.getRestaurantId());
stmt.bindDouble(6, entity.getPrice()); stmt.bindDouble(5, entity.getPrice());
stmt.bindLong(7, entity.getTotalSold()); stmt.bindLong(6, entity.getTotalSold());
stmt.bindLong(8, entity.getIsSold()); stmt.bindLong(7, entity.getIsSold());
String plu = entity.getPlu(); String plu = entity.getPlu();
if (plu != null) { if (plu != null) {
stmt.bindString(9, plu); stmt.bindString(8, plu);
} }
} }
...@@ -126,14 +122,13 @@ public class FoodDao extends AbstractDao<Food, Long> { ...@@ -126,14 +122,13 @@ public class FoodDao extends AbstractDao<Food, Long> {
public Food readEntity(Cursor cursor, int offset) { public Food readEntity(Cursor cursor, int offset) {
Food entity = new Food( // Food entity = new Food( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.getInt(offset + 1), // foodId cursor.getInt(offset + 1), // parentId
cursor.getInt(offset + 2), // parentId cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // foodName
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // foodName cursor.getInt(offset + 3), // restaurantId
cursor.getInt(offset + 4), // restaurantId cursor.getDouble(offset + 4), // price
cursor.getDouble(offset + 5), // price cursor.getInt(offset + 5), // totalSold
cursor.getInt(offset + 6), // totalSold cursor.getInt(offset + 6), // isSold
cursor.getInt(offset + 7), // isSold cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // plu
cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // plu
); );
return entity; return entity;
} }
...@@ -141,14 +136,13 @@ public class FoodDao extends AbstractDao<Food, Long> { ...@@ -141,14 +136,13 @@ public class FoodDao extends AbstractDao<Food, Long> {
@Override @Override
public void readEntity(Cursor cursor, Food entity, int offset) { public void readEntity(Cursor cursor, Food entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setFoodId(cursor.getInt(offset + 1)); entity.setParentId(cursor.getInt(offset + 1));
entity.setParentId(cursor.getInt(offset + 2)); entity.setFoodName(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
entity.setFoodName(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); entity.setRestaurantId(cursor.getInt(offset + 3));
entity.setRestaurantId(cursor.getInt(offset + 4)); entity.setPrice(cursor.getDouble(offset + 4));
entity.setPrice(cursor.getDouble(offset + 5)); entity.setTotalSold(cursor.getInt(offset + 5));
entity.setTotalSold(cursor.getInt(offset + 6)); entity.setIsSold(cursor.getInt(offset + 6));
entity.setIsSold(cursor.getInt(offset + 7)); entity.setPlu(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
entity.setPlu(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
} }
@Override @Override
......
...@@ -25,12 +25,11 @@ public class FunctionDao extends AbstractDao<Function, Long> { ...@@ -25,12 +25,11 @@ public class FunctionDao extends AbstractDao<Function, Long> {
*/ */
public static class Properties { public static class Properties {
public final static Property Id = new Property(0, Long.class, "id", true, "_id"); public final static Property Id = new Property(0, Long.class, "id", true, "_id");
public final static Property FunctionId = new Property(1, int.class, "functionId", false, "FUNCTION_ID"); public final static Property Status = new Property(1, int.class, "status", false, "STATUS");
public final static Property Status = new Property(2, int.class, "status", false, "STATUS"); public final static Property EffectiveTime = new Property(2, long.class, "effectiveTime", false, "EFFECTIVE_TIME");
public final static Property EffectiveTime = new Property(3, long.class, "effectiveTime", false, "EFFECTIVE_TIME"); public final static Property ResName = new Property(3, String.class, "resName", false, "RES_NAME");
public final static Property ResName = new Property(4, String.class, "resName", false, "RES_NAME"); public final static Property ResUrl = new Property(4, String.class, "resUrl", false, "RES_URL");
public final static Property ResUrl = new Property(5, String.class, "resUrl", false, "RES_URL"); public final static Property ImageURL = new Property(5, String.class, "imageURL", false, "IMAGE_URL");
public final static Property ImageURL = new Property(6, String.class, "imageURL", false, "IMAGE_URL");
} }
...@@ -47,12 +46,11 @@ public class FunctionDao extends AbstractDao<Function, Long> { ...@@ -47,12 +46,11 @@ public class FunctionDao extends AbstractDao<Function, Long> {
String constraint = ifNotExists? "IF NOT EXISTS ": ""; String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"FUNCTION\" (" + // db.execSQL("CREATE TABLE " + constraint + "\"FUNCTION\" (" + //
"\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
"\"FUNCTION_ID\" INTEGER NOT NULL ," + // 1: functionId "\"STATUS\" INTEGER NOT NULL ," + // 1: status
"\"STATUS\" INTEGER NOT NULL ," + // 2: status "\"EFFECTIVE_TIME\" INTEGER NOT NULL ," + // 2: effectiveTime
"\"EFFECTIVE_TIME\" INTEGER NOT NULL ," + // 3: effectiveTime "\"RES_NAME\" TEXT," + // 3: resName
"\"RES_NAME\" TEXT," + // 4: resName "\"RES_URL\" TEXT," + // 4: resUrl
"\"RES_URL\" TEXT," + // 5: resUrl "\"IMAGE_URL\" TEXT);"); // 5: imageURL
"\"IMAGE_URL\" TEXT);"); // 6: imageURL
} }
/** Drops the underlying database table. */ /** Drops the underlying database table. */
...@@ -69,23 +67,22 @@ public class FunctionDao extends AbstractDao<Function, Long> { ...@@ -69,23 +67,22 @@ public class FunctionDao extends AbstractDao<Function, Long> {
if (id != null) { if (id != null) {
stmt.bindLong(1, id); stmt.bindLong(1, id);
} }
stmt.bindLong(2, entity.getFunctionId()); stmt.bindLong(2, entity.getStatus());
stmt.bindLong(3, entity.getStatus()); stmt.bindLong(3, entity.getEffectiveTime());
stmt.bindLong(4, entity.getEffectiveTime());
String resName = entity.getResName(); String resName = entity.getResName();
if (resName != null) { if (resName != null) {
stmt.bindString(5, resName); stmt.bindString(4, resName);
} }
String resUrl = entity.getResUrl(); String resUrl = entity.getResUrl();
if (resUrl != null) { if (resUrl != null) {
stmt.bindString(6, resUrl); stmt.bindString(5, resUrl);
} }
String imageURL = entity.getImageURL(); String imageURL = entity.getImageURL();
if (imageURL != null) { if (imageURL != null) {
stmt.bindString(7, imageURL); stmt.bindString(6, imageURL);
} }
} }
...@@ -97,23 +94,22 @@ public class FunctionDao extends AbstractDao<Function, Long> { ...@@ -97,23 +94,22 @@ public class FunctionDao extends AbstractDao<Function, Long> {
if (id != null) { if (id != null) {
stmt.bindLong(1, id); stmt.bindLong(1, id);
} }
stmt.bindLong(2, entity.getFunctionId()); stmt.bindLong(2, entity.getStatus());
stmt.bindLong(3, entity.getStatus()); stmt.bindLong(3, entity.getEffectiveTime());
stmt.bindLong(4, entity.getEffectiveTime());
String resName = entity.getResName(); String resName = entity.getResName();
if (resName != null) { if (resName != null) {
stmt.bindString(5, resName); stmt.bindString(4, resName);
} }
String resUrl = entity.getResUrl(); String resUrl = entity.getResUrl();
if (resUrl != null) { if (resUrl != null) {
stmt.bindString(6, resUrl); stmt.bindString(5, resUrl);
} }
String imageURL = entity.getImageURL(); String imageURL = entity.getImageURL();
if (imageURL != null) { if (imageURL != null) {
stmt.bindString(7, imageURL); stmt.bindString(6, imageURL);
} }
} }
...@@ -126,12 +122,11 @@ public class FunctionDao extends AbstractDao<Function, Long> { ...@@ -126,12 +122,11 @@ public class FunctionDao extends AbstractDao<Function, Long> {
public Function readEntity(Cursor cursor, int offset) { public Function readEntity(Cursor cursor, int offset) {
Function entity = new Function( // Function entity = new Function( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.getInt(offset + 1), // functionId cursor.getInt(offset + 1), // status
cursor.getInt(offset + 2), // status cursor.getLong(offset + 2), // effectiveTime
cursor.getLong(offset + 3), // effectiveTime cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // resName
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // resName cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // resUrl
cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // resUrl cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // imageURL
cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6) // imageURL
); );
return entity; return entity;
} }
...@@ -139,12 +134,11 @@ public class FunctionDao extends AbstractDao<Function, Long> { ...@@ -139,12 +134,11 @@ public class FunctionDao extends AbstractDao<Function, Long> {
@Override @Override
public void readEntity(Cursor cursor, Function entity, int offset) { public void readEntity(Cursor cursor, Function entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setFunctionId(cursor.getInt(offset + 1)); entity.setStatus(cursor.getInt(offset + 1));
entity.setStatus(cursor.getInt(offset + 2)); entity.setEffectiveTime(cursor.getLong(offset + 2));
entity.setEffectiveTime(cursor.getLong(offset + 3)); entity.setResName(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
entity.setResName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); entity.setResUrl(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
entity.setResUrl(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); entity.setImageURL(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
entity.setImageURL(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
} }
@Override @Override
......
...@@ -137,12 +137,21 @@ public class FoodDaoUtils { ...@@ -137,12 +137,21 @@ public class FoodDaoUtils {
} }
/** /**
* 使用queryBuilder进行查询 * 使用queryBuilder进行查询食品組
* @return * @return
*/ */
public List<Food> queryFoodByQueryBuilder(long foodId){ public List<Food> queryFoodGroupByQueryBuilder(){
QueryBuilder<Food> queryBuilder = mManager.getDaoSession().queryBuilder(Food.class); QueryBuilder<Food> queryBuilder = mManager.getDaoSession().queryBuilder(Food.class);
return queryBuilder.where(FoodDao.Properties.FoodId.eq(foodId)).list(); return queryBuilder.where(FoodDao.Properties.ParentId.le(0)).list();
// return queryBuilder.where(FoodDao.Properties._id.ge(id)).list();
} }
/**
* 使用queryBuilder进行查询食品
* @return
*/
public List<Food> queryFoodByQueryBuilder(long parentId){
QueryBuilder<Food> queryBuilder = mManager.getDaoSession().queryBuilder(Food.class);
return queryBuilder.where(FoodDao.Properties.ParentId.eq(parentId)).list();
}
} }
...@@ -142,7 +142,7 @@ public class FunctionDaoUtils { ...@@ -142,7 +142,7 @@ public class FunctionDaoUtils {
*/ */
public List<Function> queryFunctionByQueryBuilder(long FunctionId){ public List<Function> queryFunctionByQueryBuilder(long FunctionId){
QueryBuilder<Function> queryBuilder = mManager.getDaoSession().queryBuilder(Function.class); QueryBuilder<Function> queryBuilder = mManager.getDaoSession().queryBuilder(Function.class);
return queryBuilder.where(FunctionDao.Properties.FunctionId.eq(FunctionId)).list(); return queryBuilder.where(FunctionDao.Properties.Id.eq(FunctionId)).list();
// return queryBuilder.where(FunctionDao.Properties._id.ge(id)).list(); // return queryBuilder.where(FunctionDao.Properties._id.ge(id)).list();
} }
} }
...@@ -35,10 +35,12 @@ android { ...@@ -35,10 +35,12 @@ android {
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
// test
implementation rootProject.ext.dependencies["retrofit-url-manager"] testImplementation rootProject.ext.dependencies["junit"]
implementation rootProject.ext.dependencies["progressmanager"]
debugImplementation rootProject.ext.dependencies["canary-debug"] debugImplementation rootProject.ext.dependencies["canary-debug"]
releaseImplementation rootProject.ext.dependencies["canary-release"] releaseImplementation rootProject.ext.dependencies["canary-release"]
testImplementation rootProject.ext.dependencies["canary-release"] testImplementation rootProject.ext.dependencies["canary-release"]
//
//// implementation rootProject.ext.dependencies["retrofit-url-manager"]
implementation rootProject.ext.dependencies["progressmanager"]
} }
...@@ -7,6 +7,7 @@ import com.gingersoft.gsa.cloud.base.utils.constans.AppConstans; ...@@ -7,6 +7,7 @@ import com.gingersoft.gsa.cloud.base.utils.constans.AppConstans;
import com.gingersoft.gsa.cloud.base.utils.encryption.Aes; import com.gingersoft.gsa.cloud.base.utils.encryption.Aes;
import com.gingersoft.gsa.cloud.base.utils.log.LogUtil; import com.gingersoft.gsa.cloud.base.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.base.utils.other.AppUtils; import com.gingersoft.gsa.cloud.base.utils.other.AppUtils;
import okhttp3.Headers; import okhttp3.Headers;
import okhttp3.Interceptor; import okhttp3.Interceptor;
import okhttp3.Request; import okhttp3.Request;
...@@ -31,26 +32,28 @@ public class MyGlobalHttpHandler implements GlobalHttpHandler { ...@@ -31,26 +32,28 @@ public class MyGlobalHttpHandler implements GlobalHttpHandler {
e(requestBody); e(requestBody);
String url = chain.request().url().url().toString(); String url = chain.request().url().url().toString();
String token = "";
// String memberId = RequestUtils.getMemberId(GsaCloudApplication.getAppContext()); if (GsaCloudApplication.isLogin) {
// String loginToken = RequestUtils.getLoginToken(GsaCloudApplication.getAppContext()); int memberId = GsaCloudApplication.getMemberId(GsaCloudApplication.getAppContext());
// String token = Aes.aesDecrypt("9_" + memberId + "_" + System.currentTimeMillis() + "_" + loginToken); String loginToken = GsaCloudApplication.getLoginToken(GsaCloudApplication.getAppContext());
// token = Aes.aesEncrypt("9_" + memberId + "_" + System.currentTimeMillis() + "_" + loginToken);
// token = token.replaceAll("\r|\n", ""); token = token.replaceAll("\r|\n", "");
}
// String token = "e64a3959460141a4996d92ab07b0e14b";
String token = "e64a3959460141a4996d92ab07b0e14b"; Headers.Builder builder = new Headers.Builder();
builder.set("mobileVersion", android.os.Build.VERSION.RELEASE);//set表示name1是唯一的,会覆盖掉已经存在的,add不会覆盖已经存在的头,可以存在多个
builder.set("mobielModel", android.os.Build.MODEL);
builder.set("apptype", AppConstans.APP_TYPE);
builder.set("appinfo", AppUtils.getVerName(GsaCloudApplication.getAppContext()));
builder.set("mobileId", "1");
if (GsaCloudApplication.isLogin)
builder.set("token", token);
builder.set("Domain-Name", "common");
Headers headers = new Headers.Builder()
.set("mobileVersion", android.os.Build.VERSION.RELEASE)//set表示name1是唯一的,会覆盖掉已经存在的,add不会覆盖已经存在的头,可以存在多个
.set("mobielModel", android.os.Build.MODEL)
.set("apptype", AppConstans.APP_TYPE)
.set("appinfo", AppUtils.getVerName(GsaCloudApplication.getAppContext()))
.set("mobileId", "1")
.set("token", token)
.set("Domain-Name", "common")
.build();
return chain.request().newBuilder() return chain.request().newBuilder()
.headers(headers) .headers(builder.build())
.build(); .build();
} }
......
...@@ -21,6 +21,9 @@ import timber.log.Timber; ...@@ -21,6 +21,9 @@ import timber.log.Timber;
public class MyResponseErrorListener implements ResponseErrorListener { public class MyResponseErrorListener implements ResponseErrorListener {
private final String TAG = getClass().getSimpleName();
@Override @Override
public void handleResponseError(Context context, Throwable t) { public void handleResponseError(Context context, Throwable t) {
/* 用来提供处理所有错误的监听 /* 用来提供处理所有错误的监听
...@@ -39,7 +42,8 @@ public class MyResponseErrorListener implements ResponseErrorListener { ...@@ -39,7 +42,8 @@ public class MyResponseErrorListener implements ResponseErrorListener {
msg = ArmsUtils.getString(context, R.string.response_error_data_parsing_error); msg = ArmsUtils.getString(context, R.string.response_error_data_parsing_error);
} }
// ArmsUtils.snackbarText(msg); // ArmsUtils.snackbarText(msg);
LogUtil.d("handleResponseError: " + t.getMessage()); // LogUtil.d("handleResponseError: " + t.getMessage());
LogUtil.d(TAG , t.getMessage());
ToastUtils.show(context, msg); ToastUtils.show(context, msg);
} }
......
...@@ -21,7 +21,6 @@ android { ...@@ -21,7 +21,6 @@ android {
// resourcePrefix "ui" // resourcePrefix "ui"
buildTypes { buildTypes {
release { release {
postprocessing { postprocessing {
...@@ -37,4 +36,5 @@ android { ...@@ -37,4 +36,5 @@ android {
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.github.hackware1993:MagicIndicator:1.5.0'
} }
package com.gingersoft.gsa.cloud.ui.dialog;
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.util.SparseArray;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.TranslateAnimation;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.ui.R;
import com.jess.arms.base.BaseHolder;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.utils.ArmsUtils;
import com.qmuiteam.qmui.QMUILog;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.util.QMUILangHelper;
import com.qmuiteam.qmui.util.QMUIResHelper;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet;
import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheetItemView;
import com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import butterknife.BindView;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019-12-10
* 修订历史:2019-12-10
* 描述:
*/
public class ChooseRestaurantDialog extends Dialog {
private static final String TAG = "ChooseRestaurantDialog";
// 动画时长
private final static int mAnimationDuration = 200;
// 持有 ContentView,为了做动画
private View mContentView;
private boolean mIsAnimating = false;
private ChooseRestaurantDialog.OnBottomSheetShowListener mOnBottomSheetShowListener;
public ChooseRestaurantDialog(Context context) {
super(context, R.style.QMUI_BottomSheet);
}
public void setOnBottomSheetShowListener(ChooseRestaurantDialog.OnBottomSheetShowListener onBottomSheetShowListener) {
mOnBottomSheetShowListener = onBottomSheetShowListener;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//noinspection ConstantConditions
getWindow().getDecorView().setPadding(0, 0, 0, 0);
// 在底部,宽度撑满
WindowManager.LayoutParams params = getWindow().getAttributes();
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
params.gravity = Gravity.BOTTOM | Gravity.CENTER;
int screenWidth = QMUIDisplayHelper.getScreenWidth(getContext());
int screenHeight = QMUIDisplayHelper.getScreenHeight(getContext());
params.width = screenWidth < screenHeight ? screenWidth : screenHeight;
getWindow().setAttributes(params);
setCanceledOnTouchOutside(true);
}
@Override
public void setContentView(int layoutResID) {
mContentView = LayoutInflater.from(getContext()).inflate(layoutResID, null);
super.setContentView(mContentView);
}
@Override
public void setContentView(@NonNull View view, ViewGroup.LayoutParams params) {
mContentView = view;
super.setContentView(view, params);
}
public View getContentView() {
return mContentView;
}
@Override
public void setContentView(@NonNull View view) {
mContentView = view;
super.setContentView(view);
}
/**
* BottomSheet升起动画
*/
private void animateUp() {
if (mContentView == null) {
return;
}
TranslateAnimation translate = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0f
);
AlphaAnimation alpha = new AlphaAnimation(0, 1);
AnimationSet set = new AnimationSet(true);
set.addAnimation(translate);
set.addAnimation(alpha);
set.setInterpolator(new DecelerateInterpolator());
set.setDuration(mAnimationDuration);
set.setFillAfter(true);
mContentView.startAnimation(set);
}
/**
* BottomSheet降下动画
*/
private void animateDown() {
if (mContentView == null) {
return;
}
TranslateAnimation translate = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 1f
);
AlphaAnimation alpha = new AlphaAnimation(1, 0);
AnimationSet set = new AnimationSet(true);
set.addAnimation(translate);
set.addAnimation(alpha);
set.setInterpolator(new DecelerateInterpolator());
set.setDuration(mAnimationDuration);
set.setFillAfter(true);
set.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
mIsAnimating = true;
}
@Override
public void onAnimationEnd(Animation animation) {
mIsAnimating = false;
/**
* Bugfix: Attempting to destroy the window while drawing!
*/
mContentView.post(new Runnable() {
@Override
public void run() {
// java.lang.IllegalArgumentException: View=com.android.internal.policy.PhoneWindow$DecorView{22dbf5b V.E...... R......D 0,0-1080,1083} not attached to window manager
// 在dismiss的时候可能已经detach了,简单try-catch一下
try {
ChooseRestaurantDialog.super.dismiss();
} catch (Exception e) {
QMUILog.w(TAG, "dismiss error\n" + Log.getStackTraceString(e));
}
}
});
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
mContentView.startAnimation(set);
}
@Override
public void show() {
super.show();
animateUp();
if (mOnBottomSheetShowListener != null) {
mOnBottomSheetShowListener.onShow();
}
}
@Override
public void dismiss() {
if (mIsAnimating) {
return;
}
animateDown();
}
public interface OnBottomSheetShowListener {
void onShow();
}
/**
* 生成宫格类型的 {@link QMUIBottomSheet} 对话框。
*/
public static class BottomListSheetBuilder implements View.OnClickListener {
/**
* item 出现在第一行
*/
public static final int FIRST_LINE = 0;
/**
* item 出现在第二行
*/
public static final int SECOND_LINE = 1;
private Context mContext;
private QMUIBottomSheet mDialog;
private List<List<Food>> mItems;
private int mMiniItemWidth = -1;
private QMUITopBar mTopBar;
private QMUIGroupListView mGroupListView;
public BottomListSheetBuilder(Context context) {
mContext = context;
mItems = new ArrayList<>();
}
@Override
public void onClick(View v) {
// if (mOnSheetItemClickListener != null) {
// mOnSheetItemClickListener.onClick(mDialog, v);
// }
}
public QMUIBottomSheet build() {
mDialog = new QMUIBottomSheet(mContext);
View contentView = buildViews();
if (mItems.size() == 0) {
mDialog.setContentView(contentView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (QMUIDisplayHelper.getScreenHeight(mContext) * 0.5)));
} else if (mItems.size() > 4) {
mDialog.setContentView(contentView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (QMUIDisplayHelper.getScreenHeight(mContext) * 0.6)));
} else {
mDialog.setContentView(contentView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
return mDialog;
}
private View buildViews() {
View view = (LinearLayout) View.inflate(mContext, getContentViewLayoutId(), null);
mGroupListView = view.findViewById(R.id.groupListView);
mTopBar = view.findViewById(R.id.topbar);
initTopbar();
initRestaurantListView();
return view;
}
private void initRestaurantListView() {
}
private void initTopbar() {
mTopBar.setBackgroundColor(ContextCompat.getColor(mContext, R.color.theme_color));
mTopBar.addLeftBackImageButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mDialog.dismiss();
}
});
mTopBar.setTitle("選擇餐廳");
}
protected int getContentViewLayoutId() {
return R.layout.ui_dialog_choose_restaurant;
}
/**
* 拿个数最多的一行,去决策item的平铺/拉伸策略
*
* @return item 宽度
*/
private int calculateItemWidth(int width, int maxItemCountInEachLine, int paddingLeft, int paddingRight) {
if (mMiniItemWidth == -1) {
mMiniItemWidth = QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_bottom_sheet_grid_item_mini_width);
}
final int parentSpacing = width - paddingLeft - paddingRight;
int itemWidth = mMiniItemWidth;
// 看是否需要把 Item 拉伸平分 parentSpacing
if (maxItemCountInEachLine >= 3
&& parentSpacing - maxItemCountInEachLine * itemWidth > 0
&& parentSpacing - maxItemCountInEachLine * itemWidth < itemWidth) {
int count = parentSpacing / itemWidth;
itemWidth = parentSpacing / count;
}
// 看是否需要露出半个在屏幕边缘
if (itemWidth * maxItemCountInEachLine > parentSpacing) {
int count = (width - paddingLeft) / itemWidth;
itemWidth = (int) ((width - paddingLeft) / (count + .5f));
}
return itemWidth;
}
private void addViewsInSection(SparseArray<View> items, LinearLayout parent, int itemWidth) {
for (int i = 0; i < items.size(); i++) {
setItemWidth(items.get(i), itemWidth);
parent.addView(items.get(i));
}
}
private void setItemWidth(View itemView, int itemWidth) {
LinearLayout.LayoutParams itemLp;
if (itemView.getLayoutParams() != null) {
itemLp = (LinearLayout.LayoutParams) itemView.getLayoutParams();
itemLp.width = itemWidth;
} else {
itemLp = new LinearLayout.LayoutParams(itemWidth, ViewGroup.LayoutParams.WRAP_CONTENT);
itemView.setLayoutParams(itemLp);
}
itemLp.gravity = Gravity.TOP;
}
@Retention(RetentionPolicy.SOURCE)
@IntDef({FIRST_LINE, SECOND_LINE})
public @interface Style {
}
}
}
package com.gingersoft.gsa.cloud.ui.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;
import android.widget.GridView;
import com.gingersoft.gsa.cloud.ui.R;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-01-08
* 修订历史:2020-01-08
* 描述:
*/
public class LineGridView extends GridView {
public LineGridView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public LineGridView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public LineGridView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
View localView1 = getChildAt(0);
int column = getWidth() / localView1.getWidth();
int childCount = getChildCount();
Paint localPaint;
localPaint = new Paint();
localPaint.setStyle(Paint.Style.STROKE);
localPaint.setColor(getContext().getResources().getColor(R.color.theme_black));
for (int i = 0; i < childCount; i++) {
View cellView = getChildAt(i);
if ((i + 1) % column == 0) {
canvas.drawLine(cellView.getLeft(), cellView.getBottom(), cellView.getRight(), cellView.getBottom(), localPaint);
} else if ((i + 1) > (childCount - (childCount % column))) {
canvas.drawLine(cellView.getRight(), cellView.getTop(), cellView.getRight(), cellView.getBottom(), localPaint);
} else {
canvas.drawLine(cellView.getRight(), cellView.getTop(), cellView.getRight(), cellView.getBottom(), localPaint);
canvas.drawLine(cellView.getLeft(), cellView.getBottom(), cellView.getRight(), cellView.getBottom(), localPaint);
}
}
if (childCount % column != 0) {
for (int j = 0; j < (column - childCount % column); j++) {
View lastView = getChildAt(childCount - 1);
canvas.drawLine(lastView.getRight() + lastView.getWidth() * j, lastView.getTop(), lastView.getRight() + lastView.getWidth() * j, lastView.getBottom(), localPaint);
}
}
}
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.ui.view;
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.TextView;
/**
* Created by Administrator on 2017/2/22 0022.
*/
public class MarqueeTextView extends TextView {
public MarqueeTextView(Context context) {
super(context);
}
public MarqueeTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MarqueeTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean isFocused() {
return true;
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
}
}
package com.gingersoft.gsa.cloud.ui.view;
import android.content.Context;
import android.util.AttributeSet;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019-10-26
* 修订历史:2019-10-26
* 描述:
*/
public class RecyclerViewNoBugLinearLayoutManager extends LinearLayoutManager {
public RecyclerViewNoBugLinearLayoutManager(Context context) {
super(context);
}
public RecyclerViewNoBugLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
super(context, orientation, reverseLayout);
}
public RecyclerViewNoBugLinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
@Override
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
try {
//try catch一下
super.onLayoutChildren(recycler, state);
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<stroke android:color="@color/theme_black" />
<solid android:color="@color/gray" />
<padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
</shape>
</item>
<item android:state_focused="true">
<shape>
<stroke android:color="@color/theme_black" />
<padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
</shape>
</item>
<item>
<shape>
<solid android:color="@color/theme_white_color" />
<stroke android:color="@color/theme_black" />
<padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<stroke android:color="@color/theme_black" />
<solid android:color="@color/keyboard_press" />
<padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
</shape>
</item>
<item android:state_focused="true">
<shape>
<stroke android:color="@color/theme_black" />
<padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
</shape>
</item>
<item>
<shape>
<!-- <gradient android:angle="270" android:endColor="@drawable/black" android:startColor="@drawable/light_grayish" /> -->
<solid android:color="@color/keyboard_normal" />
<stroke android:color="@color/theme_black" />
<padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<stroke android:color="@color/theme_black" />
<solid android:color="@color/Dark_grayish" />
<padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
</shape>
</item>
<item android:state_focused="true">
<shape>
<stroke android:color="@color/theme_black" />
<padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
</shape>
</item>
<item>
<shape>
<!-- <gradient android:angle="270" android:endColor="@drawable/black" android:startColor="@drawable/light_grayish" /> -->
<solid android:color="#999999" />
<stroke android:color="@color/theme_black" />
<padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<stroke android:color="@color/theme_black" />
<solid android:color="@color/keyboard_press" />
<padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
</shape>
</item>
<item android:state_focused="true">
<shape>
<stroke android:color="@color/theme_black" />
<padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
</shape>
</item>
<item>
<shape>
<!-- <gradient android:angle="270" android:endColor="@drawable/black" android:startColor="@drawable/light_grayish" /> -->
<solid android:color="@color/orange_400" />
<stroke android:color="@color/orange_400" />
<padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"><shape>
<solid
android:color="@android:color/white"/><!-- 填充的颜色 -->
</shape></item>
<item android:state_focused="true"><shape>
<solid
android:color="@android:color/white"/><!-- 填充的颜色 -->
</shape></item>
<item><shape>
<solid
android:color="@android:color/white"/><!-- 填充的颜色 -->
</shape></item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#2B2B2B"></solid>
<corners
android:radius="@dimen/normal_space5">
</corners>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/theme_white_color"></solid>
<corners android:radius="@dimen/normal_space5"></corners>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<com.qmuiteam.qmui.widget.QMUIWindowInsetLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/qmui_topbar_height"
android:background="@color/qmui_config_color_background"
android:fitsSystemWindows="true">
<com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView
android:id="@+id/groupListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</ScrollView>
<com.qmuiteam.qmui.widget.QMUITopBarLayout
android:id="@+id/topbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"/>
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ui_shape_rect_fillet_theme_black_5"
android:orientation="vertical"
android:padding="3dp">
<EditText
android:id="@+id/ed_value"
android:layout_width="220dp"
android:layout_height="45dp"
android:layout_gravity="right"
android:layout_marginTop="@dimen/normal_space"
android:layout_marginRight="@dimen/normal_space"
android:layout_marginBottom="@dimen/normal_space"
android:background="@drawable/ui_shape_rect_fillet_white_5"
android:ems="10"
android:enabled="false"
android:paddingRight="@dimen/normal_space"
android:gravity="right|center_vertical"
android:hint="@string/malnumber"
android:inputType="numberDecimal"
android:singleLine="true"
android:textColorHint="#FF0000"
android:textSize="30sp"
android:textColor="@color/theme_black"
android:textStyle="bold">
<requestFocus />
</EditText>
<include layout="@layout/ui_include_number_keyboard" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:shrinkColumns="*"
android:stretchColumns="*">
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/btn_7"
android:layout_width="1dip"
android:layout_height="match_parent"
android:layout_marginRight="1dp"
android:background="@drawable/ui_selector_input_number_keyboard"
android:focusable="true"
android:tag="7"
android:text="@string/Key_7"
android:textColor="@color/theme_white_color"
android:textSize="40sp"
android:textStyle="bold" />
<Button
android:id="@+id/btn_8"
android:layout_width="1dip"
android:layout_height="match_parent"
android:layout_marginRight="1dp"
android:background="@drawable/ui_selector_input_number_keyboard"
android:focusable="true"
android:tag="8"
android:text="@string/Key_8"
android:textColor="@color/theme_white_color"
android:textSize="40sp"
android:textStyle="bold" />
<Button
android:id="@+id/btn_9"
android:layout_width="1dip"
android:layout_height="match_parent"
android:background="@drawable/ui_selector_input_number_keyboard"
android:focusable="true"
android:tag="9"
android:text="@string/Key_9"
android:textColor="@color/theme_white_color"
android:textSize="40sp"
android:textStyle="bold" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/btn_4"
android:layout_width="1dip"
android:layout_height="match_parent"
android:layout_marginTop="1dp"
android:layout_marginRight="1dp"
android:background="@drawable/ui_selector_input_number_keyboard"
android:focusable="true"
android:tag="4"
android:text="@string/Key_4"
android:textColor="@color/theme_white_color"
android:textSize="40sp"
android:textStyle="bold" />
<Button
android:id="@+id/btn_5"
android:layout_width="1dip"
android:layout_height="match_parent"
android:layout_marginTop="1dp"
android:layout_marginRight="1dp"
android:background="@drawable/ui_selector_input_number_keyboard"
android:focusable="true"
android:tag="5"
android:text="@string/Key_5"
android:textColor="@color/theme_white_color"
android:textSize="40sp"
android:textStyle="bold" />
<Button
android:id="@+id/btn_6"
android:layout_width="1dip"
android:layout_height="match_parent"
android:layout_marginTop="1dp"
android:background="@drawable/ui_selector_input_number_keyboard"
android:focusable="true"
android:tag="6"
android:text="@string/Key_6"
android:textColor="@color/theme_white_color"
android:textSize="40sp"
android:textStyle="bold" />
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/btn_1"
android:layout_width="1dip"
android:layout_height="match_parent"
android:layout_marginTop="1dp"
android:layout_marginRight="1dp"
android:background="@drawable/ui_selector_input_number_keyboard"
android:focusable="true"
android:tag="1"
android:text="@string/Key_1"
android:textColor="@color/theme_white_color"
android:textSize="40sp"
android:textStyle="bold" />
<Button
android:id="@+id/btn_2"
android:layout_width="1dip"
android:layout_height="match_parent"
android:layout_marginTop="1dp"
android:layout_marginRight="1dp"
android:background="@drawable/ui_selector_input_number_keyboard"
android:focusable="true"
android:tag="2"
android:text="@string/Key_2"
android:textColor="@color/theme_white_color"
android:textSize="40sp"
android:textStyle="bold" />
<Button
android:id="@+id/btn_3"
android:layout_width="1dip"
android:layout_height="match_parent"
android:layout_marginTop="1dp"
android:background="@drawable/ui_selector_input_number_keyboard"
android:focusable="true"
android:tag="3"
android:text="@string/Key_3"
android:textColor="@color/theme_white_color"
android:textSize="40sp"
android:textStyle="bold" />
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/btn_back"
android:layout_width="1dip"
android:layout_height="match_parent"
android:layout_marginTop="1dp"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@drawable/ui_selector_keyboard_gary_bg"
android:focusable="true"
android:longClickable="true"
android:tag="99"
android:text="返回"
android:textColor="@color/theme_white_color"
android:textSize="40sp" />
<Button
android:id="@+id/btn_0"
android:layout_width="1dip"
android:layout_height="match_parent"
android:layout_marginTop="1dp"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@drawable/ui_selector_input_number_keyboard"
android:focusable="true"
android:tag="0"
android:text="@string/Key_0"
android:textColor="@color/theme_white_color"
android:textSize="40sp"
android:textStyle="bold" />
<Button
android:id="@+id/btn_ten_plus"
android:layout_width="1dip"
android:layout_height="match_parent"
android:layout_marginTop="1dp"
android:background="@drawable/ui_selector_keyboard_theme_bg"
android:focusable="true"
android:tag="98"
android:text="10+"
android:textColor="@color/theme_white_color"
android:textSize="40sp"
android:textStyle="bold" />
</TableRow>
</TableLayout>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
...@@ -28,4 +28,4 @@ ...@@ -28,4 +28,4 @@
android:background="@color/theme_white_color" android:background="@color/theme_white_color"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
...@@ -52,4 +52,4 @@ ...@@ -52,4 +52,4 @@
app:layout_constraintRight_toRightOf="@id/rv_keyboard_en" app:layout_constraintRight_toRightOf="@id/rv_keyboard_en"
app:layout_constraintTop_toTopOf="@id/rv_keyboard_en" /> app:layout_constraintTop_toTopOf="@id/rv_keyboard_en" />
</android.support.constraint.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file \ No newline at end of file
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
<color name="colorPrimaryDark">#BF1C42</color> <color name="colorPrimaryDark">#BF1C42</color>
<color name="colorAccent">#FF4747</color> <color name="colorAccent">#FF4747</color>
<color name="itemSelected">#b0bec5</color>
<color name="mainSelected">#90a4ae</color>
<!--App主色调--> <!--App主色调-->
<color name="theme_color">#BF1C42</color> <color name="theme_color">#BF1C42</color>
<color name="theme_white_color">#FFFFFFFF</color> <color name="theme_white_color">#FFFFFFFF</color>
......
...@@ -13,6 +13,8 @@ include 'cc-register', ...@@ -13,6 +13,8 @@ include 'cc-register',
'order-detail', 'order-detail',
'order-list', 'order-list',
'table-mode', 'table-mode',
'mealstand-mode' 'mealstand-mode',
include ':demo_interceptors', ':print-module' 'demo_interceptors',
rootProject.name = 'GSA-Cloud' 'print-module',
rootProject.name = 'GSA-Cloud' , 'pools'
apply from: rootProject.file('cc-settings.gradle') apply from: rootProject.file('cc-settings.gradle')
apply plugin: 'com.jakewharton.butterknife'
android { android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"] compileSdkVersion rootProject.ext.android["compileSdkVersion"]
...@@ -19,6 +20,12 @@ android { ...@@ -19,6 +20,12 @@ android {
targetSdkVersion rootProject.ext.android["targetSdkVersion"] targetSdkVersion rootProject.ext.android["targetSdkVersion"]
versionCode rootProject.ext.android["versionCode"] versionCode rootProject.ext.android["versionCode"]
versionName rootProject.ext.android["versionName"] versionName rootProject.ext.android["versionName"]
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
includeCompileClasspath true
}
}
} }
resourcePrefix "table" resourcePrefix "table"
...@@ -38,12 +45,21 @@ android { ...@@ -38,12 +45,21 @@ android {
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
if (project.ext.runAsApp) {
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"] annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
debugImplementation rootProject.ext.dependencies["canary-debug"]
releaseImplementation rootProject.ext.dependencies["canary-release"]
testImplementation rootProject.ext.dependencies["canary-release"]
}else {
compileOnly rootProject.ext.dependencies["dagger2-compiler"]
compileOnly rootProject.ext.dependencies["canary-debug"]
compileOnly rootProject.ext.dependencies["canary-release"]
compileOnly rootProject.ext.dependencies["canary-release"]
}
// test // test
testImplementation rootProject.ext.dependencies["junit"] testImplementation rootProject.ext.dependencies["junit"]
debugImplementation rootProject.ext.dependencies["canary-debug"] // debugImplementation rootProject.ext.dependencies["canary-debug"]
releaseImplementation rootProject.ext.dependencies["canary-release"] // releaseImplementation rootProject.ext.dependencies["canary-release"]
testImplementation rootProject.ext.dependencies["canary-release"] // testImplementation rootProject.ext.dependencies["canary-release"]
} }
package com.gingersoft.gsa.cloud.table.app;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-01-08
* 修订历史:2020-01-08
* 描述:
*/
public interface GoldConstants {
int bottomFunctionColCount = 4;
int restaurantId = 26;
int refreshTime = 5;
boolean isRefreshData = false;
}
...@@ -2,6 +2,7 @@ package com.gingersoft.gsa.cloud.table.mvp.contract; ...@@ -2,6 +2,7 @@ package com.gingersoft.gsa.cloud.table.mvp.contract;
import com.gingersoft.gsa.cloud.base.bean.BaseRespose; import com.gingersoft.gsa.cloud.base.bean.BaseRespose;
import com.gingersoft.gsa.cloud.table.mvp.model.bean.TableBean; import com.gingersoft.gsa.cloud.table.mvp.model.bean.TableBean;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.mvp.IView; import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel; import com.jess.arms.mvp.IModel;
...@@ -27,15 +28,23 @@ public interface TableContract { ...@@ -27,15 +28,23 @@ public interface TableContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息 //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView { interface View extends IView {
void returnTableList(List<TableBean.DataBean> dataBeanList); void returnTableList(List<TableBean.DataBean> dataBeanList);
void clickTableItem(int id); void openTableItem(int id);
void onStartRefreshTableData();
void onPauseRefreshTableData();
void setBottomFunctionAdapter(DefaultAdapter adapter);
void setBottomFunctionRecycleLayoutManager(int orientation);
} }
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存 //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel { interface Model extends IModel {
Observable<TableBean> getTables(String restaurantId); Observable<TableBean> getTables(int restaurantId);
Observable<BaseRespose> openTable(RequestBody requestBody); Observable<BaseRespose> openTable(RequestBody requestBody);
......
...@@ -51,7 +51,7 @@ public class TableModel extends BaseModel implements TableContract.Model { ...@@ -51,7 +51,7 @@ public class TableModel extends BaseModel implements TableContract.Model {
} }
@Override @Override
public Observable<TableBean> getTables(String restaurantId) { public Observable<TableBean> getTables(int restaurantId) {
return mRepositoryManager.obtainRetrofitService(TableService.class) return mRepositoryManager.obtainRetrofitService(TableService.class)
.getTables(restaurantId); .getTables(restaurantId);
} }
......
...@@ -19,6 +19,7 @@ public class TableBean { ...@@ -19,6 +19,7 @@ public class TableBean {
*/ */
private boolean success; private boolean success;
private String errMsg;
private long sysTime; private long sysTime;
private List<DataBean> data; private List<DataBean> data;
...@@ -30,6 +31,14 @@ public class TableBean { ...@@ -30,6 +31,14 @@ public class TableBean {
this.success = success; this.success = success;
} }
public String getErrMsg() {
return errMsg;
}
public void setErrMsg(String errMsg) {
this.errMsg = errMsg;
}
public long getSysTime() { public long getSysTime() {
return sysTime; return sysTime;
} }
......
...@@ -24,7 +24,7 @@ public interface TableService { ...@@ -24,7 +24,7 @@ public interface TableService {
@GET("restaurantTable/list" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2) @GET("restaurantTable/list" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<TableBean> getTables(@Query("restaurantId") String restaurantId); Observable<TableBean> getTables(@Query("restaurantId") int restaurantId);
@POST("restaurantTable/kickOff" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2) @POST("restaurantTable/kickOff" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
......
...@@ -90,7 +90,7 @@ public class AllTablePresenter extends BasePresenter<AllTableContract.Model, All ...@@ -90,7 +90,7 @@ public class AllTablePresenter extends BasePresenter<AllTableContract.Model, All
VibratorUtils.pressButtonSound(mApplication); VibratorUtils.pressButtonSound(mApplication);
mActivity.clickTableItem(item.getId()); mActivity.openTableItem(item.getId());
} }
} }
}); });
......
...@@ -255,7 +255,7 @@ public class StateTablePresenter extends BasePresenter<StateTableContract.Model, ...@@ -255,7 +255,7 @@ public class StateTablePresenter extends BasePresenter<StateTableContract.Model,
VibratorUtils.pressButtonSound(mApplication); VibratorUtils.pressButtonSound(mApplication);
mActivity.clickTableItem(item.getId()); mActivity.openTableItem(item.getId());
} }
} }
}); });
......
...@@ -3,11 +3,17 @@ package com.gingersoft.gsa.cloud.table.mvp.presenter; ...@@ -3,11 +3,17 @@ package com.gingersoft.gsa.cloud.table.mvp.presenter;
import android.app.Application; import android.app.Application;
import android.os.CountDownTimer; import android.os.CountDownTimer;
import android.util.Log; import android.util.Log;
import android.view.View;
import com.billy.cc.core.component.CC; import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.bean.BaseRespose; import com.gingersoft.gsa.cloud.base.bean.BaseRespose;
import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.gsa.cloud.table.app.GoldConstants;
import com.gingersoft.gsa.cloud.table.mvp.model.bean.TableBean; import com.gingersoft.gsa.cloud.table.mvp.model.bean.TableBean;
import com.gingersoft.gsa.cloud.table.mvp.ui.activity.TableActivity; import com.gingersoft.gsa.cloud.table.mvp.ui.activity.TableActivity;
import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.BottomFunctionAdapter;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.integration.AppManager; import com.jess.arms.integration.AppManager;
import com.jess.arms.di.scope.ActivityScope; import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.mvp.BasePresenter; import com.jess.arms.mvp.BasePresenter;
...@@ -15,6 +21,7 @@ import com.jess.arms.http.imageloader.ImageLoader; ...@@ -15,6 +21,7 @@ import com.jess.arms.http.imageloader.ImageLoader;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull; import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler; import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber; import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
...@@ -26,7 +33,9 @@ import javax.inject.Inject; ...@@ -26,7 +33,9 @@ import javax.inject.Inject;
import com.gingersoft.gsa.cloud.table.mvp.contract.TableContract; import com.gingersoft.gsa.cloud.table.mvp.contract.TableContract;
import com.jess.arms.utils.RxLifecycleUtils; import com.jess.arms.utils.RxLifecycleUtils;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
/** /**
...@@ -52,15 +61,24 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont ...@@ -52,15 +61,24 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
@Inject @Inject
AppManager mAppManager; AppManager mAppManager;
public String restaurantId = "26"; private TableActivity IActivity;
private List<TableBean.DataBean> mTableList;
private BottomFunctionAdapter mBottomFunctionAdapter;
private List<Function> mBottomFunctionList = new ArrayList<>();
private TableBean.DataBean mOpenTableBean;
//定时获取餐台 定时器 //定时获取餐台 定时器
private GetTableTimer tableTimer; private GetTableTimer tableTimer;
private int refreshTime = 5; private Disposable mGetTablesDataDisposable;
@Inject @Inject
public TablePresenter(TableContract.Model model, TableContract.View rootView) { public TablePresenter(TableContract.Model model, TableContract.View rootView) {
super(model, rootView); super(model, rootView);
this.IActivity = (TableActivity) rootView;
initGetTableTimer(); initGetTableTimer();
} }
...@@ -76,8 +94,55 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont ...@@ -76,8 +94,55 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
cancelTableTimer(); cancelTableTimer();
} }
public void getTables(boolean show, String restaurantId) { public void initBottomFunction() {
mModel.getTables(restaurantId) initBottomFunctionItem();
if (mBottomFunctionAdapter == null) {
mBottomFunctionAdapter = new BottomFunctionAdapter(IActivity, mBottomFunctionList);
mRootView.setBottomFunctionAdapter(mBottomFunctionAdapter);
}
initBottomFunctionListener();
}
private void initBottomFunctionListener() {
mBottomFunctionAdapter.setOnItemClickListener(new DefaultAdapter.OnRecyclerViewItemClickListener() {
@Override
public void onItemClick(View view, int viewType, Object data, int position) {
if (mBottomFunctionList.get(position).getResName().equals("↑")) {
mBottomFunctionList.add(new Function((long) 5, 1, 2025, "skyorder", "", ""));
mBottomFunctionList.add(new Function((long) 6, 1, 2025, "上菜紙", "", ""));
for (int i = 0; i < mBottomFunctionList.size(); i++) {
boolean isMore = mBottomFunctionList.get(i).getResName().equals("↑");
if (isMore)
mBottomFunctionList.get(i).setResName("↓");
}
mBottomFunctionAdapter.notifyDataSetChanged();
} else if (mBottomFunctionList.get(position).getResName().equals("↓")) {
mBottomFunctionList.remove(mBottomFunctionList.size() - 1);
mBottomFunctionList.remove(mBottomFunctionList.size() - 1);
for (int i = 0; i < mBottomFunctionList.size(); i++) {
boolean isMore = mBottomFunctionList.get(i).getResName().equals("↓");
if (isMore)
mBottomFunctionList.get(i).setResName("↑");
}
mBottomFunctionAdapter.notifyDataSetChanged();
}
}
});
}
public void initBottomFunctionItem() {
mBottomFunctionList.add(new Function((long) 1, 1, 2025, "重置檯號", "", ""));
mBottomFunctionList.add(new Function((long) 2, 1, 2025, "轉檯", "", ""));
mBottomFunctionList.add(new Function((long) 3, 1, 2025, "分檯", "", ""));
mBottomFunctionList.add(new Function((long) 4, 1, 2025, "↑", "", ""));
}
public void getTables(boolean show, int restaurantId) {
restaurantId = GsaCloudApplication.getRestaurantId(mApplication);
mModel.getTables(26)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> { .doOnSubscribe(disposable -> {
if (show) if (show)
...@@ -90,11 +155,19 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont ...@@ -90,11 +155,19 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
.subscribe(new ErrorHandleSubscriber<TableBean>(mErrorHandler) { .subscribe(new ErrorHandleSubscriber<TableBean>(mErrorHandler) {
@Override @Override
public void onSubscribe(Disposable d) {
super.onSubscribe(d);
mGetTablesDataDisposable = d;
}
@Override
public void onNext(@NonNull TableBean tableBean) { public void onNext(@NonNull TableBean tableBean) {
if (tableBean.isSuccess()) { if (tableBean.isSuccess()) {
mTableList = tableBean.getData();
mRootView.returnTableList(tableBean.getData()); mRootView.returnTableList(tableBean.getData());
} else { } else {
mRootView.showMessage("獲取餐檯數據失敗!"); if (show)
mRootView.showMessage(tableBean.getErrMsg());
} }
} }
...@@ -105,10 +178,10 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont ...@@ -105,10 +178,10 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
}); });
} }
public void openTable(int tableId) { public void openTable(int id) {
RequestBody requestBody = new FormBody.Builder() RequestBody requestBody = new FormBody.Builder()
.add("id", tableId + "") .add("id", id + "")
.build(); .build();
mModel.openTable(requestBody) mModel.openTable(requestBody)
...@@ -125,12 +198,18 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont ...@@ -125,12 +198,18 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
if (respose.isSuccess()) { if (respose.isSuccess()) {
getTables(false, restaurantId); getTables(false, GoldConstants.restaurantId);
//設置當前開台數據
mOpenTableBean = getTableById(id);
CC.obtainBuilder("Component.Meal") CC.obtainBuilder("Component.Meal")
.setActionName("showMealStandActivity") .setActionName("showMealStandActivity")
.addParam("openTableBean", mOpenTableBean)
.build() .build()
.call(); .call();
} else {
mRootView.showMessage(respose.getErrMsg());
} }
} }
...@@ -167,9 +246,22 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont ...@@ -167,9 +246,22 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
}); });
} }
private TableBean.DataBean getTableById(int id) {
if (mTableList != null) {
for (int i = 0; i < mTableList.size(); i++) {
TableBean.DataBean dataBean = mTableList.get(i);
if (dataBean.getId() == id)
return dataBean;
}
}
return null;
}
public void initGetTableTimer() { public void initGetTableTimer() {
if (tableTimer == null) { if (tableTimer == null) {
tableTimer = new GetTableTimer(refreshTime * 1000, refreshTime * 1000); tableTimer = new GetTableTimer(GoldConstants.refreshTime * 1000, GoldConstants.refreshTime * 1000);
} }
tableTimer.start(); tableTimer.start();
} }
...@@ -192,7 +284,7 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont ...@@ -192,7 +284,7 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
@Override @Override
public void onFinish() {// 计时完毕时触发 public void onFinish() {// 计时完毕时触发
if (TableActivity.isRefreshData) { if (TableActivity.isRefreshData) {
getTables(false, restaurantId); getTables(false, GoldConstants.restaurantId);
} }
this.start(); this.start();
} }
...@@ -202,4 +294,8 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont ...@@ -202,4 +294,8 @@ public class TablePresenter extends BasePresenter<TableContract.Model, TableCont
} }
} }
public Disposable getGetTablesDataDisposable() {
return mGetTablesDataDisposable;
}
} }
...@@ -5,6 +5,7 @@ import android.content.Intent; ...@@ -5,6 +5,7 @@ import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.os.Message; import android.os.Message;
import android.text.TextUtils;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.View; import android.view.View;
...@@ -14,6 +15,8 @@ import android.widget.RadioButton; ...@@ -14,6 +15,8 @@ import android.widget.RadioButton;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication; import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.log.LogUtil; import com.gingersoft.gsa.cloud.base.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.table.R; import com.gingersoft.gsa.cloud.table.R;
import com.gingersoft.gsa.cloud.table.R2;
import com.gingersoft.gsa.cloud.table.app.GoldConstants;
import com.gingersoft.gsa.cloud.table.di.component.DaggerTableComponent; import com.gingersoft.gsa.cloud.table.di.component.DaggerTableComponent;
import com.gingersoft.gsa.cloud.table.mvp.model.bean.TableBean; import com.gingersoft.gsa.cloud.table.mvp.model.bean.TableBean;
import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.BaseFragmentAdapter; import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.BaseFragmentAdapter;
...@@ -23,6 +26,7 @@ import com.gingersoft.gsa.cloud.table.mvp.ui.fragment.StateTableFragment; ...@@ -23,6 +26,7 @@ import com.gingersoft.gsa.cloud.table.mvp.ui.fragment.StateTableFragment;
import com.gingersoft.gsa.cloud.ui.dialog.LoadingDialog; import com.gingersoft.gsa.cloud.ui.dialog.LoadingDialog;
import com.gingersoft.gsa.cloud.ui.view.PagerSlidingTabStrip; import com.gingersoft.gsa.cloud.ui.view.PagerSlidingTabStrip;
import com.jess.arms.base.BaseActivity; import com.jess.arms.base.BaseActivity;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.di.component.AppComponent; import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils; import com.jess.arms.utils.ArmsUtils;
import com.gingersoft.gsa.cloud.table.mvp.contract.TableContract; import com.gingersoft.gsa.cloud.table.mvp.contract.TableContract;
...@@ -42,6 +46,9 @@ import androidx.annotation.Nullable; ...@@ -42,6 +46,9 @@ import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.PagerTabStrip; import androidx.viewpager.widget.PagerTabStrip;
import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;
...@@ -65,18 +72,20 @@ import static com.jess.arms.utils.Preconditions.checkNotNull; ...@@ -65,18 +72,20 @@ import static com.jess.arms.utils.Preconditions.checkNotNull;
*/ */
public class TableActivity extends BaseActivity<TablePresenter> implements TableContract.View { public class TableActivity extends BaseActivity<TablePresenter> implements TableContract.View {
@BindView(R.id.topbar) @BindView(R2.id.topbar)
QMUITopBar mTopBar; QMUITopBar mTopBar;
@BindView(R.id.pts_table_type) @BindView(R2.id.pts_table_type)
PagerSlidingTabStrip tabs; PagerSlidingTabStrip tabs;
@BindView(R.id.vp_table_type) @BindView(R2.id.vp_table_type)
ViewPager pager_content; ViewPager pager_content;
@BindView(R.id.ll_operat_choose) @BindView(R2.id.rv_bottom_function)
RecyclerView rv_bottom_function;
@BindView(R2.id.ll_operat_choose)
LinearLayout ll_operat_choose; LinearLayout ll_operat_choose;
@BindView(R.id.btn_sure_operat) @BindView(R2.id.btn_sure_operat)
QMUIButton btn_sure_operat; QMUIButton btn_sure_operat;
@BindView(R.id.btn_cancel_operat) @BindView(R2.id.btn_cancel_operat)
QMUIButton btn_cancel_operat; QMUIButton btn_cancel_operat;
...@@ -112,6 +121,167 @@ public class TableActivity extends BaseActivity<TablePresenter> implements Table ...@@ -112,6 +121,167 @@ public class TableActivity extends BaseActivity<TablePresenter> implements Table
.inject(this); .inject(this);
} }
@Override
public int initView(@Nullable Bundle savedInstanceState) {
return R.layout.table_activity_table; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
}
@Override
public void initData(@Nullable Bundle savedInstanceState) {
initTabBarViewPage();
mPresenter.initBottomFunction();
mPresenter.getTables(true, GoldConstants.restaurantId);
}
@Override
public void initIntent() {
}
@Override
public void initTopBar() {
mTopBar.setBackgroundColor(ContextCompat.getColor(this, R.color.theme_color));
mTopBar.addLeftBackImageButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
killMyself();
}
});
mTopBar.setTitle("餐檯模式");
}
@Override
public void initLanguage() {
}
@Override
public void initLayoutParams() {
}
@Override
public void initLayoutVisible() {
}
@Override
public void showLoading(String message) {
if (!TextUtils.isEmpty(message))
LoadingDialog.showDialogForLoading(this, message, true);
else
LoadingDialog.showDialogForLoading(this);
}
@Override
public void hideLoading() {
LoadingDialog.cancelDialogForLoading();
}
@Override
public void showMessage(@NonNull String message) {
checkNotNull(message);
ArmsUtils.snackbarText(message);
}
@Override
public void launchActivity(@NonNull Intent intent) {
checkNotNull(intent);
ArmsUtils.startActivity(intent);
}
@Override
public void killMyself() {
finish();
}
@Override
public void returnTableList(List<TableBean.DataBean> dataBeanList) {
if (dataBeanList != null && dataBeanList.size() > 0) {
nofilyFragmentUpdateAllTableData(dataBeanList, 1);
}
}
@Override
public void openTableItem(int id) {
mPresenter.openTable(id);
}
// @OnClick({R2.id.btn_init_table, R2.id.btn_cancel_operat})
// public void onClick(View v) {
// switch (v.getId()) {
// case R2.id.btn_init_table:
// mTableOperatingType = 1;
//
// break;
// case R2.id.btn_sure_operat:
// sureOperat();
// break;
// case R2.id.btn_cancel_operat:
// mTableOperatingType = 0;
//
// break;
// }
// }
private void sureOperat() {
}
@Override
public void onStartRefreshTableData() {
isRefreshData = true;
mPresenter.getTables(false, GoldConstants.restaurantId);
}
@Override
public void onPauseRefreshTableData() {
isRefreshData = false;
if (mPresenter.getGetTablesDataDisposable() != null && !mPresenter.getGetTablesDataDisposable().isDisposed()) {
mPresenter.getGetTablesDataDisposable().dispose();
}
}
@Override
public void setBottomFunctionAdapter(DefaultAdapter adapter) {
setBottomFunctionRecycleLayoutManager(LinearLayoutManager.VERTICAL);
rv_bottom_function.setAdapter(adapter);
}
private GridLayoutManager bottomFunctionRecycleLayoutManager;
@Override
public void setBottomFunctionRecycleLayoutManager(int orientation) {
bottomFunctionRecycleLayoutManager = new GridLayoutManager(this, GoldConstants.bottomFunctionColCount, orientation, false);
rv_bottom_function.setLayoutManager(bottomFunctionRecycleLayoutManager);
rv_bottom_function.setItemAnimator(new DefaultItemAnimator());
}
private void nofilyFragmentUpdateAllTableData(List<TableBean.DataBean> dataBeanList, int status) {
//更新所有餐台页数据
if (allTableFragment != null) {
Message message = Message.obtain();
message.what = 1;
message.obj = dataBeanList;
message.arg1 = status;
allTableFragment.setData(message);
}
//更新所有餐台状态页数据
if (stateTableFragment != null) {
Message message = Message.obtain();
message.what = 1;
message.obj = dataBeanList;
message.arg1 = status;
stateTableFragment.setData(message);
}
}
private void initTabBarViewPage() { private void initTabBarViewPage() {
fm = getSupportFragmentManager(); fm = getSupportFragmentManager();
...@@ -235,138 +405,6 @@ public class TableActivity extends BaseActivity<TablePresenter> implements Table ...@@ -235,138 +405,6 @@ public class TableActivity extends BaseActivity<TablePresenter> implements Table
}); });
} }
@Override
public int initView(@Nullable Bundle savedInstanceState) {
return R.layout.table_activity_table; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
}
@Override
public void initData(@Nullable Bundle savedInstanceState) {
String token = GsaCloudApplication.getLoginToken(this);
LogUtil.d(TAG, " token " + token);
initTabBarViewPage();
mPresenter.getTables(true, mPresenter.restaurantId);
}
@Override
public void initIntent() {
}
@Override
public void initTopBar() {
mTopBar.setBackgroundColor(ContextCompat.getColor(this, R.color.theme_color));
mTopBar.addLeftBackImageButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
killMyself();
}
});
mTopBar.setTitle("餐檯模式");
}
@Override
public void initLanguage() {
}
@Override
public void initLayoutParams() {
}
@Override
public void initLayoutVisible() {
}
@Override
public void showLoading(String message) {
if (message != null)
LoadingDialog.showDialogForLoading(this, message, true);
else
LoadingDialog.showDialogForLoading(this);
}
@Override
public void hideLoading() {
LoadingDialog.cancelDialogForLoading();
}
@Override
public void showMessage(@NonNull String message) {
checkNotNull(message);
ArmsUtils.snackbarText(message);
}
@Override
public void launchActivity(@NonNull Intent intent) {
checkNotNull(intent);
ArmsUtils.startActivity(intent);
}
@Override
public void killMyself() {
finish();
}
@Override
public void returnTableList(List<TableBean.DataBean> dataBeanList) {
if (dataBeanList != null && dataBeanList.size() > 0) {
nofilyFragmentUpdateAllTableData(dataBeanList, 1);
}
}
@Override
public void clickTableItem(int id) {
mPresenter.openTable(id);
}
@OnClick({R.id.btn_init_table,R.id.btn_cancel_operat})
public void onClick(View v) {
switch (v.getId()){
case R.id.btn_init_table:
mTableOperatingType = 1;
break;
case R.id.btn_sure_operat:
sureOperat();
break;
case R.id.btn_cancel_operat:
mTableOperatingType = 0;
break;
}
}
private void sureOperat() {
}
private void nofilyFragmentUpdateAllTableData(List<TableBean.DataBean> dataBeanList, int status) {
//更新所有餐台页数据
if (allTableFragment != null) {
Message message = Message.obtain();
message.what = 1;
message.obj = dataBeanList;
message.arg1 = status;
allTableFragment.setData(message);
}
//更新所有餐台状态页数据
if (stateTableFragment != null) {
Message message = Message.obtain();
message.what = 1;
message.obj = dataBeanList;
message.arg1 = status;
stateTableFragment.setData(message);
}
}
public static class SortTableByName implements Comparator { public static class SortTableByName implements Comparator {
@Override @Override
......
package com.gingersoft.gsa.cloud.table.mvp.ui.adapter;
import android.content.Context;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.StateListDrawable;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.utils.ViewUtils;
import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.gsa.cloud.table.R;
import com.gingersoft.gsa.cloud.table.R2;
import com.gingersoft.gsa.cloud.table.mvp.model.bean.TableBean;
import com.jess.arms.base.BaseHolder;
import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.utils.ArmsUtils;
import java.util.List;
import butterknife.BindView;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2018/8/31
* 修订历史:2018/8/31
* 描述:餐檯底部功能列表
*/
public class BottomFunctionAdapter extends DefaultAdapter<Function> {
private Context mContext;
public BottomFunctionAdapter(Context context, List<Function> infos) {
super(infos);
this.mContext = context;
}
@Override
public int getItemCount() {
return mInfos.size();
}
@Override
public BaseHolder<Function> getHolder(View v, int viewType) {
return new BottomFunctionItemHolder(v);
}
@Override
public int getLayoutId(int viewType) {
return R.layout.table_item_bottom_function;
}
class BottomFunctionItemHolder extends BaseHolder<Function> {
@BindView(R2.id.tv_name)
TextView tv_name;
@BindView(R2.id.iv_icon)
ImageView iv_icon;
public BottomFunctionItemHolder(View itemView) {
super(itemView);
}
@Override
public void setData(Function item, int position) {
initItemData(item);
}
private void initItemData(Function item) {
tv_name.setText(item.getResName());
}
private void initItemTableClick(TableBean.DataBean item, int position) {
}
}
// private OnItemClickListener mOnItemClickListener;
//
// public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
// mOnItemClickListener = onItemClickListener;
// }
//
// public interface OnItemClickListener {
//
// void onItemClick(TableBean.DataBean datasBean, int position);
//
// }
}
...@@ -14,6 +14,7 @@ import android.widget.TextView; ...@@ -14,6 +14,7 @@ import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.utils.ViewUtils; import com.gingersoft.gsa.cloud.base.utils.ViewUtils;
import com.gingersoft.gsa.cloud.table.R; import com.gingersoft.gsa.cloud.table.R;
import com.gingersoft.gsa.cloud.table.R2;
import com.gingersoft.gsa.cloud.table.mvp.model.bean.TableBean; import com.gingersoft.gsa.cloud.table.mvp.model.bean.TableBean;
import com.jess.arms.base.BaseHolder; import com.jess.arms.base.BaseHolder;
import com.jess.arms.base.DefaultAdapter; import com.jess.arms.base.DefaultAdapter;
...@@ -83,15 +84,15 @@ public class TableAdapter extends DefaultAdapter<TableBean.DataBean> { ...@@ -83,15 +84,15 @@ public class TableAdapter extends DefaultAdapter<TableBean.DataBean> {
class TableItemHolder extends BaseHolder<TableBean.DataBean> { class TableItemHolder extends BaseHolder<TableBean.DataBean> {
@BindView(R.id.fl_container) @BindView(R2.id.fl_container)
RelativeLayout fl_container; RelativeLayout fl_container;
@BindView(R.id.btn_table) @BindView(R2.id.btn_table)
Button btn_table; Button btn_table;
@BindView(R.id.btn_showMain) @BindView(R2.id.btn_showMain)
Button btn_showMain; Button btn_showMain;
@BindView(R.id.iv_vip) @BindView(R2.id.iv_vip)
ImageView iv_vip; ImageView iv_vip;
@BindView(R.id.tv_scan_flag) @BindView(R2.id.tv_scan_flag)
TextView tv_scan_flag; TextView tv_scan_flag;
public TableItemHolder(View itemView) { public TableItemHolder(View itemView) {
......
...@@ -7,6 +7,9 @@ import android.view.LayoutInflater; ...@@ -7,6 +7,9 @@ import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.gingersoft.gsa.cloud.table.R;
import com.gingersoft.gsa.cloud.table.app.GoldConstants;
import com.gingersoft.gsa.cloud.table.di.component.DaggerAllTableComponent; import com.gingersoft.gsa.cloud.table.di.component.DaggerAllTableComponent;
import com.gingersoft.gsa.cloud.table.mvp.model.bean.TableBean; import com.gingersoft.gsa.cloud.table.mvp.model.bean.TableBean;
import com.gingersoft.gsa.cloud.table.mvp.ui.activity.TableActivity; import com.gingersoft.gsa.cloud.table.mvp.ui.activity.TableActivity;
...@@ -16,10 +19,8 @@ import com.jess.arms.di.component.AppComponent; ...@@ -16,10 +19,8 @@ import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils; import com.jess.arms.utils.ArmsUtils;
import com.gingersoft.gsa.cloud.table.mvp.contract.AllTableContract; import com.gingersoft.gsa.cloud.table.mvp.contract.AllTableContract;
import com.gingersoft.gsa.cloud.table.mvp.presenter.AllTablePresenter; import com.gingersoft.gsa.cloud.table.mvp.presenter.AllTablePresenter;
import com.gingersoft.gsa.cloud.table.R; import com.gingersoft.gsa.cloud.table.R2;
import java.util.List; import java.util.List;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.recyclerview.widget.DefaultItemAnimator; import androidx.recyclerview.widget.DefaultItemAnimator;
...@@ -50,7 +51,7 @@ import static com.jess.arms.utils.Preconditions.checkNotNull; ...@@ -50,7 +51,7 @@ import static com.jess.arms.utils.Preconditions.checkNotNull;
public class AllTableFragment extends BaseFragment<AllTablePresenter> implements AllTableContract.View { public class AllTableFragment extends BaseFragment<AllTablePresenter> implements AllTableContract.View {
@BindView(R.id.recycle_all_table) @BindView(R2.id.recycle_all_table)
RecyclerView recycle_all_table; RecyclerView recycle_all_table;
private TableActivity mActivity; private TableActivity mActivity;
...@@ -81,17 +82,21 @@ public class AllTableFragment extends BaseFragment<AllTablePresenter> implements ...@@ -81,17 +82,21 @@ public class AllTableFragment extends BaseFragment<AllTablePresenter> implements
public void initData(@Nullable Bundle savedInstanceState) { public void initData(@Nullable Bundle savedInstanceState) {
mActivity = (TableActivity) getActivity(); mActivity = (TableActivity) getActivity();
initRecycleScrollListener();
}
private void initRecycleScrollListener() {
recycle_all_table.addOnScrollListener(new RecyclerView.OnScrollListener() { recycle_all_table.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override @Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) { public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
switch (newState) { switch (newState) {
case SCROLL_STATE_IDLE://停止滚动 case SCROLL_STATE_IDLE://停止滚动
// mActivity.onStartRefreshTableData(); mActivity.onStartRefreshTableData();
break; break;
case SCROLL_STATE_DRAGGING://正在被外部拖拽,一般为用户正在用手指滚动 case SCROLL_STATE_DRAGGING://正在被外部拖拽,一般为用户正在用手指滚动
case SCROLL_STATE_SETTLING://自动滚动开始 case SCROLL_STATE_SETTLING://自动滚动开始
// mActivity.onPauseRefreshTableData(); mActivity.onPauseRefreshTableData();
break; break;
} }
} }
...@@ -104,11 +109,11 @@ public class AllTableFragment extends BaseFragment<AllTablePresenter> implements ...@@ -104,11 +109,11 @@ public class AllTableFragment extends BaseFragment<AllTablePresenter> implements
switch (action){ switch (action){
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE: //用户滑动 先停止刷新餐台数据 case MotionEvent.ACTION_MOVE: //用户滑动 先停止刷新餐台数据
// mActivity.onPauseRefreshTableData(); mActivity.onPauseRefreshTableData();
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_CANCEL:
TableActivity.isRefreshData = true;//用户手抬起是 继续刷新餐台数据 mActivity.onStartRefreshTableData();//用户手抬起是 继续刷新餐台数据
break; break;
} }
return false; return false;
......
...@@ -8,8 +8,9 @@ import android.view.View; ...@@ -8,8 +8,9 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import com.gingersoft.gsa.cloud.base.utils.VibratorUtils; import com.gingersoft.gsa.cloud.base.utils.VibratorUtils;
import com.gingersoft.gsa.cloud.table.R;
import com.gingersoft.gsa.cloud.table.R2;
import com.gingersoft.gsa.cloud.table.di.component.DaggerInputTableComponent; import com.gingersoft.gsa.cloud.table.di.component.DaggerInputTableComponent;
import com.gingersoft.gsa.cloud.table.mvp.model.bean.TableBean; import com.gingersoft.gsa.cloud.table.mvp.model.bean.TableBean;
import com.gingersoft.gsa.cloud.table.mvp.ui.activity.TableActivity; import com.gingersoft.gsa.cloud.table.mvp.ui.activity.TableActivity;
...@@ -18,17 +19,14 @@ import com.jess.arms.di.component.AppComponent; ...@@ -18,17 +19,14 @@ import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils; import com.jess.arms.utils.ArmsUtils;
import com.gingersoft.gsa.cloud.table.mvp.contract.InputTableContract; import com.gingersoft.gsa.cloud.table.mvp.contract.InputTableContract;
import com.gingersoft.gsa.cloud.table.mvp.presenter.InputTablePresenter; import com.gingersoft.gsa.cloud.table.mvp.presenter.InputTablePresenter;
import com.gingersoft.gsa.cloud.table.R; import com.gingersoft.gsa.cloud.table.R2;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import butterknife.BindView; import butterknife.BindView;
import butterknife.OnClick; import butterknife.OnClick;
import butterknife.OnLongClick; import butterknife.OnLongClick;
import static com.jess.arms.utils.Preconditions.checkNotNull; import static com.jess.arms.utils.Preconditions.checkNotNull;
...@@ -46,40 +44,40 @@ import static com.jess.arms.utils.Preconditions.checkNotNull; ...@@ -46,40 +44,40 @@ import static com.jess.arms.utils.Preconditions.checkNotNull;
*/ */
public class InputTableFragment extends BaseFragment<InputTablePresenter> implements InputTableContract.View { public class InputTableFragment extends BaseFragment<InputTablePresenter> implements InputTableContract.View {
@BindView(R.id.ed_value) @BindView(R2.id.ed_value)
EditText ed_value; EditText ed_value;
@BindView(R.id.btn_0) @BindView(R2.id.btn_0)
Button btn_0; Button btn_0;
@BindView(R.id.btn_1) @BindView(R2.id.btn_1)
Button btn_1; Button btn_1;
@BindView(R.id.btn_2) @BindView(R2.id.btn_2)
Button btn_2; Button btn_2;
@BindView(R.id.btn_3) @BindView(R2.id.btn_3)
Button btn_3; Button btn_3;
@BindView(R.id.btn_4) @BindView(R2.id.btn_4)
Button btn_4; Button btn_4;
@BindView(R.id.btn_5) @BindView(R2.id.btn_5)
Button btn_5; Button btn_5;
@BindView(R.id.btn_6) @BindView(R2.id.btn_6)
Button btn_6; Button btn_6;
@BindView(R.id.btn_7) @BindView(R2.id.btn_7)
Button btn_7; Button btn_7;
@BindView(R.id.btn_8) @BindView(R2.id.btn_8)
Button btn_8; Button btn_8;
@BindView(R.id.btn_9) @BindView(R2.id.btn_9)
Button btn_9; Button btn_9;
@BindView(R.id.btn_clear) @BindView(R2.id.btn_clear)
Button btn_clear; Button btn_clear;
@BindView(R.id.btn_A) @BindView(R2.id.btn_A)
Button btn_A; Button btn_A;
@BindView(R.id.btn_B) @BindView(R2.id.btn_B)
Button btn_B; Button btn_B;
@BindView(R.id.btn_C) @BindView(R2.id.btn_C)
Button btn_C; Button btn_C;
@BindView(R.id.btn_more) @BindView(R2.id.btn_more)
Button btn_more; Button btn_more;
@BindView(R.id.btn_right) @BindView(R2.id.btn_right)
Button btn_right; Button btn_right;
private TableActivity mActivity; private TableActivity mActivity;
...@@ -157,7 +155,7 @@ public class InputTableFragment extends BaseFragment<InputTablePresenter> implem ...@@ -157,7 +155,7 @@ public class InputTableFragment extends BaseFragment<InputTablePresenter> implem
ed_value.setHint("please input table"); ed_value.setHint("please input table");
} }
@OnLongClick({R.id.btn_clear}) @OnLongClick({R2.id.btn_clear})
public boolean clearClick() { public boolean clearClick() {
inputstr = ""; inputstr = "";
ed_value.setText(inputstr); ed_value.setText(inputstr);
...@@ -166,8 +164,8 @@ public class InputTableFragment extends BaseFragment<InputTablePresenter> implem ...@@ -166,8 +164,8 @@ public class InputTableFragment extends BaseFragment<InputTablePresenter> implem
return false; return false;
} }
@OnClick({R.id.btn_0, R.id.btn_1, R.id.btn_2, R.id.btn_3, R.id.btn_4, R.id.btn_5, R.id.btn_6, R.id.btn_7, R.id.btn_8 @OnClick({R2.id.btn_0, R2.id.btn_1, R2.id.btn_2, R2.id.btn_3, R2.id.btn_4, R2.id.btn_5, R2.id.btn_6, R2.id.btn_7, R2.id.btn_8
, R.id.btn_9, R.id.btn_A, R.id.btn_B, R.id.btn_C, R.id.btn_more, R.id.btn_right, R.id.btn_clear}) , R2.id.btn_9, R2.id.btn_A, R2.id.btn_B, R2.id.btn_C, R2.id.btn_more, R2.id.btn_right, R2.id.btn_clear})
public void onClick(View v) { public void onClick(View v) {
int i = Integer.parseInt(v.getTag().toString()); int i = Integer.parseInt(v.getTag().toString());
...@@ -283,7 +281,7 @@ public class InputTableFragment extends BaseFragment<InputTablePresenter> implem ...@@ -283,7 +281,7 @@ public class InputTableFragment extends BaseFragment<InputTablePresenter> implem
} }
int id = getTableIdByName(t_name); int id = getTableIdByName(t_name);
mActivity.clickTableItem(id); mActivity.openTableItem(id);
} }
private void load_meal_before_splite() { private void load_meal_before_splite() {
......
...@@ -4,9 +4,10 @@ import android.content.Intent; ...@@ -4,9 +4,10 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Message; import android.os.Message;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.gingersoft.gsa.cloud.table.R2;
import com.gingersoft.gsa.cloud.table.di.component.DaggerStateTableComponent; import com.gingersoft.gsa.cloud.table.di.component.DaggerStateTableComponent;
import com.gingersoft.gsa.cloud.table.mvp.model.bean.TableBean; import com.gingersoft.gsa.cloud.table.mvp.model.bean.TableBean;
import com.gingersoft.gsa.cloud.table.mvp.ui.activity.TableActivity; import com.gingersoft.gsa.cloud.table.mvp.ui.activity.TableActivity;
...@@ -30,6 +31,9 @@ import androidx.recyclerview.widget.LinearLayoutManager; ...@@ -30,6 +31,9 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView; import butterknife.BindView;
import static android.widget.AbsListView.OnScrollListener.SCROLL_STATE_IDLE;
import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_DRAGGING;
import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_SETTLING;
import static com.jess.arms.utils.Preconditions.checkNotNull; import static com.jess.arms.utils.Preconditions.checkNotNull;
...@@ -48,7 +52,7 @@ import static com.jess.arms.utils.Preconditions.checkNotNull; ...@@ -48,7 +52,7 @@ import static com.jess.arms.utils.Preconditions.checkNotNull;
public class StateTableFragment extends BaseFragment<StateTablePresenter> implements StateTableContract.View { public class StateTableFragment extends BaseFragment<StateTablePresenter> implements StateTableContract.View {
@BindView(R.id.recycle_state_table) @BindView(R2.id.recycle_state_table)
RecyclerView recycle_state_table; RecyclerView recycle_state_table;
private TableActivity mActivity; private TableActivity mActivity;
...@@ -80,6 +84,43 @@ public class StateTableFragment extends BaseFragment<StateTablePresenter> implem ...@@ -80,6 +84,43 @@ public class StateTableFragment extends BaseFragment<StateTablePresenter> implem
public void initData(@Nullable Bundle savedInstanceState) { public void initData(@Nullable Bundle savedInstanceState) {
this.mActivity = (TableActivity) getActivity(); this.mActivity = (TableActivity) getActivity();
initRecycleScrollListener();
}
private void initRecycleScrollListener() {
recycle_state_table.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
switch (newState) {
case SCROLL_STATE_IDLE://停止滚动
mActivity.onStartRefreshTableData();
break;
case SCROLL_STATE_DRAGGING://正在被外部拖拽,一般为用户正在用手指滚动
case SCROLL_STATE_SETTLING://自动滚动开始
mActivity.onPauseRefreshTableData();
break;
}
}
});
recycle_state_table.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action){
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE: //用户滑动 先停止刷新餐台数据
mActivity.onPauseRefreshTableData();
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mActivity.onStartRefreshTableData();//用户手抬起是 继续刷新餐台数据
break;
}
return false;
}
});
} }
@Override @Override
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.qmuiteam.qmui.widget.QMUIWindowInsetLayout 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:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/qmui_topbar_height">
<com.gingersoft.gsa.cloud.ui.view.PagerSlidingTabStrip
android:id="@+id/pts_table_type"
android:layout_width="match_parent"
android:layout_height="?attr/qmui_topbar_height"
android:background="@color/theme_white_color" />
<androidx.viewpager.widget.ViewPager
android:id="@+id/vp_table_type"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/qmui_topbar_height"/>
</RelativeLayout>
<com.qmuiteam.qmui.widget.QMUITopBar
android:id="@+id/topbar"
android:layout_width="match_parent"
android:layout_height="?attr/qmui_topbar_height"
app:qmui_topbar_title_color="@color/theme_white_color" />
<RadioGroup
android:id="@+id/rg_table_function"
android:layout_width="match_parent"
android:layout_height="@dimen/head_height"
android:layout_gravity="bottom"
android:background="@color/theme_white_color"
android:orientation="horizontal"
android:padding="1dp">
<RadioButton
android:id="@+id/btn_init_table"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/ui_selector_item_background"
android:button="@null"
android:gravity="center"
android:text="重置檯號"
android:textColor="@color/theme_grey_color"
android:textSize="@dimen/font_normal" />
</RadioGroup>
<LinearLayout <LinearLayout
android:id="@+id/ll_operat_choose" android:id="@+id/ll_operat_choose"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/head_height" android:layout_height="@dimen/head_height"
android:background="@color/theme_white_color"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
android:background="@color/theme_white_color"
android:paddingBottom="2dp"
android:paddingLeft="@dimen/normal_space15" android:paddingLeft="@dimen/normal_space15"
android:paddingTop="2dp"
android:paddingRight="@dimen/normal_space15" android:paddingRight="@dimen/normal_space15"
android:paddingBottom="2dp" android:paddingTop="2dp"
android:visibility="invisible"> android:visibility="gone">
<com.qmuiteam.qmui.layout.QMUIButton <com.qmuiteam.qmui.layout.QMUIButton
android:id="@+id/btn_sure_operat" android:id="@+id/btn_sure_operat"
...@@ -77,8 +30,43 @@ ...@@ -77,8 +30,43 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:text="Button" android:background="@color/theme_hint_color"
app:btnSolidColor="@color/theme_hint_color" /> android:text="Button" />
</LinearLayout> </LinearLayout>
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout> <RelativeLayout
\ No newline at end of file android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/rv_bottom_function"
android:layout_marginTop="?attr/qmui_topbar_height">
<androidx.viewpager.widget.ViewPager
android:id="@+id/vp_table_type"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/qmui_topbar_height" />
<com.gingersoft.gsa.cloud.ui.view.PagerSlidingTabStrip
android:id="@+id/pts_table_type"
android:layout_width="match_parent"
android:layout_height="?attr/qmui_topbar_height"
android:background="@color/theme_white_color" />
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_bottom_function"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
android:background="@color/theme_white_color"
android:orientation="horizontal"
android:padding="1dp" />
<com.qmuiteam.qmui.widget.QMUITopBar
android:id="@+id/topbar"
android:layout_width="match_parent"
android:layout_height="?attr/qmui_topbar_height"
app:qmui_topbar_title_color="@color/theme_white_color" />
</RelativeLayout>
\ 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="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:background="@drawable/ui_selector_item_background">
<ImageView
android:id="@+id/iv_icon"
android:layout_width="@dimen/dp_25"
android:layout_height="@dimen/dp_25"
android:layout_marginTop="@dimen/dp_5"
android:src="@mipmap/ic_launcher_round" />
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="功能"
android:layout_marginTop="@dimen/dp_5"
android:textColor="@color/theme_black"
android:textSize="@dimen/font_normal" />
</LinearLayout>
\ No newline at end of file
ext.mainApp = true //设置为true,表示此module为主app module,一直以application方式编译 ext.mainApp = true //设置为true,表示此module为主app module,一直以application方式编译
apply from: rootProject.file("cc-settings.gradle") apply from: rootProject.file("cc-settings.gradle")
apply plugin: 'com.jakewharton.butterknife'
android { android {
signingConfigs { signingConfigs {
...@@ -31,13 +32,6 @@ android { ...@@ -31,13 +32,6 @@ android {
resourcePrefix "user_login" resourcePrefix "user_login"
buildTypes { buildTypes {
debug {
minifyEnabled false
debuggable true
// signingConfig signingConfigs.releaseconfig
}
release { release {
postprocessing { postprocessing {
removeUnusedCode false removeUnusedCode false
...@@ -71,12 +65,14 @@ android { ...@@ -71,12 +65,14 @@ android {
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
// addComponent 'main' addComponent 'main'
// addComponent 'download-data' addComponent 'download-data'
// addComponent 'table-mode' addComponent 'table-mode'
// addComponent 'mealstand-mode' addComponent 'mealstand-mode'
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
// annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
implementation rootProject.ext.dependencies["autosize"] implementation rootProject.ext.dependencies["autosize"]
implementation rootProject.ext.dependencies["fastjson"] implementation rootProject.ext.dependencies["fastjson"]
} }
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" /> <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" /> <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
......
package com.gingersoft.gsa.cloud.user.login; package com.gingersoft.gsa.cloud.user.login;
import android.content.Context;
import com.billy.cc.core.component.CC; import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult; import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil; import com.billy.cc.core.component.CCUtil;
import com.billy.cc.core.component.IComponent; import com.billy.cc.core.component.IComponent;
import com.gingersoft.gsa.cloud.user.login.mvp.bean.LoginBean;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.LoginActivity; import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.LoginActivity;
public class ComponentLogin implements IComponent { public class ComponentLogin implements IComponent {
@Override @Override
public String getName() { public String getName() {
//组件的名称,调用此组件的方式: //组件的名称,调用此组件的方式:
...@@ -21,9 +23,10 @@ public class ComponentLogin implements IComponent { ...@@ -21,9 +23,10 @@ public class ComponentLogin implements IComponent {
* 组件被调用时的入口 * 组件被调用时的入口
* 要确保每个逻辑分支都会调用到CC.sendCCResult, * 要确保每个逻辑分支都会调用到CC.sendCCResult,
* 包括try-catch,if-else,switch-case-default,startActivity * 包括try-catch,if-else,switch-case-default,startActivity
*
* @param cc 组件调用对象,可从此对象中获取相关信息 * @param cc 组件调用对象,可从此对象中获取相关信息
* @return true:将异步调用CC.sendCCResult(...),用于异步实现相关功能,例如:文件加载、网络请求等 * @return true:将异步调用CC.sendCCResult(...),用于异步实现相关功能,例如:文件加载、网络请求等
* false:会同步调用CC.sendCCResult(...),即在onCall方法return之前调用,否则将被视为不合法的实现 * false:会同步调用CC.sendCCResult(...),即在onCall方法return之前调用,否则将被视为不合法的实现
*/ */
@Override @Override
public boolean onCall(CC cc) { public boolean onCall(CC cc) {
......
...@@ -14,11 +14,12 @@ public class LoginBean { ...@@ -14,11 +14,12 @@ public class LoginBean {
/** /**
* success : true * success : true
* sysTime : 1577607524714 * sysTime : 1578563902000
* data : {"user":{"userId":1,"userName":"admin","brands":[{"brandId":242,"brandName":"莫拉塔"},{"brandId":243,"brandName":"蕭蕭"}],"restaurants":[{"restaurantId":314,"restaurantName":"222222"},{"restaurantId":317,"restaurantName":"barrytestdasd"},{"restaurantId":337,"restaurantName":"小張"},{"restaurantId":345,"restaurantName":"1"}]},"token":"a32a24a9237b4c70b420fe3ad7af3dbd"} * data : {"user":{"userId":1,"userName":"admin","brands":[{"brandId":242,"brandName":"莫拉塔","restaurants":[]},{"brandId":243,"brandName":"蕭蕭","restaurants":[{"restaurantId":337,"restaurantName":"小張"}]}]},"token":"24ce30df203b41619a21967dbd9988b9"}
*/ */
private boolean success; private boolean success;
private String errMsg;
private long sysTime; private long sysTime;
private DataBean data; private DataBean data;
...@@ -30,6 +31,14 @@ public class LoginBean { ...@@ -30,6 +31,14 @@ public class LoginBean {
this.success = success; this.success = success;
} }
public String getErrMsg() {
return errMsg;
}
public void setErrMsg(String errMsg) {
this.errMsg = errMsg;
}
public long getSysTime() { public long getSysTime() {
return sysTime; return sysTime;
} }
...@@ -48,8 +57,8 @@ public class LoginBean { ...@@ -48,8 +57,8 @@ public class LoginBean {
public static class DataBean { public static class DataBean {
/** /**
* user : {"userId":1,"userName":"admin","brands":[{"brandId":242,"brandName":"莫拉塔"},{"brandId":243,"brandName":"蕭蕭"}],"restaurants":[{"restaurantId":314,"restaurantName":"222222"},{"restaurantId":317,"restaurantName":"barrytestdasd"},{"restaurantId":337,"restaurantName":"小張"},{"restaurantId":345,"restaurantName":"1"}]} * user : {"userId":1,"userName":"admin","brands":[{"brandId":242,"brandName":"莫拉塔","restaurants":[]},{"brandId":243,"brandName":"蕭蕭","restaurants":[{"restaurantId":337,"restaurantName":"小張"}]}]}
* token : a32a24a9237b4c70b420fe3ad7af3dbd * token : 24ce30df203b41619a21967dbd9988b9
*/ */
private UserBean user; private UserBean user;
...@@ -75,14 +84,12 @@ public class LoginBean { ...@@ -75,14 +84,12 @@ public class LoginBean {
/** /**
* userId : 1 * userId : 1
* userName : admin * userName : admin
* brands : [{"brandId":242,"brandName":"莫拉塔"},{"brandId":243,"brandName":"蕭蕭"}] * brands : [{"brandId":242,"brandName":"莫拉塔","restaurants":[]},{"brandId":243,"brandName":"蕭蕭","restaurants":[{"restaurantId":337,"restaurantName":"小張"}]}]
* restaurants : [{"restaurantId":314,"restaurantName":"222222"},{"restaurantId":317,"restaurantName":"barrytestdasd"},{"restaurantId":337,"restaurantName":"小張"},{"restaurantId":345,"restaurantName":"1"}]
*/ */
private int userId; private int userId;
private String userName; private String userName;
private List<BrandsBean> brands; private List<BrandsBean> brands;
private List<RestaurantsBean> restaurants;
public int getUserId() { public int getUserId() {
return userId; return userId;
...@@ -108,22 +115,16 @@ public class LoginBean { ...@@ -108,22 +115,16 @@ public class LoginBean {
this.brands = brands; this.brands = brands;
} }
public List<RestaurantsBean> getRestaurants() {
return restaurants;
}
public void setRestaurants(List<RestaurantsBean> restaurants) {
this.restaurants = restaurants;
}
public static class BrandsBean { public static class BrandsBean {
/** /**
* brandId : 242 * brandId : 242
* brandName : 莫拉塔 * brandName : 莫拉塔
* restaurants : []
*/ */
private int brandId; private int brandId;
private String brandName; private String brandName;
private List<?> restaurants;
public int getBrandId() { public int getBrandId() {
return brandId; return brandId;
...@@ -140,31 +141,13 @@ public class LoginBean { ...@@ -140,31 +141,13 @@ public class LoginBean {
public void setBrandName(String brandName) { public void setBrandName(String brandName) {
this.brandName = brandName; this.brandName = brandName;
} }
}
public static class RestaurantsBean {
/**
* restaurantId : 314
* restaurantName : 222222
*/
private int restaurantId;
private String restaurantName;
public int getRestaurantId() {
return restaurantId;
}
public void setRestaurantId(int restaurantId) {
this.restaurantId = restaurantId;
}
public String getRestaurantName() { public List<?> getRestaurants() {
return restaurantName; return restaurants;
} }
public void setRestaurantName(String restaurantName) { public void setRestaurants(List<?> restaurants) {
this.restaurantName = restaurantName; this.restaurants = restaurants;
} }
} }
} }
......
...@@ -3,6 +3,7 @@ package com.gingersoft.gsa.cloud.user.login.mvp.presenter; ...@@ -3,6 +3,7 @@ package com.gingersoft.gsa.cloud.user.login.mvp.presenter;
import android.app.Application; import android.app.Application;
import android.util.Log; import android.util.Log;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils; import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.user.login.mvp.bean.LoginBean; import com.gingersoft.gsa.cloud.user.login.mvp.bean.LoginBean;
import com.gingersoft.gsa.cloud.user.login.mvp.bean.TestLoginBean; import com.gingersoft.gsa.cloud.user.login.mvp.bean.TestLoginBean;
...@@ -81,14 +82,17 @@ public class LoginPresenter extends BasePresenter<LoginContract.Model, LoginCont ...@@ -81,14 +82,17 @@ public class LoginPresenter extends BasePresenter<LoginContract.Model, LoginCont
.doAfterTerminate(() -> mRootView.hideLoading()) .doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView)) .compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<LoginBean>(mErrorHandler) { .subscribe(new ErrorHandleSubscriber<LoginBean>(mErrorHandler) {
@Override @Override
public void onNext(@NonNull LoginBean info) { public void onNext(@NonNull LoginBean info) {
Log.e("login", "" + info); Log.e("login", "" + info);
if (info != null && info.isSuccess()) { if (info != null && info.isSuccess()) {
GsaCloudApplication.isLogin = true;
mRootView.showMessage("登陸成功"); mRootView.showMessage("登陸成功");
mRootView.loginSuccess(info); mRootView.loginSuccess(info);
} else { } else {
mRootView.showMessage("登錄失敗"); GsaCloudApplication.isLogin = false;
mRootView.showMessage(info.getErrMsg());
} }
} }
}); });
...@@ -112,6 +116,7 @@ public class LoginPresenter extends BasePresenter<LoginContract.Model, LoginCont ...@@ -112,6 +116,7 @@ public class LoginPresenter extends BasePresenter<LoginContract.Model, LoginCont
@Override @Override
public void onNext(@NonNull Object info) { public void onNext(@NonNull Object info) {
Log.e("login", "" + info); Log.e("login", "" + info);
GsaCloudApplication.isLogin = false;
mRootView.loginOut(); mRootView.loginOut();
} }
}); });
......
...@@ -4,12 +4,13 @@ import android.content.Intent; ...@@ -4,12 +4,13 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import com.billy.cc.core.component.CC; import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication; import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils; import com.gingersoft.gsa.cloud.base.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.base.utils.request.RequestUtils; import com.gingersoft.gsa.cloud.base.utils.request.RequestUtils;
import com.gingersoft.gsa.cloud.user.login.R; import com.gingersoft.gsa.cloud.user.login.R;
import com.gingersoft.gsa.cloud.user.login.R2;
import com.gingersoft.gsa.cloud.user.login.di.component.DaggerLoginComponent; import com.gingersoft.gsa.cloud.user.login.di.component.DaggerLoginComponent;
import com.gingersoft.gsa.cloud.user.login.mvp.bean.LoginBean; import com.gingersoft.gsa.cloud.user.login.mvp.bean.LoginBean;
import com.gingersoft.gsa.cloud.user.login.mvp.bean.TestLoginBean; import com.gingersoft.gsa.cloud.user.login.mvp.bean.TestLoginBean;
...@@ -20,9 +21,7 @@ import com.gingersoft.gsa.cloud.user.login.mvp.contract.LoginContract; ...@@ -20,9 +21,7 @@ import com.gingersoft.gsa.cloud.user.login.mvp.contract.LoginContract;
import com.gingersoft.gsa.cloud.user.login.mvp.presenter.LoginPresenter; import com.gingersoft.gsa.cloud.user.login.mvp.presenter.LoginPresenter;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils; import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.ui.view.MyEditText; import com.gingersoft.gsa.cloud.ui.view.MyEditText;
import java.io.IOException; import java.io.IOException;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import butterknife.BindView; import butterknife.BindView;
...@@ -52,9 +51,9 @@ import static com.jess.arms.utils.Preconditions.checkNotNull; ...@@ -52,9 +51,9 @@ import static com.jess.arms.utils.Preconditions.checkNotNull;
* ================================================ * ================================================
*/ */
public class LoginActivity extends BaseActivity<LoginPresenter> implements LoginContract.View, View.OnClickListener { public class LoginActivity extends BaseActivity<LoginPresenter> implements LoginContract.View, View.OnClickListener {
@BindView(R.id.ed_login_user_account) @BindView(R2.id.ed_login_user_account)
MyEditText edAccount; MyEditText edAccount;
@BindView(R.id.ed_login_user_pwd) @BindView(R2.id.ed_login_user_pwd)
MyEditText edPwd; MyEditText edPwd;
@Override @Override
...@@ -77,7 +76,6 @@ public class LoginActivity extends BaseActivity<LoginPresenter> implements Login ...@@ -77,7 +76,6 @@ public class LoginActivity extends BaseActivity<LoginPresenter> implements Login
findViewById(R.id.tv_gsa_user_login).setOnClickListener(this); findViewById(R.id.tv_gsa_user_login).setOnClickListener(this);
edAccount = findViewById(R.id.ed_login_user_account); edAccount = findViewById(R.id.ed_login_user_account);
edPwd = findViewById(R.id.ed_login_user_pwd); edPwd = findViewById(R.id.ed_login_user_pwd);
} }
@Override @Override
...@@ -136,15 +134,16 @@ public class LoginActivity extends BaseActivity<LoginPresenter> implements Login ...@@ -136,15 +134,16 @@ public class LoginActivity extends BaseActivity<LoginPresenter> implements Login
public void loginSuccess(LoginBean loginBean) { public void loginSuccess(LoginBean loginBean) {
GsaCloudApplication.setLoginToken(LoginActivity.this, loginBean.getData().getToken()); GsaCloudApplication.setLoginToken(LoginActivity.this, loginBean.getData().getToken());
if (loginBean.getData().getUser() != null) { if (loginBean.getData().getUser() != null) {
// GsaCloudApplication.setMemberId(LoginActivity.this, loginBean.getData().getUser().getId()); GsaCloudApplication.setMemberId(LoginActivity.this, loginBean.getData().getUser().getUserId());
// GsaCloudApplication.setRestaurantId(LoginActivity.this, loginBean.getData().getUser().getRestaurantId()); // GsaCloudApplication.setRestaurantId(LoginActivity.this, loginBean.getData().getUser().getRestaurants().get(0).getRestaurantId());
} }
ToastUtils.show(LoginActivity.this, "登錄成功"); ToastUtils.show(LoginActivity.this, "登錄成功");
CC.obtainBuilder("Component.Table") CC.obtainBuilder("Component.Download")
.setActionName("showTableActivity") .setActionName("showDownloadActivity")
.build() .build()
.call(); .call();
} }
......
apply from: rootProject.file("cc-settings.gradle")
android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion rootProject.ext.android["minSdkVersion"]
targetSdkVersion rootProject.ext.android["targetSdkVersion"]
if (project.ext.runAsApp) {
applicationId 'com.gingersoft.gsa.cloud.user.register'
}
versionCode rootProject.ext.android["versionCode"]
versionName rootProject.ext.android["versionName"]
}
resourcePrefix "user_register"
buildTypes {
release {
postprocessing {
removeUnusedCode false
removeUnusedResources false
obfuscate false
optimizeCode false
proguardFiles 'proguard.cfg'
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package com.gingersoft.cloud.gsa.component.order.list;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.gingersoft.cloud.gsa.component.order.list", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gingersoft.gsa.cloud.user.register">
<application>
<activity android:name=".RegisterActivity">
</activity>
</application>
</manifest>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gingersoft.gsa.cloud.user.register">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/user_register_AppTheme">
<activity android:name=".RegisterActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
package debug;
import android.app.Application;
import com.billy.cc.core.component.CC;
/**
* @author billy.qi
* @since 17/11/20 20:02
*/
public class MyApp extends Application {
@Override
public void onCreate() {
super.onCreate();
CC.enableVerboseLog(true);
CC.enableDebug(true);
CC.enableRemoteCC(true);
}
}
<resources>
<string name="demo_a_app_name">Demo_A</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="user_register_colorPrimary">#3F51B5</color>
<color name="user_register_colorPrimaryDark">#303F9F</color>
<color name="user_register_colorAccent">#FF4081</color>
</resources>
<resources>
<string name="user_register_app_name">Demo_A</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="user_register_AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/user_register_colorPrimary</item>
<item name="colorPrimaryDark">@color/user_register_colorPrimaryDark</item>
<item name="colorAccent">@color/user_register_colorAccent</item>
</style>
</resources>
package com.gingersoft.gsa.cloud.user.register;
import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil;
import com.billy.cc.core.component.IComponent;
public class ComponentRegister implements IComponent {
@Override
public String getName() {
//组件的名称,调用此组件的方式:
// CC.obtainBuilder("ComponentA")...build().callAsync()
return "Component.Register";
}
/**
* 组件被调用时的入口
* 要确保每个逻辑分支都会调用到CC.sendCCResult,
* 包括try-catch,if-else,switch-case-default,startActivity
* @param cc 组件调用对象,可从此对象中获取相关信息
* @return true:将异步调用CC.sendCCResult(...),用于异步实现相关功能,例如:文件加载、网络请求等
* false:会同步调用CC.sendCCResult(...),即在onCall方法return之前调用,否则将被视为不合法的实现
*/
@Override
public boolean onCall(CC cc) {
String actionName = cc.getActionName();
switch (actionName) {
case "showRegisterActivity":
openActivity(cc);
break;
case "getLifecycleFragment":
//demo for provide fragment object to other component
getLifecycleFragment(cc);
break;
case "lifecycleFragment.addText":
lifecycleFragmentDoubleText(cc);
break;
case "getInfo":
getInfo(cc);
break;
default:
//这个逻辑分支上没有调用CC.sendCCResult(...),是一种错误的示例
//并且方法的返回值为false,代表不会异步调用CC.sendCCResult(...)
//在LocalCCInterceptor中将会返回错误码为-10的CCResult
break;
}
return false;
}
private void lifecycleFragmentDoubleText(CC cc) {
// LifecycleFragment lifecycleFragment = cc.getParamItem("fragment");
// if (lifecycleFragment != null) {
// String text = cc.getParamItem("text", "");
// lifecycleFragment.addText(text);
// CC.sendCCResult(cc.getCallId(), CCResult.success());
// } else {
// CC.sendCCResult(cc.getCallId(), CCResult.error("no fragment params"));
// }
}
private void getLifecycleFragment(CC cc) {
// CC.sendCCResult(cc.getCallId(), CCResult.successWithNoKey(new LifecycleFragment()));
}
private void getInfo(CC cc) {
String userName = "billy";
CC.sendCCResult(cc.getCallId(), CCResult.success("userName", userName));
}
private void openActivity(CC cc) {
CCUtil.navigateTo(cc, RegisterActivity.class);
CC.sendCCResult(cc.getCallId(), CCResult.success());
}
}
package com.gingersoft.gsa.cloud.user.register;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
public class RegisterActivity extends AppCompatActivity {
private static final String COMPONENT_NAME_A = "COMPONENT_NAME_A";
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_register_activity);
TextView textView = new TextView(this);
textView.setGravity(Gravity.CENTER);
textView.setText("this is register activity");
setContentView(textView);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// CC cc = CC.obtainBuilder(COMPONENT_NAME_A)
// .setActionName("getInfo")
// .build();
// CCResult result = cc.call();
}
});
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>
<?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"?>
<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:orientation="vertical">
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>
<resources>
<string name="user_register_name">component-user-register</string>
</resources>
package com.gingersoft.cloud.gsa.component.order.list;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment