Procházet zdrojové kódy

Merge branch 'fix-printer-pages'

Wayne před 6 roky
rodič
revize
401531b3b5

+ 9 - 1
src/main/java/com/bomostory/sceneeditmodule/screen/movie/MovieEditActivity.kt

@@ -437,6 +437,7 @@ class MovieEditActivity : AppCompatActivity(),
             exportPdfDialog.image1Path = viewModel.project?.scene1File?.path ?: ""
             exportPdfDialog.image2Path = viewModel.project?.scene2File?.path ?: ""
             exportPdfDialog.onClickPrint = Runnable {
+                var isBooklet = false
                 when (exportPdfDialog.type) {
                     ExportPdfDialog.Type.Standard -> {
                         val name = "standard_${viewModel.project?.name}_${System.currentTimeMillis()}.pdf"
@@ -449,6 +450,7 @@ class MovieEditActivity : AppCompatActivity(),
                         Pair(file, observable)
                     }
                     ExportPdfDialog.Type.Booklet -> {
+                        isBooklet = true
                         val name = "booklet_${viewModel.project?.name}_${System.currentTimeMillis()}.pdf"
                         if (!Config.PDF_FOLDER.exists()) {
                             Config.PDF_FOLDER.mkdirs()
@@ -465,7 +467,13 @@ class MovieEditActivity : AppCompatActivity(),
                         val context = this@MovieEditActivity
                         val file = first
                         viewModel.project?.story?.let {
-                            val pages = it.scenes.size
+                            val pages = if (isBooklet) {
+                                val scenes = it.scenes.size
+                                val scenesPerBook = 22
+                                Math.ceil(scenes.toDouble() / scenesPerBook.toDouble()).toInt() * 2
+                            } else {
+                                it.scenes.size
+                            }
                             PrintTools.getInstance().doPrint(context, file, pages)
                         }
                     })