package com.dayu.baselibrary.tools.print;
|
|
import android.app.Application;
|
import android.content.Context;
|
import android.util.Log;
|
|
import com.android.newpos.printer.PrinterManager;
|
import com.dayu.baselibrary.utils.ModelUtils;
|
import com.pos.device.SDKManager;
|
|
import java.util.List;
|
|
/**
|
* author: zuo
|
* Date: 2024-09-27
|
* Time: 10:29
|
* 备注:打印相关的路由
|
*/
|
public class PrintAdater {
|
|
static PrintAdater printAdater;
|
|
public static PrintAdater getInstance() {
|
if (printAdater == null) {
|
printAdater = new PrintAdater();
|
}
|
return printAdater;
|
}
|
|
/**
|
* 连接服务
|
*/
|
public void connectPrinterService(Application context) {
|
switch (ModelUtils.getModelType()) {
|
case ModelUtils.ShangMiType:
|
ShangMiAidlUtil.getInstance().connectPrinterService(context);
|
break;
|
case ModelUtils.HuaZhiRongHaiType:
|
HuaZhiRongHaiPrint.getInstance().connectPrinterService(context);
|
break;
|
}
|
}
|
|
/**
|
* 断开服务
|
*
|
* @param context context
|
*/
|
public static void disconnectPrinterService(Context context) {
|
switch (ModelUtils.getModelType()) {
|
case ModelUtils.ShangMiType:
|
ShangMiAidlUtil.getInstance().connectPrinterService(context);
|
break;
|
}
|
}
|
|
/**
|
* 打印指定字体的文本,字体设置只对本次有效
|
*
|
* @param content: 要打印文字
|
* @param isBold: 是否加粗
|
* @param size: 字体大小
|
*/
|
public static void printText(List<String> content, float size, boolean isBold, boolean isUnderLine) {
|
switch (ModelUtils.getModelType()) {
|
case ModelUtils.ShangMiType:
|
ShangMiAidlUtil.getInstance().printText(content, size, isBold, isUnderLine);
|
break;
|
case ModelUtils.HuaZhiRongHaiType:
|
HuaZhiRongHaiPrint.getInstance().printText(content, size, isBold, isUnderLine);
|
break;
|
}
|
}
|
|
}
|