Commit f8ac03e3 by Wyh

3-25 啟動圖,引導頁,其他一些小問題

parent 9ae76d77
......@@ -10,11 +10,11 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:3.5.2'
// classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
......
apply from: rootProject.file('cc-settings.gradle')
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'com.jakewharton.butterknife'
android {
......@@ -55,4 +57,9 @@ dependencies {
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
implementation 'cn.bingoogolapple:bga-progressbar:1.0.1'//进度条
implementation files('libs/nineoldandroids-2.4.0.jar')
compile "androidx.core:core-ktx:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
}
......@@ -31,6 +31,11 @@ public class FoodRankingAdapter extends BaseQuickAdapter<SalesFoodsBean.DataBean
}
@Override
public int getItemCount() {
return getData().size() > 11 ? 11 : getData().size();
}
@Override
protected void convert(BaseViewHolder helper, SalesFoodsBean.DataBean.SalesRankingBean item) {
if (helper.getAdapterPosition() == 0) {
helper.setTextColor(R.id.tv_ranking_foodname, mContext.getResources().getColor(R.color.theme_hint_color));
......@@ -58,8 +63,8 @@ public class FoodRankingAdapter extends BaseQuickAdapter<SalesFoodsBean.DataBean
helper.setText(R.id.tv_ranking_foodname, item.getProductName());
helper.setText(R.id.tv_ranking_food_sales_num, item.getNumber() + "");
helper.setText(R.id.tv_ranking_food_sales_amount, item.getAmount() + "");
helper.setText(R.id.tv_ranking_proportion_quantity, (MoneyUtil.divide(item.getNumber(), totalNum, 2, ROUND_HALF_UP) * 100) + "%");
helper.setText(R.id.tv_ranking_ratio_amount, (MoneyUtil.divide(item.getAmount(), totalAmount, 2, ROUND_HALF_UP) * 100) + "%");
helper.setText(R.id.tv_ranking_proportion_quantity, (MoneyUtil.priceCalculation(MoneyUtil.divide(item.getNumber(), totalNum, 2, ROUND_HALF_UP), 100)) + "%");
helper.setText(R.id.tv_ranking_ratio_amount, (MoneyUtil.priceCalculation(MoneyUtil.divide(item.getAmount(), totalAmount, 2, ROUND_HALF_UP), 100)) + "%");
}
}
}
......@@ -3,6 +3,8 @@ package com.gingersoft.gsa.cloud.main.mvp.ui.adapter;
import android.content.Context;
import android.os.Build;
import androidx.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.gingersoft.gsa.cloud.main.R;
......@@ -11,8 +13,6 @@ import com.gingersoft.gsa.cloud.main.mvp.ui.view.MyProgressBar;
import java.util.List;
import androidx.annotation.Nullable;
/**
* Created by Wyh on 2020/2/24.
*/
......@@ -22,7 +22,13 @@ public class PaymentMethodAdapter extends BaseQuickAdapter<PaymentMethodBean.Dat
R.color.payment_method_color2, R.color.payment_method_color3,
R.color.payment_method_color4, R.color.payment_method_color5,
R.color.payment_method_color6, R.color.payment_method_color7,
R.color.payment_method_color8};
R.color.payment_method_color8, R.color.payment_method_color9,
R.color.payment_method_color10, R.color.payment_method_color11,
R.color.payment_method_color12, R.color.payment_method_color13,
R.color.payment_method_color14, R.color.payment_method_color15,
R.color.payment_method_color16, R.color.payment_method_color17,
R.color.payment_method_color18, R.color.payment_method_color19,
R.color.payment_method_color20};
private Context context;
public PaymentMethodAdapter(Context context, @Nullable List<PaymentMethodBean.DataBean> data) {
......
......@@ -3,6 +3,8 @@ package com.gingersoft.gsa.cloud.main.mvp.ui.adapter;
import android.content.Context;
import android.graphics.drawable.GradientDrawable;
import androidx.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.gingersoft.gsa.cloud.main.R;
......@@ -10,18 +12,12 @@ import com.gingersoft.gsa.cloud.main.mvp.model.bean.PaymentMethodBean;
import java.util.List;
import androidx.annotation.Nullable;
/**
* Created by Wyh on 2020/2/24.
*/
public class PaymentMethodColorAdapter extends BaseQuickAdapter<PaymentMethodBean.DataBean, BaseViewHolder> {
private int[] colors = new int[]{R.color.payment_method_color1,
R.color.payment_method_color2, R.color.payment_method_color3,
R.color.payment_method_color4, R.color.payment_method_color5,
R.color.payment_method_color6, R.color.payment_method_color7,
R.color.payment_method_color8};
private Context context;
public PaymentMethodColorAdapter(Context context, @Nullable List<PaymentMethodBean.DataBean> data) {
super(R.layout.item_payment_color, data);
......@@ -32,7 +28,7 @@ public class PaymentMethodColorAdapter extends BaseQuickAdapter<PaymentMethodBea
protected void convert(BaseViewHolder helper, PaymentMethodBean.DataBean item) {
GradientDrawable drawable = new GradientDrawable();
drawable.setShape(GradientDrawable.OVAL);
drawable.setColor(context.getResources().getColor(colors[helper.getAdapterPosition() % colors.length]));
drawable.setColor(context.getResources().getColor(PaymentMethodAdapter.colors[helper.getAdapterPosition() % PaymentMethodAdapter.colors.length]));
helper.getView(R.id.circle_color).setBackground(drawable);
helper.setText(R.id.tv_payment_method, item.getPayName());
}
......
......@@ -25,6 +25,11 @@ public class SortNumberingAdapter extends BaseQuickAdapter<SalesFoodsBean.DataBe
}
@Override
public int getItemCount() {
return getData().size() > 11 ? 11 : getData().size();
}
@Override
protected void convert(BaseViewHolder helper, SalesFoodsBean.DataBean.SalesRankingBean item) {
helper.getView(R.id.iv_ranking_numbering).setVisibility(View.GONE);
if (helper.getAdapterPosition() == 0) {
......
......@@ -33,12 +33,14 @@ import com.gingersoft.gsa.cloud.ui.AAChartCore.AAChartCoreLib.AAChartEnum.AAChar
import com.gingersoft.gsa.cloud.ui.AAChartCore.AAChartCoreLib.AAChartEnum.AAChartType;
import com.gingersoft.gsa.cloud.ui.AAChartCore.AAChartCoreLib.AATools.AAGradientColor;
import com.gingersoft.gsa.cloud.ui.AAChartCore.AAChartCoreLib.AATools.AALinearGradientDirection;
import com.gingersoft.gsa.cloud.ui.view.TriangleView;
import com.jess.arms.base.BaseFragment;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -75,8 +77,12 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
TextView mTvStartTime;
@BindView(R2.id.tv_end_time)
TextView mTvEndTime;
@BindView(R2.id.iv_time_triangle)
TriangleView triangleView;
private BusinessInfoAdapter businessInfoAdapter;
//查詢多少天的數據
private int manyDay = 2;
public static BusinessReportFragment newInstance() {
BusinessReportFragment fragment = new BusinessReportFragment();
......@@ -101,7 +107,7 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
@Override
public void initData(@Nullable Bundle savedInstanceState) {
//獲取一段時間內的營業信息,默認獲取七天的數據
String startTime = TimeUtils.getOldDate(-6);
String startTime = TimeUtils.getOldDate(-manyDay);
mPresenter.getRestaurantAmount(GsaCloudApplication.getRestaurantId(mContext) + "", startTime, TimeUtils.getOldDate(1));
mPresenter.getRestaurantBusinessInfo(GsaCloudApplication.getRestaurantId(mContext) + "", startTime, TimeUtils.getOldDate(1));
......@@ -185,21 +191,21 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
*/
@Override
public void loadChart(List<MainBusinessBean.DataBean> data) {
Object[] chartData = new Object[7];
Object[] chartData = new Object[manyDay + 1];
String[] xData = new String[7];
for (int i = 0; i < 7; i++) {
xData[i] = TimeUtils.getDistanceDate(-6 + i, Calendar.DATE, TimeUtils.DEFAULT_DATE_MD);
String[] xData = new String[manyDay + 1];
for (int i = 0; i <= manyDay; i++) {
xData[i] = TimeUtils.getDistanceDate(-(manyDay - i), Calendar.DATE, TimeUtils.DEFAULT_DATE_MD);
}
//將數據以 時間為key,數據為value存入map
Map<String, MainBusinessBean.DataBean> map = new HashMap<>();
for (int i = 0; i < data.size(); i++) {
map.put(data.get(i).getStartingTime(), data.get(i));
}
//y軸 數據間隔
double yAxisTickInterval = 0;
//第一條線
for (int i = 0; i < 7; i++) {
for (int i = 0; i <= manyDay; i++) {
//通過今年年份+月份+日期,獲取對應的對象
MainBusinessBean.DataBean bean = map.get(TimeUtils.getDistanceDate(0, Calendar.YEAR, DEFAULT_DATE_Y) + xData[i]);
if (bean != null) {
......@@ -280,10 +286,11 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
}
}
@OnClick({R2.id.tv_start_time})
@OnClick({R2.id.tv_start_time, R2.id.iv_time_triangle})
@Override
public void onClick(View v) {
if (v.getId() == R.id.tv_start_time) {
if (v.getId() == R.id.tv_start_time || v.getId() == R.id.iv_time_triangle) {
triangleView.toggle();
Calendar cal = Calendar.getInstance();
try {
//設置默認時間為當前的起止時間
......@@ -295,9 +302,29 @@ public class BusinessReportFragment extends BaseFragment<BusinessReportPresenter
TimePickerUtils.showReportTimePicker(mContext, cal, (date, v1) ->
{
mTvStartTime.setText(TimeUtils.DATE_FORMAT_DATE.format(date));
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
calendar.setTime(new Date());
//如果不是當前月份,那麼報表最多顯示最近七天
if (month != calendar.get(Calendar.MONTH)) {
manyDay = 7;
} else {
//如果選中的是當前月份,判斷天數是否大於7
if (calendar.get(Calendar.DAY_OF_MONTH) - day > 7) {
manyDay = 7;
} else {
manyDay = calendar.get(Calendar.DAY_OF_MONTH) - day;
if (manyDay < 0) {
manyDay = 0;
}
}
}
mPresenter.getRestaurantAmount(GsaCloudApplication.getRestaurantId(mContext) + "", mTvStartTime.getText().toString(), TimeUtils.getOldDate(1));
mPresenter.getRestaurantBusinessInfo(GsaCloudApplication.getRestaurantId(mContext) + "", mTvStartTime.getText().toString(), TimeUtils.getOldDate(1));
});
}).setOnDismissListener(o -> triangleView.toggle());
}
}
}
......@@ -27,6 +27,7 @@ import com.gingersoft.gsa.cloud.main.mvp.model.bean.PaymentMethodBean;
import com.gingersoft.gsa.cloud.main.mvp.presenter.PaymentMethodReportPresenter;
import com.gingersoft.gsa.cloud.main.mvp.ui.adapter.PaymentMethodAdapter;
import com.gingersoft.gsa.cloud.main.mvp.ui.adapter.PaymentMethodColorAdapter;
import com.gingersoft.gsa.cloud.ui.view.TriangleView;
import com.github.mikephil.charting.animation.Easing;
import com.github.mikephil.charting.charts.PieChart;
import com.github.mikephil.charting.components.Legend;
......@@ -34,7 +35,6 @@ import com.github.mikephil.charting.data.PieData;
import com.github.mikephil.charting.data.PieDataSet;
import com.github.mikephil.charting.data.PieEntry;
import com.github.mikephil.charting.formatter.PercentFormatter;
import com.github.mikephil.charting.utils.MPPointF;
import com.jess.arms.base.BaseFragment;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
......@@ -77,6 +77,8 @@ public class PaymentMethodReportFragment extends BaseFragment<PaymentMethodRepor
TextView mTvStartTime;
@BindView(R2.id.tv_end_time)
TextView mTvEndTime;
@BindView(R2.id.iv_payment_time_triangle)
TriangleView triangleView;
public static PaymentMethodReportFragment newInstance() {
PaymentMethodReportFragment fragment = new PaymentMethodReportFragment();
......@@ -210,25 +212,26 @@ public class PaymentMethodReportFragment extends BaseFragment<PaymentMethodRepor
//不顯示右側底部小字
chart.setUsePercentValues(true);
chart.getDescription().setEnabled(false);
chart.setExtraOffsets(0, 0, 0, 0);
// chart.setExtraOffsets(0, 0, 0, 0);
//滑動摩擦係數
chart.setDragDecelerationFrictionCoef(0.95f);
//是否繪製中心圓
chart.setDrawHoleEnabled(true);
chart.setHoleColor(Color.WHITE);
chart.setTransparentCircleColor(Color.WHITE);
chart.setTransparentCircleColor(Color.BLACK);
chart.setTransparentCircleAlpha(110);
chart.setHoleRadius(28f);
chart.setTransparentCircleRadius(0f);
//不繪製中心文字
chart.setDrawCenterText(false);
//設置旋轉角度
chart.setRotationAngle(0);
// enable rotation of the chart by touch
//設置可以觸摸旋轉
chart.setRotationEnabled(true);
chart.setHighlightPerTapEnabled(true);
// chart.setHighlightPerTapEnabled(true);
//設置單位
// chart.setUnit(" €");
// chart.setDrawUnitsInChart(true);
......@@ -236,12 +239,10 @@ public class PaymentMethodReportFragment extends BaseFragment<PaymentMethodRepor
// chart.setOnChartValueSelectedListener(this);
chart.animateY(1400, Easing.EaseInOutQuad);
// chart.spin(2000, 0, 360);
Legend l = chart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
// l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
// l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
// l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(false);
l.setEnabled(false);
// entry label styling
......@@ -257,13 +258,9 @@ public class PaymentMethodReportFragment extends BaseFragment<PaymentMethodRepor
ArrayList<Integer> colors = new ArrayList<>();
for (int i = 0; i < dataBeans.size(); i++) {
float percentage = Float.parseFloat(dataBeans.get(i).getPercentage().replace("%", ""));
if (percentage > 5) {//比例大於0才添加
if (percentage > 3) {//比例大於3才添加
entries.add(new PieEntry(percentage, dataBeans.get(i).getPayName()));
if (i < PaymentMethodAdapter.colors.length) {
colors.add(mContext.getResources().getColor(PaymentMethodAdapter.colors[i]));
} else {
colors.add(mContext.getResources().getColor(PaymentMethodAdapter.colors[i % PaymentMethodAdapter.colors.length]));
}
colors.add(mContext.getResources().getColor(PaymentMethodAdapter.colors[i % PaymentMethodAdapter.colors.length]));
}
}
PieDataSet dataSet = new PieDataSet(entries, "Election Results");
......@@ -271,10 +268,7 @@ public class PaymentMethodReportFragment extends BaseFragment<PaymentMethodRepor
dataSet.setDrawIcons(false);
dataSet.setSliceSpace(1f);
dataSet.setIconsOffset(new MPPointF(0, 40));
dataSet.setSelectionShift(5f);
// add a lot of colors
//dataSet.setSelectionShift(0f);
dataSet.setSelectionShift(10f);
PieData data = new PieData(dataSet);
data.setValueFormatter(new PercentFormatter(chart));
......@@ -282,16 +276,14 @@ public class PaymentMethodReportFragment extends BaseFragment<PaymentMethodRepor
data.setValueTextColor(mContext.getResources().getColor(R.color.white));
chart.setData(data);
// undo all highlights
chart.highlightValues(null);
chart.invalidate();
}
@OnClick({R2.id.tv_start_time})
@OnClick({R2.id.tv_start_time, R2.id.iv_payment_time_triangle})
@Override
public void onClick(View v) {
if (v.getId() == R.id.tv_start_time) {
if (v.getId() == R.id.tv_start_time || v.getId() == R.id.iv_payment_time_triangle) {
triangleView.toggle();
Calendar cal = Calendar.getInstance();
try {
//設置默認時間為當前的起止時間
......@@ -303,7 +295,7 @@ public class PaymentMethodReportFragment extends BaseFragment<PaymentMethodRepor
TimePickerUtils.showReportTimePicker(mContext, cal, (date, v1) -> {
mTvStartTime.setText(TimeUtils.DATE_FORMAT_DATE.format(date));
mPresenter.getPaymentInfo(GsaCloudApplication.getRestaurantId(mContext) + "", mTvStartTime.getText().toString());
});
}).setOnDismissListener(o -> triangleView.toggle());
}
}
}
......@@ -28,6 +28,7 @@ import com.gingersoft.gsa.cloud.main.mvp.model.bean.SalesFoodsBean;
import com.gingersoft.gsa.cloud.main.mvp.presenter.SalesPresenter;
import com.gingersoft.gsa.cloud.main.mvp.ui.adapter.FoodRankingAdapter;
import com.gingersoft.gsa.cloud.main.mvp.ui.adapter.SortNumberingAdapter;
import com.gingersoft.gsa.cloud.ui.view.TriangleView;
import com.github.mikephil.charting.charts.PieChart;
import com.github.mikephil.charting.components.Legend;
import com.github.mikephil.charting.data.Entry;
......@@ -80,7 +81,8 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
TextView mTvStartTime;
@BindView(R2.id.tv_end_time)
TextView mTvEndTime;
@BindView(R2.id.iv_sale_time_triangle)
TriangleView triangleView;
public static SalesFragment newInstance() {
SalesFragment fragment = new SalesFragment();
return fragment;
......@@ -226,7 +228,7 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
private void loadChart(List<SalesFoodsBean.DataBean.SalesRankingBean> info) {
//是否以百分比顯示值
salesChart.setUsePercentValues(true);
salesChart.setUsePercentValues(false);
//不顯示右側底部小字
salesChart.getDescription().setEnabled(false);
//控制轉動速度0為立即停止
......@@ -239,11 +241,11 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
salesChart.setHoleColor(Color.WHITE);
salesChart.setTransparentCircleColor(Color.WHITE);
salesChart.setTransparentCircleAlpha(200);
// salesChart.setTransparentCircleAlpha(100);
//中心圓的大小,相當於百分比
salesChart.setHoleRadius(24f);
//中心圓外部的半透明部分,百分比
salesChart.setTransparentCircleRadius(10f);
//中心圓外部的半透明部分,百分比,需要比HoleRadius大
salesChart.setTransparentCircleRadius(0f);
//是否繪製文字
salesChart.setDrawCenterText(true);
......@@ -293,14 +295,14 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
if (info.get(i) != null) {
//金額佔比
float money = MoneyUtil.divide(info.get(i).getAmount(), totalAmount, 2, ROUND_HALF_UP);
if (money > 0.05) {
if (money > 0.03) {
entries.add(new PieEntry(money, info.get(i).getProductName()));
}
}
}
}
PieDataSet dataSet = new PieDataSet(entries, "Election Results");
dataSet.setSliceSpace(3f);//設置餅狀圖空隙
dataSet.setSliceSpace(1f);//設置餅狀圖空隙
dataSet.setSelectionShift(5f);//放大時突出多少
// add a lot of colors
ArrayList<Integer> colors = new ArrayList<>();
......@@ -333,7 +335,7 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
dataSet.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
dataSet.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE);
dataSet.setValueLineColor(mContext.getResources().getColor(R.color.line_color));
dataSet.setValueLineColor(mContext.getResources().getColor(R.color.theme_color));
PieData data = new PieData(dataSet);
salesChart.setUsePercentValues(true);
......@@ -347,10 +349,11 @@ public class SalesFragment extends BaseFragment<SalesPresenter> implements Sales
salesChart.invalidate();
}
@OnClick({R2.id.tv_start_time})
@OnClick({R2.id.tv_start_time, R2.id.iv_sale_time_triangle})
@Override
public void onClick(View v) {
if (v.getId() == R.id.tv_start_time) {
if (v.getId() == R.id.tv_start_time || v.getId() == R.id.iv_sale_time_triangle) {
triangleView.toggle();
//打開時間選擇器
Calendar cal = Calendar.getInstance();
try {
......@@ -362,7 +365,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(GsaCloudApplication.getRestaurantId(mContext) + "", mTvStartTime.getText().toString());
});
}).setOnDismissListener(o -> triangleView.toggle());
}
}
......
......@@ -55,6 +55,13 @@
android:textColor="#181818"
android:textSize="@dimen/sp_10" />
<com.gingersoft.gsa.cloud.ui.view.TriangleView
android:id="@+id/iv_time_triangle"
android:layout_marginLeft="@dimen/dp_2"
android:layout_width="@dimen/dp_8"
app:trv_direction="bottom"
android:layout_height="@dimen/dp_5" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
......@@ -128,11 +128,13 @@
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent" />-->
<TextView
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_more_report"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp_10"
android:paddingBottom="@dimen/dp_10"
android:paddingLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_10"
android:text="更多報表 >"
android:textColor="#3c3c3c"
android:textSize="@dimen/sp_12"
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<com.gingersoft.gsa.cloud.ui.view.MyScrollView 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"
......@@ -53,6 +53,13 @@
android:textColor="#181818"
android:textSize="@dimen/dp_10" />
<com.gingersoft.gsa.cloud.ui.view.TriangleView
android:id="@+id/iv_payment_time_triangle"
android:layout_marginLeft="@dimen/dp_2"
android:layout_width="@dimen/dp_8"
app:trv_direction="bottom"
android:layout_height="@dimen/dp_5" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -77,7 +84,7 @@
<com.github.mikephil.charting.charts.PieChart
android:id="@+id/report_payment_method_chart"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_170"
android:layout_height="@dimen/dp_180"
android:layout_marginTop="@dimen/dp_10"
android:visibility="visible"
app:layout_constraintLeft_toLeftOf="parent"
......@@ -167,4 +174,4 @@
android:layout_marginRight="@dimen/dp_15" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
\ No newline at end of file
</com.gingersoft.gsa.cloud.ui.view.MyScrollView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<com.gingersoft.gsa.cloud.ui.view.MyScrollView 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"
......@@ -55,6 +55,13 @@
android:textColor="#181818"
android:textSize="@dimen/sp_10" />
<com.gingersoft.gsa.cloud.ui.view.TriangleView
android:id="@+id/iv_sale_time_triangle"
android:layout_marginLeft="@dimen/dp_2"
android:layout_width="@dimen/dp_8"
app:trv_direction="bottom"
android:layout_height="@dimen/dp_5"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -139,4 +146,4 @@
</LinearLayout>
</com.lihang.ShadowLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
\ No newline at end of file
</com.gingersoft.gsa.cloud.ui.view.MyScrollView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.qmuiteam.qmui.alpha.QMUIAlphaLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
......@@ -23,4 +23,4 @@
android:textSize="@dimen/sp_17" />
</LinearLayout>
\ No newline at end of file
</com.qmuiteam.qmui.alpha.QMUIAlphaLinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.qmuiteam.qmui.alpha.QMUIAlphaLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
......@@ -21,4 +21,4 @@
android:textColor="@color/normal_color"
android:textSize="@dimen/sp_12" />
</LinearLayout>
\ No newline at end of file
</com.qmuiteam.qmui.alpha.QMUIAlphaLinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.qmuiteam.qmui.alpha.QMUIAlphaLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
......@@ -22,4 +22,4 @@
android:textColor="@color/normal_color"
android:textSize="@dimen/sp_12" />
</LinearLayout>
\ No newline at end of file
</com.qmuiteam.qmui.alpha.QMUIAlphaLinearLayout>
\ No newline at end of file
......@@ -17,4 +17,17 @@
<color name="payment_method_color6">#00A0E9</color>
<color name="payment_method_color7">#EFE75E</color>
<color name="payment_method_color8">#5358F1</color>
<color name="payment_method_color9">#ff2d51</color>
<color name="payment_method_color10">#426666</color>
<color name="payment_method_color11">#bce672</color>
<color name="payment_method_color12">#44cef6</color>
<color name="payment_method_color13">#ffa631</color>
<color name="payment_method_color14">#a3d900</color>
<color name="payment_method_color15">#f00056</color>
<color name="payment_method_color16">#bf242a</color>
<color name="payment_method_color17">#a1afc9</color>
<color name="payment_method_color18">#c89c23</color>
<color name="payment_method_color19">#e4c6d0</color>
<color name="payment_method_color20">#103371</color>
</resources>
......@@ -2,6 +2,7 @@ package com.joe.print.mvp.print;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
......@@ -366,4 +367,14 @@ public class PrintUtils {
//580為程序支持的打印紙最大寬度
return ImageUtils.zoomDrawable(LayoutToBitmapUtils.loadBitmapFromView(view), paperWidth);//将view轉bitmap
}
/**
* 當前設備是不是打印設備
*
* @return
*/
public static boolean isPrintDevice() {
return GsaCloudApplication.mV2.contains(Build.MODEL) || GsaCloudApplication.mN5.contains(Build.MODEL);
}
}
package com.joe.print.mvp.print;
import android.content.Context;
import android.graphics.Bitmap;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.print.PrintDataMaker;
import com.gingersoft.gsa.cloud.print.PrinterWriter;
import com.gingersoft.gsa.cloud.print.PrinterWriter58mm;
import com.gingersoft.gsa.cloud.print.PrinterWriter80mm;
import com.joe.print.R;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
/**
* 测试数据生成
......@@ -21,7 +20,7 @@ import java.util.Locale;
public class TestPrintDataMaker implements PrintDataMaker {
private Context context;
// private String qr;
// private String qr;
private int width;
private int height;
......@@ -40,57 +39,69 @@ public class TestPrintDataMaker implements PrintDataMaker {
printer = type == PrinterWriter58mm.TYPE_58 ? new PrinterWriter58mm(height, width) : new PrinterWriter80mm(height, width);
printer.setAlignCenter();
data.add(printer.getDataAndReset());
ArrayList<byte[]> image1 = printer.getImageByte(context.getResources(), R.mipmap.ic_logo);
data.addAll(image1);
printer.setAlignLeft();
printer.printLine();
printer.printLineFeed();
printer.printLineFeed();
printer.setAlignCenter();
printer.setEmphasizedOn();
printer.setFontSize(1);
printer.print("Selftest");
printer.printLineFeed();
printer.setFontSize(0);
printer.setEmphasizedOff();
printer.printLineFeed();
printer.print("Gingersoft");
printer.printLineFeed();
printer.print("客服电话:××××××××");
printer.printLineFeed();
printer.setAlignLeft();
printer.printLineFeed();
printer.print("订单号:88888888888888888");
printer.printLineFeed();
printer.print("预计送达:" +
new SimpleDateFormat("yyyy/MM/dd HH:mm", Locale.getDefault())
.format(new Date(System.currentTimeMillis())));
printer.printLineFeed();
printer.setEmphasizedOn();
printer.print("#8(已付款)");
printer.printLineFeed();
printer.print("××区××路×××大厦××楼×××室");
printer.printLineFeed();
printer.setEmphasizedOff();
// printer.print("13843211234");
// printer.print("(张某某)");
printer.printLineFeed();
printer.print("备注:多加点辣椒,多加点香菜,多加点酸萝卜,多送点一次性手套");
printer.printLineFeed();
printer.printLine();
printer.printLineFeed();
printer.printLineFeed();
printer.printLineFeed();
printer.feedPaperCutPartial();
ArrayList<byte[]> image = printer.getImageByte(context.getResources(), R.mipmap.ic_logo);
data.addAll(image);
List<Bitmap> bitmaps = PrintUtils.getPrintBitmap(context, -1, width);//根據打印類型獲得不同的bitmap
if (bitmaps.size() <= 0) {
ToastUtils.show(context, "打印失敗");
return null;
}
for (int i = 0; i < bitmaps.size(); i++) {
ArrayList<byte[]> image1 = printer.getImageByte(bitmaps.get(i));
data.addAll(image1);//draw2PxPoint2(bitmaps.get(i)
printer.printLineFeed();
printer.printLineFeed();
printer.printLineFeed();
printer.printLineFeed();
printer.printLineFeed();
printer.feedPaperCutPartial();
}
data.add(printer.getDataAndReset());
// printer.setAlignLeft();
// printer.printLine();
// printer.printLineFeed();
//
// printer.printLineFeed();
// printer.setAlignCenter();
// printer.setEmphasizedOn();
// printer.setFontSize(1);
// printer.print("Selftest");
// printer.printLineFeed();
// printer.setFontSize(0);
// printer.setEmphasizedOff();
// printer.printLineFeed();
//
// printer.print("Gingersoft");
// printer.printLineFeed();
// printer.print("客服电话:××××××××");
// printer.printLineFeed();
//
// printer.setAlignLeft();
// printer.printLineFeed();
//
// printer.print("订单号:88888888888888888");
// printer.printLineFeed();
//
// printer.print("预计送达:" +
// new SimpleDateFormat("yyyy/MM/dd HH:mm", Locale.getDefault())
// .format(new Date(System.currentTimeMillis())));
// printer.printLineFeed();
//
// printer.setEmphasizedOn();
// printer.print("#8(已付款)");
// printer.printLineFeed();
// printer.print("××区××路×××大厦××楼×××室");
// printer.printLineFeed();
// printer.setEmphasizedOff();
// printer.printLineFeed();
// printer.print("备注:多加点辣椒,多加点香菜,多加点酸萝卜,多送点一次性手套");
// printer.printLineFeed();
//
// printer.printLine();
// printer.printLineFeed();
// printer.printLineFeed();
// printer.printLineFeed();
data.add(printer.getDataAndClose());
return data;
......
......@@ -241,4 +241,11 @@ public class IpPrintActivity extends Activity implements PrintSocketHolder.OnSta
public void onDismiss(DialogInterface dialog) {
finish();
}
@Override
protected void onDestroy() {
super.onDestroy();
if (executor != null)
executor.closeSocket();
}
}
......@@ -18,6 +18,7 @@ import com.joe.print.R2;
import com.joe.print.di.component.DaggerPrintListComponent;
import com.joe.print.mvp.contract.PrintListContract;
import com.joe.print.mvp.presenter.PrintListPresenter;
import com.joe.print.mvp.print.PrintUtils;
import com.joe.print.mvp.ui.fragment.IpPrintListActivityFragment;
import com.joe.print.mvp.ui.fragment.LocalPrintFragment;
import com.qmuiteam.qmui.widget.QMUITopBar;
......@@ -79,12 +80,15 @@ public class PrinterListActivity extends BaseActivity<PrintListPresenter> implem
*/
private void initViewPager() {
List<String> titles = new ArrayList<>();
titles.add("本機打印");
titles.add("網絡打印");
List<Fragment> mFragments = new ArrayList<>();
mFragments.add(LocalPrintFragment.newInstance());
mFragments.add(IpPrintListActivityFragment.newInstance());
if (PrintUtils.isPrintDevice()) {
titles.add("本機打印");
mFragments.add(LocalPrintFragment.newInstance());
}
titles.add("網絡打印");
//实例化适配器
mTabFragmentAdapter = new TabFragmentAdapter(getSupportFragmentManager(), 1);
//设置加载的Fragment集合
......
......@@ -63,14 +63,14 @@ public class LocalPrintFragment extends BaseFragment<LocalPrintPresenter> implem
@Override
public void initData(@Nullable Bundle savedInstanceState) {
ivSetLocationPrintBtn.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (SPUtils.get(mContext, Constans.DEFAULT_PRINT_METHOD, "").equals(Constans.LOCAL_PRINT)) {
//如果默認打印方式為本地,修改為IP打印
SPUtils.put(mContext, Constans.DEFAULT_PRINT_METHOD, Constans.IP_PRINT);
ivSetLocationPrintBtn.setChecked(false);
} else {
if(isChecked){
//修改默認打印方式為本地
SPUtils.put(mContext, Constans.DEFAULT_PRINT_METHOD, Constans.LOCAL_PRINT);
ivSetLocationPrintBtn.setChecked(true);
} else {
//如果默認打印方式為本地,修改為IP打印
SPUtils.put(mContext, Constans.DEFAULT_PRINT_METHOD, Constans.IP_PRINT);
ivSetLocationPrintBtn.setChecked(false);
}
});
}
......
......@@ -10,7 +10,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="打印測試"
android:text="打印測試打印測試打印測試打印測試打印測試打印測試打印測試打印測試打印測試打印測試打印測試打印測試打印測試打印測試打印測試打印測試打印測試打印測試打印測試打印測試打印測試打"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_25" />
......
......@@ -8,6 +8,8 @@ public class UserConstans {
public final static String LOGIN_PASSWORD = "login_password";
public final static String AUTO_LOGIN = "auto_login";
public final static String IS_GUIDE = "is_guide";
public static String memberId = "member_id";
public static String memberName = "member_name";
......
......@@ -19,7 +19,7 @@ public class TimePickerUtils {
* @param defaultTime 默認選中時間
* @param onTimeSelectListener 選中時間回調
*/
public static void showReportTimePicker(Context mContext, Calendar defaultTime, TimePickerView.OnTimeSelectListener onTimeSelectListener) {
public static TimePickerView showReportTimePicker(Context mContext, Calendar defaultTime, TimePickerView.OnTimeSelectListener onTimeSelectListener) {
//獲取今年第一天的日期
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_YEAR, cal.getActualMinimum(Calendar.DAY_OF_YEAR));
......@@ -49,6 +49,7 @@ public class TimePickerUtils {
//設置默認選中時間
pvTime.setDate(defaultTime);//注:根据需求来决定是否使用该方法(一般是精确到秒的情况),此项可以在弹出选择器的时候重新设置当前时间,避免在初始化之后由于时间已经设定,导致选中时间与当前时间不匹配的问题。
pvTime.show();
return pvTime;
}
}
......@@ -447,6 +447,7 @@ public class TimeUtils {
try {
date = new Date(time);
} catch (IllegalArgumentException e) {
e.printStackTrace();
try {
date = dateFormat.parse(time);
} catch (ParseException ex) {
......
......@@ -7,16 +7,16 @@
<enum name="bottom" value="2" />
<enum name="all" value="3" />
</attr>
<attr name="shadow_left" format="reference"/>
<attr name="shadow_right" format="reference"/>
<attr name="shadow_bottom" format="reference"/>
<attr name="shadow_left" format="reference" />
<attr name="shadow_right" format="reference" />
<attr name="shadow_bottom" format="reference" />
</declare-styleable>
<attr name="SwipeBackLayoutStyle" format="reference"/>
<attr name="SwipeBackLayoutStyle" format="reference" />
<!-- QMUI-->
<attr name="app_primary_color" format="color"/> <!-- topbar -->
<attr name="app_content_bg_color" format="color"/> <!-- content-->
<attr name="app_primary_color" format="color" /> <!-- topbar -->
<attr name="app_content_bg_color" format="color" /> <!-- content-->
<declare-styleable name="MaxHeightRecyclerView">
<attr name="maxHeight" format="dimension" />
......@@ -356,4 +356,57 @@
<!-- <attr name="initPosition" format="integer"/>-->
<!-- <attr name="drawItemCount" format="integer"/>-->
<!-- </declare-styleable>-->
<declare-styleable name="Indicator">
<!--未选中的指示器颜色-->
<attr name="normal_color" format="reference|color" />
<!--选中的指示器颜色-->
<attr name="selected_color" format="reference|color" />
<!--指示器每个item之间的间距-->
<attr name="spacing" format="dimension" />
<!--指示器排列方向-->
<attr name="orientation" format="enum">
<enum name="horizontal" value="0" />
<enum name="vertical" value="1" />
</attr>
<!--指示器类型 命名规则:未选中样式_选中样式-->
<attr name="style" format="enum">
<!--都是圆点-->
<enum name="circle_circle" value="0" />
<!--都是方形-->
<enum name="rect_rect" value="1" />
<!--未选中是圆点,选中是方形-->
<enum name="circle_rect" value="2" />
</attr>
<!--都是圆点指示器半径大小-->
<attr name="circle_circle_radius" format="dimension" />
<!--都是方形指示器长度-->
<attr name="rect_rect_itemWidth" format="dimension" />
<!--都是方形指示器高度-->
<attr name="rect_rect_itemHeight" format="dimension" />
<!--都是方形指示器圆角-->
<attr name="rect_rect_corner" format="dimension" />
<!--circle_rect 模式圆点半径-->
<attr name="circle_rect_radius" format="dimension" />
<!--circle_rect 模式方形宽度-->
<attr name="circle_rect_itemWidth" format="dimension" />
<!--circle_rect 模式方形高度-->
<attr name="circle_rect_itemHeight" format="dimension" />
<!--circle_rect 模式方形圆角-->
<attr name="circle_rect_corner" format="dimension" />
</declare-styleable>
<declare-styleable name="TriangleView">
<attr name="trv_color" format="color" />
<attr name="trv_direction">
<enum name="top" value="0" />
<enum name="bottom" value="1" />
<enum name="right" value="2" />
<enum name="left" value="3" />
</attr>
</declare-styleable>
</resources>
\ No newline at end of file
......@@ -11,7 +11,7 @@
<!-- <color name="theme_color">#BF1C42</color>-->
<color name="theme_color">#398BED</color>
<color name="normal_color">#333333</color>
<!-- 統一頁面背景色-->
<!-- 統一頁面背景色-->
<color name="theme_bg_color">#F0edf1</color>
......@@ -439,6 +439,7 @@
<color name="line_color2">#F0F0F0</color>
<color name="scroll_bar_color">#CACACA</color>
<color name="color_c8">#c8c8c8</color>
<color name="hint_color">#676767</color>
<color name="main_home_function_head_bg">#F4F4F4</color>
......
......@@ -9,6 +9,12 @@ import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.base.common.bean.OrderBean;
import com.gingersoft.gsa.cloud.base.common.bean.OrderDetail;
......@@ -18,7 +24,10 @@ 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.LanguageUtils;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtil;
import com.gingersoft.gsa.cloud.table.R;
import com.gingersoft.gsa.cloud.table.R2;
import com.gingersoft.gsa.cloud.table.di.component.DaggerOrderDetailComponent;
import com.gingersoft.gsa.cloud.table.mvp.contract.OrderDetailContract;
import com.gingersoft.gsa.cloud.table.mvp.model.bean.OrderDetailItem;
import com.gingersoft.gsa.cloud.table.mvp.model.utils.OrderAssemblyUtil;
import com.gingersoft.gsa.cloud.table.mvp.presenter.OrderDetailPresenter;
......@@ -28,12 +37,8 @@ import com.gingersoft.gsa.cloud.table.mvp.ui.adapter.OrderDetailPayMethodAdapter
import com.gingersoft.gsa.cloud.ui.bean.view.SectionTextItem3;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.base.delegate.IActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.gingersoft.gsa.cloud.table.di.component.DaggerOrderDetailComponent;
import com.gingersoft.gsa.cloud.table.mvp.contract.OrderDetailContract;
import com.gingersoft.gsa.cloud.table.R;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
......@@ -43,11 +48,6 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.OnClick;
......
......@@ -2,6 +2,7 @@ package com.gingersoft.gsa.cloud.user.login.mvp.ui.activity;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
......@@ -12,6 +13,7 @@ import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
......@@ -21,9 +23,6 @@ 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.other.SPUtils;
import com.gingersoft.gsa.cloud.base.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.utils.FoodDaoUtils;
import com.gingersoft.gsa.cloud.ui.bean.mode.LoginBean;
import com.gingersoft.gsa.cloud.ui.widget.dialog.ChooseRestaurantDialog;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
......@@ -36,7 +35,6 @@ import com.gingersoft.gsa.cloud.user.login.mvp.presenter.LoginPresenter;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.integration.AppManager;
import com.jess.arms.utils.ArmsUtils;
import com.tbruyelle.rxpermissions2.RxPermissions;
import java.util.List;
import java.util.Objects;
......@@ -80,6 +78,8 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
CheckBox mRbAutoLogin;
@BindView(R2.id.ic_look_pwd)
ImageView mIvSeePwd;
@BindView(R2.id.tv_app_version)
TextView mTvVersion;
private boolean passwrodVisibility = false;
......@@ -101,8 +101,12 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
@Override
public void initData(@Nullable Bundle savedInstanceState) {
try {
mTvVersion.setText("v" + getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
mPresenter.requestExternalStoragePermission();
findViewById(R.id.tv_gsa_user_login).setOnClickListener(this);
if (!Objects.equals(SPUtils.get(mContext, UserConstans.LOGIN_USERNAME, ""), "")) {
edAccount.setText("" + SPUtils.get(mContext, UserConstans.LOGIN_USERNAME, ""));
mRbRememberPwd.setChecked(true);
......
package com.gingersoft.gsa.cloud.user.login.mvp.ui.activity;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.ScaleAnimation;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.viewpager2.widget.ViewPager2;
import com.gingersoft.gsa.cloud.base.utils.constans.UserConstans;
import com.gingersoft.gsa.cloud.base.utils.encryption.Aes;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.ui.bean.mode.LoginBean;
import com.gingersoft.gsa.cloud.ui.widget.Indicator.UIndicator;
import com.gingersoft.gsa.cloud.ui.widget.dialog.ChooseRestaurantDialog;
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.DaggerWelcomeComponent;
import com.gingersoft.gsa.cloud.user.login.di.module.WelcomeModule;
import com.gingersoft.gsa.cloud.user.login.mvp.bean.GuideBean;
import com.gingersoft.gsa.cloud.user.login.mvp.contract.LoginInterfaceImpl;
import com.gingersoft.gsa.cloud.user.login.mvp.contract.WelcomeContract;
import com.gingersoft.gsa.cloud.user.login.mvp.presenter.WelcomePresenter;
import com.gingersoft.gsa.cloud.user.login.mvp.ui.adapter.GuideAdapter;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.OnClick;
import static com.jess.arms.utils.Preconditions.checkNotNull;
public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implements WelcomeContract.View {
@BindView(R.id.content_view)
public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implements WelcomeContract.View, View.OnClickListener {
@BindView(R2.id.content_view)
ConstraintLayout contentView;
@BindView(R2.id.cl_guide_layout)
ConstraintLayout guideView;
@BindView(R2.id.vp2_guide)
ViewPager2 mVpGuide;
@BindView(R2.id.guide_magic_indicator)
UIndicator magicIndicator;
@BindView(R2.id.tv_guide_title)
TextView mTvGuideTitle;
@BindView(R2.id.tv_guide_details)
TextView mTvGuideDetails;
List<GuideBean> guideBeanList = new ArrayList<>();
private final long ANIMATION_TIME = 1300;
@Override
public void setupActivityComponent(@NonNull AppComponent appComponent) {
DaggerWelcomeComponent //如找不到该类,请编译一下项目
......@@ -63,13 +91,18 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
@Override
public void onAnimationEnd(Animation animation) {
// startActivity(new Intent(mContext, LoginActivity.class));
if ((boolean) SPUtils.get(mContext, UserConstans.AUTO_LOGIN, false)) {
//自動登陸
String pwd = Aes.aesDecrypt((String) SPUtils.get(mContext, UserConstans.LOGIN_PASSWORD, ""));
mPresenter.login(SPUtils.get(mContext, UserConstans.LOGIN_USERNAME, "") + "", pwd);
if ((boolean) SPUtils.get(mContext, UserConstans.IS_GUIDE, true)) {
//是第一次進入,顯示引導頁
showGuide();
} else {
startActivity(new Intent(mContext, LoginActivity.class));
if ((boolean) SPUtils.get(mContext, UserConstans.AUTO_LOGIN, false)) {
//自動登陸
String pwd = Aes.aesDecrypt((String) SPUtils.get(mContext, UserConstans.LOGIN_PASSWORD, ""));
mPresenter.login(SPUtils.get(mContext, UserConstans.LOGIN_USERNAME, "") + "", pwd);
} else {
killMyself();
startActivity(new Intent(mContext, LoginActivity.class));
}
}
}
......@@ -78,8 +111,96 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
}
});
guideBeanList.add(new GuideBean("多终端云同步,轻松管理所有", "為您搭建優良高效管理平台", getResources().getDrawable(R.mipmap.pic_guide_one)));
guideBeanList.add(new GuideBean("數據分析可視化", "數據統計一目了然,直觀看到數據變化趨勢", getResources().getDrawable(R.mipmap.pic_guide_two)));
guideBeanList.add(new GuideBean("多種點餐方式", "提供方便快捷的點餐服務,減低落錯單機會", getResources().getDrawable(R.mipmap.pic_guide_three)));
GuideAdapter adapter = new GuideAdapter(mContext, guideBeanList);
mVpGuide.setAdapter(adapter);
//设置一个缩放动画
mVpGuide.setPageTransformer(mAnimator);
mVpGuide.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
updateUI(position);
}
});
mVpGuide.setScrollBarFadeDuration((int) ANIMATION_TIME);
magicIndicator.attachToViewPager(mVpGuide);
}
private void updateUI(int position) {
mTvGuideTitle.setText(guideBeanList.get(position).getTitle());
mTvGuideDetails.setText(guideBeanList.get(position).getDetails());
setAnimator();
}
private void setAnimator() {
ObjectAnimator translationAnim = ObjectAnimator.ofFloat(mTvGuideTitle, "translationX", -120f, 0f);
translationAnim.setDuration(ANIMATION_TIME);
translationAnim.setInterpolator(new DecelerateInterpolator());
ObjectAnimator translationAnim2 = ObjectAnimator.ofFloat(mTvGuideDetails, "translationX", -120f, 0f);
translationAnim2.setDuration(ANIMATION_TIME);
translationAnim2.setInterpolator(new DecelerateInterpolator());
ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(mTvGuideTitle, "alpha", 0f, 1f);
alphaAnimator.setDuration(ANIMATION_TIME);
ObjectAnimator alphaAnimator1 = ObjectAnimator.ofFloat(mTvGuideDetails, "alpha", 0f, 1f);
alphaAnimator1.setDuration(ANIMATION_TIME);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(translationAnim, alphaAnimator, translationAnim2, alphaAnimator1);
animatorSet.start();
}
/**
* 顯示引導圖
*/
private void showGuide() {
Animation hideAnim = AnimationUtils.loadAnimation(mContext, R.anim.anim_alpha_hide);
hideAnim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
guideView.startAnimation(AnimationUtils.loadAnimation(mContext, R.anim.anim_alpha_show));
guideView.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(Animation animation) {
contentView.setVisibility(View.GONE);
guideView.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
contentView.startAnimation(hideAnim);
}
ViewPager2.PageTransformer mAnimator = (page, position) -> {
Float absPos = Math.abs(position);
Float scaleX;
Float scaleY;
if (absPos > 1) {
scaleX = 0F;
scaleY = 0F;
} else {
scaleX = 1 - absPos;
scaleY = 1 - absPos;
}
page.setScaleX(scaleX);
page.setScaleY(scaleY);
// page.setRotationX(scaleX);
};
@Override
public void initIntent() {
......@@ -157,6 +278,16 @@ public class WelcomeActivity extends LoginInterfaceImpl<WelcomePresenter> implem
})
.build()
.show();
}
@OnClick({R2.id.iv_guide_close})
@Override
public void onClick(View v) {
if (v.getId() == R.id.iv_guide_close) {
//去登陸頁,設置下次不顯示引導頁
SPUtils.put(mContext, UserConstans.IS_GUIDE, false);
startActivity(new Intent(mContext, LoginActivity.class));
killMyself();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/content_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tv_welcome_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="多功能管理,讓管理更輕鬆"
android:textColor="@color/theme_color"
android:textSize="@dimen/sp_16"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintBottom_toTopOf="@id/iv_welcome_center"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iv_welcome_center"
android:layout_width="@dimen/dp_203"
android:layout_height="@dimen/dp_256"
android:layout_marginTop="@dimen/dp_36"
android:src="@mipmap/png_welcome_center"
app:layout_constraintVertical_bias="0.6"
app:layout_constraintBottom_toTopOf="@id/iv_welcome_logo"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_welcome_title" />
<ImageView
android:id="@+id/iv_welcome_logo"
android:layout_width="@dimen/dp_56"
android:layout_height="@dimen/dp_56"
android:layout_marginTop="@dimen/dp_16"
android:src="@mipmap/ic_logo"
app:layout_constraintBottom_toTopOf="@id/iv_welcome_bottom"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_welcome_center" />
<ImageView
android:id="@+id/iv_welcome_bottom"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/content_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@mipmap/png_welcome_bottom"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_height="match_parent"
android:background="@color/white"
android:visibility="visible">
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@mipmap/img_start" />
<!-- <TextView-->
<!-- android:id="@+id/tv_welcome_title"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="多功能管理,讓管理更輕鬆"-->
<!-- android:textColor="@color/theme_color"-->
<!-- android:textSize="@dimen/sp_16"-->
<!-- app:layout_constraintBottom_toTopOf="@id/iv_welcome_center"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- app:layout_constraintVertical_chainStyle="packed" />-->
<!-- <ImageView-->
<!-- android:id="@+id/iv_welcome_center"-->
<!-- android:layout_width="@dimen/dp_203"-->
<!-- android:layout_height="@dimen/dp_256"-->
<!-- android:layout_marginTop="@dimen/dp_36"-->
<!-- android:src="@mipmap/png_welcome_center"-->
<!-- app:layout_constraintBottom_toTopOf="@id/iv_welcome_logo"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@id/tv_welcome_title"-->
<!-- app:layout_constraintVertical_bias="0.6" />-->
<!-- <ImageView-->
<!-- android:id="@+id/iv_welcome_logo"-->
<!-- android:layout_width="@dimen/dp_56"-->
<!-- android:layout_height="@dimen/dp_56"-->
<!-- android:layout_marginTop="@dimen/dp_16"-->
<!-- android:src="@mipmap/ic_logo"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@id/iv_welcome_center" />-->
<!-- <ImageView-->
<!-- android:id="@+id/iv_welcome_bottom"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:src="@mipmap/png_welcome_bottom"-->
<!-- app:layout_constraintBottom_toBottomOf="parent" />-->
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_guide_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/pic_guide_bg"
android:visibility="gone">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/vp2_guide"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/tv_guide_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_18"
android:text="多终端云同步,轻松管理所有"
android:textColor="@color/white"
android:textSize="@dimen/dp_19"
app:layout_constraintBottom_toTopOf="@id/tv_guide_details"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.12"
app:layout_constraintVertical_chainStyle="packed" />
<TextView
android:id="@+id/tv_guide_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_14"
android:text="為您搭建優良高效管理平台"
android:textColor="@color/white"
android:textSize="@dimen/dp_13"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="@id/tv_guide_title"
app:layout_constraintTop_toBottomOf="@id/tv_guide_title" />
<ImageView
android:id="@+id/iv_guide_close"
android:layout_width="@dimen/dp_42"
android:layout_height="@dimen/dp_42"
android:padding="@dimen/dp_12"
android:src="@drawable/ic_guide_close"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.gingersoft.gsa.cloud.ui.widget.Indicator.UIndicator
android:id="@+id/guide_magic_indicator"
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_5"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginBottom="@dimen/dp_10"
app:circle_rect_corner="@dimen/dp_3"
app:circle_rect_itemHeight="@dimen/dp_5"
app:circle_rect_itemWidth="@dimen/dp_14"
app:circle_rect_radius="@dimen/dp_3"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_goneMarginBottom="@dimen/dp_15"
app:normal_color="@color/white"
app:selected_color="@color/white"
app:spacing="@dimen/dp_5"
app:style="circle_rect" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -177,7 +177,7 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/rb_remember_password" />
<TextView
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/tv_gsa_user_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -194,6 +194,7 @@
<TextView
android:id="@+id/tv_app_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp_10"
......
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