Pārlūkot izejas kodu

Add ShareDialog(no preview)

Wayne 6 gadi atpakaļ
vecāks
revīzija
d5cf80d202

+ 52 - 0
src/main/java/com/bomostory/sceneeditmodule/share/ShareDialog.kt

@@ -0,0 +1,52 @@
+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 kotlinx.android.synthetic.main.dialog_share.view.*
+
+class ShareDialog : DialogFragment() {
+
+    private val dialogTag = this::class.java.simpleName
+
+    var name: String = ""
+    var author: String = ""
+
+    var onClickEditCover = Runnable {}
+    var onClickExportPdf = Runnable {}
+    var onClickPrint = Runnable {}
+    var onClickBomo = Runnable {}
+    var onClickYoutube = Runnable {}
+    var onClickFacebook = Runnable {}
+    var onClickTwitter = Runnable {}
+    var onClickMore = Runnable {}
+
+    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+        return inflater.inflate(R.layout.dialog_share, container, false).apply {
+            tv_shareDialog_name.text = name
+            tv_shareDialog_author.text = author
+            tv_shareDialog_editCover.setOnClickListener { onClickEditCover.run() }
+            tv_shareDialog_exportPdf.setOnClickListener { onClickExportPdf.run() }
+            tv_shareDialog_print.setOnClickListener { onClickPrint.run() }
+            iv_shareDialog_bomo.setOnClickListener { onClickBomo.run() }
+            iv_shareDialog_youtube.setOnClickListener { onClickYoutube.run() }
+            iv_shareDialog_facebook.setOnClickListener { onClickFacebook.run() }
+            iv_shareDialog_twitter.setOnClickListener { onClickTwitter.run() }
+            iv_shareDialog_more.setOnClickListener { onClickMore.run() }
+        }
+    }
+
+    fun show(manager: FragmentManager?) {
+        manager?.apply {
+            val ft = beginTransaction()
+            findFragmentByTag(dialogTag)?.let { ft.remove(it) }
+            ft.addToBackStack(null)
+            ft.commit()
+        }
+        super.show(manager, dialogTag)
+    }
+}