Commit 2f9e3c89 authored by wanglei's avatar wanglei

...需同步到功能...

parent 16983440
...@@ -19,7 +19,6 @@ import com.base.superpdfreader.utils.BarUtils ...@@ -19,7 +19,6 @@ import com.base.superpdfreader.utils.BarUtils
import com.base.superpdfreader.view.DialogViews.showGerPermission import com.base.superpdfreader.view.DialogViews.showGerPermission
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import java.io.File
class ImageSelectionActivity : BaseActivity<ActivityImageSelectionBinding>() { class ImageSelectionActivity : BaseActivity<ActivityImageSelectionBinding>() {
......
...@@ -39,24 +39,8 @@ class DocumentListFragment() : BaseFragment<FragmentDocumentListBinding>() { ...@@ -39,24 +39,8 @@ class DocumentListFragment() : BaseFragment<FragmentDocumentListBinding>() {
binding.tvAllow.background = binding.tvAllow.background =
ContextCompat.getDrawable(requireContext(), R.drawable.bg_allow_pdf) ContextCompat.getDrawable(requireContext(), R.drawable.bg_allow_pdf)
} }
MODE_WORD -> {
binding.tvAllow.background =
ContextCompat.getDrawable(requireContext(), R.drawable.bg_allow_word)
}
MODE_PPT -> {
binding.tvAllow.background =
ContextCompat.getDrawable(requireContext(), R.drawable.bg_allow_ppt)
}
MODE_EXCEL -> {
binding.tvAllow.background =
ContextCompat.getDrawable(requireContext(), R.drawable.bg_allow_excel)
}
} }
adapter = DocumentAdapter { bean -> adapter = DocumentAdapter { bean ->
if (dialog == null) { if (dialog == null) {
val launcher = (requireActivity() as MainActivity).launcher val launcher = (requireActivity() as MainActivity).launcher
dialog = requireContext().showDocumentDetailDialog(UI_MODE, dialog = requireContext().showDocumentDetailDialog(UI_MODE,
...@@ -67,7 +51,6 @@ class DocumentListFragment() : BaseFragment<FragmentDocumentListBinding>() { ...@@ -67,7 +51,6 @@ class DocumentListFragment() : BaseFragment<FragmentDocumentListBinding>() {
initData() initData()
}) })
} }
} }
binding.rv.adapter = adapter binding.rv.adapter = adapter
} }
...@@ -79,17 +62,19 @@ class DocumentListFragment() : BaseFragment<FragmentDocumentListBinding>() { ...@@ -79,17 +62,19 @@ class DocumentListFragment() : BaseFragment<FragmentDocumentListBinding>() {
override fun setListener() { override fun setListener() {
binding.tvAllow.setOnClickListener { binding.tvAllow.setOnClickListener {
val launcher = (requireActivity() as MainActivity).launcher val launcher = (requireActivity() as MainActivity).launcher
if (dialog == null) {
dialog = requireContext().showGerPermission(null, deny = {}, allow = { dialog = requireContext().showGerPermission(null, deny = {}, allow = {
requireContext().requestStorePermission(launcher, requireContext().requestStorePermission(launcher,
jumpAction = {}, jumpAction = {},
result = { flag -> result = { flag ->
binding.llPermission.isVisible = !flag binding.llPermission.isVisible = !flag
initData() initData()
} }
) )
}) }, dismiss = {
dialog = null
})
}
} }
binding.swipeRefresh.setOnRefreshListener { binding.swipeRefresh.setOnRefreshListener {
...@@ -107,47 +92,6 @@ class DocumentListFragment() : BaseFragment<FragmentDocumentListBinding>() { ...@@ -107,47 +92,6 @@ class DocumentListFragment() : BaseFragment<FragmentDocumentListBinding>() {
} }
} }
MODE_WORD -> {
val files = arrayListOf<Pair<File, Uri>>()
requireContext().geFileMedia(
files,
arrayOf(
"application/msword",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
)
)
launch(Dispatchers.Main) {
adapter.addData(MODE_WORD, R.mipmap.doc, files)
}
}
MODE_PPT -> {
val files = arrayListOf<Pair<File, Uri>>()
requireContext().geFileMedia(
files, arrayOf(
"application/vnd.ms-powerpoint",
"application/vnd.openxmlformats-officedocument.presentationml.presentation"
)
)
launch(Dispatchers.Main) {
adapter.addData(MODE_PPT, R.mipmap.ppt, files)
}
}
MODE_EXCEL -> {
val files = arrayListOf<Pair<File, Uri>>()
requireContext().geFileMedia(
files, arrayOf(
"application/vnd.ms-excel",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
)
)
launch(Dispatchers.Main) {
adapter.addData(MODE_EXCEL, R.mipmap.xls, files)
}
}
} }
} }
......
...@@ -23,7 +23,8 @@ object DialogViews { ...@@ -23,7 +23,8 @@ object DialogViews {
fun Context.showGerPermission( fun Context.showGerPermission(
tittle: String? = null, tittle: String? = null,
deny: ((view: Dialog) -> Unit)? = null, deny: ((view: Dialog) -> Unit)? = null,
allow: ((view: Dialog) -> Unit)? = null allow: ((view: Dialog) -> Unit)? = null,
dismiss: (() -> Unit)? = null,
): Dialog { ): Dialog {
val dialog = Dialog(this) val dialog = Dialog(this)
val binding = DialogPermissonOpenBinding.inflate(LayoutInflater.from(this)) val binding = DialogPermissonOpenBinding.inflate(LayoutInflater.from(this))
...@@ -59,6 +60,9 @@ object DialogViews { ...@@ -59,6 +60,9 @@ object DialogViews {
dialog.dismiss() dialog.dismiss()
allow?.invoke(dialog) allow?.invoke(dialog)
} }
dialog.setOnDismissListener {
dismiss?.invoke()
}
dialog.show() dialog.show()
return dialog return dialog
} }
......
...@@ -89,6 +89,9 @@ object PDFSaveDialog { ...@@ -89,6 +89,9 @@ object PDFSaveDialog {
saveAction.invoke(pdfParameterBean) saveAction.invoke(pdfParameterBean)
dialog.dismiss() dialog.dismiss()
} }
binding.flGuanbi.setOnClickListener {
dialog.dismiss()
}
//https://cloud.tencent.com/developer/article/1829876 //https://cloud.tencent.com/developer/article/1829876
val parentView = binding.root.parent as View val parentView = binding.root.parent as View
BottomSheetBehavior.from(parentView).state = BottomSheetBehavior.STATE_EXPANDED BottomSheetBehavior.from(parentView).state = BottomSheetBehavior.STATE_EXPANDED
......
...@@ -24,14 +24,22 @@ ...@@ -24,14 +24,22 @@
android:textStyle="bold" android:textStyle="bold"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
<ImageView <FrameLayout
android:id="@+id/iv_guanbi" android:id="@+id/fl_guanbi"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end" android:layout_gravity="center_vertical|end"
android:layout_marginEnd="11dp" android:layout_marginEnd="6dp"
android:src="@mipmap/guanbi" android:padding="5dp">
tools:ignore="ContentDescription" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/guanbi"
tools:ignore="ContentDescription" />
</FrameLayout>
</FrameLayout> </FrameLayout>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment