Commit 35b7599f by 王宇航

3-3

parent cfa82849
......@@ -72,12 +72,21 @@ public abstract class BaseFragment<P extends IPresenter> extends Fragment implem
return mLifecycleSubject;
}
private View view;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mContext = getActivity();
return initView(inflater, container, savedInstanceState);
if (view != null) {
ViewGroup viewGroup = (ViewGroup) view.getRootView();
if (viewGroup != null) {
viewGroup.removeView(view);
}
return view;
}
view = initView(inflater, container, savedInstanceState);
return view;
}
......
......@@ -26,7 +26,7 @@ buildscript {
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2'
// classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.8'
// classpath fileTree(dir:'plugins', include:['*.jar'])
classpath fileTree(dir:'plugins', include:['*.jar'])
}
}
......
......@@ -61,9 +61,9 @@ public class PaymentMethodReportPresenter extends BasePresenter<PaymentMethodRep
this.mApplication = null;
}
public void getPaymentInfo(String startTime) {
public void getPaymentInfo(String restaurandId, String startTime) {
RequestBody requestBody = new FormBody.Builder()
.add("restaurantId", "26")
.add("restaurantId", restaurandId)
.add("startTime", startTime)//TimeUtils.getYesterdayTime(TimeUtils.DATE_FORMAT_DATE)
.add("endTime", TimeUtils.getYear(0))//TimeUtils.getCurrentTimeInString(TimeUtils.DATE_FORMAT_DATE)
.build();
......
......@@ -63,9 +63,9 @@ public class SalesPresenter extends BasePresenter<SalesContract.Model, SalesCont
this.mApplication = null;
}
public void getSalesReportInfo(String startTime) {
public void getSalesReportInfo(String restaurantId, String startTime) {
RequestBody requestBody = new FormBody.Builder()
.add("restaurantId", "26")
.add("restaurantId", restaurantId)
.add("startTime", startTime)//TimeUtils.getYesterdayTime(TimeUtils.DATE_FORMAT_DATE)
.add("endTime", TimeUtils.getYear(0))//TimeUtils.getCurrentTimeInString(TimeUtils.DATE_FORMAT_DATE)
.build();
......
......@@ -2,15 +2,20 @@ package com.gingersoft.gsa.cloud.main.mvp.ui.activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Message;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.JsonUtils;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.gsa.cloud.database.utils.FunctionDaoUtils;
import com.gingersoft.gsa.cloud.main.BuildConfig;
import com.gingersoft.gsa.cloud.main.R;
import com.gingersoft.gsa.cloud.main.R2;
import com.gingersoft.gsa.cloud.main.di.component.DaggerNewMainComponent;
......@@ -18,18 +23,21 @@ 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.fragment.MainTopFragment;
import com.gingersoft.gsa.cloud.main.mvp.ui.view.SlidingMenu;
import com.gingersoft.gsa.cloud.ui.bean.mode.LoginBean;
import com.gingersoft.gsa.cloud.ui.widget.dialog.ChooseRestaurantDialog;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.qmuiteam.qmui.widget.pullRefreshLayout.QMUIPullRefreshLayout;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
......@@ -63,7 +71,7 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
@BindView(R2.id.slideMenu)
SlidingMenu slideMenu;
// @BindView(R2.id.layout_ordering_meals)
// @BindView(R2.id.layout_ordering_meals)
// LinearLayout orderingMeals;
// @BindView(R2.id.layout_management)
// LinearLayout layoutManagement;
......@@ -71,6 +79,15 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
TextView tvRestaurantName;
@BindView(R2.id.tv_username)
TextView tvUserName;
@BindView(R2.id.ll_switch_server)
LinearLayout switchServer;
@BindView(R2.id.tv_store_name)
TextView tvStoreName;
@BindView(R2.id.qm_refresh)
QMUIPullRefreshLayout refresh;
private MainTopFragment mainTopFragment;
@Override
public void setupActivityComponent(@NonNull AppComponent appComponent) {
......@@ -94,21 +111,60 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
@Override
public void initData(@Nullable Bundle savedInstanceState) {
initShadow();
FragmentManager fragmentManager = getSupportFragmentManager();
mainTopFragment = (MainTopFragment) fragmentManager.findFragmentById(R.id.main_top_fragment);
switchServer.setVisibility(BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
tvStoreName.setText(GsaCloudApplication.getRestaurantName(mContext));
refresh.setOnPullListener(new QMUIPullRefreshLayout.OnPullListener() {
@Override
public void onMoveTarget(int offset) {
}
@Override
public void onMoveRefreshView(int offset) {
}
@Override
public void onRefresh() {
if (mainTopFragment != null) {
Message msg = new Message();
msg.what = 0;
mainTopFragment.setData(msg);
}
}
});
initFuncationData();
setTitleInfo();
}
private void initShadow() {
public void onFinishRefresh(){
refresh.finishRefresh();
}
private void initFuncationData() {
FunctionDaoUtils functionDao = new FunctionDaoUtils(mContext);
List<Function> functions = functionDao.queryAllFunction();
if (functions == null) {
return;
}
List<SectionItem> data = new ArrayList<>();
data.add(new SectionItem(R.drawable.ic_dining_table_mode, "餐檯模式"));
data.add(new SectionItem(R.drawable.ic_delivery_mode, "外送模式"));
data.add(new SectionItem(R.drawable.ic_outsourcing_model, "外賣模式"));
data.add(new SectionItem(R.drawable.ic_pre_order_mode, "預點餐模式"));
// int lastIndex;
// if (functions.size() >= 4) {
// lastIndex = 4;
// } else {
// lastIndex = functions.size();
// }
MainOrderingAdapter adapter = new MainOrderingAdapter(R.layout.main_home_funcation_item, data);
rvOrdering.setLayoutManager(new GridLayoutManager(mContext, 4) {
@Override
public boolean canScrollVertically() {
......@@ -187,7 +243,7 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
LoginBean.DataBean.UserBean.BrandsBean brandsBean = getBrandByRestaurantId(brandsBeans, item.getId());
if(brandsBean != null) {
if (brandsBean != null) {
saveBrandAndRestaurantInfo(brandsBean.getBrandId(), brandsBean.getBrandName(), item.getId(), item.getText());
}
......@@ -280,14 +336,7 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
finish();
}
public View.OnClickListener mSlidingMenuOnclick = new View.OnClickListener() {
@Override
public void onClick(View v) {
slideMenu.toggle();
}
};
@OnClick({R2.id.layout_login_out, R2.id.iv_personal_center,R2.id.tv_restaurant_name})
@OnClick({R2.id.ll_switch_server, R2.id.layout_login_out, R2.id.iv_personal_center, R2.id.tv_restaurant_name})
@Override
public void onClick(View v) {
if (v.getId() == R.id.layout_login_out) {
......@@ -297,6 +346,13 @@ public class NewMainActivity extends BaseActivity<NewMainPresenter> implements N
slideMenu.toggle();
} else if (v.getId() == R.id.tv_restaurant_name) {
showChooseRestaurantDialog();
} else if (v.getId() == R.id.ll_switch_server) {
//切換環境
CC.obtainBuilder("User.Component.Login")
.setActionName("switchServer")
.build()
.call();
finish();
}
}
......
......@@ -18,6 +18,13 @@ public class BusinessInfoAdapter extends BaseQuickAdapter<BusinessBean, BaseView
super(R.layout.report_business_info_item, data);
}
// @Override
// public void setNewData(@Nullable List<BusinessBean> data) {
//// super.setNewData(data);
// this.mData = data;
// notifyDataSetChanged();
// }
@Override
protected void convert(BaseViewHolder helper, BusinessBean item) {
helper.setText(R.id.tv_business_info_amount, item.getAmount() + "");
......
......@@ -106,7 +106,7 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
@Override
public void initData(@Nullable Bundle savedInstanceState) {
//獲取一段時間內的營業信息,默認獲取七天的數據
mPresenter.getRestaurantBusinessInfo("26", TimeUtils.getOldDate(-6), TimeUtils.getOldDate(0));
mPresenter.getRestaurantBusinessInfo(GsaCloudApplication.getRestaurantId(mContext) +"", TimeUtils.getOldDate(-6), TimeUtils.getOldDate(0));
mRestaurantName.setText(GsaCloudApplication.getRestaurantName(mContext));
mTvStartTime.setText(TimeUtils.getOldDate(-6));
......
......@@ -33,13 +33,13 @@ import com.gingersoft.gsa.cloud.main.mvp.contract.MainTopContract;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.HomeTurnoverBean;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.MainOrderInfoChartBean;
import com.gingersoft.gsa.cloud.main.mvp.presenter.MainTopPresenter;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.NewMainActivity;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.ReportActivity;
import com.gingersoft.gsa.cloud.main.mvp.ui.view.CustomMarkView;
import com.jess.arms.base.BaseFragment;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......@@ -124,9 +124,13 @@ public class MainTopFragment extends BaseFragment<MainTopPresenter> implements M
@Override
public void initData(@Nullable Bundle savedInstanceState) {
getInfo();
time.setText(TimeUtils.getCurrentTimeInString(TimeUtils.dateFormatYMDE));
}
private void getInfo() {
mPresenter.getRestaurantReport(GsaCloudApplication.getRestaurantId(mContext) + "");//GsaCloudApplication.getRestaurantId(mContext) 獲取餐廳營業信息
mPresenter.getOrderInfoChart();
time.setText(TimeUtils.getCurrentTimeInString(new SimpleDateFormat("yyyy-MM-dd E")));
}
/**
......@@ -167,7 +171,17 @@ public class MainTopFragment extends BaseFragment<MainTopPresenter> implements M
*/
@Override
public void setData(@Nullable Object data) {
if (data instanceof Message) {
switch (((Message) data).what) {
case 0:
//刷新數據
getInfo();
break;
default:
//do something
break;
}
}
}
......@@ -219,19 +233,23 @@ public class MainTopFragment extends BaseFragment<MainTopPresenter> implements M
if (yesterdayBean != null) {
double turnover = MoneyUtil.sub(Double.parseDouble(bean.getBusiness_amount()), Double.parseDouble(yesterdayBean.getBusiness_amount()));
ivTurnoverTrend.setVisibility(View.VISIBLE);
ivTurnoverTrend.setImageResource(getTrendImg(turnover));
tvTurnoverTrend.setText(String.format(getString(R.string.format_one_point), turnover));
double sales = MoneyUtil.sub(Double.parseDouble(bean.getSales()), Double.parseDouble(yesterdayBean.getSales()));
tvProjectAmountTrend.setText(String.format(getString(R.string.format_one_point), sales));
ivProjectAmountState.setVisibility(View.VISIBLE);
ivProjectAmountState.setImageResource(getTrendImg(sales));
int people = Integer.parseInt(bean.getPeople()) - Integer.parseInt(yesterdayBean.getPeople());
ivPeopleTrend.setImageResource(getTrendImg(people));
ivPeopleTrend.setVisibility(View.VISIBLE);
tvPeopleTrend.setText(people + "");
int billNum = Integer.parseInt(bean.getNumber_bill()) - Integer.parseInt(yesterdayBean.getNumber_bill());
ivBillTrend.setImageResource(getTrendImg(billNum));
ivBillTrend.setVisibility(View.VISIBLE);
tvBillTrend.setText(billNum + "");
}
}
......@@ -239,6 +257,8 @@ public class MainTopFragment extends BaseFragment<MainTopPresenter> implements M
@Override
public void loadChart(List<MainOrderInfoChartBean.DataBean> dataBeans) {
((NewMainActivity)getActivity()).onFinishRefresh();
Resources res = getResources();
FontStyle.setDefaultTextSpSize(mContext, 12);
//存儲今天的線條數據
......@@ -342,8 +362,8 @@ public class MainTopFragment extends BaseFragment<MainTopPresenter> implements M
lineChart.setShowChartName(false);
//底部不顯示顏色代表的意思
lineChart.getLegend().setDisplay(false);
lineChart.getMatrixHelper().setWidthMultiple(1f);
lineChart.getMatrixHelper().setCanZoom(false);
lineChart.getMatrixHelper().setWidthMultiple(1.5f);
lineChart.getMatrixHelper().setCanZoom(true);
lineChart.getHorizontalAxis().setRotateAngle(0);//設置底部文字旋轉角度
lineChart.setFirstAnim(true);
lineChart.setChartData(chartData2);
......
......@@ -9,6 +9,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.time.TimePickerUtils;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
......@@ -98,7 +99,7 @@ public class PaymentMethodReportFragment extends BaseFragment<PaymentMethodRepor
@Override
public void initData(@Nullable Bundle savedInstanceState) {
mPresenter.getPaymentInfo(TimeUtils.getYear(-1));
mPresenter.getPaymentInfo(GsaCloudApplication.getRestaurantId(mContext) + "", TimeUtils.getYear(-1));
mTvStartTime.setText(TimeUtils.getOldDate(-6));
mTvEndTime.setText(TimeUtils.getOldDate(0));
......@@ -299,7 +300,7 @@ public class PaymentMethodReportFragment extends BaseFragment<PaymentMethodRepor
//打開時間選擇器
TimePickerUtils.showReportTimePicker(mContext, cal, (date, v1) -> {
mTvStartTime.setText(TimeUtils.DATE_FORMAT_DATE.format(date));
mPresenter.getPaymentInfo(mTvStartTime.getText().toString());
mPresenter.getPaymentInfo(GsaCloudApplication.getRestaurantId(mContext) + "", mTvStartTime.getText().toString());
});
}
}
......
......@@ -9,6 +9,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.time.TimePickerUtils;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
......@@ -99,7 +100,7 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
@Override
public void initData(@Nullable Bundle savedInstanceState) {
mPresenter.getSalesReportInfo(TimeUtils.getYear(-1));
mPresenter.getSalesReportInfo(GsaCloudApplication.getRestaurantId(mContext) + "", TimeUtils.getYear(-1));
mTvStartTime.setText(TimeUtils.getYear(-1));
mTvEndTime.setText(TimeUtils.getOldDate(0));
......@@ -340,7 +341,7 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
}
TimePickerUtils.showReportTimePicker(mContext, cal, (date, v1) -> {
mTvStartTime.setText(TimeUtils.DATE_FORMAT_DATE.format(date));
mPresenter.getSalesReportInfo(mTvStartTime.getText().toString());
mPresenter.getSalesReportInfo(GsaCloudApplication.getRestaurantId(mContext) + "", mTvStartTime.getText().toString());
});
}
}
......

4.24 KB | W: | H:

4.08 KB | W: | H:

main/src/main/res/drawable-xhdpi/ic_dining_table_mode.png
main/src/main/res/drawable-xhdpi/ic_dining_table_mode.png
main/src/main/res/drawable-xhdpi/ic_dining_table_mode.png
main/src/main/res/drawable-xhdpi/ic_dining_table_mode.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -27,8 +27,8 @@
android:textColor="@color/white"
android:textSize="@dimen/sp_12"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/cl_title_layout" />
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
<TextView
android:id="@+id/tv_today_amount"
......@@ -186,7 +186,6 @@
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -197,7 +196,8 @@
<ImageView
android:id="@+id/iv_project_amount_state"
android:layout_width="@dimen/dp_8"
android:layout_height="@dimen/dp_9" />
android:layout_height="@dimen/dp_9"
android:visibility="gone" />
<TextView
android:id="@+id/tv_project_amount_trend"
......@@ -278,7 +278,8 @@
<ImageView
android:id="@+id/iv_people_trend"
android:layout_width="@dimen/dp_8"
android:layout_height="@dimen/dp_9" />
android:layout_height="@dimen/dp_9"
android:visibility="gone" />
<TextView
android:id="@+id/tv_people_trend"
......@@ -350,7 +351,8 @@
<ImageView
android:id="@+id/iv_bill_trend"
android:layout_width="@dimen/dp_8"
android:layout_height="@dimen/dp_9" />
android:layout_height="@dimen/dp_9"
android:visibility="gone" />
<TextView
android:id="@+id/tv_bill_trend"
......
......@@ -7,8 +7,8 @@
<ImageView
android:id="@+id/iv_main_home_item_function_icon"
android:layout_width="@dimen/dp_50"
android:layout_height="@dimen/dp_50"
android:layout_width="@dimen/dp_44"
android:layout_height="@dimen/dp_44"
android:src="@drawable/ic_dining_table" />
<TextView
......@@ -19,6 +19,6 @@
android:text="餐檯模式"
android:layout_marginTop="@dimen/dp_8"
android:textColor="@color/normal_color"
android:textSize="@dimen/sp_14" />
android:textSize="@dimen/sp_12" />
</LinearLayout>
\ No newline at end of file
......@@ -7,8 +7,8 @@
<ImageView
android:id="@+id/iv_main_home_item_function_icon"
android:layout_width="@dimen/dp_30"
android:layout_height="@dimen/dp_30"
android:layout_width="@dimen/dp_32"
android:layout_height="wrap_content"
android:src="@drawable/ic_dining_table" />
<TextView
......@@ -20,6 +20,6 @@
android:singleLine="true"
android:text="餐檯模式"
android:textColor="@color/normal_color"
android:textSize="@dimen/sp_13" />
android:textSize="@dimen/sp_12" />
</LinearLayout>
\ No newline at end of file
package com.gingersoft.gsa.cloud.base.utils;
package com.joe.print.mvp.print;
import android.content.Context;
import android.graphics.Bitmap;
......@@ -6,7 +6,6 @@ import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.base.adapter.print.BillAdapter;
import com.gingersoft.gsa.cloud.base.adapter.print.BillTypeAdapter;
import com.gingersoft.gsa.cloud.base.adapter.print.FoodAdapter;
......@@ -17,9 +16,11 @@ import com.gingersoft.gsa.cloud.base.common.bean.OrderDetail;
import com.gingersoft.gsa.cloud.base.common.bean.TableBean;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage;
import com.gingersoft.gsa.cloud.base.common.bean.mealManage.OpenTableManage;
import com.gingersoft.gsa.cloud.base.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.base.utils.view.ImageUtils;
import com.gingersoft.gsa.cloud.base.utils.view.LayoutToBitmapUtils;
import com.joe.print.R;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
......@@ -53,7 +54,10 @@ public class PrintUtils {
public static List<Bitmap> getPrintBitmap(Context mContext, int type, int paperWidth) {
List<Bitmap> bitmaps = new ArrayList<>();
PrintUtils.paperWidth = paperWidth;
if (type == 0) {
if (type == -1) {
//測試紙
bitmaps.add(PrintUtils.getTestPrintBitmap(mContext));
} else if (type == 0) {
//上菜紙
bitmaps.add(PrintUtils.getPrintBitmap(mContext, MyOrderManage.getInstance().getNewFoodList()));
} else if (type == 1) {
......@@ -322,9 +326,18 @@ public class PrintUtils {
//操作人員
tvOperator.setText(GsaCloudApplication.userName);
LayoutToBitmapUtils.layoutView(context, view);//先测量view
//580為程序支持的打印紙最大寬度
return ImageUtils.zoomDrawable(LayoutToBitmapUtils.loadBitmapFromView(view), paperWidth);//将view轉bitmap
}
private static Bitmap getTestPrintBitmap(Context context){
View view = LinearLayout.inflate(context, R.layout.print_test, null);
LayoutToBitmapUtils.layoutView(context, view);//先测量view
//580為程序支持的打印紙最大寬度
return ImageUtils.zoomDrawable(LayoutToBitmapUtils.loadBitmapFromView(view), paperWidth);//将view轉bitmap
}
}
......@@ -3,7 +3,6 @@ package com.joe.print.mvp.print;
import android.content.Context;
import android.graphics.Bitmap;
import com.gingersoft.gsa.cloud.base.utils.PrintUtils;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import java.util.ArrayList;
......@@ -41,9 +40,6 @@ public class SendPrint implements PrintDataMaker {
printer.setAlignCenter();
data.add(printer.getDataAndReset());
// //壓縮bitmap到指定大小
// bitmap = ImageUtils.zoomDrawabe(bitmap, width, bitmap.getHeight());
// ArrayList<byte[]> image1 = PrinterUtils.decodeBitmapToDataList(bitmap, parting);//bitmap转字节码
List<Bitmap> bitmaps = PrintUtils.getPrintBitmap(mContext, printType, width);//根據打印類型獲得不同的bitmap
if (bitmaps.size() <= 0) {
ToastUtils.show(mContext, "打印失敗");
......
......@@ -41,6 +41,7 @@ public class OldPrintActivity extends Activity implements PrintSocketHolder.OnSt
private int paperType = 1;//打印紙類型 1:58mm,2::80mm
private int printWidth = 560;//打印出來的內容寬度
/**
* -1:打印測試
* 0:上菜紙
* 1:印單
* 2:結賬單
......@@ -83,7 +84,8 @@ public class OldPrintActivity extends Activity implements PrintSocketHolder.OnSt
dialog.dismiss();
}
dialog = LoadingDialog.showNewDialogForLoading(this, "初始化...", true);
dialog.setOnDismissListener(this);
dialog.setOnDismissListener(dialog -> dismiss(""));
dialog.setOnCancelListener(dialog -> dismiss(""));
if (executor == null) {
executor = new PrintExecutor(ip, Integer.parseInt(port), paperType);
executor.setOnStateChangedListener(this);
......@@ -154,9 +156,12 @@ public class OldPrintActivity extends Activity implements PrintSocketHolder.OnSt
private void dismiss(String msg) {
ToastUtils.show(this, msg);
if(msg != null && !msg.equals("")){
ToastUtils.show(this, msg);
}
//延遲一秒
dialog.dismiss();
dialog.setOnCancelListener(dialog -> finish());
LoadingDialog.cancelDialogForLoading();
//判断是否为CC调用打开本页面
if (callId != null) {
......@@ -171,7 +176,6 @@ public class OldPrintActivity extends Activity implements PrintSocketHolder.OnSt
}
finish();
}
@Override
public void onDismiss(DialogInterface dialog) {
finish();
......
......@@ -15,7 +15,6 @@ import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.PrinterManger.PrinterManager;
import com.gingersoft.gsa.cloud.base.utils.PrintUtils;
import com.gingersoft.gsa.cloud.base.utils.constans.Constans;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
......@@ -33,6 +32,7 @@ import com.joe.print.R;
import com.joe.print.di.component.DaggerPrintComponent;
import com.joe.print.mvp.contract.PrintContract;
import com.joe.print.mvp.presenter.PrintPresenter;
import com.joe.print.mvp.print.PrintUtils;
import com.joe.print.mvp.print.SunMiPrint;
import com.joe.print.mvp.ui.adapter.DialogPrinterListAdapter;
import com.yanzhenjie.recyclerview.widget.DefaultItemDecoration;
......@@ -280,7 +280,6 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
@Override
public void showMessage(@NonNull String message) {
checkNotNull(message);
// ArmsUtils.snackbarText(message);
ToastUtils.show(mContext, message);
}
......@@ -319,11 +318,13 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
intent.putExtra("paperType", deviceBeans.get(position).getType());
intent.putExtra("type", type);
startActivity(intent);
dialog.dismiss();
finish();
});
dialog.setOnDismissListener(dialog1 -> finish());
dialog.setOnDismissListener(PrintActivity.this);
dialog.setOnCancelListener(dialog1 -> finish());
}
}
// .setWidth(ArmsUtils.getScreenHeidth(mContext))
.setHeight(ArmsUtils.getScreenHeidth(mContext) / 2)
.createDialogView()
.show();
......@@ -336,4 +337,5 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
finish();
}
}
}
<?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="match_parent"
android:gravity="center"
android:orientation="vertical">
<!-- 打印測試-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="打印測試"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/sp_25" />
</LinearLayout>
\ No newline at end of file
......@@ -2,7 +2,7 @@ ext.alwaysLib = true //虽然apply了cc-settings-2.gradle,但一直作为libra
apply from: rootProject.file("cc-settings.gradle")
apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'org.greenrobot.greendao'
//apply plugin: 'android-aspectjx'
apply plugin: 'android-aspectjx'
android {
compileSdkVersion rootProject.ext.android["compileSdkVersion"]
......@@ -85,6 +85,6 @@ dependencies {
//陰影背景
// implementation 'com.github.Liberuman:ShadowDrawable:0.1'
api 'com.github.lihangleo2:ShadowLayout:2.1.6'
// implementation 'org.aspectj:aspectjrt:1.8.9'
api 'com.contrarywind:Android-PickerView:3.2.4'//時間選擇控件
implementation 'org.aspectj:aspectjrt:1.8.9'
}
//package com.gingersoft.gsa.cloud.aspectj;
//
//import java.lang.annotation.ElementType;
//import java.lang.annotation.Retention;
//import java.lang.annotation.RetentionPolicy;
//import java.lang.annotation.Target;
//
///**
// * Created by Wyh on 2020/2/29.
// */
//@Retention(RetentionPolicy.RUNTIME)
//@Target(ElementType.METHOD)
//public @interface SingleClick {
// /* 点击间隔时间 */
// long value() default 1000;
//}
package com.gingersoft.gsa.cloud.aspectj;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Created by Wyh on 2020/2/29.
* 雙擊檢測
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface SingleClick {
/* 点击间隔时间 */
long value() default 1000;
}
//package com.gingersoft.gsa.cloud.aspectj;
//
//import android.view.View;
//
//import java.lang.reflect.Method;
//
///**
// * Created by Wyh on 2020/2/29.
// */
//@Aspect
//public class SingleClickAspect {
// private static final long DEFAULT_TIME_INTERVAL = 5000;
//
// /**
// * 定义切点,标记切点为所有被@SingleClick注解的方法
// * 注意:这里me.baron.test.annotation.SingleClick需要替换成
// * 你自己项目中SingleClick这个类的全路径哦
// */
// @Pointcut("execution(@com.gingersoft.gsa.cloud.aspectj.SingleClick * *(..))")
// public void methodAnnotated() {
// }
//
// /**
// * 定义一个切面方法,包裹切点方法
// */
// @Around("methodAnnotated()")
// public void aroundJoinPoint(ProceedingJoinPoint joinPoint) throws Throwable {
// // 取出方法的参数
// View view = null;
// for (Object arg : joinPoint.getArgs()) {
// if (arg instanceof View) {
// view = (View) arg;
// break;
// }
// }
// if (view == null) {
// return;
// }
// // 取出方法的注解
// MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
// Method method = methodSignature.getMethod();
// if (!method.isAnnotationPresent(SingleClick.class)) {
// return;
// }
// SingleClick singleClick = method.getAnnotation(SingleClick.class);
// // 判断是否快速点击
// if (!XClickUtil.isFastDoubleClick(view, singleClick.value())) {
// // 不是快速点击,执行原方法
// joinPoint.proceed();
// }
// }
//}
package com.gingersoft.gsa.cloud.aspectj;
import android.view.View;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import java.lang.reflect.Method;
/**
* Created by Wyh on 2020/2/29.
*/
@Aspect
public class SingleClickAspect {
private static final long DEFAULT_TIME_INTERVAL = 5000;
/**
* 定义切点,标记切点为所有被@SingleClick注解的方法
* 注意:这里me.baron.test.annotation.SingleClick需要替换成
* 你自己项目中SingleClick这个类的全路径哦
*/
@Pointcut("execution(@com.gingersoft.gsa.cloud.aspectj.SingleClick * *(..))")
public void methodAnnotated() {
}
/**
* 定义一个切面方法,包裹切点方法
*/
@Around("methodAnnotated()")
public void aroundJoinPoint(ProceedingJoinPoint joinPoint) throws Throwable {
// 取出方法的参数
View view = null;
for (Object arg : joinPoint.getArgs()) {
if (arg instanceof View) {
view = (View) arg;
break;
}
}
if (view == null) {
return;
}
// 取出方法的注解
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Method method = methodSignature.getMethod();
if (!method.isAnnotationPresent(SingleClick.class)) {
return;
}
SingleClick singleClick = method.getAnnotation(SingleClick.class);
// 判断是否快速点击
if (!XClickUtil.isFastDoubleClick(view, singleClick.value())) {
// 不是快速点击,执行原方法
joinPoint.proceed();
}
}
}
package com.gingersoft.gsa.cloud.aspectj;
import org.aspectj.lang.annotation.Aspect;
/**
* Created by Wyh on 2020/3/2.
*/
@Aspect
public class SwitchPrintAspect {
}
package com.gingersoft.gsa.cloud.aspectj;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Created by Wyh on 2020/3/2.
* 切換默認打印方式
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface SwitchPrintMethod {
}
//package com.gingersoft.gsa.cloud.aspectj;
//
//import android.view.View;
//
///**
// * Created by Wyh on 2020/2/29.
// */
//public class XClickUtil {
// /**
// * 最近一次点击的时间
// */
// private static long mLastClickTime;
// /**
// * 最近一次点击的控件ID
// */
// private static int mLastClickViewId;
//
// /**
// * 是否是快速点击
// *
// * @param v 点击的控件
// * @param intervalMillis 时间间期(毫秒)
// * @return true:是,false:不是
// */
// public static boolean isFastDoubleClick(View v, long intervalMillis) {
// int viewId = v.getId();
// long time = System.currentTimeMillis();
// long timeInterval = Math.abs(time - mLastClickTime);
// if (timeInterval < intervalMillis && viewId == mLastClickViewId) {
// return true;
// } else {
// mLastClickTime = time;
// mLastClickViewId = viewId;
// return false;
// }
// }
//}
package com.gingersoft.gsa.cloud.aspectj;
import android.view.View;
/**
* Created by Wyh on 2020/2/29.
*/
public class XClickUtil {
/**
* 最近一次点击的时间
*/
private static long mLastClickTime;
/**
* 最近一次点击的控件ID
*/
private static int mLastClickViewId;
/**
* 是否是快速点击
*
* @param v 点击的控件
* @param intervalMillis 时间间期(毫秒)
* @return true:是,false:不是
*/
public static boolean isFastDoubleClick(View v, long intervalMillis) {
int viewId = v.getId();
long time = System.currentTimeMillis();
long timeInterval = Math.abs(time - mLastClickTime);
if (timeInterval < intervalMillis && viewId == mLastClickViewId) {
return true;
} else {
mLastClickTime = time;
mLastClickViewId = viewId;
return false;
}
}
}
......@@ -16,6 +16,7 @@ import com.elvishew.xlog.printer.file.clean.FileLastModifiedCleanStrategy;
import com.elvishew.xlog.printer.file.naming.DateFileNameGenerator;
import com.gingersoft.gsa.cloud.base.BuildConfig;
import com.gingersoft.gsa.cloud.base.common.bean.CurrentAndroidSetting;
import com.gingersoft.gsa.cloud.base.utils.constans.HttpsConstans;
import com.gingersoft.gsa.cloud.base.utils.constans.UserConstans;
import com.gingersoft.gsa.cloud.base.utils.crash.AppCrashHandler;
import com.gingersoft.gsa.cloud.base.utils.file.FileUtils;
......
......@@ -51,7 +51,7 @@ public class TimeUtils {
*/
public static String dateFormatAHM = "aHH:mm";
public static String dateFormatYMDE = "yyyy/MM/dd E";
public static SimpleDateFormat dateFormatYMDE = new SimpleDateFormat("yyyy/MM/dd E");
public static String dateFormatYMD2 = "yyyy/MM/dd";
private TimeUtils() {
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/alpha_20_white" android:state_checkable="true" />
<item android:drawable="@color/alpha_20_white" android:state_pressed="true" />
<item android:drawable="@color/alpha_20_white" android:state_checked="true" />
<item android:drawable="@color/trans" />
</selector>
\ No newline at end of file
......@@ -4,11 +4,12 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
<Button
android:id="@+id/tv_item_keyboard"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/selector_keyboard_btn_bg"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_24" />
......
......@@ -132,6 +132,26 @@
<color name="alpha_90_white">#E6FFFFFF</color>
<color name="alpha_95_white">#F2FFFFFF</color>
<color name="alpha_05_black">#0D000000</color>
<color name="alpha_10_black">#1A000000</color>
<color name="alpha_15_black">#26000000</color>
<color name="alpha_20_black">#33000000</color>
<color name="alpha_25_black">#40000000</color>
<color name="alpha_30_black">#4D000000</color>
<color name="alpha_35_black">#59000000</color>
<color name="alpha_40_black">#66000000</color>
<color name="alpha_45_black">#73000000</color>
<color name="alpha_50_black">#80000000</color>
<color name="alpha_55_black">#8C000000</color>
<color name="alpha_60_black">#99000000</color>
<color name="alpha_65_black">#A6000000</color>
<color name="alpha_70_black">#B3000000</color>
<color name="alpha_75_black">#BF000000</color>
<color name="alpha_80_black">#CC000000</color>
<color name="alpha_85_black">#D9000000</color>
<color name="alpha_90_black">#E6000000</color>
<color name="alpha_95_black">#F2000000</color>
<color name="red_50">#fde0dc</color>
<color name="red_100">#f9bdbb</color>
<color name="red_200">#f69988</color>
......
ext.mainApp = true //设置为true,表示此module为主app module,一直以application方式编译
apply from: rootProject.file("cc-settings.gradle")
apply plugin: 'com.jakewharton.butterknife'
//apply plugin: 'android-aspectjx'
apply plugin: 'android-aspectjx'
android {
signingConfigs {
GSAndroidNew {
......
......@@ -5,6 +5,7 @@ import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil;
import com.billy.cc.core.component.IComponent;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.LoginActivity;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.activity.SwitchServerActivity;
public class ComponentLogin implements IComponent {
......@@ -43,6 +44,11 @@ public class ComponentLogin implements IComponent {
case "getInfo":
getInfo(cc);
break;
case "switchServer":
//切換環境
CCUtil.navigateTo(cc, SwitchServerActivity.class);
CC.sendCCResult(cc.getCallId(), CCResult.success());
break;
default:
//这个逻辑分支上没有调用CC.sendCCResult(...),是一种错误的示例
//并且方法的返回值为false,代表不会异步调用CC.sendCCResult(...)
......
package com.gingersoft.gsa.cloud.user.login.mvp.ui.activity;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
......@@ -19,7 +20,6 @@ import com.gingersoft.gsa.cloud.base.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.ui.bean.mode.LoginBean;
import com.gingersoft.gsa.cloud.ui.bean.view.SectionTextItem;
import com.gingersoft.gsa.cloud.ui.widget.dialog.ChooseRestaurantDialog;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.gingersoft.gsa.cloud.user.login.R;
......@@ -236,6 +236,16 @@ public class LoginActivity extends BaseActivity<LoginPresenter> implements Login
}
@Override
protected void onDestroy() {
super.onDestroy();
if (dialog != null) {
dialog.dismiss();
}
}
private Dialog dialog;
@Override
public void loginSuccess(LoginBean loginBean) {
//記住密碼
RememberPwd();
......@@ -270,25 +280,18 @@ public class LoginActivity extends BaseActivity<LoginPresenter> implements Login
}
jumpDownloadActivity();
} else {
new ChooseRestaurantDialog.BottomListSheetBuilder(this)
dialog = new ChooseRestaurantDialog.BottomListSheetBuilder(this)
.addBrandItems(brandsBeans)
.setOnItemClickListener(new ChooseRestaurantDialog.BottomListSheetBuilder.OnItemClickListener() {
@Override
public void onItemClick(ChooseRestaurantDialog dialog, SectionTextItem item, int position) {
LoginBean.DataBean.UserBean.BrandsBean brandsBean = getBrandByRestaurantId(brands, item.getId());
if (brandsBean != null) {
saveBrandAndRestaurantInfo(brandsBean.getBrandId(), brandsBean.getBrandName(), item.getId(), item.getText());
}
jumpDownloadActivity();
killMyself();
dialog.dismiss();
.setOnItemClickListener((dialog, item, position) -> {
LoginBean.DataBean.UserBean.BrandsBean brandsBean = getBrandByRestaurantId(brands, item.getId());
if (brandsBean != null) {
saveBrandAndRestaurantInfo(brandsBean.getBrandId(), brandsBean.getBrandName(), item.getId(), item.getText());
}
})
.build()
.show();
jumpDownloadActivity();
dialog.dismiss();
killMyself();
}).build();
dialog.show();
}
}
}
......
......@@ -19,7 +19,6 @@ import com.jess.arms.utils.ArmsUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import butterknife.BindView;
import me.jessyan.retrofiturlmanager.RetrofitUrlManager;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......
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