Commit e8c65531 by 王宇航

首頁側滑登出、廚房單打印

parent b5fb8a06
......@@ -56,7 +56,7 @@ public abstract class DefaultAdapter<T> extends RecyclerView.Adapter<BaseHolder<
mHolder.setOnItemClickListener(new BaseHolder.OnViewClickListener() {//设置Item点击事件
@Override
public void onViewClick(View view, int position) {
if (mOnItemClickListener != null && mInfos.size() > 0) {
if (mOnItemClickListener != null && mInfos != null && mInfos.size() > 0) {
mOnItemClickListener.onItemClick(view, viewType, mInfos.get(position), position);
}
}
......
......@@ -39,12 +39,13 @@ public class CCUtil {
/**
* 将一个json对象解析为map对象
*
* @param json json对象
* @return map对象
*/
public static Map<String, Object> convertToMap(JSONObject json) {
Map<String, Object> params = null;
try{
try {
if (json != null) {
params = new HashMap<>(json.length());
Iterator<String> keys = json.keys();
......@@ -56,12 +57,12 @@ public class CCUtil {
value = null;
}
params.put(key, value);
} catch(Exception e) {
} catch (Exception e) {
CCUtil.printStackTrace(e);
}
}
}
} catch(Exception e) {
} catch (Exception e) {
CCUtil.printStackTrace(e);
}
return params;
......@@ -80,33 +81,33 @@ public class CCUtil {
} else if (v instanceof SparseArray) {
Map<Integer, Object> map = new HashMap<>();
SparseArray sp = (SparseArray) v;
for(int i = 0; i < sp.size(); i++) {
for (int i = 0; i < sp.size(); i++) {
map.put(sp.keyAt(i), sp.valueAt(i));
}
return convertToJson(map);
} else if (v instanceof SparseIntArray) {
Map<Integer, Integer> map = new HashMap<>();
SparseIntArray sp = (SparseIntArray) v;
for(int i = 0; i < sp.size(); i++) {
for (int i = 0; i < sp.size(); i++) {
map.put(sp.keyAt(i), sp.valueAt(i));
}
return convertToJson(map);
} else if (v instanceof SparseBooleanArray) {
Map<Integer, Boolean> map = new HashMap<>();
SparseBooleanArray sp = (SparseBooleanArray) v;
for(int i = 0; i < sp.size(); i++) {
for (int i = 0; i < sp.size(); i++) {
map.put(sp.keyAt(i), sp.valueAt(i));
}
return convertToJson(map);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && v instanceof SparseLongArray) {
Map<Integer, Long> map = new HashMap<>();
SparseLongArray sp = (SparseLongArray) v;
for(int i = 0; i < sp.size(); i++) {
for (int i = 0; i < sp.size(); i++) {
map.put(sp.keyAt(i), sp.valueAt(i));
}
return convertToJson(map);
} else if ( v instanceof String || v instanceof Integer
} else if (v instanceof String || v instanceof Integer
|| v instanceof Long || v instanceof Float
|| v instanceof Double || v instanceof Boolean
|| v instanceof Short || v instanceof Byte
......@@ -116,7 +117,7 @@ public class CCUtil {
} else {
try {
jsonString = RemoteParamUtil.convertObject2JsonString(v);
} catch(Exception e) {
} catch (Exception e) {
CCUtil.printStackTrace(e);
jsonString = null;
}
......@@ -143,12 +144,13 @@ public class CCUtil {
* 将一个map对象转换成json对象
* 1. 用于日志输出
* 2. 用于需要将CC或CCResult转成json进行传递的场景(如:JsBridge传值)
*
* @param map map对象
* @return json对象
*/
public static JSONObject convertToJson(Map<?, ?> map) {
if (map != null) {
try{
try {
JSONObject json = new JSONObject();
for (Map.Entry<?, ?> entry : map.entrySet()) {
Object value = entry.getValue();
......@@ -163,7 +165,7 @@ public class CCUtil {
}
}
return json;
} catch(Exception e) {
} catch (Exception e) {
CCUtil.printStackTrace(e);
}
}
......@@ -172,10 +174,11 @@ public class CCUtil {
private static Boolean isRunningMainProcess = null;
private static String curProcessName = null;
/**
* 进程是否以包名在运行(当前进程是否为主进程)
*/
public static boolean isMainProcess(){
public static boolean isMainProcess() {
if (isRunningMainProcess == null) {
Application application = CC.getApplication();
if (application == null) {
......@@ -188,6 +191,7 @@ public class CCUtil {
/**
* 获取当前进程的名称
*
* @return 进程名
*/
public static String getCurProcessName() {
......@@ -209,7 +213,7 @@ public class CCUtil {
}
}
}
} catch (Exception e){
} catch (Exception e) {
CCUtil.printStackTrace(e);
}
return PROCESS_UNKNOWN;
......@@ -230,7 +234,7 @@ public class CCUtil {
}
}
}
} catch (Exception e){
} catch (Exception e) {
CCUtil.printStackTrace(e);
}
return null;
......@@ -238,6 +242,7 @@ public class CCUtil {
/**
* 反射获取application对象
*
* @return application
*/
static Application initApplication() {
......@@ -247,7 +252,7 @@ public class CCUtil {
if (app != null) {
return app;
}
} catch(Exception e) {
} catch (Exception e) {
CCUtil.printStackTrace(e);
}
try {
......@@ -265,7 +270,7 @@ public class CCUtil {
public static void put(JSONObject json, String key, Object value) {
try {
json.put(key, value);
} catch(Exception e) {
} catch (Exception e) {
CCUtil.printStackTrace(e);
}
}
......@@ -281,6 +286,7 @@ public class CCUtil {
* 1. {@link CCUtil#getNavigateParam(Bundle, String, Object)}<br>
* 2. {@link CCUtil#getNavigateParam(Activity, String, Object)}<br>
* 可通过 {@link #getNavigateCallId(Activity)} 获取调起该页面的CC.callId
*
* @param cc 当前CC调用
* @param activityClass 要跳转到的activity
*/
......@@ -293,8 +299,29 @@ public class CCUtil {
}
/**
* 跳转到指定的activity,
* 并将CC的参数通过extra传递给该activity,
* 可通过以下方式获取指定参数:<br>
* 1. {@link CCUtil#getNavigateParam(Bundle, String, Object)}<br>
* 2. {@link CCUtil#getNavigateParam(Activity, String, Object)}<br>
* 可通过 {@link #getNavigateCallId(Activity)} 获取调起该页面的CC.callId
*
* @param cc 当前CC调用
* @param activityClass 要跳转到的activity
*/
public static void navigateClearTopTo(CC cc, Class<? extends Activity> activityClass) {
Intent intent = createNavigateIntent(cc, activityClass);
RemoteCC remoteCC = new RemoteCC(cc);
intent.putExtra(EXTRA_KEY_REMOTE_CC, remoteCC);
intent.putExtra(EXTRA_KEY_CALL_ID, cc.getCallId());
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
cc.getContext().startActivity(intent);
}
/**
* 为activity跳转创建一个intent,如果调用方没设置context
* 使用application来startActivity时自动添加{@link Intent#FLAG_ACTIVITY_NEW_TASK}
*
* @param cc CC对象
* @param activityClass 要跳转的activity
* @return intent
......@@ -311,6 +338,7 @@ public class CCUtil {
/**
* 在组件类中通过{@link #navigateTo(CC, Class)}跳转页面后,可通过此方法快捷获取CC的参数
*
* @param activity activity
* @param key key
* @param defaultValue 默认值
......@@ -335,8 +363,10 @@ public class CCUtil {
}
return null;
}
/**
* 在组件类中通过{@link #navigateTo(CC, Class)}跳转页面后,可通过此方法快捷获取CC的参数
*
* @param bundle bundle参数
* @param key 需要取值的key
* @param defaultValue 默认值
......
......@@ -23,7 +23,7 @@
<!-- arms配置 -->
<meta-data
android:name="network.config.GlobalConfiguration"
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" />
<meta-data
......
......@@ -4,6 +4,7 @@ import android.app.Application;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.base.common.bean.FoodBean;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.database.bean.Combo;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.bean.FoodModifier;
......@@ -261,12 +262,11 @@ public class DownloadPresenter extends BasePresenter<DownloadContract.Model, Dow
}
private void endDownReturn() {
mRootView.showMessage("跳轉到首頁");
CC.obtainBuilder("Component.Main")
.setActionName("showMainActivity")
.build()
.call();
mRootView.killMyself();
}
......
......@@ -44,16 +44,17 @@ android {
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(include: ['*.jar'], dir: 'libs')
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
debugImplementation rootProject.ext.dependencies["canary-debug"]
releaseImplementation rootProject.ext.dependencies["canary-release"]
testImplementation rootProject.ext.dependencies["canary-release"]
testImplementation rootProject.ext.dependencies["junit"]
implementation rootProject.ext.dependencies["BaseRecyclerViewAdapter"]
implementation 'com.github.Liberuman:ShadowDrawable:0.1'//陰影背景
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'//報表圖
implementation 'com.github.Liberuman:ShadowDrawable:0.1'
//陰影背景
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
//報表圖
implementation project(':chart')
implementation files('libs/nineoldandroids-2.4.0.jar')
}
......@@ -31,7 +31,7 @@
</activity>
<meta-data
android:name="network.config.GlobalConfiguration"
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" />
<meta-data
android:name="design_width_in_dp"
......
......@@ -72,7 +72,7 @@ public class ComponentMain implements IComponent {
}
private void openActivity(CC cc) {
CCUtil.navigateTo(cc, NewMainActivity.class);
CCUtil.navigateClearTopTo(cc, NewMainActivity.class);
CC.sendCCResult(cc.getCallId(), CCResult.success());
}
......
......@@ -3,6 +3,9 @@ package com.gingersoft.gsa.cloud.main.mvp.contract;
import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
* ================================================
......@@ -19,11 +22,11 @@ import com.jess.arms.mvp.IModel;
public interface NewMainContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
void loginOut();
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {
Observable<Object> loginOut(RequestBody requestBody);
}
}
......@@ -2,6 +2,8 @@ package com.gingersoft.gsa.cloud.main.mvp.model;
import android.app.Application;
import com.gingersoft.gsa.cloud.main.mvp.model.service.MainService;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.MainActivity;
import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
......@@ -12,6 +14,9 @@ import javax.inject.Inject;
import com.gingersoft.gsa.cloud.main.mvp.contract.NewMainContract;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
* ================================================
......@@ -43,4 +48,10 @@ public class NewMainModel extends BaseModel implements NewMainContract.Model {
this.mGson = null;
this.mApplication = null;
}
@Override
public Observable<Object> loginOut(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(MainService.class)
.loginOut(requestBody);
}
}
\ No newline at end of file
......@@ -45,19 +45,23 @@ public class HomeTurnoverBean {
public static class DataBean {
/**
* Business_amount : 2734.00
* Business_amount : 2734.00 營業總金額
* Bill_decimal : 0.00
* discount : -23.00
* discount : -23.00 折扣
* TipsAmount : 0.00
* CreditCardAmount : 0.00
* people : 62.00
* sales : 2685.00
* number_bill : 31.00
* people : 62.00 消費人數 營業總金額除以賬單數量=平均值
* sales : 2685.00 項目總金額
* number_bill : 31.00 賬單數量 營業總金額除以賬單數量=平均值
* billNum_skyOder : 1.00
* billPrice_table : 2623.00
* billPrice_skyOder : 111.00
* billNum_table : 30.00
* servicecharge : 72.00
* billNum_Takeout
* CreditCardNum
* billPrice_Takeout
* TipsNum
* servicecharge : 72.00 服務費
*/
private String Business_amount; //營業總金額
private String Bill_decimal;
......
package com.gingersoft.gsa.cloud.main.mvp.model.service;
import io.reactivex.Observable;
import me.jessyan.retrofiturlmanager.RetrofitUrlManager;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.POST;
/**
* Created by Wyh on 2020/2/22.
*/
public interface MainService {
@POST("gsa/logout" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<Object> loginOut(@Body RequestBody requestBody);
}
package com.gingersoft.gsa.cloud.main.mvp.presenter;
import android.app.Application;
import android.content.Intent;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.ui.bean.mode.LoginBean;
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.main.mvp.contract.NewMainContract;
import com.jess.arms.utils.RxLifecycleUtils;
/**
......@@ -50,4 +61,24 @@ public class NewMainPresenter extends BasePresenter<NewMainContract.Model, NewMa
this.mImageLoader = null;
this.mApplication = null;
}
public void loginOut(){
RequestBody requestBody = new FormBody.Builder()
.build();
mModel.loginOut(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(""))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<Object>(mErrorHandler) {
@Override
public void onNext(@NonNull Object info) {
mRootView.loginOut();
}
});
}
}
......@@ -3,35 +3,34 @@ package com.gingersoft.gsa.cloud.main.mvp.ui.activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.LinearLayout;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.main.R;
import com.gingersoft.gsa.cloud.main.R2;
import com.gingersoft.gsa.cloud.main.di.component.DaggerNewMainComponent;
import com.gingersoft.gsa.cloud.main.mvp.contract.NewMainContract;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.SectionItem;
import com.gingersoft.gsa.cloud.main.mvp.presenter.NewMainPresenter;
import com.gingersoft.gsa.cloud.main.mvp.ui.adapter.MainOrderingAdapter;
import com.gingersoft.gsa.cloud.main.mvp.ui.view.SlidingMenu;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.gingersoft.gsa.cloud.main.mvp.contract.NewMainContract;
import com.gingersoft.gsa.cloud.main.mvp.presenter.NewMainPresenter;
import com.gingersoft.gsa.cloud.main.R;
import com.qmuiteam.qmui.widget.section.QMUISection;
import com.sxu.shadowdrawable.ShadowDrawable;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.OnClick;
import static com.jess.arms.utils.Preconditions.checkNotNull;
import static com.qmuiteam.qmui.util.QMUIDisplayHelper.dpToPx;
......@@ -49,7 +48,7 @@ import static com.qmuiteam.qmui.util.QMUIDisplayHelper.dpToPx;
* <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
* ================================================
*/
public class NewMainActivity extends BaseActivity<NewMainPresenter> implements NewMainContract.View {
public class NewMainActivity extends BaseActivity<NewMainPresenter> implements NewMainContract.View, View.OnClickListener {
@BindView(R2.id.rv_ordering_meals)
RecyclerView rvOrdering;//點餐
@BindView(R2.id.rv_management)
......@@ -57,6 +56,15 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
@BindView(R2.id.rv_staff_management)
RecyclerView rvStaffManagement;//管理
// @BindView(R2.id.drawer_layout)
// DrawerLayout drawerLayout;
@BindView(R2.id.slideMenu)
SlidingMenu slideMenu;
@BindView(R2.id.layout_ordering_meals)
LinearLayout orderingMeals;
@BindView(R2.id.layout_management)
LinearLayout layoutManagement;
@Override
public void setupActivityComponent(@NonNull AppComponent appComponent) {
......@@ -75,11 +83,12 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
@Override
public void initData(@Nullable Bundle savedInstanceState) {
ShadowDrawable.setShadowDrawable(findViewById(R.id.layout_ordering_meals), Color.parseColor("#FFFFFF"), dpToPx(5),
initDrawerLayout();
ShadowDrawable.setShadowDrawable(orderingMeals, Color.parseColor("#FFFFFF"), dpToPx(5),
Color.parseColor("#73888888"), dpToPx(5), 0, 2);
ShadowDrawable.setShadowDrawable(findViewById(R.id.layout_management), Color.parseColor("#FFFFFF"), dpToPx(5),
ShadowDrawable.setShadowDrawable(layoutManagement, Color.parseColor("#FFFFFF"), dpToPx(5),
Color.parseColor("#00000000"), dpToPx(5), 0, 2);
List<SectionItem> data = new ArrayList<>();
data.add(new SectionItem(R.drawable.ic_dining_table_mode, "餐檯模式"));
data.add(new SectionItem(R.drawable.ic_delivery_mode, "外送模式"));
......@@ -93,7 +102,7 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
}
});
adapter.setOnItemClickListener((adapter1, view, position) -> {
if(data.get(position).getText().equals("餐檯模式")){
if (data.get(position).getText().equals("餐檯模式")) {
CC.obtainBuilder("Component.Table")
.setActionName("showTableActivity")
.build()
......@@ -119,7 +128,7 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
rvManagement.setAdapter(managementAdapter);
managementAdapter.setOnItemClickListener((adapter12, view, position) -> {
if(managementData.get(position).getText().equals("打印管理")){
if (managementData.get(position).getText().equals("打印管理")) {
CC.obtainBuilder("Component.Print")
.setActionName("showPrintActivity")
.build()
......@@ -142,6 +151,9 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
rvStaffManagement.setAdapter(staffAdapter);
}
private void initDrawerLayout() {
}
@Override
public void initIntent() {
......@@ -194,4 +206,47 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
public void killMyself() {
finish();
}
public View.OnClickListener mSlidingMenuOnclick = new View.OnClickListener() {
@Override
public void onClick(View v) {
slideMenu.toggle();
}
};
@OnClick({R2.id.layout_login_out})
@Override
public void onClick(View v) {
if (v.getId() == R.id.layout_login_out) {
//登出
mPresenter.loginOut();
}
}
@Override
public void loginOut() {
GsaCloudApplication.isLogin = false;
CC.obtainBuilder("User.Component.Login")
.setActionName("showActivityA")
.build()
.call();
finish();
}
private long mExitTime;
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if ((System.currentTimeMillis() - mExitTime) > 2000) {
showMessage("再按一次退出應用");
mExitTime = System.currentTimeMillis();
} else {
finish();
System.exit(0);
}
return true;
}
return super.onKeyDown(keyCode, event);
}
}
package com.gingersoft.gsa.cloud.main.mvp.ui.view;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import com.daivd.chart.utils.DensityUtils;
import com.gingersoft.gsa.cloud.main.R;
import com.jess.arms.utils.ArmsUtils;
import com.nineoldandroids.view.ViewHelper;
import com.sxu.shadowdrawable.ShadowDrawable;
/**
* des :SlidingMenu 侧边栏 侧滑菜单
*/
public class SlidingMenu extends HorizontalScrollView {
private int mScreenWidth;
private int mMenuRightPadding;
private int mMenuWidth;
private int mHalfMenuWidth;
private boolean isOpen;
private boolean once;
private ViewGroup mMenu;
private ViewGroup mContent;
private Drawable contentBg;
public SlidingMenu(Context context) {
this(context, null);
}
public SlidingMenu(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public SlidingMenu(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mScreenWidth = ArmsUtils.getScreenWidth(context);
// TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.SlidingMenu, defStyleAttr, 0);
// int count = a.getIndexCount();
// for (int i = 0; i < count; i++) {
// int attr = a.getIndex(i);
// switch (attr) {
// case R.styleable.SlidingMenu_rightPadding: {
//// 默认是50
// mMenuRightPadding = a.getDimensionPixelSize(attr, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50f, getResources().getDisplayMetrics()));
// break;
// }
// }
// }
// a.recycle();
mMenuRightPadding = DensityUtils.dp2px(context, 140);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
/**
* 显示设置一个宽度
*/
if (!once) {
LinearLayout wrapper = (LinearLayout) getChildAt(0);
mMenu = (ViewGroup) wrapper.getChildAt(0);
mContent = (ViewGroup) wrapper.getChildAt(1);
contentBg = mContent.getBackground();
mMenuWidth = mScreenWidth - mMenuRightPadding;
mHalfMenuWidth = mMenuWidth / 2;
mMenu.getLayoutParams().width = mMenuWidth;
mContent.getLayoutParams().width = mScreenWidth;
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
if (changed) {
// 将菜单隐藏
this.scrollTo(mMenuWidth, 0);
once = true;
}
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
int action = ev.getAction();
switch (action) {
// Up时,进行判断,如果显示区域大于菜单宽度一半则完全显示,否则隐藏
case MotionEvent.ACTION_UP: {
int scrollX = getScrollX();
if (scrollX > mHalfMenuWidth) {
this.smoothScrollTo(mMenuWidth, 0);
isOpen = false;
} else {
this.smoothScrollTo(0, 0);
isOpen = true;
}
return true;
}
}
return super.onTouchEvent(ev);
}
/**
* 打开菜单
*/
public void openMenu() {
if (isOpen)
return;
this.smoothScrollTo(0, 0);
isOpen = true;
ShadowDrawable.setShadowDrawable(mContent, Color.parseColor("#FFFFFF"), 50,
Color.parseColor("#73888888"), 50, 0, 2);
invalidate();
}
/**
* 关闭菜单
*/
public void closeMenu() {
if (isOpen) {
this.smoothScrollTo(mMenuWidth, 0);
isOpen = false;
mContent.setBackground(contentBg);
}
}
/**
* 切换菜单状态
*/
public void toggle() {
if (isOpen) {
closeMenu();
} else {
openMenu();
}
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
float scale = l * 1.0f / mMenuWidth;
float leftScale = 1 - 0.3f * scale;
float rightScale = 0.8f + scale * 0.2f;
ViewHelper.setScaleX(mMenu, leftScale);
ViewHelper.setScaleY(mMenu, leftScale);
ViewHelper.setAlpha(mMenu, 0.6f + 0.4f * (1 - scale));
ViewHelper.setTranslationX(mMenu, mMenuWidth * scale * 0.7f);
ViewHelper.setPivotX(mContent, 0);
ViewHelper.setPivotY(mContent, mContent.getHeight() / 2);
ViewHelper.setScaleX(mContent, rightScale);
ViewHelper.setScaleY(mContent, rightScale);
}
}
\ No newline at end of file

4.45 KB | W: | H:

1.14 KB | W: | H:

main/src/main/res/drawable-xhdpi/ic_msg.png
main/src/main/res/drawable-xhdpi/ic_msg.png
main/src/main/res/drawable-xhdpi/ic_msg.png
main/src/main/res/drawable-xhdpi/ic_msg.png
  • 2-up
  • Swipe
  • Onion skin
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<com.gingersoft.gsa.cloud.main.mvp.ui.view.SlidingMenu xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/slideMenu"
android:layout_width="match_parent"
android:background="#F0edf1"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="@color/theme_color">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"><!-- 側邊欄內容-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/theme_color"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_15"
android:text="个人中心"
android:textColor="@color/white"
android:textSize="@dimen/sp_17" />
<ImageView
android:layout_width="@dimen/dp_76"
android:layout_height="@dimen/dp_76"
android:layout_marginTop="@dimen/dp_14"
android:src="@drawable/ic_header" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_6"
android:text="NAME"
android:textColor="@color/white"
android:textSize="@dimen/sp_20" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="店鋪名稱"
android:textColor="@color/white"
android:textSize="@dimen/sp_20" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_37"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="@dimen/dp_29"
android:layout_height="@dimen/dp_27"
android:layout_marginLeft="@dimen/dp_18"
android:src="@drawable/ic_mall_center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_14"
android:text="商城中心"
android:textColor="@color/white"
android:textSize="@dimen/sp_17" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_28"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="@dimen/dp_29"
android:layout_height="@dimen/dp_27"
android:layout_marginLeft="@dimen/dp_18"
android:src="@drawable/ic_about_us" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_14"
android:text="關於我們"
android:textColor="@color/white"
android:textSize="@dimen/sp_17" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_28"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="@dimen/dp_29"
android:layout_height="@dimen/dp_27"
android:layout_marginLeft="@dimen/dp_18"
android:src="@drawable/ic_password" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_14"
android:text="修改密碼"
android:textColor="@color/white"
android:textSize="@dimen/sp_17" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_28"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="@dimen/dp_29"
android:layout_height="@dimen/dp_27"
android:layout_marginLeft="@dimen/dp_18"
android:src="@drawable/ic_setting" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_14"
android:text="設置"
android:textColor="@color/white"
android:textSize="@dimen/sp_17" />
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:id="@+id/layout_login_out"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp_45"
android:gravity="center_vertical|bottom"
android:orientation="horizontal">
<ImageView
android:layout_width="@dimen/dp_29"
android:layout_height="@dimen/dp_27"
android:layout_marginLeft="@dimen/dp_18"
android:src="@drawable/ic_loginout" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_6"
android:text="登出"
android:textColor="@color/white"
android:textSize="@dimen/sp_17" />
</LinearLayout>
</LinearLayout>
<!-- 主頁內容-->
<androidx.core.widget.NestedScrollView
android:id="@+id/content_scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F0edf1">
<LinearLayout
android:layout_width="match_parent"
......@@ -86,9 +254,9 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_20"
android:text="員工"
android:layout_marginLeft="@dimen/dp_15"
android:textColor="#181818"
android:textSize="@dimen/sp_14" />
......@@ -103,4 +271,7 @@
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
\ No newline at end of file
</androidx.core.widget.NestedScrollView>
</LinearLayout>
</com.gingersoft.gsa.cloud.main.mvp.ui.view.SlidingMenu>
......@@ -28,9 +28,10 @@
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="@dimen/dp_22"
android:layout_height="@dimen/dp_25"
android:src="@drawable/ic_personal_center"
android:id="@+id/iv_personal_center"
android:layout_width="@dimen/dp_37"
android:layout_height="@dimen/dp_37"
android:src="@drawable/ic_my"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
......@@ -47,8 +48,8 @@
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:layout_width="@dimen/dp_26"
android:layout_height="@dimen/dp_28"
android:layout_width="@dimen/dp_24"
android:layout_height="@dimen/dp_26"
android:src="@drawable/ic_msg"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
......@@ -94,13 +95,11 @@
app:layout_constraintRight_toLeftOf="@id/tv_compare_today_state"
app:layout_constraintTop_toBottomOf="@id/tv_today_amount" />
<TextView
<ImageView
android:id="@+id/tv_compare_today_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="↑"
android:textColor="@color/white"
android:textSize="@dimen/sp_12"
android:layout_width="@dimen/dp_8"
android:layout_height="@dimen/dp_9"
app:layout_constraintBottom_toBottomOf="@id/tv_compare_today_text"
app:layout_constraintLeft_toRightOf="@id/tv_compare_today_text"
app:layout_constraintRight_toLeftOf="@id/tv_compare_today_size"
......@@ -147,8 +146,8 @@
android:layout_width="0dp"
android:layout_height="160dp"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:paddingRight="@dimen/dp_10"
app:layout_constraintLeft_toLeftOf="@id/cv_white_bg"
app:layout_constraintRight_toRightOf="@id/cv_white_bg"
......@@ -222,11 +221,12 @@
android:textSize="@dimen/sp_12" />
<ImageView
android:id="@+id/iv_project_amount_state"
android:layout_width="@dimen/dp_8"
android:layout_height="@dimen/dp_9"
android:src="@drawable/ic_rise" />
android:layout_height="@dimen/dp_9" />
<TextView
android:id="@+id/tv_project_amount_trend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#3c3c3c"
......@@ -258,17 +258,30 @@
android:textColor="#3c3c3c"
android:textSize="@dimen/sp_12" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="平均:1000"
android:text="平均:"
android:textColor="#3c3c3c"
android:textSize="@dimen/sp_12" />
<LinearLayout
<TextView
android:id="@+id/tv_per_capita_consumption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#3c3c3c"
android:textSize="@dimen/sp_12" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
......@@ -281,15 +294,14 @@
android:textSize="@dimen/sp_12" />
<ImageView
android:id="@+id/iv_people_trend"
android:layout_width="@dimen/dp_8"
android:layout_height="@dimen/dp_9"
android:src="@drawable/ic_rise" />
android:layout_height="@dimen/dp_9" />
<TextView
android:id="@+id/tv_people_trend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1000"
android:layout_height="match_parent"
android:textColor="#3c3c3c"
android:textSize="@dimen/sp_12" />
</LinearLayout>
......@@ -319,13 +331,25 @@
android:textColor="#3c3c3c"
android:textSize="@dimen/sp_12" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="平均:1000"
android:text="平均:"
android:textColor="#3c3c3c"
android:textSize="@dimen/sp_12" />
<TextView
android:id="@+id/tv_average_consumption_per_order"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#3c3c3c"
android:textSize="@dimen/sp_12" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -341,14 +365,14 @@
android:textSize="@dimen/sp_12" />
<ImageView
android:id="@+id/iv_bill_trend"
android:layout_width="@dimen/dp_8"
android:layout_height="@dimen/dp_9"
android:src="@drawable/ic_down" />
android:layout_height="@dimen/dp_9" />
<TextView
android:id="@+id/tv_bill_trend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1000"
android:textColor="#3c3c3c"
android:textSize="@dimen/sp_12" />
</LinearLayout>
......
......@@ -23,4 +23,6 @@
<string name="function_manage">管理选项</string>
<string name="function_soldout_ctrl">沽清控制</string>
<string name="quit_system">退出系統</string>
<string name="format_one_point">%1$.1f</string>
</resources>
......@@ -17,6 +17,7 @@ import com.billy.cc.core.component.CCUtil;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.OrderDetail;
import com.gingersoft.gsa.cloud.base.common.bean.PrinterManger.PrinterManager;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage;
import com.gingersoft.gsa.cloud.base.utils.PrintUtils;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.base.utils.view.ImageUtils;
......@@ -39,7 +40,11 @@ import com.joe.print.mvp.ui.adapter.PrinterListAdapter;
import com.yanzhenjie.recyclerview.widget.DefaultItemDecoration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
......@@ -107,8 +112,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
type = CCUtil.getNavigateParam(this, "type", 1001);
if (type == 0) {
//上菜紙
List<OrderDetail> foods = CCUtil.getNavigateParam(this, "NewFoods", new ArrayList<>());
bitmap = PrintUtils.getPrintBitmap(mContext, foods);
bitmap = PrintUtils.getPrintBitmap(mContext, MyOrderManage.getInstance().getNewFoodList());
} else if (type == 1) {
//印單
bitmap = PrintUtils.getPrintBitmap(mContext);
......@@ -116,9 +120,22 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
//結賬單
bitmap = PrintUtils.getPrintBillBitmap(mContext);
} else if (type == 3) {
//廚房單
List<OrderDetail> foods = CCUtil.getNavigateParam(this, "NewFoods", new ArrayList<>());
bitmap = PrintUtils.getKitChenPrintBitmap(mContext, foods);
//廚房單,需要切紙
List<OrderDetail> orderDetails = MyOrderManage.getInstance().getNewFoodList();
if (orderDetails != null) {
Map<String, List<OrderDetail>> map = new HashMap<>();
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
map = orderDetails.stream().collect(Collectors.groupingBy(OrderDetail::getPrintseting));
} else {
for (int i = 0; i < orderDetails.size(); i++) {
}
}
bitmap = PrintUtils.getKitChenPrintBitmap(mContext, MyOrderManage.getInstance().getNewFoodList());
} else {
ToastUtils.show(mContext, "食品列表為空,打印失敗");
finish();
}
} else {
ToastUtils.show(mContext, "打印失敗");
finish();
......
package com.gingersoft.gsa.cloud.base.application;
import android.content.Context;
import android.util.Log;
import com.billy.cc.core.component.CC;
import com.elvishew.xlog.LogConfiguration;
import com.elvishew.xlog.LogLevel;
import com.elvishew.xlog.interceptor.BlacklistTagsFilterInterceptor;
import com.gingersoft.gsa.cloud.base.BuildConfig;
import com.gingersoft.gsa.cloud.base.common.bean.CurrentAndroidSetting;
import com.gingersoft.gsa.cloud.base.utils.constans.UserConstans;
import com.gingersoft.gsa.cloud.base.utils.crash.AppCrashHandler;
......@@ -32,13 +37,21 @@ public class GsaCloudApplication extends BaseApplication {
CC.enableVerboseLog(true);
CC.enableDebug(true);
CC.enableRemoteCC(true);
// initXLog();
initGreenDao();
AppCrashHandler.getInstance().init(this, "test");
androidSetting = new CurrentAndroidSetting();
}
private void initXLog(){
LogConfiguration config = new LogConfiguration.Builder()
.logLevel(BuildConfig.DEBUG? LogLevel.ALL: LogLevel.NONE)
.tag("GSA-TAG")
.addInterceptor(new BlacklistTagsFilterInterceptor("","",""))
.build();
}
private void initGreenDao() {
DaoManager mManager = DaoManager.getInstance();
......
......@@ -5,6 +5,7 @@ import com.gingersoft.gsa.cloud.database.bean.Combo;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.bean.Modifier;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
......@@ -15,7 +16,8 @@ import java.util.List;
* 修订历史:2020-02-18
* 描述:訂單實體類
*/
public class OrderDetail {
public class OrderDetail implements Serializable {
private static final long serialVersionUID = -958791295551999853L;
/**
* 是否选择
* 0 未选中
......
......@@ -52,6 +52,8 @@ public class MyOrderManage {
private OrderBean orderBean;
//食品列表
private List<OrderDetail> orderFoodList = new ArrayList<>();
//本次送單食品,用於打印
private List<OrderDetail> newFoodList = new ArrayList<>();
// private List<DatasBean> comboOrders = new ArrayList<>();
// private List<MixOldOrder> MixOldOrders = new ArrayList<>();
// private List<MixComboGroupDiscount.DatasBean> mixComboGroup_Discounts;
......@@ -1171,4 +1173,12 @@ public class MyOrderManage {
public void setBillMoney(List<PayMethod> billMoney) {
this.billMoney = billMoney;
}
public List<OrderDetail> getNewFoodList() {
return newFoodList;
}
public void setNewFoodList(List<OrderDetail> newFoodList) {
this.newFoodList = newFoodList;
}
}
package com.gingersoft.gsa.cloud.base.utils;
import android.content.Context;
import android.os.Environment;
import android.text.TextUtils;
import com.elvishew.xlog.XLog;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2018/11/16
* 修订历史:2018/11/16
* 描述:7.0 兼容
* <files-path name="name" path="path" /> 对应getFilesDir()。
* <cache-path name="name" path="path" /> 对应getCacheDir()。
* <external-path name="name" path="path" /> 对应Environment.getExternalStorageDirectory()。
* <external-files-path name="name" path="path" /> 对应getExternalFilesDir()。
* <external-cache-path name="name" path="path" /> 对应getExternalCacheDir()。
*/
public class FileUtils {
public static String FirstFolder = "GSACloud";//一级目录
public static String file = "file";//文件文件夹
public static String Image = "image";//图片文件夹
public static String Log = "xLog";//日志存储
public static String ActionLog = "actionLog";//操作日志
public static String ErrorLog = "errorLog";//错误日志存储
public static String APK = "Download";//安装包目录放在系统目录
/*ALBUM_PATH取得机器的SD卡位置,File.separator为分隔符“/”*/
public final static String ALBUM_PATH = Environment.getExternalStorageDirectory() + File.separator + FirstFolder + File.separator;
public final static String IMAGE_PATH = ALBUM_PATH + Image + File.separator;
public final static String File_PATH = ALBUM_PATH + file + File.separator;
public final static String LOG_PATH = ALBUM_PATH + Log + File.separator;
public final static String ACTIONLOG_PATH = LOG_PATH + ActionLog + File.separator;
public final static String ERRORLOG_PATH = LOG_PATH + ErrorLog + File.separator;
public final static String APK_PATH = Environment.getExternalStorageDirectory() + File.separator + APK + File.separator;
public final static String FILE_EXTENSION_SEPARATOR = ".";
//操作日志單最大文件大小
public final static int ACTION_MAX_SIZE = 1024 * 1024 * 5;
//操作日志文件按照時間刪除
public final static int ACTION_MAX_FILE_TIME = 1000 * 60 * 60 * 12;
private FileUtils() {
throw new AssertionError();
}
public static StringBuilder readFile(String filePath, String charsetName) {
File file = new File(filePath);
StringBuilder fileContent = new StringBuilder("");
if (file == null || !file.isFile()) {
return null;
}
BufferedReader reader = null;
try {
InputStreamReader is = new InputStreamReader(new FileInputStream(
file), charsetName);
reader = new BufferedReader(is);
String line = null;
while ((line = reader.readLine()) != null) {
if (!fileContent.toString().equals("")) {
fileContent.append("\r\n");
}
fileContent.append(line);
}
reader.close();
return fileContent;
} catch (IOException e) {
throw new RuntimeException("IOException occurred. ", e);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
throw new RuntimeException("IOException occurred. ", e);
}
}
}
}
/**
* 写文件
*
* @param
* @return boolean 返回类型
*/
public static boolean writeFile(String filePath, String content,
boolean append) {
if (TextUtils.isEmpty(content)) {
return false;
}
FileWriter fileWriter = null;
try {
makeDirs(filePath);
fileWriter = new FileWriter(filePath, append);
fileWriter.write(content);
fileWriter.close();
return true;
} catch (IOException e) {
throw new RuntimeException("IOException occurred. ", e);
} finally {
if (fileWriter != null) {
try {
fileWriter.close();
} catch (IOException e) {
throw new RuntimeException("IOException occurred. ", e);
}
}
}
}
/**
* 创建文件的路径
*
* @param
* @return boolean 返回类型
*/
public static boolean makeDirs(String filePath) {
String folderName = getFolderName(filePath);
if (TextUtils.isEmpty(folderName)) {
return false;
}
File folder = new File(folderName);
return (folder.exists() && folder.isDirectory()) ? true : folder.mkdirs();
}
public static String getFolderName(String filePath) {
if (TextUtils.isEmpty(filePath)) {
return filePath;
}
int filePosi = filePath.lastIndexOf(File.separator);
return (filePosi == -1) ? "" : filePath.substring(0, filePosi);
}
/**
* 写文本文件 在Android系统中,文件保存在 /data/data/PACKAGE_NAME/files 目录下
*
* @param context
*/
public static void write(Context context, String fileName, String content) {
if (content == null)
content = "";
try {
FileOutputStream fos = context.openFileOutput(fileName,
Context.MODE_PRIVATE);
fos.write(content.getBytes());
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 读取文本文件 文件保存在 /data/data/PACKAGE_NAME/files
*
* @param context
* @param fileName
* @return
*/
public static String read(Context context, String fileName) {
try {
FileInputStream in = context.openFileInput(fileName);
return readInStream(in);
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
public static String readInStream(FileInputStream inStream) {
try {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] buffer = new byte[512];
int length = -1;
while ((length = inStream.read(buffer)) != -1) {
outStream.write(buffer, 0, length);
}
outStream.close();
inStream.close();
return outStream.toString();
} catch (IOException e) {
XLog.tag("FileTest").d(e.getMessage());
}
return null;
}
/**
* 创建文件
*
* @param folderPath
* @param fileName
* @return
*/
public static File createFile(String folderPath, String fileName) {
File destDir = new File(folderPath);
if (!destDir.exists()) {
destDir.mkdirs();
}
return new File(folderPath, fileName + fileName);
}
/*
* 在SD卡上创建目录
*/
public static File creatSDDir(String dirName) {
File dir = new File(dirName);
if (!dir.exists()) {
dir.mkdirs();
}
return dir;
}
/**
* 获取文件大小
*
* @param filePath
* @return
*/
public static long getFileSize(String filePath) {
long size = 0;
File file = new File(filePath);
if (file != null && file.exists()) {
size = file.length();
}
return size;
}
/*
* Java文件操作 获取文件扩展名
* */
public static String getExtensionName(String filename) {
if ((filename != null) && (filename.length() > 0)) {
int dot = filename.lastIndexOf('.');
if ((dot > -1) && (dot < (filename.length() - 1))) {
return filename.substring(dot + 1);
}
}
return filename;
}
/*
* Java文件操作 获取不带扩展名的文件名
* */
public static String getFileNameNoEx(String filename) {
if ((filename != null) && (filename.length() > 0)) {
int dot = filename.lastIndexOf('.');
if ((dot > -1) && (dot < (filename.length()))) {
return filename.substring(0, dot);
}
}
return filename;
}
}
......@@ -203,15 +203,13 @@ public class PrintUtils {
TextView tvOperator = view.findViewById(R.id.tv_operator);
RecyclerView rvFood = view.findViewById(R.id.rv_kitchen_food);
TextView tvTableNumber2 = view.findViewById(R.id.tv_kitchen_print_table_number2);
if (foodList != null && foodList.size() > 0) {
if (foodList != null && foodList.size() > 0 && foodList.get(0) != null) {
KitChenPrintFoodAdapter foodAdapter = new KitChenPrintFoodAdapter(foodList);
rvFood.setLayoutManager(new LinearLayoutManager(context));
rvFood.setAdapter(foodAdapter);
//廚房位置
if (foodList.get(0) != null) {
tvKitChenLocation.setText(foodList.get(0).getPrintseting());
}
}
if (OpenTableManage.getDefault().getTableBean() != null) {
// 台號
tvTableNumber.setText(OpenTableManage.getDefault().getTableBean().getTableName() + "");
......
......@@ -12,10 +12,14 @@ import android.telecom.Call;
import android.util.Base64;
import android.util.Log;
import android.widget.Toast;
import com.gingersoft.gsa.cloud.base.utils.FileUtils;
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.toast.ToastUtils;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.utils.DeviceUtils;
import java.io.File;
import java.io.FileInputStream;
......@@ -201,7 +205,7 @@ public class AppCrashHandler implements UncaughtExceptionHandler {
// 把上面获取的堆栈信息转为字符串,打印出来
String stacktrace = result.toString();
printWriter.close();
LogUtil.d(TAG,stacktrace);
LogUtil.d(TAG, stacktrace);
//收集设备信息
collectCrashDeviceInfo(mContext);
......@@ -406,24 +410,22 @@ public class AppCrashHandler implements UncaughtExceptionHandler {
// 保存文件
long timetamp = System.currentTimeMillis();
String time = format.format(new Date());
// String fileName = "crash-" + GSAApplication.machineName + "-" + DeviceUtils.getVersionName(GSAApplication.getAppContext()) + "-" + time + "-" + timetamp + "-" + info.get("versionName") + ".xml";
// if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {//外部存储卡
// try {
// File dir = new File(FileUtils.ERRORLOG_PATH);
// Log.i("CrashHandler", dir.toString());
// //不存在就創建目錄
// if (!dir.exists())
// dir.mkdirs();
// FileOutputStream fos = new FileOutputStream(new File(FileUtils.ERRORLOG_PATH, fileName));
// fos.write(sb.toString().getBytes());
// fos.close();
// return fileName;
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
String fileName = "crash-" + "-" + DeviceUtils.getVersionName(mContext) + "-" + time + "-" + timetamp + "-" + info.get("versionName") + ".xml";
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {//外部存储卡
try {
File dir = new File(FileUtils.ERRORLOG_PATH);
Log.i("CrashHandler", dir.toString());
//不存在就創建目錄
if (!dir.exists())
dir.mkdirs();
FileOutputStream fos = new FileOutputStream(new File(FileUtils.ERRORLOG_PATH, fileName));
fos.write(sb.toString().getBytes());
fos.close();
return fileName;
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
......
package com.gingersoft.gsa.cloud.base.utils.time;
import com.gingersoft.gsa.cloud.base.utils.log.LogUtil;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
......@@ -93,6 +95,28 @@ public class TimeUtils {
}
/**
* 获取前n天日期、后n天日期
*
* @param distanceDay 前几天 如获取前7天日期则传-7即可;如果后7天则传7
* @return
*/
public static String getOldDate(int distanceDay) {
SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd");
Date beginDate = new Date();
Calendar date = Calendar.getInstance();
date.setTime(beginDate);
date.set(Calendar.DATE, date.get(Calendar.DATE) + distanceDay);
Date endDate = null;
try {
endDate = dft.parse(dft.format(date.getTime()));
} catch (ParseException e) {
e.printStackTrace();
}
return dft.format(endDate);
}
/**
* 把日期型字符串转换为数字型字符串
*
* @param time
......
......@@ -281,11 +281,11 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
public void onNext(@NonNull BaseResult info) {
if (info != null && info.isSuccess()) {
mRootView.showMessage("送單成功");
printSendOrder(MyOrderManage.getInstance().getOrderFoodList());
IActivity.returnTableActivity(true);
} else {
mRootView.showMessage("送單失敗");
}
printSendOrder(MyOrderManage.getInstance().getOrderFoodList());
}
});
}
......@@ -352,10 +352,10 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
if (info != null && info.isSuccess()) {
mRootView.showMessage("送單成功");
// mRootView.launchActivity(new Intent(IActivity, MealStandActivity.class));
printSendOrder(newFoods);
} else {
mRootView.showMessage("送單失敗");
}
printSendOrder(newFoods);
}
});
}
......@@ -364,9 +364,9 @@ public class MealStandPresenter extends BaseOrderPresenter<MealStandContract.Mod
* 打印上菜紙
*/
private void printSendOrder(List<OrderDetail> newFoods) {
MyOrderManage.getInstance().setNewFoodList(newFoods);
CC.obtainBuilder("Component.Print")
.setActionName("printActivity")
.addParam("NewFoods", newFoods)
.addParam("type", 3)
.build()
.callAsync((cc, result) -> {
......
......@@ -22,7 +22,8 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".mvp.ui.activity.LoginActivity" >
<activity android:name=".mvp.ui.activity.LoginActivity"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
......
......@@ -76,8 +76,6 @@ public class LoginActivity extends BaseActivity<LoginPresenter> implements Login
@Override
public void initData(@Nullable Bundle savedInstanceState) {
findViewById(R.id.tv_gsa_user_login).setOnClickListener(this);
edAccount = findViewById(R.id.ed_login_user_account);
edPwd = findViewById(R.id.ed_login_user_pwd);
// if(GsaCloudApplication.getLoginToken(mContext).length() > 0){
// jumpActivity();
// finish();
......
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