Commit b9711b76 by 王宇航

首頁佈局

parent 01f2540c
......@@ -114,7 +114,8 @@ ext {
"qmui" : "com.qmuiteam:qmui:2.0.0-alpha03",
"arms" : "me.jessyan:arms:2.5.2",
"fastjson" : "com.alibaba:fastjson:1.2.46",
"zxing" : "cn.yipianfengye.android:zxing-library:2.2"
"zxing" : "cn.yipianfengye.android:zxing-library:2.2",
"BaseRecyclerViewAdapter" : "com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.46"
]
}
......@@ -52,4 +52,6 @@ dependencies {
// compileOnly rootProject.ext.dependencies["canary-release"]
// }
testImplementation rootProject.ext.dependencies["junit"]
implementation rootProject.ext.dependencies["BaseRecyclerViewAdapter"]
}
package debug;
import android.app.Application;
import com.billy.cc.core.component.CC;
import com.jess.arms.base.BaseApplication;
/**
* @author billy.qi
* @since 17/11/20 20:02
*/
public class MyApp extends Application {
public class MyApp extends BaseApplication {
@Override
public void onCreate() {
super.onCreate();
......
......@@ -127,7 +127,7 @@ public class MainActivity extends BaseFragmentActivity<MainPresenter> implements
.setText(getString(R.string.report))
.build(mContext);
QMUITab my = builder
.setNormalDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_normal_main))
.setNormalDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_normal_my))
.setSelectedDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_selected_my))
.setText(getString(R.string.my))
.build(mContext);
......
package com.gingersoft.gsa.cloud.main.mvp.ui.adapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import java.util.Map;
import androidx.annotation.Nullable;
/**
* Created by Wyh on 2020/1/11.
*/
public class PersonalAdapter extends BaseQuickAdapter<Map<String, Object>, BaseViewHolder> {
public PersonalAdapter(int layoutResId, @Nullable List<Map<String, Object>> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, Map<String, Object> item) {
}
}
package com.gingersoft.gsa.cloud.main.mvp.ui.fragment;
import android.content.Intent;
import android.media.Image;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.main.R;
import com.gingersoft.gsa.cloud.main.R2;
......@@ -35,6 +39,7 @@ import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import dagger.Component;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......@@ -104,8 +109,19 @@ public class HomeFragment extends BaseFragment<HomePresenter> implements HomeCon
}
private void initTopBar() {
mTopBar.addLeftImageButton(R.drawable.ic_main_home_refresh, R.id.main_home_refresh);
View refreshView = View.inflate(mContext, R.layout.main_home_title_img, null);
refreshView.setOnClickListener(this);
ImageView refresh = refreshView.findViewById(R.id.main_home_title_iv);
refresh.setImageResource(R.drawable.ic_main_home_refresh);
mTopBar.addLeftView(refreshView, R.id.main_home_refresh);
mTopBar.setTitle("店鋪名稱");
View msgView = View.inflate(mContext, R.layout.main_home_title_img, null);
msgView.setOnClickListener(this);
ImageView msg = msgView.findViewById(R.id.main_home_title_iv);
msg.setImageResource(R.drawable.selector_msg);
mTopBar.addRightView(msgView, R.id.main_home_msg);
// mTopBar.addRightImageButton(R.drawable.selector_msg, R.id.main_home_msg).setOnClickListener(this);
}
......@@ -124,7 +140,10 @@ public class HomeFragment extends BaseFragment<HomePresenter> implements HomeCon
@Override
public void onItemClick(QMUIStickySectionAdapter.ViewHolder holder, int position) {
CC.obtainBuilder("Component.Table")
.setActionName("showTableActivity")
.build()
.call();
}
@Override
......@@ -201,8 +220,10 @@ public class HomeFragment extends BaseFragment<HomePresenter> implements HomeCon
public void onClick(View v) {
if (v.getId() == R.id.main_home_refresh) {
//刷新
v.startAnimation(AnimationUtils.loadAnimation(mContext, R.anim.rotate_center));
} else if (v.getId() == R.id.main_home_msg) {
//消息
}
}
......
......@@ -17,6 +17,8 @@ import com.jess.arms.utils.ArmsUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......@@ -34,6 +36,9 @@ import static com.jess.arms.utils.Preconditions.checkNotNull;
* ================================================
*/
public class MyFragment extends BaseFragment<MyPresenter> implements MyContract.View {
@BindView(R.id.main_personal_center_rv)
RecyclerView rvMyList;
public static MyFragment newInstance() {
MyFragment fragment = new MyFragment();
......@@ -57,45 +62,10 @@ public class MyFragment extends BaseFragment<MyPresenter> implements MyContract.
@Override
public void initData(@Nullable Bundle savedInstanceState) {
}
/**
* 通过此方法可以使 Fragment 能够与外界做一些交互和通信, 比如说外部的 Activity 想让自己持有的某个 Fragment 对象执行一些方法,
* 建议在有多个需要与外界交互的方法时, 统一传 {@link Message}, 通过 what 字段来区分不同的方法, 在 {@link #setData(Object)}
* 方法中就可以 {@code switch} 做不同的操作, 这样就可以用统一的入口方法做多个不同的操作, 可以起到分发的作用
* <p>
* 调用此方法时请注意调用时 Fragment 的生命周期, 如果调用 {@link #setData(Object)} 方法时 {@link Fragment#onCreate(Bundle)} 还没执行
* 但在 {@link #setData(Object)} 里却调用了 Presenter 的方法, 是会报空的, 因为 Dagger 注入是在 {@link Fragment#onCreate(Bundle)} 方法中执行的
* 然后才创建的 Presenter, 如果要做一些初始化操作,可以不必让外部调用 {@link #setData(Object)}, 在 {@link #initData(Bundle)} 中初始化就可以了
* <p>
* Example usage:
* <pre>
* public void setData(@Nullable Object data) {
* if (data != null && data instanceof Message) {
* switch (((Message) data).what) {
* case 0:
* loadData(((Message) data).arg1);
* break;
* case 1:
* refreshUI();
* break;
* default:
* //do something
* break;
* }
* }
* }
*
* // call setData(Object):
* Message data = new Message();
* data.what = 0;
* data.arg1 = 1;
* fragment.setData(data);
* </pre>
*
* @param data 当不需要参数时 {@code data} 可以为 {@code null}
*/
@Override
public void setData(@Nullable Object data) {
......
......@@ -5,8 +5,10 @@
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="我的" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/main_personal_center_rv"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/main_home_title_iv"
android:layout_width="@dimen/head_height"
android:layout_height="@dimen/head_height"
android:layout_centerInParent="true"
android:padding="@dimen/dp_12" />
</RelativeLayout>
......@@ -43,6 +43,6 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation rootProject.ext.dependencies["zxing"]
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.46'
implementation 'am.util:printer:2.1.0'
implementation rootProject.ext.dependencies["BaseRecyclerViewAdapter"]
}
......@@ -16,6 +16,7 @@ import java.util.List;
import am.util.printer.PrintExecutor;
import am.util.printer.PrintSocketHolder;
import am.util.printer.PrinterWriter58mm;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
......@@ -35,42 +36,42 @@ public class PrintActivity extends Activity implements PrintSocketHolder.OnState
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_print);
setContentView(R.layout.print_layout_print);
rvFood = findViewById(R.id.rv_food);
rvBill = findViewById(R.id.rv_bill_amount);
List<FoodBean> data = new ArrayList<>();
data.add(new FoodBean("包子(主項)",1,13.54));
data.add(new FoodBean("番薯爸爸",2,8.0));
data.add(new FoodBean("包子(主項)",3,37.34));
data.add(new FoodBean("測卡很快就酸辣粉十大減肥和思考",33,1334.2254));
FoodAdapter foodAdapter = new FoodAdapter(data);
rvFood.setLayoutManager(new LinearLayoutManager(this));
rvFood.setAdapter(foodAdapter);
List<BillingBean> billingBeans = new ArrayList<>();
billingBeans.add(new BillingBean("合計", 58.88));
billingBeans.add(new BillingBean("10%服務費", 5.08));
billingBeans.add(new BillingBean("賬單小數", -0.06));
billingBeans.add(new BillingBean("上課交電話費扣水電費可接受的咖啡機", 837248.8829372));
BillAdapter billAdapter = new BillAdapter(billingBeans);
rvBill.setLayoutManager(new LinearLayoutManager(this));
rvBill.setAdapter(billAdapter);
// findViewById(R.id.btn_print).setOnClickListener(v -> {
// if (executor == null) {
// executor = new PrintExecutor("192.168.1.217", 9100, PrinterWriter58mm.TYPE_58);
// executor.setOnStateChangedListener(PrintActivity.this::onResult);
// executor.setOnPrintResultListener(PrintActivity.this);
// }
// executor.setIp("192.168.1.217", 9100);
// executor.doPrinterRequestAsync(maker);
// });
setContentView(R.layout.activity_print);
// setContentView(R.layout.print_layout_print);
// rvFood = findViewById(R.id.rv_food);
// rvBill = findViewById(R.id.rv_bill_amount);
//
// List<FoodBean> data = new ArrayList<>();
// data.add(new FoodBean("包子(主項)",1,13.54));
// data.add(new FoodBean("番薯爸爸",2,8.0));
// data.add(new FoodBean("包子(主項)",3,37.34));
// data.add(new FoodBean("測卡很快就酸辣粉十大減肥和思考",33,1334.2254));
//
// FoodAdapter foodAdapter = new FoodAdapter(data);
// rvFood.setLayoutManager(new LinearLayoutManager(this));
// rvFood.setAdapter(foodAdapter);
//
//
// List<BillingBean> billingBeans = new ArrayList<>();
// billingBeans.add(new BillingBean("合計", 58.88));
// billingBeans.add(new BillingBean("10%服務費", 5.08));
// billingBeans.add(new BillingBean("賬單小數", -0.06));
// billingBeans.add(new BillingBean("上課交電話費扣水電費可接受的咖啡機", 837248.8829372));
//
// BillAdapter billAdapter = new BillAdapter(billingBeans);
// rvBill.setLayoutManager(new LinearLayoutManager(this));
// rvBill.setAdapter(billAdapter);
maker = new SendPrint(this, 255, 560);
findViewById(R.id.btn_print).setOnClickListener(v -> {
if (executor == null) {
executor = new PrintExecutor("192.168.1.217", 9100, PrinterWriter58mm.TYPE_58);
executor.setOnStateChangedListener(PrintActivity.this::onResult);
executor.setOnPrintResultListener(PrintActivity.this);
}
executor.setIp("192.168.1.217", 9100);
executor.doPrinterRequestAsync(maker);
});
// view = findViewById(R.id.iv_print);
}
......
......@@ -13,6 +13,9 @@ import com.joe.print.adapter.FoodAdapter;
import com.joe.print.bean.BillingBean;
import com.joe.print.bean.FoodBean;
import com.joe.print.utils.BitmapUtil;
import com.joe.print.utils.ImageUtils;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
......@@ -48,38 +51,15 @@ public class SendPrint implements PrintDataMaker {
PrinterWriter printer;
printer = type == PrinterWriter58mm.TYPE_58 ? new PrinterWriter58mm(parting, width) : new PrinterWriter80mm(parting, width);
printer.setAlignCenter();
data.add(printer.getDataAndReset());
View view = LinearLayout.inflate(context, R.layout.print_layout_print, null);
RecyclerView rvFood = view.findViewById(R.id.rv_food);
RecyclerView rvBill = view.findViewById(R.id.rv_bill_amount);
List<FoodBean> foodBeans = new ArrayList<>();
foodBeans.add(new FoodBean("包子(主項)", 1, 13.54));
foodBeans.add(new FoodBean("番薯爸爸", 2, 8.0));
foodBeans.add(new FoodBean("包子(主項)", 3, 37.34));
foodBeans.add(new FoodBean("測卡很快就酸辣粉十大減肥和思考", 33, 1334.2254));
FoodAdapter foodAdapter = new FoodAdapter(foodBeans);
rvFood.setLayoutManager(new LinearLayoutManager(context));
rvFood.setAdapter(foodAdapter);
List<BillingBean> billingBeans = new ArrayList<>();
billingBeans.add(new BillingBean("合計", 58.88));
billingBeans.add(new BillingBean("10%服務費", 5.08));
billingBeans.add(new BillingBean("賬單小數", -0.06));
billingBeans.add(new BillingBean("上課交電話費扣水電費可接受的咖啡機", 837248.8829372));
BillAdapter billAdapter = new BillAdapter(billingBeans);
rvBill.setLayoutManager(new LinearLayoutManager(context));
rvBill.setAdapter(billAdapter);
//加载条形码
ImageView ivBarCode = view.findViewById(R.id.iv_bar_code);
ivBarCode.setImageBitmap(BitmapUtil.generateBitmap("12312112131", 2, 450, 150));
data.add(printer.getDataAndReset());
View view = initView();
LayoutToBitmapUtils.layoutView(context, view);//先测量view
Bitmap bitmap = LayoutToBitmapUtils.loadBitmapFromView(view);//将view轉bitmap
//壓縮bitmap到指定大小
bitmap = ImageUtils.scalingBitmap(bitmap, width);
ArrayList<byte[]> image1 = PrinterUtils.decodeBitmapToDataList(bitmap, parting);//bitmap转字节码
data.addAll(image1);
......@@ -92,9 +72,6 @@ public class SendPrint implements PrintDataMaker {
// .getImageByte(context.getResources(), R.drawable.ic_printer_qr);
// data.addAll(image2);
// }
printer.printLineFeed();
printer.printLineFeed();
printer.printLineFeed();
......@@ -107,4 +84,36 @@ public class SendPrint implements PrintDataMaker {
return new ArrayList<>();
}
}
@NotNull
private View initView() {
View view = LinearLayout.inflate(context, R.layout.print_layout_print, null);
RecyclerView rvFood = view.findViewById(R.id.rv_food);
RecyclerView rvBill = view.findViewById(R.id.rv_bill_amount);
List<FoodBean> foodBeans = new ArrayList<>();
foodBeans.add(new FoodBean("包子(主項)", 1, 13.54));
foodBeans.add(new FoodBean("番薯爸爸", 2, 8.0));
foodBeans.add(new FoodBean("包子(主項)", 3, 37.34));
foodBeans.add(new FoodBean("測卡很快就酸辣粉十大減肥和思考", 33, 1334.2254));
FoodAdapter foodAdapter = new FoodAdapter(foodBeans);
rvFood.setLayoutManager(new LinearLayoutManager(context));
rvFood.setAdapter(foodAdapter);
List<BillingBean> billingBeans = new ArrayList<>();
billingBeans.add(new BillingBean("合計", 58.88));
billingBeans.add(new BillingBean("10%服務費", 5.08));
billingBeans.add(new BillingBean("賬單小數", -0.06));
billingBeans.add(new BillingBean("上課交電話費扣水電費可接受的咖啡機", 837248.8829372));
BillAdapter billAdapter = new BillAdapter(billingBeans);
rvBill.setLayoutManager(new LinearLayoutManager(context));
rvBill.setAdapter(billAdapter);
//加载条形码
ImageView ivBarCode = view.findViewById(R.id.iv_bar_code);
ivBarCode.setImageBitmap(BitmapUtil.generateBitmap("12312112131", 2, 450, 150));
return view;
}
}
......@@ -160,4 +160,30 @@ public class ImageUtils {
return Bitmap.createBitmap(oldbmp, 0, 0, width, height,
matrix, true);
}
/**
* 缩放图片
*
* @param image 图片
* @param maxWidth 最大宽
* @return 缩放后的图片
*/
public static Bitmap scalingBitmap(Bitmap image, int maxWidth) {
if (image == null || image.getWidth() <= 0 || image.getHeight() <= 0)
return null;
try {
final int width = image.getWidth();
final int height = image.getHeight();
// 精确缩放
float scale = 1;
if (maxWidth <= 0 || width <= maxWidth) {
scale = maxWidth / (float) width;
}
Matrix matrix = new Matrix();
matrix.postScale(scale, scale);
return Bitmap.createBitmap(image, 0, 0, width, height, matrix, true);
} catch (OutOfMemoryError e) {
return null;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:duration="1500"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="3"
android:toDegrees="360" />
\ No newline at end of file
......@@ -37,4 +37,5 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.github.hackware1993:MagicIndicator:1.5.0'
}
......@@ -77,8 +77,8 @@ public class LoginActivity extends BaseActivity<LoginPresenter> implements Login
edAccount = findViewById(R.id.ed_login_user_account);
edPwd = findViewById(R.id.ed_login_user_pwd);
if(GsaCloudApplication.getLoginToken(mContext).length() > 0){
finish();
jumpActivity();
finish();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment