瀏覽代碼

Add ExportPdfDialog

Wayne 6 年之前
父節點
當前提交
79af937879
共有 2 個文件被更改,包括 67 次插入0 次删除
  1. 2 0
      build.gradle
  2. 65 0
      src/main/java/com/bomostory/sceneeditmodule/share/ExportPdfDialog.kt

+ 2 - 0
build.gradle

@@ -48,6 +48,8 @@ dependencies {
     implementation project(':Bomo_for_Android_cloudModule')
     implementation project(':Bomo_for_Android_encodeModule')
     implementation project(':uikit')
+
+    implementation 'com.squareup.picasso:picasso:2.71828'
 }
 repositories {
     mavenCentral()

+ 65 - 0
src/main/java/com/bomostory/sceneeditmodule/share/ExportPdfDialog.kt

@@ -0,0 +1,65 @@
+package com.bomostory.sceneeditmodule.share
+
+import android.os.Bundle
+import android.support.v4.app.DialogFragment
+import android.support.v4.app.FragmentManager
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import com.example.tfat.myapplication.R
+import com.squareup.picasso.Picasso
+import kotlinx.android.synthetic.main.dialog_export_pdf.view.*
+
+class ExportPdfDialog : DialogFragment() {
+    private val dialogTag = this::class.java.simpleName
+
+    enum class Type {
+        Standard,
+        Booklet,
+    }
+
+    var image1Path = ""
+    var image2Path = ""
+    var image3Path = ""
+    var onClickPrint = Runnable { }
+    var type = Type.Standard
+
+    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+        return inflater.inflate(R.layout.dialog_export_pdf, container, false).apply {
+            rb_exportPdfDialog_foldableBooklet.setOnCheckedChangeListener { _, b ->
+                if (b) {
+                    rb_exportPdfDialog_standard.isChecked = false
+                    type = Type.Booklet
+                }
+            }
+            rb_exportPdfDialog_standard.setOnCheckedChangeListener { _, b ->
+                if (b) {
+                    rb_exportPdfDialog_foldableBooklet.isChecked = false
+                    type = Type.Standard
+                }
+            }
+            btn_exportPdfDialog_cancel.setOnClickListener { this@ExportPdfDialog.dismiss() }
+            btn_exportPdfDialog_print.setOnClickListener { onClickPrint.run() }
+            if (image1Path != "") {
+                Picasso.get().load(image1Path).into(iv_exportPdfDialog_standard_1)
+                Picasso.get().load(image1Path).into(iv_exportPdfDialog_foldableBooklet_1)
+            }
+            if (image2Path != "") {
+                Picasso.get().load(image2Path).into(iv_exportPdfDialog_standard_2)
+            }
+            if (image3Path != "") {
+                Picasso.get().load(image3Path).into(iv_exportPdfDialog_standard_3)
+            }
+        }
+    }
+
+    fun show(manager: FragmentManager?) {
+        manager?.apply {
+            val ft = beginTransaction()
+            findFragmentByTag(dialogTag)?.let { ft.remove(it) }
+            ft.addToBackStack(null)
+            ft.commit()
+        }
+        super.show(manager, dialogTag)
+    }
+}