|
@@ -10,14 +10,6 @@ import android.widget.TextView
|
|
|
import android.widget.Toast
|
|
|
import androidx.annotation.LayoutRes
|
|
|
import androidx.fragment.app.Fragment
|
|
|
-import com.cocking.fight.screen.dialogfragment.StatementDialogViewModel
|
|
|
-import com.mazenrashed.printooth.Printooth
|
|
|
-import com.mazenrashed.printooth.data.printable.Printable
|
|
|
-import com.mazenrashed.printooth.data.printable.TextPrintable
|
|
|
-import com.mazenrashed.printooth.data.printer.DefaultPrinter
|
|
|
-import com.mazenrashed.printooth.utilities.Printing
|
|
|
-import com.sambath.sbc.app.App
|
|
|
-import com.sambath.sbc.app.ShareActivity
|
|
|
import com.sambath.sbc.remote.LottoSet
|
|
|
import com.sambath.sbc.remote.ReportOne
|
|
|
import com.sambath.sbc.remote.User
|
|
@@ -31,21 +23,21 @@ abstract class BaseFragment(
|
|
|
@LayoutRes private val layoutRes: Int
|
|
|
) : Fragment() {
|
|
|
private lateinit var user: User
|
|
|
- private var printing: Printing? = null
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
super.onCreate(savedInstanceState)
|
|
|
- if (Printooth.hasPairedPrinter()) printing = Printooth.printer()
|
|
|
user = ModelPreferencesManager.get<User>(Const.USER_KEY)!!
|
|
|
}
|
|
|
|
|
|
- fun currencyType() : String{
|
|
|
+ fun currencyType(): String {
|
|
|
when (user.currencyType) {
|
|
|
1 -> {//dollar
|
|
|
return "$"
|
|
|
}
|
|
|
+
|
|
|
2 -> {//riel
|
|
|
return "៛"
|
|
|
}
|
|
|
+
|
|
|
3 -> {//baht
|
|
|
return "฿"
|
|
|
}
|
|
@@ -54,9 +46,7 @@ abstract class BaseFragment(
|
|
|
}
|
|
|
|
|
|
override fun onCreateView(
|
|
|
- inflater: LayoutInflater,
|
|
|
- container: ViewGroup?,
|
|
|
- savedInstanceState: Bundle?
|
|
|
+ inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
|
|
): View? {
|
|
|
return inflater.inflate(layoutRes, container, false)
|
|
|
}
|
|
@@ -99,431 +89,6 @@ abstract class BaseFragment(
|
|
|
|
|
|
}
|
|
|
|
|
|
- fun printSomePrintable(
|
|
|
- userName: String,
|
|
|
- ticketID: String,
|
|
|
- gameID: String,
|
|
|
- betDate: String,
|
|
|
- betType: String,
|
|
|
- betCast: String,
|
|
|
- winLose: String
|
|
|
- ) {
|
|
|
- if (Printooth.hasPairedPrinter() && printing == null) printing = Printooth.printer()
|
|
|
- if (printing == null) {
|
|
|
- Toast.makeText(requireContext(), "No printing paired", Toast.LENGTH_SHORT).show()
|
|
|
- } else {
|
|
|
- val printables =
|
|
|
- getSomePrintables(userName, ticketID, gameID, betDate, betType, betCast, winLose)
|
|
|
- printing?.print(printables)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private fun getSomePrintables(
|
|
|
- userName: String,
|
|
|
- ticketID: String,
|
|
|
- gameID: String,
|
|
|
- betDate: String,
|
|
|
- betType: String,
|
|
|
- betCast: String,
|
|
|
- winLose: String
|
|
|
- ) = ArrayList<Printable>().apply {
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText(userName)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setAlignment(DefaultPrinter.ALIGNMENT_CENTER)
|
|
|
- .setLineSpacing(DefaultPrinter.LINE_SPACING_30)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .build()
|
|
|
- )
|
|
|
-
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("----------------")
|
|
|
- .setLineSpacing(DefaultPrinter.LINE_SPACING_30)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC1252)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Ticket ID: $ticketID")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Game ID : $gameID")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
-
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Date : $betDate")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
-
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Bet Type : $betType")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
-
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Bet Point: $betCast")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Win/Lose : $winLose")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("----------------")
|
|
|
- .setLineSpacing(DefaultPrinter.LINE_SPACING_30)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("www.wa855.net")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setAlignment(DefaultPrinter.ALIGNMENT_CENTER)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC437)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- fun printCfPrintable(
|
|
|
- userName: String,
|
|
|
- fightNo: String,
|
|
|
- betDate: String,
|
|
|
- betType: String,
|
|
|
- amount: String,
|
|
|
- payout: String
|
|
|
- ) {
|
|
|
- if (Printooth.hasPairedPrinter() && printing == null) printing = Printooth.printer()
|
|
|
- if (printing == null) {
|
|
|
- Toast.makeText(requireContext(), "No printing paired", Toast.LENGTH_SHORT).show()
|
|
|
- } else {
|
|
|
- printing?.print(getCfPrintables(userName, fightNo, betDate, betType, amount, payout))
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- fun printCfPrintable(
|
|
|
- user: User,
|
|
|
- fightNo: String,
|
|
|
- betDate: String,
|
|
|
- betType: String,
|
|
|
- amount: String,
|
|
|
- payoutRate: String,
|
|
|
- payout: String,
|
|
|
- id: String,
|
|
|
- channelId: Int
|
|
|
- ) {
|
|
|
- if (Printooth.hasPairedPrinter() && printing == null) printing = Printooth.printer()
|
|
|
- if (printing == null) {
|
|
|
- Toast.makeText(requireContext(), "No printing paired", Toast.LENGTH_SHORT).show()
|
|
|
- } else {
|
|
|
- var currencyType: String = ""
|
|
|
- when (user.currencyType) {
|
|
|
- 1 -> {
|
|
|
- currencyType = "Dollar"
|
|
|
- }
|
|
|
- 2 -> {
|
|
|
- currencyType = "Riel"
|
|
|
- }
|
|
|
- 3 -> {
|
|
|
- currencyType = "Baht"
|
|
|
- }
|
|
|
- }
|
|
|
- printing?.print(
|
|
|
- getCfPrintables(
|
|
|
- user.userName,
|
|
|
- currencyType,
|
|
|
- fightNo,
|
|
|
- betDate,
|
|
|
- betType,
|
|
|
- amount,
|
|
|
- payoutRate,
|
|
|
- payout,
|
|
|
- id,
|
|
|
- channelId
|
|
|
- )
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private fun getCfPrintables(
|
|
|
- userName: String,
|
|
|
- currencyType: String,
|
|
|
- fightNo: String,
|
|
|
- betDate: String,
|
|
|
- betType: String,
|
|
|
- amount: String,
|
|
|
- payoutRate: String,
|
|
|
- payout: String,
|
|
|
- id: String,
|
|
|
- channelId: Int
|
|
|
- ) = ArrayList<Printable>().apply {
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("SBC2888")
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setAlignment(DefaultPrinter.ALIGNMENT_CENTER)
|
|
|
- .setLineSpacing(DefaultPrinter.LINE_SPACING_30)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Channel : $channelId")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Bet ID : ${id}")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("----------------")
|
|
|
- .setLineSpacing(DefaultPrinter.LINE_SPACING_30)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC1252)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Fight No : $fightNo")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Account:")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText(userName)
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setAlignment(DefaultPrinter.ALIGNMENT_CENTER)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Bet Type : $betType")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Date : $betDate")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
-// add(
|
|
|
-// TextPrintable.Builder()
|
|
|
-// .setText("Bet Point")
|
|
|
-// .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
-// .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
-// .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
-// .setNewLinesAfter(1)
|
|
|
-// .build()
|
|
|
-// )
|
|
|
-// add(
|
|
|
-// TextPrintable.Builder()
|
|
|
-// .setText("$amount x $payoutRate")
|
|
|
-// .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
-// .setAlignment(DefaultPrinter.ALIGNMENT_CENTER)
|
|
|
-// .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
-// .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
-// .setNewLinesAfter(1)
|
|
|
-// .build()
|
|
|
-// )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Currency Type : $currencyType")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Bet point : $payout")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("----------------")
|
|
|
- .setLineSpacing(DefaultPrinter.LINE_SPACING_30)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("www.wa855.net")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setAlignment(DefaultPrinter.ALIGNMENT_CENTER)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC437)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- private fun getCfPrintables(
|
|
|
- userName: String,
|
|
|
- fightNo: String,
|
|
|
- betDate: String,
|
|
|
- betType: String,
|
|
|
- amount: String,
|
|
|
- payout: String
|
|
|
- ) = ArrayList<Printable>().apply {
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("SBC2888")
|
|
|
- .setUnderlined(DefaultPrinter.UNDERLINED_MODE_ON)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setAlignment(DefaultPrinter.ALIGNMENT_CENTER)
|
|
|
- .setLineSpacing(DefaultPrinter.LINE_SPACING_30)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("----------------")
|
|
|
- .setLineSpacing(DefaultPrinter.LINE_SPACING_10)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC1252)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Round : $fightNo")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Date : $betDate")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Account: $userName")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Type : $betType")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Bet x Odds:")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("$amount x $payout")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setAlignment(DefaultPrinter.ALIGNMENT_CENTER)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Payout : $amount")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("----------------")
|
|
|
- .setLineSpacing(DefaultPrinter.LINE_SPACING_10)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("www.wa855.net")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setAlignment(DefaultPrinter.ALIGNMENT_CENTER)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC437)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
private fun getLastFourChars(str: String, n: Int): String {
|
|
|
var lastChars = str
|
|
|
if (lastChars.length > n) {
|
|
@@ -531,185 +96,4 @@ abstract class BaseFragment(
|
|
|
}
|
|
|
return lastChars
|
|
|
}
|
|
|
-
|
|
|
- fun printSBCPrintable(reportOne: ReportOne, currencyType: Int, channelId: Int) {
|
|
|
- if (Printooth.hasPairedPrinter() && printing == null) printing = Printooth.printer()
|
|
|
- if (printing == null) {
|
|
|
- Toast.makeText(requireContext(), "No printing paired", Toast.LENGTH_SHORT).show()
|
|
|
- } else {
|
|
|
- var winOrLose: String = ""
|
|
|
- var sign: String = ""
|
|
|
- winOrLose = if (reportOne.is_win == true) {
|
|
|
- "WIN"
|
|
|
- } else {
|
|
|
- "LOSE"
|
|
|
- }
|
|
|
- when (currencyType) {
|
|
|
- 1 -> {
|
|
|
- sign = "Dollar"
|
|
|
- }
|
|
|
- 2 -> {
|
|
|
- sign = "Riel"
|
|
|
- }
|
|
|
- 3 -> {
|
|
|
- sign = "Baht"
|
|
|
- }
|
|
|
- }
|
|
|
- printing?.print(getSBCPrintables(reportOne, getLastFourChars(reportOne._id, 4), winOrLose, sign, channelId))
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private fun getSBCPrintables(
|
|
|
- reportOne: ReportOne,
|
|
|
- betId: String,
|
|
|
- winLose: String,
|
|
|
- currencyType: String,
|
|
|
- channelId: Int
|
|
|
- ) = ArrayList<Printable>().apply {
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("SBC2888")
|
|
|
- .setUnderlined(DefaultPrinter.UNDERLINED_MODE_ON)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setAlignment(DefaultPrinter.ALIGNMENT_CENTER)
|
|
|
- .setLineSpacing(DefaultPrinter.LINE_SPACING_30)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Channel : $channelId")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Bet ID : $betId")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("----------------")
|
|
|
- .setLineSpacing(DefaultPrinter.LINE_SPACING_10)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC1252)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Fight No : ${reportOne.fightNo}")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Bet Type : ${reportOne.betName}")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Date : ${reportOne.date}")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Amount : ${reportOne.amount}")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Payout : ${reportOne.payout}")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Cast : ${reportOne.cast}")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Amount Win : ${reportOne.amountWin}")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
-
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Currency Type : $currencyType")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Result : ${reportOne.resultName}")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("Win/Lose : $winLose")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_SMALL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC850)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("----------------")
|
|
|
- .setLineSpacing(DefaultPrinter.LINE_SPACING_10)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- add(
|
|
|
- TextPrintable.Builder()
|
|
|
- .setText("www.wa855.net")
|
|
|
- .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
|
|
|
- .setAlignment(DefaultPrinter.ALIGNMENT_CENTER)
|
|
|
- .setFontSize(DefaultPrinter.FONT_SIZE_NORMAL)
|
|
|
- .setCharacterCode(DefaultPrinter.CHARCODE_PC437)
|
|
|
- .setNewLinesAfter(1)
|
|
|
- .build()
|
|
|
- )
|
|
|
- }
|
|
|
}
|