add project adins

This commit is contained in:
Alfrid Sanjaya Leo Putra 2024-07-25 14:44:22 +07:00
commit f8f85d679d
5299 changed files with 625430 additions and 0 deletions

View file

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="text_color">#FFFFFF</color>
<color name="divider_color">#11000000</color>
<color name="msg_color">#FFFFFFFF</color>
<color name="dialog_bg">#ff002843</color>
<color name="btn_press_color">#6601141f</color>
<color name="btn_unpress_color">#22000000</color>
<color name="txt_view">#000e2b</color>
<!-- Text View -->
<color name="tv_darker">#01141f</color>
<color name="tv_dark">#48699c</color>
<color name="tv_normal">#016cac</color>
<color name="tv_normal_press">#016cac</color>
<color name="tv_light">#2c97d7</color>
<color name="tv_lighter">#73c4f5</color>
<color name="tv_gray">#cccccc</color>
<color name="tv_white">#FFFFFF</color>
<color name="tv_black">#000000</color>
<!-- Text View -->
<color name="tv_darker_trans">#33041741</color>
<color name="tv_dark_trans">#50005baa</color>
<color name="tv_normal_trans">#500a4cde</color>
<color name="tv_light_trans">#506795fb</color>
<!-- Theme about colors -->
<color name="theme_default_primary">#536dfe</color>
<color name="theme_default_primary_dark">#3f51b5</color>
<color name="theme_accent">#ff4081</color>
<color name="theme_window_background">#ECECEC</color>
<color name="card">#FAFAFA</color>
<color name="title_openSource">#212121</color>
<color name="text_openSource">#727272</color>
<color name="dividerDark_openSource">#AAA</color>
<color name="dividerLight_openSource">#DADADA</color>
<color name="default_progress_bar_color">#FF33B5E5</color>
<color name="crop__button_bar">#f3f3f3</color>
<color name="crop__button_text">#666666</color>
<color name="crop__selector_pressed">#1a000000</color>
<color name="crop__selector_focused">#77000000</color>
<color name="drawer_background">#cfcfcf</color>
<!-- Action Bar -->
<!-- <color name="ab_start">#2c2d31</color> -->
<!-- <color name="ab_end">#2c2d31</color> -->
<color name="ab_start">#4c74b0</color>
<color name="ab_end">#4c74b0</color>
<!-- Gradient -->
<color name="gradient_start1">#ffab16</color>
<color name="gradient_start">#ff8e0d</color>
<color name="gradient_end2">#ff960d</color>
<color name="gradient_end1">#ff8e0d</color>
<color name="gradient_end">#ff8e0a</color>
<!-- Graph Color -->
<color name="graphColor1">#FBBA72</color>
<color name="graphColor2">#F86624</color>
<color name="graphColor3">#BA5624</color>
<color name="graphColor4">#8F250C</color>
<!-- Rank Legends Color -->
<color name="rankColor1">#FF0000</color>
<color name="rankColor2">#000000</color>
<color name="rankColor3">#32CD32</color>
<color name="rankColor4">#0000FF</color>
<color name="login_color">#ef7d0a</color>
<!--#fbac18-->
<!--#e38931-->
</resources>

View file

@ -0,0 +1,990 @@
package com.adins.mss.foundation.print;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.os.AsyncTask;
import androidx.core.content.ContextCompat;
import androidx.core.view.MotionEventCompat;
import android.util.Log;
import android.widget.Toast;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.R;
import com.adins.mss.base.crashlytics.FireCrash;
import com.adins.mss.base.dynamicform.Constant;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.LogoPrint;
import com.adins.mss.dao.PrintResult;
import com.adins.mss.foundation.db.dataaccess.LogoPrintDataAccess;
import com.adins.mss.foundation.security.storepreferences.ObscuredSharedPreferences;
import com.adins.mss.logger.Logger;
import com.woosim.printer.WoosimCmd;
import com.woosim.printer.WoosimImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Vector;
import zj.com.command.sdk.PrinterCommand;
import zj.com.customize.sdk.Other;
/**
* Created by angga.permadi on 3/3/2016.
*/
public class AB200MPrintManager extends AbstractPrintManager {
public static final String PRINT_PREFERENCES = "PRINT_PREFERENCES";
public static final String PRINTER_KEY = "PRINTER_KEY";
public static final String PRINTER_WOOSIM = "woosim";
public static final int TEXT_ATTRIBUTE_EMPHASIZED = 1;
public static final String TAG = "AB200MPrintManager";
private String deviceName;
private PrinterConnect printerConnect;
private String lastPrinterConnected;
public AB200MPrintManager(Context context, List<PrintResult> list) {
super(context, list);
ObscuredSharedPreferences preferences = ObscuredSharedPreferences.getPrefs(context, PRINT_PREFERENCES, Context.MODE_PRIVATE);
lastPrinterConnected = preferences.getString(PRINTER_KEY, "");
}
@Override
public boolean isConnected() {
return connected;
}
@Override
public boolean isPrinterConnected() {
return BluePrintDriver.isPrinterConnected();
}
@Override
public void connect() throws Exception {
if (printerConnect != null) {
printerConnect.cancel(true);
printerConnect = null;
}
printerConnect = new PrinterConnect();
printerConnect.execute();
}
@Override
public void connect(BluetoothDevice device) throws Exception {
if (printerConnect != null) {
printerConnect.cancel(true);
printerConnect = null;
}
printerConnect = new PrinterConnect(device);
printerConnect.execute();
}
@Override
public void disconnect() throws Exception {
BluePrintDriver.close();
deviceName = null;
connected = false;
if (listener != null) {
listener.onDisconnect();
}
}
@Override
public void printText(String text, int alignment, int attribute, int size, boolean s) {
BluePrintDriver.InitPrinter();
if (BluePrintDriver.IsNoConnection()) {
return;
}
switch (attribute) {
case AbstractPrintManager.TEXT_ATTRIBUTE_FONT_A:
break;
case AbstractPrintManager.TEXT_ATTRIBUTE_EMPHASIZED:
BluePrintDriver.AddBold((byte) TEXT_ATTRIBUTE_EMPHASIZED);
break;
default:
break;
}
BluePrintDriver.AddAlignMode((byte) alignment);
BluePrintDriver.ImportData(text);
if (!BluePrintDriver.excute()) {
connected = false;
Logger.d("", "onError print ");
}
BluePrintDriver.ClearData();
}
@Override
public void printBitmap(Bitmap bitmap, int alignment, int span, int level, boolean s) {
if (BluePrintDriver.IsNoConnection()) {
return;
}
//olivia : utk dapat nama logo sesuai nama tenant
String tenant = GlobalData.getSharedGlobalData().getTenant();
int pos = tenant.indexOf("@");
String tenantName = tenant.substring(pos+1, tenant.length());
if (deviceName != null && deviceName.toLowerCase().contains(PRINTER_WOOSIM)) {
Bitmap logo = null;
LogoPrint logoPrint = LogoPrintDataAccess.getOne(context, tenantName);
if (logoPrint != null) {
logo = BitmapFactory.decodeByteArray(logoPrint.getImage_bitmap(), 0, logoPrint.getImage_bitmap().length);
} else {
BitmapDrawable drawable = (BitmapDrawable) ContextCompat.getDrawable(context, R.drawable.adins_logo);
if (drawable != null) logo = drawable.getBitmap();
}
int nMode = 0;
int nPaperWidth = 320;
if (logo != null) {
int width = ((nPaperWidth + 7) / 8) * 8;
int height = logo.getHeight() * width / logo.getWidth();
height = ((height + 7) / 8) * 8;
Bitmap rszBitmap = logo;
if (logo.getWidth() != width) {
rszBitmap = Other.resizeImage(logo, width, height);
}
byte[] data = WoosimImage.printBitmap(0, 0, 256, 200, rszBitmap);
BluePrintDriver.printByteData(zj.com.command.sdk.Command.ESC_Init);
BluePrintDriver.printByteData(WoosimCmd.setTextAlign(WoosimCmd.ALIGN_CENTER));
BluePrintDriver.printByteData(data);
BluePrintDriver.printByteData(PrinterCommand.POS_Set_PrtAndFeedPaper(20));
}
} else {
LogoPrint logoPrint = LogoPrintDataAccess.getOne(context, tenantName);
if (logoPrint != null) {
bitmap = BitmapFactory.decodeByteArray(logoPrint.getImage_bitmap(), 0, logoPrint.getImage_bitmap().length);
} else {
BitmapDrawable drawable = (BitmapDrawable) ContextCompat.getDrawable(context, R.drawable.adins_logo);
if (drawable != null) bitmap = drawable.getBitmap();
}
if (bitmap != null) {
/**
* 2019.06.20
* Bugfix: PRDAITMSS-722
* Print Logo Bitmap not properly printed
*/
BluePrintDriver.printByteData(zj.com.command.sdk.Command.ESC_Init);
BluePrintDriver.printByteData(zj.com.command.sdk.Command.LF);
BluePrintDriver.printByteData(WoosimCmd.setTextAlign(1));
printBitmapSzzcs(bitmap);
BluePrintDriver.printByteData(PrinterCommand.POS_Set_PrtAndFeedPaper(30));
}
}
}
/**
* 2019.06.20
* Print using Bitmap data
*/
@Override
public void print(Bitmap bitmap) {
byte[] data = WoosimImage.bmp2PrintableImage(0, 0, bitmap.getWidth(), bitmap.getHeight(), bitmap);
BluePrintDriver.printByteData(WoosimCmd.initPrinter());
BluePrintDriver.printByteData(WoosimCmd.printLineFeed(3));
BluePrintDriver.printByteData(WoosimCmd.setTextAlign(1));
BluePrintDriver.printByteData(data);
BluePrintDriver.printByteData(WoosimCmd.cutPaper(1));
}
@Override
public void lineFeed(int lines, boolean s) {
for (int i = 0; i < lines; i++) {
BluePrintDriver.printString("");
}
}
@Override
public void releaseResources() {
super.releaseResources();
deviceName = null;
if (printerConnect != null) {
printerConnect.cancel(true);
printerConnect = null;
}
}
/*PRINT SATO*/
@Override
public boolean printSato() throws Exception {
if (connected) {
byte[] logo = getByteFromImage("adira_new.prn");
BluePrintDriver.ImportData(this.getDataToPrint(), logo);
if (!BluePrintDriver.excute()) {
connected = false;
Logger.d("", "onError print ");
}
BluePrintDriver.ClearData();
} else {
throw new Exception("Device is not connected to the Sato printer");
}
return true;
}
private byte[] getByteFromImage(String image) throws IOException {
byte[] imgBytes = null;
ByteArrayOutputStream baos = null;
AssetManager am = context.getResources().getAssets();
InputStream in = null;
try {
baos = new ByteArrayOutputStream();
// this image is inside my mobile application
in = am.open(image); // <<--- image = nama file .prn yang taruh di asset
byte[] buffer = new byte[4096];
int n = 0;
while ((n = in.read(buffer)) != -1) {
baos.write(buffer, 0, n);
}
imgBytes = baos.toByteArray();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
// whatever happends close the streams
if (baos != null) {
try {
baos.close();
} catch (Exception ex) {
FireCrash.log(ex);
}
}
if (in != null) {
try {
in.close();
} catch (Exception ex) {
FireCrash.log(ex);
}
}
}
byte[] a = new byte[]{2, 27, 65, 27, 73, 71, 49, 27, 80, 83};
byte[] b = new byte[]{27, 81, 48, 48, 48, 49, 27, 90, 3};
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
outputStream.write(a);
outputStream.write(imgBytes);
outputStream.write(b);
byte[] c = outputStream.toByteArray();
return c;
}
private String getDataToPrint() throws Exception {
int verticalPosition = 96 - 33; // 96, sebagai posisi awal
char start = (char) 27;
char begin = (char) 2;
char end = (char) 3;
StringBuilder sbToPrint = new StringBuilder();
sbToPrint.append(begin).append(start);
for (PrintResult bean : Constant.getListOfPrintItem()) {
String type = bean.getPrint_type_id();
String vPosition = "";
if ((verticalPosition + 33) < 100) {
verticalPosition = verticalPosition + 33;
vPosition = "00" + verticalPosition;
} else if ((verticalPosition + 33) < 1000) {
verticalPosition = verticalPosition + 33;
vPosition = "0" + verticalPosition;
} else {
vPosition = "" + verticalPosition;
verticalPosition = verticalPosition + 33;
}
if (Global.PRINT_NEW_LINE.equals(type)) {
String label = bean.getLabel();
sbToPrint.append(start).append(
"L" + vPosition + "000101111000");
sbToPrint.append(start).append("D" + label);
} else if (Global.PRINT_LABEL_CENTER.equals(type)) {
String label = bean.getLabel();
// nilai sebenarnya 384, dikurangi aj bt jaga2 kalo slah perhtungan
Vector vt = FontSato.wrap(374, label.trim());
for (int j = 0; j < vt.size(); j++) {
SentencesSato setn = null;
try {
setn = (SentencesSato) vt.elementAt(j);
} catch (Exception e) {
FireCrash.log(e);
if (Global.IS_DEV) Log.i(TAG,"eato " + e);
}
// ------------- agar posisi bisa ditengah,
if(setn == null)
continue;
int iHposition = (384 - setn.getLenghtSentemce()) / 2;
String sHposition = "0";
if (iHposition < 10) {
sHposition = "000" + iHposition;
} else if (iHposition < 100) {
sHposition = "00" + iHposition;
} else if (iHposition < 1000) {
sHposition = "0" + iHposition;
}
// -------------
if (j == 0) {
sbToPrint.append(start).append("L"
+ vPosition
+ sHposition
+ "01111000");
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
} else {
sbToPrint.append(start).append("L"
+ vPrintPosition(verticalPosition)
+ sHposition
+ "01111000");
verticalPosition = verticalPosition + 33;
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
}
}
} else if (Global.PRINT_LABEL_CENTER_BOLD.equals(type)) {
String label = bean.getLabel();
// nilai sebenarnya 384, dikurangi aj bt jaga2 kalo slah perhtungan
Vector vt = FontSato.wrap(374, label.trim());
for (int j = 0; j < vt.size(); j++) {
SentencesSato setn = null;
try {
setn = (SentencesSato) vt.elementAt(j);
} catch (Exception e) {
FireCrash.log(e);
if (Global.IS_DEV) Log.i(TAG,"eato " + e);
}
// ------------- agar posisi bisa ditengah,
int iHposition = (384 - setn.getLenghtSentemce()) / 2;
String sHposition = "0";
if (iHposition < 10) {
sHposition = "000" + iHposition;
} else if (iHposition < 100) {
sHposition = "00" + iHposition;
} else if (iHposition < 1000) {
sHposition = "0" + iHposition;
}
// -------------
if (j == 0) {
sbToPrint.append(start).append("L"
+ vPosition
+ sHposition
+ "01111000");
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
} else {
sbToPrint.append(start).append("L"
+ vPrintPosition(verticalPosition)
+ sHposition
+ "01111000");
verticalPosition = verticalPosition + 33;
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
}
}
} else if (Global.PRINT_LABEL.equals(type) || Global.PRINT_LABEL_BOLD.equals(type)) {
String label = bean.getLabel();
// nilai sebenarnya 384, dikurangi aj bt jaga2 kalo slah perhtungan
Vector vt = FontSato.wrap(374, label.trim());
for (int j = 0; j < vt.size(); j++) {
SentencesSato setn = null;
try {
setn = (SentencesSato) vt.elementAt(j);
} catch (Exception e) {
FireCrash.log(e);
if (Global.IS_DEV) Log.i(TAG,"sato " + e);
}
if (j == 0) {
sbToPrint.append(start).append("L"
+ vPosition
+ "000101111000");
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
} else {
sbToPrint.append(start).append("L"
+ vPrintPosition(verticalPosition)
+ "000101111000");
verticalPosition = verticalPosition + 33;
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
}
}
} else if (Global.PRINT_ANSWER.equals(type)) {
String label = bean.getLabel();
String answer = bean.getValue();
if (answer != null && !answer.equals("")) {
if (label.equals("")
|| label == null
|| label.equals("null")) { // jika pertanyaan tidak ada labelnya maka posisi ditengahkan
// nilai sebenarnya 384, dikurangi aj bt jaga2 kalo slah perhtungan
Vector vt = FontSato.wrap(374, answer.trim());
for (int j = 0; j < vt.size(); j++) {
SentencesSato setn = null;
try {
setn = (SentencesSato) vt.elementAt(j);
} catch (Exception e) {
FireCrash.log(e);
if (Global.IS_DEV) Log.i(TAG, "sato " + e);
}
// ------------- agar posisi bisa ditengah,
int iHposition = (384 - setn.getLenghtSentemce()) / 2;
String sHposition = "0";
if (iHposition < 10) {
sHposition = "000" + iHposition;
} else if (iHposition < 100) {
sHposition = "00" + iHposition;
} else if (iHposition < 1000) {
sHposition = "0" + iHposition;
}
// -------------
if (j == 0) {
sbToPrint.append(start).append("L"
+ vPosition
+ sHposition
+ "01111000");
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
} else {
sbToPrint.append(start).append("L"
+ vPrintPosition(verticalPosition)
+ sHposition
+ "01111000");
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
verticalPosition = verticalPosition + 33;
}
}
} else {
sbToPrint.append(start).append("L"
+ vPosition
+ "000101111000");
sbToPrint.append(start).append("D" + label);
sbToPrint.append(start).append("L"
+ vPosition
+ "020001111000");
sbToPrint.append(start).append("D:");
Vector vt = FontSato.wrap(166, answer.trim()); // panjang area yang akan diprint
for (int j = 0; j < vt.size(); j++) {
SentencesSato setn = null;
try {
setn = (SentencesSato) vt.elementAt(j);
} catch (Exception e) {
FireCrash.log(e);
if (Global.IS_DEV) Log.i(TAG, "sato " + e);
}
if (j == 0) {
sbToPrint.append(start).append("L"
+ vPosition
+ "0208"
+ "01111000");
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
} else {
sbToPrint.append(start).append("L"
+ vPrintPosition(verticalPosition)
+ "0208"
+ "01111000");
verticalPosition = verticalPosition + 33;
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
}
}
}
} else {
verticalPosition = verticalPosition - 33;
}
} else if (Global.PRINT_USER_NAME.equals(type)) {
String label = bean.getLabel();
String answer = GlobalData.getSharedGlobalData().getUser().getFullname();
sbToPrint.append(start).append("L"
+ vPosition
+ "000101111000");
sbToPrint.append(start).append("D" + label);
sbToPrint.append(start).append("L"
+ vPosition
+ "020001111000");
sbToPrint.append(start).append("D:");
Vector vt = FontSato.wrap(166, answer.trim()); // panjang area yang akan diprint
for (int j = 0; j < vt.size(); j++) {
SentencesSato setn = null;
try {
setn = (SentencesSato) vt.elementAt(j);
} catch (Exception e) {
FireCrash.log(e);
if (Global.IS_DEV) Log.i(TAG, "sato " + e);
}
if (j == 0) {
sbToPrint.append(start).append("L"
+ vPosition
+ "0208"
+ "01111000");
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
} else {
sbToPrint.append(start).append("L"
+ vPrintPosition(verticalPosition)
+ "0208"
+ "01111000");
verticalPosition = verticalPosition + 33;
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
}
}
} else if (Global.PRINT_LOGIN_ID.equals(type)) {
String label = bean.getLabel();
String answer = GlobalData.getSharedGlobalData().getUser().getLogin_id();
sbToPrint.append(start).append("L"
+ vPosition
+ "000101111000");
sbToPrint.append(start).append("D" + label);
sbToPrint.append(start).append("L"
+ vPosition
+ "020001111000");
sbToPrint.append(start).append("D:");
Vector vt = FontSato.wrap(166, answer.trim()); // panjang area yang akan diprint
for (int j = 0; j < vt.size(); j++) {
SentencesSato setn = null;
try {
setn = (SentencesSato) vt.elementAt(j);
} catch (Exception e) {
FireCrash.log(e);
if (Global.IS_DEV) Log.i(TAG, "sato " + e);
}
if (j == 0) {
sbToPrint.append(start).append("L"
+ vPosition
+ "0208"
+ "01111000");
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
} else {
sbToPrint.append(start).append("L"
+ vPrintPosition(verticalPosition)
+ "0208"
+ "01111000");
verticalPosition = verticalPosition + 33;
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
}
}
} else if (Global.PRINT_BRANCH_NAME.equals(type) || Global.PRINT_BRANCH_ADDRESS.equals(type)) {
String label = bean.getLabel();
// nilai sebenarnya 384, dikurangi aj bt jaga2 kalo slah perhtungan
Vector vt = FontSato.wrap(374, label.trim());
for (int j = 0; j < vt.size(); j++) {
SentencesSato setn = null;
try {
setn = (SentencesSato) vt.elementAt(j);
} catch (Exception e) {
FireCrash.log(e);
if (Global.IS_DEV) Log.i(TAG,"eato " + e);
}
// ------------- agar posisi bisa ditengah,
int iHposition = (384 - setn.getLenghtSentemce()) / 2;
String sHposition = "0";
if (iHposition < 10) {
sHposition = "000" + iHposition;
} else if (iHposition < 100) {
sHposition = "00" + iHposition;
} else if (iHposition < 1000) {
sHposition = "0" + iHposition;
}
// -------------
if (j == 0) {
sbToPrint.append(start).append("L"
+ vPosition
+ sHposition
+ "01111000");
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
} else {
sbToPrint.append(start).append("L"
+ vPrintPosition(verticalPosition)
+ sHposition
+ "01111000");
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
verticalPosition = verticalPosition + 33;
}
}
} else if (Global.PRINT_BT_ID.equals(type)) {
String label = bean.getLabel();
String answer = bean.getValue();
sbToPrint.append(start).append("L"
+ vPosition
+ "000101111000");
sbToPrint.append(start).append("D" + label);
sbToPrint.append(start).append("L"
+ vPosition
+ "020001111000");
sbToPrint.append(start).append("D:");
Vector vt;
vt = FontSato.wrap(166, answer.trim()); // panjang area yang akan diprint
for (int j = 0; j < vt.size(); j++) {
SentencesSato setn = null;
try {
setn = (SentencesSato) vt.elementAt(j);
} catch (Exception e) {
FireCrash.log(e);
if (Global.IS_DEV) Log.i(TAG, "sato " + e);
}
if (j == 0) {
sbToPrint.append(start).append("L"
+ vPosition
+ "0208"
+ "01111000");
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
} else {
sbToPrint.append(start).append("L"
+ vPrintPosition(verticalPosition)
+ "0208"
+ "01111000");
verticalPosition = verticalPosition + 33;
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
}
}
} else if (Global.PRINT_TIMESTAMP.equals(type)) {
SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy hh:mm");
Date date = new Date();
String answer = df.format(date);
String label = bean.getLabel();
sbToPrint.append(start).append("L"
+ vPosition
+ "000101111000");
sbToPrint.append(start).append("D" + label);
sbToPrint.append(start).append("L"
+ vPosition
+ "020001111000");
sbToPrint.append(start).append("D:");
Vector vt;
vt = FontSato.wrap(166, answer.trim()); // panjang area yang akan diprint
for (int j = 0; j < vt.size(); j++) {
SentencesSato setn = null;
try {
setn = (SentencesSato) vt.elementAt(j);
} catch (Exception e) {
FireCrash.log(e);
if (Global.IS_DEV) Log.i(TAG, "sato " + e);
}
if (j == 0) {
sbToPrint.append(start).append("L"
+ vPosition
+ "0208"
+ "01111000");
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
} else {
sbToPrint.append(start).append("L"
+ vPrintPosition(verticalPosition)
+ "0208"
+ "01111000");
verticalPosition = verticalPosition + 33;
sbToPrint.append(start).append("D"
+ setn.getSentence().trim());
}
}
}
}
// ENDING LINE
verticalPosition = verticalPosition + 33;
sbToPrint.append(start).append(
"L" + vPrintPosition(verticalPosition) + "000101222000");
verticalPosition = verticalPosition + 33;
sbToPrint.append(start).append("D----------------");
sbToPrint.append(start).append("Q0001").append(start).append("Z");
sbToPrint.append(end);
return sbToPrint.toString();
}
public String vPrintPosition(int verticalPosition) {
String vPosition = "";
if ((verticalPosition + 33) < 100) {
verticalPosition = verticalPosition + 33;
vPosition = "00" + verticalPosition;
} else if ((verticalPosition + 33) < 1000) {
verticalPosition = verticalPosition + 33;
vPosition = "0" + verticalPosition;
} else {
vPosition = "" + verticalPosition;
verticalPosition = verticalPosition + 33;
}
return vPosition;
}
public class PrinterConnect extends AsyncTask<Void, Void, Boolean> {
String selectedPrinter;
BluetoothDevice inDevice;
public PrinterConnect() {
}
public PrinterConnect(BluetoothDevice inDevice) {
this.inDevice = inDevice;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
if (listener != null) {
listener.onConnecting();
}
}
@Override
protected Boolean doInBackground(Void... params) {
if (inDevice == null) {
if (pairedDevices != null && !pairedDevices.isEmpty()) {
List<BluetoothDevice> pairedPrinters = new ArrayList<>();
if (lastPrinterConnected != null && !lastPrinterConnected.isEmpty()) {
for (BluetoothDevice device : pairedDevices) {
if (device.getAddress().equals(lastPrinterConnected))
pairedPrinters.add(0, device);
else
pairedPrinters.add(device);
}
} else {
pairedPrinters.addAll(pairedDevices);
}
for (BluetoothDevice device : pairedPrinters) {
if (device != null) {
Logger.d("Device Address : ", device.getAddress() + ", Device Name : " + device.getName());
BluePrintDriver.close();
if (!BluePrintDriver.OpenPrinter(device.getAddress())) {
BluePrintDriver.close();
} else {
deviceName = device.getName() == null ? device.getAddress() : device.getName();
selectedPrinter = device.getAddress();
return true;
}
}
}
}
return false;
} else {
Logger.d("Device Address : ", inDevice.getAddress() + ", Device Name : " + inDevice.getName());
BluePrintDriver.close();
if (!BluePrintDriver.OpenPrinter(inDevice.getAddress())) {
BluePrintDriver.close();
} else {
deviceName = inDevice.getName() == null ? inDevice.getAddress() : inDevice.getName();
selectedPrinter = inDevice.getAddress();
return true;
}
return false;
}
}
@Override
protected void onPostExecute(Boolean aBoolean) {
super.onPostExecute(aBoolean);
if (Boolean.TRUE.equals(aBoolean)) {
connected = true;
if (listener != null) {
listener.onConnected(deviceName);
}
if (selectedPrinter != null && !selectedPrinter.isEmpty()) {
ObscuredSharedPreferences preferences = ObscuredSharedPreferences.getPrefs(context, PRINT_PREFERENCES, Context.MODE_PRIVATE);
ObscuredSharedPreferences.Editor sharedPrefEditor = preferences.edit();
sharedPrefEditor.putString(PRINTER_KEY, selectedPrinter);
sharedPrefEditor.commit();
lastPrinterConnected = selectedPrinter;
}
} else {
Toast.makeText(context, context.getString(R.string.no_paired_device), Toast.LENGTH_SHORT).show();
connected = false;
if (listener != null) {
listener.onConnectFailed();
}
}
}
}
// Nendi: 2019.06.20
// Resize bitmap for printing
private void printBitmapSzzcs(Bitmap bitmap) {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
ArrayList arrayList = new ArrayList();
byte[] obj = new byte[4];
obj[0] = (byte) 29;
obj[1] = (byte) 118;
obj[2] = (byte) 48;
arrayList.add(obj);
int i = (width % 8 == 0 ? width / 8 : (width / 8) + 1) % 256;
int i2 = (width % 8 == 0 ? width / 8 : (width / 8) + 1) / 256;
int i3 = height % 256;
int i4 = height / 256;
arrayList.add(new byte[]{(byte) i, (byte) i2, (byte) i3, (byte) i4});
int i5 = width % 8;
StringBuilder stringBuffer = new StringBuilder();
if (i5 > 0) {
for (i2 = 0; i2 < 8 - i5; i2++) {
stringBuffer.append("0");
}
}
StringBuilder stringBuffer2 = new StringBuilder();
for (i3 = 0; i3 < height; i3++) {
i = 0;
stringBuffer2.setLength(0);
byte[] obj2 = new byte[(i5 == 0 ? width / 8 : (width / 8) + 1)];
i4 = 0;
while (i4 < width) {
i2 = bitmap.getPixel(i4, i3);
int i6 = (i2 >> 16) & MotionEventCompat.ACTION_MASK;
int i7 = (i2 >> 8) & MotionEventCompat.ACTION_MASK;
i2 &= MotionEventCompat.ACTION_MASK;
if (i6 > 200 || i7 > 200 || i2 > 200) {
stringBuffer2.append("0");
} else {
stringBuffer2.append("1");
}
if (stringBuffer2.length() == 8) {
i2 = i + 1;
obj2[i] = (byte) Integer.parseInt(stringBuffer2.toString(), 2);
stringBuffer2.setLength(0);
} else {
i2 = i;
}
i4++;
i = i2;
}
if (i5 > 0) {
stringBuffer2.append(stringBuffer);
obj2[i] = (byte) Integer.parseInt(stringBuffer2.toString(), 2);
}
arrayList.add(obj2);
}
BluePrintDriver.printByteData(printBitmapSzzcs(arrayList));
}
// Nendi: 2019.06.20
// Get bytes for image printing
private static byte[] printBitmapSzzcs(List<byte[]> list) {
int i = 0;
for (byte[] length : list) {
i = length.length + i;
}
byte[] obj = new byte[i];
i = 0;
for (byte[] length2 : list) {
System.arraycopy(length2, 0, obj, i, length2.length);
i = length2.length + i;
}
String str = "BTPrinter";
StringBuilder stringBuilder = new StringBuilder("");
for (byte b : obj) {
String toHexString = Integer.toHexString(b & MotionEventCompat.ACTION_MASK);
if (toHexString.length() < 2) {
stringBuilder.append(0);
}
stringBuilder.append(toHexString);
}
Log.e(str, stringBuilder.toString());
return obj;
}
}

View file

@ -0,0 +1,48 @@
package com.adins.mss.dummy.userhelp_dummy.Adapter;
import android.app.Activity;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.adins.mss.base.R;
import com.adins.mss.base.timeline.NewTimelineFragment;
import com.adins.mss.dummy.userhelp_dummy.UserHelpGeneralDummy;
public class TimelineDummyAdapter extends RecyclerView.Adapter<TimelineDummyAdapter.DummyViewHolder> {
RecyclerView rv;
NewTimelineFragment activity;
public TimelineDummyAdapter(NewTimelineFragment activity, RecyclerView rv) {
this.rv = rv;
this.activity = activity;
}
@NonNull
@Override
public DummyViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.dummy_userhelp_timeline_item, viewGroup, false);
DummyViewHolder viewHolder = new DummyViewHolder (v);
UserHelpGeneralDummy userHelpGeneralDummy = new UserHelpGeneralDummy();
userHelpGeneralDummy.showDummyTimeline(activity.getActivity(), activity.getClass().getSimpleName(), rv, activity);
return viewHolder;
}
@Override
public void onBindViewHolder(@NonNull DummyViewHolder dummyViewHolder, int i) {
}
@Override
public int getItemCount() {
return 1;
}
public class DummyViewHolder extends RecyclerView.ViewHolder {
public DummyViewHolder(@NonNull View itemView) {
super(itemView);
}
}
}

View file

@ -0,0 +1,356 @@
package com.adins.mss.dao;
import java.util.List;
import java.util.ArrayList;
import android.database.Cursor;
import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.SqlUtils;
import de.greenrobot.dao.internal.DaoConfig;
import de.greenrobot.dao.database.Database;
import de.greenrobot.dao.database.DatabaseStatement;
import de.greenrobot.dao.query.Query;
import de.greenrobot.dao.query.QueryBuilder;
import com.adins.mss.dao.LocationInfo;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "TR_LOCATION".
*/
public class LocationInfoDao extends AbstractDao<LocationInfo, String> {
public static final String TABLENAME = "TR_LOCATION";
/**
* Properties of entity LocationInfo.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Uuid_location_info = new Property(0, String.class, "uuid_location_info", true, "UUID_LOCATION_INFO");
public final static Property Latitude = new Property(1, String.class, "latitude", false, "LATITUDE");
public final static Property Longitude = new Property(2, String.class, "longitude", false, "LONGITUDE");
public final static Property Mcc = new Property(3, String.class, "mcc", false, "MCC");
public final static Property Mnc = new Property(4, String.class, "mnc", false, "MNC");
public final static Property Lac = new Property(5, String.class, "lac", false, "LAC");
public final static Property Cid = new Property(6, String.class, "cid", false, "CID");
public final static Property Handset_time = new Property(7, java.util.Date.class, "handset_time", false, "HANDSET_TIME");
public final static Property Mode = new Property(8, String.class, "mode", false, "MODE");
public final static Property Accuracy = new Property(9, Integer.class, "accuracy", false, "ACCURACY");
public final static Property Gps_time = new Property(10, java.util.Date.class, "gps_time", false, "GPS_TIME");
public final static Property Is_gps_time = new Property(11, String.class, "is_gps_time", false, "IS_GPS_TIME");
public final static Property Usr_crt = new Property(12, String.class, "usr_crt", false, "USR_CRT");
public final static Property Dtm_crt = new Property(13, java.util.Date.class, "dtm_crt", false, "DTM_CRT");
public final static Property Location_type = new Property(14, String.class, "location_type", false, "LOCATION_TYPE");
public final static Property Uuid_user = new Property(15, String.class, "uuid_user", false, "UUID_USER");
};
private DaoSession daoSession;
private Query<LocationInfo> user_LocationInfoListQuery;
public LocationInfoDao(DaoConfig config) {
super(config);
}
public LocationInfoDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
this.daoSession = daoSession;
}
/** Creates the underlying database table. */
public static void createTable(Database db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"TR_LOCATION\" (" + //
"\"UUID_LOCATION_INFO\" TEXT PRIMARY KEY NOT NULL ," + // 0: uuid_location_info
"\"LATITUDE\" TEXT," + // 1: latitude
"\"LONGITUDE\" TEXT," + // 2: longitude
"\"MCC\" TEXT," + // 3: mcc
"\"MNC\" TEXT," + // 4: mnc
"\"LAC\" TEXT," + // 5: lac
"\"CID\" TEXT," + // 6: cid
"\"HANDSET_TIME\" INTEGER," + // 7: handset_time
"\"MODE\" TEXT," + // 8: mode
"\"ACCURACY\" INTEGER," + // 9: accuracy
"\"GPS_TIME\" INTEGER," + // 10: gps_time
"\"IS_GPS_TIME\" TEXT," + // 11: is_gps_time
"\"USR_CRT\" TEXT," + // 12: usr_crt
"\"DTM_CRT\" INTEGER," + // 13: dtm_crt
"\"LOCATION_TYPE\" TEXT," + // 14: location_type
"\"UUID_USER\" TEXT);"); // 15: uuid_user
}
/** Drops the underlying database table. */
public static void dropTable(Database db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"TR_LOCATION\"";
db.execSQL(sql);
}
/** @inheritdoc */
@Override
protected void bindValues(DatabaseStatement stmt, LocationInfo entity) {
stmt.clearBindings();
stmt.bindString(1, entity.getUuid_location_info());
String latitude = entity.getLatitude();
if (latitude != null) {
stmt.bindString(2, latitude);
}
String longitude = entity.getLongitude();
if (longitude != null) {
stmt.bindString(3, longitude);
}
String mcc = entity.getMcc();
if (mcc != null) {
stmt.bindString(4, mcc);
}
String mnc = entity.getMnc();
if (mnc != null) {
stmt.bindString(5, mnc);
}
String lac = entity.getLac();
if (lac != null) {
stmt.bindString(6, lac);
}
String cid = entity.getCid();
if (cid != null) {
stmt.bindString(7, cid);
}
java.util.Date handset_time = entity.getHandset_time();
if (handset_time != null) {
stmt.bindLong(8, handset_time.getTime());
}
String mode = entity.getMode();
if (mode != null) {
stmt.bindString(9, mode);
}
Integer accuracy = entity.getAccuracy();
if (accuracy != null) {
stmt.bindLong(10, accuracy);
}
java.util.Date gps_time = entity.getGps_time();
if (gps_time != null) {
stmt.bindLong(11, gps_time.getTime());
}
String is_gps_time = entity.getIs_gps_time();
if (is_gps_time != null) {
stmt.bindString(12, is_gps_time);
}
String usr_crt = entity.getUsr_crt();
if (usr_crt != null) {
stmt.bindString(13, usr_crt);
}
java.util.Date dtm_crt = entity.getDtm_crt();
if (dtm_crt != null) {
stmt.bindLong(14, dtm_crt.getTime());
}
String location_type = entity.getLocation_type();
if (location_type != null) {
stmt.bindString(15, location_type);
}
String uuid_user = entity.getUuid_user();
if (uuid_user != null) {
stmt.bindString(16, uuid_user);
}
}
@Override
protected void attachEntity(LocationInfo entity) {
super.attachEntity(entity);
entity.__setDaoSession(daoSession);
}
/** @inheritdoc */
@Override
public String readKey(Cursor cursor, int offset) {
return cursor.getString(offset + 0);
}
/** @inheritdoc */
@Override
public LocationInfo readEntity(Cursor cursor, int offset) {
LocationInfo entity = new LocationInfo( //
cursor.getString(offset + 0), // uuid_location_info
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // latitude
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // longitude
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // mcc
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // mnc
cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // lac
cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // cid
cursor.isNull(offset + 7) ? null : new java.util.Date(cursor.getLong(offset + 7)), // handset_time
cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // mode
cursor.isNull(offset + 9) ? null : cursor.getInt(offset + 9), // accuracy
cursor.isNull(offset + 10) ? null : new java.util.Date(cursor.getLong(offset + 10)), // gps_time
cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // is_gps_time
cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // usr_crt
cursor.isNull(offset + 13) ? null : new java.util.Date(cursor.getLong(offset + 13)), // dtm_crt
cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // location_type
cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15) // uuid_user
);
return entity;
}
/** @inheritdoc */
@Override
public void readEntity(Cursor cursor, LocationInfo entity, int offset) {
entity.setUuid_location_info(cursor.getString(offset + 0));
entity.setLatitude(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
entity.setLongitude(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
entity.setMcc(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
entity.setMnc(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
entity.setLac(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
entity.setCid(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
entity.setHandset_time(cursor.isNull(offset + 7) ? null : new java.util.Date(cursor.getLong(offset + 7)));
entity.setMode(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
entity.setAccuracy(cursor.isNull(offset + 9) ? null : cursor.getInt(offset + 9));
entity.setGps_time(cursor.isNull(offset + 10) ? null : new java.util.Date(cursor.getLong(offset + 10)));
entity.setIs_gps_time(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
entity.setUsr_crt(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12));
entity.setDtm_crt(cursor.isNull(offset + 13) ? null : new java.util.Date(cursor.getLong(offset + 13)));
entity.setLocation_type(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14));
entity.setUuid_user(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15));
}
/** @inheritdoc */
@Override
protected String updateKeyAfterInsert(LocationInfo entity, long rowId) {
return entity.getUuid_location_info();
}
/** @inheritdoc */
@Override
public String getKey(LocationInfo entity) {
if(entity != null) {
return entity.getUuid_location_info();
} else {
return null;
}
}
/** @inheritdoc */
@Override
protected boolean isEntityUpdateable() {
return true;
}
/** Internal query to resolve the "locationInfoList" to-many relationship of User. */
public List<LocationInfo> _queryUser_LocationInfoList(String uuid_user) {
synchronized (this) {
if (user_LocationInfoListQuery == null) {
QueryBuilder<LocationInfo> queryBuilder = queryBuilder();
queryBuilder.where(Properties.Uuid_user.eq(null));
user_LocationInfoListQuery = queryBuilder.build();
}
}
Query<LocationInfo> query = user_LocationInfoListQuery.forCurrentThread();
query.setParameter(0, uuid_user);
return query.list();
}
private String selectDeep;
protected String getSelectDeep() {
if (selectDeep == null) {
StringBuilder builder = new StringBuilder("SELECT ");
SqlUtils.appendColumns(builder, "T", getAllColumns());
builder.append(',');
SqlUtils.appendColumns(builder, "T0", daoSession.getUserDao().getAllColumns());
builder.append(" FROM TR_LOCATION T");
builder.append(" LEFT JOIN MS_USER T0 ON T.\"UUID_USER\"=T0.\"UUID_USER\"");
builder.append(' ');
selectDeep = builder.toString();
}
return selectDeep;
}
protected LocationInfo loadCurrentDeep(Cursor cursor, boolean lock) {
LocationInfo entity = loadCurrent(cursor, 0, lock);
int offset = getAllColumns().length;
User user = loadCurrentOther(daoSession.getUserDao(), cursor, offset);
entity.setUser(user);
return entity;
}
public LocationInfo loadDeep(Long key) {
assertSinglePk();
if (key == null) {
return null;
}
StringBuilder builder = new StringBuilder(getSelectDeep());
builder.append("WHERE ");
SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
String sql = builder.toString();
String[] keyArray = new String[] { key.toString() };
Cursor cursor = db.rawQuery(sql, keyArray);
try {
boolean available = cursor.moveToFirst();
if (!available) {
return null;
} else if (!cursor.isLast()) {
throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
}
return loadCurrentDeep(cursor, true);
} finally {
cursor.close();
}
}
/** Reads all available rows from the given cursor and returns a list of new ImageTO objects. */
public List<LocationInfo> loadAllDeepFromCursor(Cursor cursor) {
int count = cursor.getCount();
List<LocationInfo> list = new ArrayList<LocationInfo>(count);
if (cursor.moveToFirst()) {
if (identityScope != null) {
identityScope.lock();
identityScope.reserveRoom(count);
}
try {
do {
list.add(loadCurrentDeep(cursor, false));
} while (cursor.moveToNext());
} finally {
if (identityScope != null) {
identityScope.unlock();
}
}
}
return list;
}
protected List<LocationInfo> loadDeepAllAndCloseCursor(Cursor cursor) {
try {
return loadAllDeepFromCursor(cursor);
} finally {
cursor.close();
}
}
/** A raw-style query where you can pass any WHERE clause and arguments. */
public List<LocationInfo> queryDeep(String where, String... selectionArg) {
Cursor cursor = db.rawQuery(getSelectDeep() + where, selectionArg);
return loadDeepAllAndCloseCursor(cursor);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 KiB

View file

@ -0,0 +1,95 @@
<?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="wrap_content"
android:orientation="vertical"
android:layout_margin="@dimen/line_height"
android:background="@drawable/spinner_background" >
<TextView
android:id="@+id/txtTaskID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dummy_task_id"
android:textColor="@color/tv_white"
android:layout_gravity="center_horizontal"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
<ImageView
android:id="@+id/imgStatus"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_schema"
android:layout_gravity="center_horizontal" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/txtName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:text="@string/dummy_header_name_2"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/tv_white" />
<TextView
android:id="@+id/txtDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:lines="1"
android:text="@string/dummy_date"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/tv_white" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal" >
<TextView
android:id="@+id/txtStatusTask"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dummy_status_task"
android:visibility="gone"
android:textColor="@color/tv_white"
android:textSize="10dp" />
<TextView
android:id="@+id/txtScheme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textColor="@color/tv_white"
android:minLines="2"
android:gravity="center_horizontal"
android:layout_gravity="center_horizontal"
android:text="@string/dummy_scheme_name"
android:textSize="10dp" />
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,169 @@
package com.adins.mss.foundation.db.dataaccess;
import android.content.Context;
import com.adins.mss.dao.DaoSession;
import com.adins.mss.dao.PaymentHistoryD;
import com.adins.mss.dao.PaymentHistoryDDao;
import com.adins.mss.foundation.db.DaoOpenHelper;
import java.util.Collections;
import java.util.List;
import de.greenrobot.dao.query.QueryBuilder;
public class PaymentHistoryDDataAccess {
private PaymentHistoryDDataAccess() {
}
/**
* use to generate dao session that you can access modelDao
*
* @param context --> context from activity
* @return
*/
protected static DaoSession getDaoSession(Context context) {
return DaoOpenHelper.getDaoSession(context);
}
/**
* get paymentHistory dao and you can access the DB
*
* @param context
* @return
*/
protected static PaymentHistoryDDao getPaymentHistoryDao(Context context) {
return getDaoSession(context).getPaymentHistoryDDao();
}
/**
* Clear session, close db and set daoOpenHelper to null
*/
public static void closeAll() {
DaoOpenHelper.closeAll();
}
/**
* add paymentHistory as entity
*
* @param context
* @param PaymentHistoryD
*/
public static void add(Context context, PaymentHistoryD PaymentHistoryD) {
getPaymentHistoryDao(context).insert(PaymentHistoryD);
getDaoSession(context).clear();
}
/**
* add paymentHistory as list entity
*
* @param context
* @param PaymentHistoryDList
*/
public static void add(Context context, List<PaymentHistoryD> PaymentHistoryDList) {
getPaymentHistoryDao(context).insertInTx(PaymentHistoryDList);
getDaoSession(context).clear();
}
public static void addOrReplace(Context context, PaymentHistoryD paymentHistoryD) {
getPaymentHistoryDao(context).insertOrReplaceInTx(paymentHistoryD);
getDaoSession(context).clear();
}
public static void addOrReplace(Context context, List<PaymentHistoryD> paymentHistoryDList) {
getPaymentHistoryDao(context).insertOrReplaceInTx(paymentHistoryDList);
getDaoSession(context).clear();
}
public static void update(Context context, PaymentHistoryD paymentHistoryD) {
getPaymentHistoryDao(context).updateInTx(paymentHistoryD);
getDaoSession(context).clear();
}
/**
* delete all content in table.
*
* @param context
*/
public static void clean(Context context) {
getPaymentHistoryDao(context).deleteAll();
getDaoSession(context).clear();
}
/**
* @param context
* @param PaymentHistoryD
*/
public static void delete(Context context, PaymentHistoryD PaymentHistoryD) {
getPaymentHistoryDao(context).deleteInTx(PaymentHistoryD);
getDaoSession(context).clear();
}
/**
* delete all record by user
*
* @param context
* @param uuidTaskH
*/
public static void delete(Context context, String uuidTaskH) {
QueryBuilder<PaymentHistoryD> qb = getPaymentHistoryDao(context).queryBuilder();
qb.where(PaymentHistoryDDao.Properties.Uuid_task_h.eq(uuidTaskH));
qb.build();
if (!qb.list().isEmpty()) {
getPaymentHistoryDao(context).deleteInTx(qb.list());
}
getDaoSession(context).clear();
}
/**
* @param context
* @param PaymentHistoryD
*/
public static void updatePaymentHistory(Context context, PaymentHistoryD PaymentHistoryD) {
getPaymentHistoryDao(context).update(PaymentHistoryD);
getDaoSession(context).clear();
}
/**
* get all data by uuidTaskH
*
* @param context
* @param uuidTaskH
* @return
*/
public static List<PaymentHistoryD> getAll(Context context, String uuidTaskH) {
QueryBuilder<PaymentHistoryD> qb = getPaymentHistoryDao(context).queryBuilder();
qb.where(PaymentHistoryDDao.Properties.Uuid_task_h.eq(uuidTaskH));
qb.build();
if (!qb.list().isEmpty()) {
return qb.list();
} else return Collections.emptyList();
}
public static List<PaymentHistoryD> getAllByHistoryH(Context context, String uuidPaymentHistoryH) {
QueryBuilder<PaymentHistoryD> qb = getPaymentHistoryDao(context).queryBuilder();
qb.where(PaymentHistoryDDao.Properties.Uuid_payment_history_h.eq(uuidPaymentHistoryH));
qb.build();
if (!qb.list().isEmpty()) {
return qb.list();
} else return Collections.emptyList();
}
public static PaymentHistoryD getOne(Context context, String uuid_task_h) {
QueryBuilder<PaymentHistoryD> qb = getPaymentHistoryDao(context).queryBuilder();
qb.where(PaymentHistoryDDao.Properties.Uuid_task_h.eq(uuid_task_h));
qb.build();
if (qb.list().isEmpty())
return null;
return qb.list().get(0);
}
public static PaymentHistoryD getOneHistory(Context context, String uuidHistoryD) {
QueryBuilder<PaymentHistoryD> qb = getPaymentHistoryDao(context).queryBuilder();
qb.where(PaymentHistoryDDao.Properties.Uuid_payment_history_d.eq(uuidHistoryD));
qb.build();
if (qb.list().isEmpty())
return null;
return qb.list().get(0);
}
}