Commit e1d9ed3b authored by wanglei's avatar wanglei

...

parent 165acf40
......@@ -18,6 +18,7 @@ import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentMore
import com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.hideKeyboard
import com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.showKeyBoard
import com.base.pdfviewerscannerwhite.utils.LogEx
import com.base.pdfviewerscannerwhite.utils.SpStringUtils
import com.cherry.lib.doc.bean.DocEngine
import com.cherry.lib.doc.office.constant.EventConstant
import com.cherry.lib.doc.office.ss.control.SSControl
......@@ -265,6 +266,8 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
LogEx.logDebug(TAG, "initData-pathOrUri = $pathOrUri")
LogEx.logDebug(TAG, "initData-docSourceType = $docSourceType")
LogEx.logDebug(TAG, "initData-fileType = $fileType")
SpStringUtils.addSpString(SpStringUtils.LAST_VIEW_KEY, pathOrUri ?: "")
}
......
......@@ -69,6 +69,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
assets = intent.extras?.getString("assets") ?: ""
LogEx.logDebug(TAG, "path=$path")
LogEx.logDebug(TAG, "uri=$uri")
SpStringUtils.addSpString(LAST_VIEW_KEY, path)
val file = File(path)
binding.tvPdfName.text = file.name
......@@ -171,6 +172,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
}
binding.ivWancheng.setOnClickListener {
changeEditSaveUI()
binding.mupdfReaderView.setMode(MuPDFReaderView.Mode.Viewing)
}
binding.ivBianji.setOnClickListener {
bianJiScaleXiao {
......@@ -525,6 +527,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
binding.llGlideLine.setBackgroundColor(Color.TRANSPARENT)
binding.llStrikethrough.setBackgroundColor(Color.TRANSPARENT)
binding.llPaintingBrush.setBackgroundColor(Color.TRANSPARENT)
}
override fun onPause() {
......
......@@ -14,6 +14,7 @@ import com.base.pdfviewerscannerwhite.databinding.ActivityPptBinding
import com.base.pdfviewerscannerwhite.helper.BaseActivity
import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentMore
import com.base.pdfviewerscannerwhite.utils.LogEx
import com.base.pdfviewerscannerwhite.utils.SpStringUtils
import com.cherry.lib.doc.bean.DocEngine
import com.cherry.lib.doc.office.pg.control.PGControl
import com.cherry.lib.doc.util.Constant
......@@ -111,6 +112,8 @@ class PptActivity : BaseActivity<ActivityPptBinding>() {
LogEx.logDebug(TAG, "initData-docUrl = $pathOrUri")
LogEx.logDebug(TAG, "initData-docSourceType = $docSourceType")
LogEx.logDebug(TAG, "initData-fileType = $fileType")
SpStringUtils.addSpString(SpStringUtils.LAST_VIEW_KEY, pathOrUri ?: "")
}
private fun showTopLayout() {
......
......@@ -21,6 +21,7 @@ import com.base.pdfviewerscannerwhite.ui.view.DialogView.showDocumentMore
import com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.hideKeyboard
import com.base.pdfviewerscannerwhite.utils.KeyBoardUtils.showKeyBoard
import com.base.pdfviewerscannerwhite.utils.LogEx
import com.base.pdfviewerscannerwhite.utils.SpStringUtils
import com.cherry.lib.doc.bean.DocEngine
import com.cherry.lib.doc.office.constant.EventConstant.APP_PAGE_DOWN_ID
import com.cherry.lib.doc.office.constant.EventConstant.APP_PAGE_UP_ID
......@@ -295,6 +296,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
LogEx.logDebug(TAG, "initData-docSourceType = $docSourceType")
LogEx.logDebug(TAG, "initData-fileType = $fileType")
LogEx.logDebug(TAG, "initData-engine = $engine")
SpStringUtils.addSpString(SpStringUtils.LAST_VIEW_KEY, pathOrUri ?: "")
}
companion object {
......
......@@ -57,19 +57,18 @@ class MainActivity : BaseActivity<ActivityMain2Binding>(), MainView {
LogEx.logDebug(TAG, "initView")
mainPresenter = MainPresenter(this, this, lifecycleScope)
mainPresenter.initScannerLauncher(this)
showStoragePermission(launcher, allowAction = {
// mainPresenter.initAllDocumentData()
Log.d("glc","我被调用了B")
})
}
override fun onResume() {
super.onResume()
if (checkStorePermission() && needRefresh) {
mainPresenter.initAllDocumentData()
Log.d("glc","我被调用了A")
// Log.d("glc","我被调用了A")
} else {
showStoragePermission(launcher, allowAction = {
// mainPresenter.initAllDocumentData()
// Log.d("glc","我被调用了B")
})
}
}
......
......@@ -24,6 +24,7 @@ import com.base.pdfviewerscannerwhite.ui.document.pdf.PdfBoxUtils
import com.base.pdfviewerscannerwhite.utils.AssetUtils.saveAssetsFile
import com.base.pdfviewerscannerwhite.utils.SpStringUtils
import com.base.pdfviewerscannerwhite.utils.SpStringUtils.BOOKMARK_KEY
import com.base.pdfviewerscannerwhite.utils.SpStringUtils.LAST_VIEW_KEY
import com.base.pdfviewerscannerwhite.utils.ToastUtils.toast
import com.base.pdfviewerscannerwhite.utils.getMediaFile
import com.base.pdfviewerscannerwhite.utils.upDateDemoStore
......@@ -58,7 +59,7 @@ class MainPresenter(
private lateinit var scannerLauncher: ActivityResultLauncher<IntentSenderRequest>
fun initAllDocumentData() = lifecycleScope.launch(Dispatchers.IO) {
Log.d("glc","pdfs 清理前:"+pdfDocuments.size)
Log.d("glc", "pdfs 清理前:" + pdfDocuments.size)
context.upDateDemoStore()
if (!ConstObject.haveSaveDemo) {
context.saveAssetsFile()
......@@ -70,9 +71,9 @@ class MainPresenter(
wordDocuments.clear()
excelDocuments.clear()
pptDocuments.clear()
Log.d("glc","pdfs:"+pdfs.size)
Log.d("glc", "pdfs:" + pdfs.size)
pdfDocuments.addAll(pdfs)
Log.d("glc","添加了 pdfDocuments:"+pdfDocuments.size)
Log.d("glc", "添加了 pdfDocuments:" + pdfDocuments.size)
wordDocuments.addAll(initAllWordData())
excelDocuments.addAll(initAllExcelData())
pptDocuments.addAll(initAllPptData())
......@@ -85,7 +86,9 @@ class MainPresenter(
fun getDataByType(documentType: String, dataType: String): List<DocumentBean> {
val bookmarkList = SpStringUtils.getSpStringList(SpStringUtils.BOOKMARK_KEY)
Log.d("glc","pdfDocuments:"+pdfDocuments.size)
Log.d("glc", "pdfDocuments:" + pdfDocuments.size)
val recentList = SpStringUtils.getSpStringList(LAST_VIEW_KEY)
when (documentType) {
TYPE_PDF -> {
pdfDocuments.forEach {
......@@ -97,7 +100,7 @@ class MainPresenter(
}
RECENT_DATA_TYPE -> {
return pdfDocuments.filter { recentFilter(it) }
return pdfDocuments.filter { recentFilter(recentList, it) }
}
BOOKMARK_DATA_TYPE -> {
......@@ -118,7 +121,7 @@ class MainPresenter(
}
RECENT_DATA_TYPE -> {
return wordDocuments.filter { recentFilter(it) }
return wordDocuments.filter { recentFilter(recentList, it) }
}
BOOKMARK_DATA_TYPE -> {
......@@ -139,7 +142,7 @@ class MainPresenter(
}
RECENT_DATA_TYPE -> {
return excelDocuments.filter { recentFilter(it) }
return excelDocuments.filter { recentFilter(recentList, it) }
}
BOOKMARK_DATA_TYPE -> {
......@@ -159,7 +162,7 @@ class MainPresenter(
}
RECENT_DATA_TYPE -> {
return pptDocuments.filter { recentFilter(it) }
return pptDocuments.filter { recentFilter(recentList, it) }
}
BOOKMARK_DATA_TYPE -> {
......@@ -172,8 +175,8 @@ class MainPresenter(
return listOf()
}
private fun recentFilter(documentBean: DocumentBean): Boolean {
return (System.currentTimeMillis() - File(documentBean.path).lastModified()) < 300L * 24 * 60 * 60 * 1000
private fun recentFilter(recentList: List<String>, documentBean: DocumentBean): Boolean {
return recentList.contains(documentBean.path)
}
......
......@@ -15,7 +15,9 @@ object SpStringUtils {
fun addSpString(key: String, value: String) {
val list = getSpStringList(key).toMutableList()
if (!list.contains(value)) {
list.add(value)
}
val string = list.joinToString(separator = "|||")
AppPreferences.getInstance().put(key, string)
}
......
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