Blame view

footsafety/app/src/main/java/com/printer/sdk/serial/RawPrintable.kt 785 Bytes
f7a13682   “wangming”   项目初始化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  package com.printer.sdk.serial
  
  data class RawPrintable private constructor(val command: ByteArray,
                                              val newLinesAfter: Int) : Printable {
  
      override fun getPrintableByteArray(printer: Printer): List<ByteArray> {
          val operations = mutableListOf(command)
  
          if (newLinesAfter > 0) {
              operations.add(printer.feedLineCommand.plus(newLinesAfter.toByte()))
          }
  
          return operations
      }
  
      class Builder(private var raw: ByteArray) {
          private var newLinesAfter = 0
  
          fun setNewLinesAfter(lines: Int): Builder {
              this.newLinesAfter = lines
              return this
          }
  
          fun build(): RawPrintable {
              return RawPrintable(raw, newLinesAfter)
          }
      }
  
  }