|
@@ -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)
|
|
|
+ }
|
|
|
+}
|