|
@@ -1,5 +1,8 @@
|
|
package com.bomostory.sceneeditmodule.share
|
|
package com.bomostory.sceneeditmodule.share
|
|
|
|
|
|
|
|
+import android.content.Context
|
|
|
|
+import android.graphics.Bitmap
|
|
|
|
+import android.graphics.BitmapFactory
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
import android.support.v4.app.DialogFragment
|
|
import android.support.v4.app.DialogFragment
|
|
import android.support.v4.app.FragmentManager
|
|
import android.support.v4.app.FragmentManager
|
|
@@ -7,7 +10,6 @@ import android.view.LayoutInflater
|
|
import android.view.View
|
|
import android.view.View
|
|
import android.view.ViewGroup
|
|
import android.view.ViewGroup
|
|
import com.example.tfat.myapplication.R
|
|
import com.example.tfat.myapplication.R
|
|
-import com.squareup.picasso.Picasso
|
|
|
|
import kotlinx.android.synthetic.main.dialog_export_pdf.view.*
|
|
import kotlinx.android.synthetic.main.dialog_export_pdf.view.*
|
|
|
|
|
|
class ExportPdfDialog : DialogFragment() {
|
|
class ExportPdfDialog : DialogFragment() {
|
|
@@ -41,18 +43,45 @@ class ExportPdfDialog : DialogFragment() {
|
|
btn_exportPdfDialog_cancel.setOnClickListener { this@ExportPdfDialog.dismiss() }
|
|
btn_exportPdfDialog_cancel.setOnClickListener { this@ExportPdfDialog.dismiss() }
|
|
btn_exportPdfDialog_print.setOnClickListener { onClickPrint.run() }
|
|
btn_exportPdfDialog_print.setOnClickListener { onClickPrint.run() }
|
|
if (image1Path != "") {
|
|
if (image1Path != "") {
|
|
|
|
+ val bitmap = decodeImage(context, image1Path)
|
|
|
|
+ iv_exportPdfDialog_standard_1.setImageBitmap(bitmap)
|
|
|
|
+ // Picasso not work, don't know why
|
|
|
|
+ /*
|
|
Picasso.get().load(image1Path).into(iv_exportPdfDialog_standard_1)
|
|
Picasso.get().load(image1Path).into(iv_exportPdfDialog_standard_1)
|
|
- Picasso.get().load(image1Path).into(iv_exportPdfDialog_foldableBooklet_1)
|
|
|
|
|
|
+ */
|
|
}
|
|
}
|
|
if (image2Path != "") {
|
|
if (image2Path != "") {
|
|
|
|
+ val bitmap = decodeImage(context, image2Path)
|
|
|
|
+ iv_exportPdfDialog_standard_2.setImageBitmap(bitmap)
|
|
|
|
+ // Picasso not work, don't know why
|
|
|
|
+ /*
|
|
Picasso.get().load(image2Path).into(iv_exportPdfDialog_standard_2)
|
|
Picasso.get().load(image2Path).into(iv_exportPdfDialog_standard_2)
|
|
|
|
+ */
|
|
}
|
|
}
|
|
if (image3Path != "") {
|
|
if (image3Path != "") {
|
|
|
|
+ val bitmap = decodeImage(context, image3Path)
|
|
|
|
+ iv_exportPdfDialog_standard_3.setImageBitmap(bitmap)
|
|
|
|
+ // Picasso not work, don't know why
|
|
|
|
+ /*
|
|
Picasso.get().load(image3Path).into(iv_exportPdfDialog_standard_3)
|
|
Picasso.get().load(image3Path).into(iv_exportPdfDialog_standard_3)
|
|
|
|
+ */
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private fun decodeImage(context: Context, imgPath: String): Bitmap {
|
|
|
|
+ val options = BitmapFactory.Options().apply {
|
|
|
|
+ inJustDecodeBounds = true
|
|
|
|
+ }
|
|
|
|
+ BitmapFactory.decodeFile(imgPath, options)
|
|
|
|
+ options.apply {
|
|
|
|
+ inJustDecodeBounds = false
|
|
|
|
+ val viewWidth = context.resources.getDimension(R.dimen.export_pdf_screenshot_width)
|
|
|
|
+ inSampleSize = (outWidth / viewWidth).toInt()
|
|
|
|
+ }
|
|
|
|
+ return BitmapFactory.decodeFile(imgPath, options)
|
|
|
|
+ }
|
|
|
|
+
|
|
fun show(manager: FragmentManager?) {
|
|
fun show(manager: FragmentManager?) {
|
|
manager?.apply {
|
|
manager?.apply {
|
|
val ft = beginTransaction()
|
|
val ft = beginTransaction()
|