Commit ad0675a6 authored by wanglei's avatar wanglei Committed by wanglei

...

parent 581efd02
...@@ -4,6 +4,7 @@ import android.annotation.SuppressLint ...@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.app.Activity import android.app.Activity
import android.app.Dialog import android.app.Dialog
import android.content.Intent import android.content.Intent
import androidx.core.view.isEmpty
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.base.pdfviewerscannerwhite.bean.ConstObject import com.base.pdfviewerscannerwhite.bean.ConstObject
...@@ -24,12 +25,14 @@ import com.base.pdfviewerscannerwhite.ui.document.word.WordActivity ...@@ -24,12 +25,14 @@ import com.base.pdfviewerscannerwhite.ui.document.word.WordActivity
import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentHomeMoreDialog import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentHomeMoreDialog
import com.base.pdfviewerscannerwhite.ui.view.PdfDialog.showPdfHomeMoreDialog import com.base.pdfviewerscannerwhite.ui.view.PdfDialog.showPdfHomeMoreDialog
import com.base.pdfviewerscannerwhite.ui.view.PdfDialog.showPdfPwdDialog import com.base.pdfviewerscannerwhite.ui.view.PdfDialog.showPdfPwdDialog
import com.base.pdfviewerscannerwhite.utils.LogEx
import com.base.pdfviewerscannerwhite.utils.PermissionUtils.checkStorePermission import com.base.pdfviewerscannerwhite.utils.PermissionUtils.checkStorePermission
import java.io.File import java.io.File
import java.util.Locale import java.util.Locale
class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView { class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView {
private val TAG = "DocumentFragment"
var type = TYPE_PDF var type = TYPE_PDF
private var documentList: ArrayList<DocumentBean> = arrayListOf() private var documentList: ArrayList<DocumentBean> = arrayListOf()
lateinit var adapter: DocumentAdapter lateinit var adapter: DocumentAdapter
...@@ -108,10 +111,10 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView ...@@ -108,10 +111,10 @@ class DocumentFragment() : BaseFragment<FragmentDocumentBinding>(), DocumentView
} }
override fun deleteDocument(item: DocumentBean) { override fun deleteDocument(item: DocumentBean) {
val list = documentList.toMutableList() val flag = documentList.removeIf { it.path == item.path }
documentPresenter.deleteDocumentBean(item) LogEx.logDebug(TAG, "deleteDocument $item.path flag=$flag")
list.remove(item) adapter.submitList(documentList)
adapter.submitList(list) binding.llEmpty.isVisible = adapter.items.isEmpty()
} }
fun setRecentList() { fun setRecentList() {
......
...@@ -96,9 +96,13 @@ object PdfDialog { ...@@ -96,9 +96,13 @@ object PdfDialog {
dialog.dismiss() dialog.dismiss()
showDeleteDialog { showDeleteDialog {
runCatching { runCatching {
File(item.path).delete() val flag = File(item.path).delete()
} if (flag){
documentFragment.deleteDocument(item) documentFragment.deleteDocument(item)
mainActivity.deleteDocument(item)
}
}
} }
} }
binding.llDetail.setOnClickListener { binding.llDetail.setOnClickListener {
......
...@@ -4,18 +4,17 @@ ...@@ -4,18 +4,17 @@
android:id="@+id/fl_border" android:id="@+id/fl_border"
android:layout_width="103dp" android:layout_width="103dp"
android:layout_height="145dp" android:layout_height="145dp"
android:layout_marginHorizontal="12.5dp" android:layout_marginHorizontal="5dp"
android:layout_marginVertical="7dp" android:layout_marginVertical="5dp"
android:background="@drawable/bg_selector_pager_border"> android:background="@drawable/bg_selector_pager_border">
<ImageView <ImageView
android:id="@+id/iv_pager" android:id="@+id/iv_pager"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="2dp" android:layout_margin="2dp"
android:importantForAccessibility="no" android:importantForAccessibility="no"
android:scaleType="fitXY" /> android:scaleType="centerCrop" />
<ImageView <ImageView
android:id="@+id/iv_selector" android:id="@+id/iv_selector"
......
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