Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
P
pdf all reader
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
pdf all reader
Commits
c13b5df5
Commit
c13b5df5
authored
Nov 15, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
390e2591
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
82 additions
and
47 deletions
+82
-47
DocumentFragment.kt
...ase/pdfreaderallpdfreader/ui/document/DocumentFragment.kt
+10
-8
DocumentEx.kt
...java/com/base/pdfreaderallpdfreader/ui/main/DocumentEx.kt
+40
-26
MainActivity.kt
...va/com/base/pdfreaderallpdfreader/ui/main/MainActivity.kt
+2
-0
RecentFragment.kt
...se/pdfreaderallpdfreader/ui/main/recent/RecentFragment.kt
+3
-0
PdfActivity.kt
...java/com/base/pdfreaderallpdfreader/ui/pdf/PdfActivity.kt
+8
-4
MediaStoreUtils.kt
...a/com/base/pdfreaderallpdfreader/utils/MediaStoreUtils.kt
+0
-7
UriUtils.kt
...ain/java/com/base/pdfreaderallpdfreader/utils/UriUtils.kt
+15
-0
activity_pdf.xml
app/src/main/res/layout/activity_pdf.xml
+4
-2
No files found.
app/src/main/java/com/base/pdfreaderallpdfreader/ui/document/DocumentFragment.kt
View file @
c13b5df5
...
@@ -32,6 +32,7 @@ import com.base.pdfreaderallpdfreader.ui.view.DialogCallBack
...
@@ -32,6 +32,7 @@ import com.base.pdfreaderallpdfreader.ui.view.DialogCallBack
import
com.base.pdfreaderallpdfreader.ui.view.DocumentDialog.showDocumentHomeMoreDialog
import
com.base.pdfreaderallpdfreader.ui.view.DocumentDialog.showDocumentHomeMoreDialog
import
com.base.pdfreaderallpdfreader.ui.view.PdfDialog.showPdfHomeMoreDialog
import
com.base.pdfreaderallpdfreader.ui.view.PdfDialog.showPdfHomeMoreDialog
import
com.base.pdfreaderallpdfreader.ui.word.WordActivity
import
com.base.pdfreaderallpdfreader.ui.word.WordActivity
import
com.base.pdfreaderallpdfreader.utils.LogEx
import
com.base.pdfreaderallpdfreader.utils.PdfBoxUtils.checkPdfEncryption
import
com.base.pdfreaderallpdfreader.utils.PdfBoxUtils.checkPdfEncryption
import
com.base.pdfreaderallpdfreader.utils.SpStringUtils
import
com.base.pdfreaderallpdfreader.utils.SpStringUtils
import
com.base.pdfreaderallpdfreader.utils.SpStringUtils.BOOKMARK_KEY
import
com.base.pdfreaderallpdfreader.utils.SpStringUtils.BOOKMARK_KEY
...
@@ -44,6 +45,7 @@ class DocumentFragment() : Fragment(), DialogCallBack {
...
@@ -44,6 +45,7 @@ class DocumentFragment() : Fragment(), DialogCallBack {
private
var
type
=
TYPE_PDF
private
var
type
=
TYPE_PDF
private
val
TAG
=
"DocumentFragment"
private
lateinit
var
binding
:
FragmentDocumentBinding
private
lateinit
var
binding
:
FragmentDocumentBinding
private
var
adapter
:
DocumentAdapter
?
=
null
private
var
adapter
:
DocumentAdapter
?
=
null
...
@@ -99,8 +101,9 @@ class DocumentFragment() : Fragment(), DialogCallBack {
...
@@ -99,8 +101,9 @@ class DocumentFragment() : Fragment(), DialogCallBack {
binding
.
ivTop
.
isVisible
=
false
binding
.
ivTop
.
isVisible
=
false
}
}
binding
.
swipeRefreshLayout
.
setOnRefreshListener
{
binding
.
swipeRefreshLayout
.
setOnRefreshListener
{
initData
()
initData
(
"swipeRefreshLayout"
)
}
}
binding
.
swipeRefreshLayout
.
isRefreshing
=
true
}
}
override
fun
onResume
()
{
override
fun
onResume
()
{
...
@@ -108,19 +111,17 @@ class DocumentFragment() : Fragment(), DialogCallBack {
...
@@ -108,19 +111,17 @@ class DocumentFragment() : Fragment(), DialogCallBack {
if
(
type
==
TYPE_PDF
)
{
if
(
type
==
TYPE_PDF
)
{
if
(
pdfNeedRefresh
)
{
if
(
pdfNeedRefresh
)
{
pdfNeedRefresh
=
false
pdfNeedRefresh
=
false
initData
()
initData
(
"onResume"
)
}
}
}
else
{
}
else
{
initData
()
initData
(
"onResume"
)
}
}
}
}
private
fun
initData
()
{
private
fun
initData
(
where
:
String
=
""
)
{
binding
.
swipeRefreshLayout
.
isRefreshing
=
true
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
LogEx
.
logDebug
(
TAG
,
"initData $type where=$where"
)
requireContext
().
updateMediaStore
()
val
list
:
List
<
DocumentBean
>
val
list
:
List
<
DocumentBean
>
when
(
type
)
{
when
(
type
)
{
...
@@ -187,7 +188,8 @@ class DocumentFragment() : Fragment(), DialogCallBack {
...
@@ -187,7 +188,8 @@ class DocumentFragment() : Fragment(), DialogCallBack {
val
newFile
=
File
(
file
.
parentFile
,
newName
)
val
newFile
=
File
(
file
.
parentFile
,
newName
)
val
result
=
file
.
renameTo
(
newFile
)
val
result
=
file
.
renameTo
(
newFile
)
if
(
result
)
{
if
(
result
)
{
initData
()
requireContext
().
updateMediaStore
()
initData
(
"renameDocumentBean"
)
}
}
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
e
.
printStackTrace
()
...
...
app/src/main/java/com/base/pdfreaderallpdfreader/ui/main/DocumentEx.kt
View file @
c13b5df5
...
@@ -4,6 +4,7 @@ import android.content.Context
...
@@ -4,6 +4,7 @@ import android.content.Context
import
android.media.MediaScannerConnection
import
android.media.MediaScannerConnection
import
android.net.Uri
import
android.net.Uri
import
android.os.Environment
import
android.os.Environment
import
com.base.pdfreaderallpdfreader.R
import
com.base.pdfreaderallpdfreader.bean.ConstObject
import
com.base.pdfreaderallpdfreader.bean.ConstObject
import
com.base.pdfreaderallpdfreader.bean.ConstObject.MIME_TYPE_DOC
import
com.base.pdfreaderallpdfreader.bean.ConstObject.MIME_TYPE_DOC
import
com.base.pdfreaderallpdfreader.bean.ConstObject.MIME_TYPE_DOCX
import
com.base.pdfreaderallpdfreader.bean.ConstObject.MIME_TYPE_DOCX
...
@@ -25,20 +26,18 @@ import com.base.pdfreaderallpdfreader.utils.PdfBoxUtils.checkPdfEncryption
...
@@ -25,20 +26,18 @@ import com.base.pdfreaderallpdfreader.utils.PdfBoxUtils.checkPdfEncryption
import
com.base.pdfreaderallpdfreader.utils.PermissionUtils.checkStorePermission
import
com.base.pdfreaderallpdfreader.utils.PermissionUtils.checkStorePermission
import
com.base.pdfreaderallpdfreader.utils.SpStringUtils
import
com.base.pdfreaderallpdfreader.utils.SpStringUtils
import
com.base.pdfreaderallpdfreader.utils.SpStringUtils.BOOKMARK_KEY
import
com.base.pdfreaderallpdfreader.utils.SpStringUtils.BOOKMARK_KEY
import
com.base.pdfreaderallpdfreader.utils.UriUtils.isUriValid
import
com.base.pdfreaderallpdfreader.utils.getMediaFile
import
com.base.pdfreaderallpdfreader.utils.getMediaFile
import
java.io.File
import
java.io.File
import
java.io.FileOutputStream
import
java.io.FileOutputStream
import
java.io.IOException
import
java.io.IOException
fun
Context
.
upDateDemoStore
()
{
val
demoFile
=
File
(
filesDir
,
"demo"
)
MediaScannerConnection
.
scanFile
(
this
,
arrayOf
(
demoFile
.
absolutePath
),
null
)
{
path
:
String
?,
uri
:
Uri
?
->
}
}
fun
getDocumentAppDir
():
File
{
fun
getDocumentAppDir
():
File
{
val
appDir
=
File
(
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_DOCUMENTS
),
context
.
packageName
)
val
appDir
=
File
(
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_DOCUMENTS
),
context
.
getString
(
R
.
string
.
app_name
)
)
if
(!
appDir
.
exists
())
if
(!
appDir
.
exists
())
appDir
.
exists
()
appDir
.
exists
()
return
appDir
return
appDir
...
@@ -109,7 +108,6 @@ fun getPPtDemo(): DocumentBean {
...
@@ -109,7 +108,6 @@ fun getPPtDemo(): DocumentBean {
}
}
fun
getAllDocument
(
context
:
Context
):
MutableList
<
DocumentBean
>
{
fun
getAllDocument
(
context
:
Context
):
MutableList
<
DocumentBean
>
{
context
.
upDateDemoStore
()
if
(!
ConstObject
.
haveSaveDemo
)
{
if
(!
ConstObject
.
haveSaveDemo
)
{
context
.
saveAssetsFile
()
context
.
saveAssetsFile
()
...
@@ -128,7 +126,7 @@ fun getAllDocument(context: Context): MutableList<DocumentBean> {
...
@@ -128,7 +126,7 @@ fun getAllDocument(context: Context): MutableList<DocumentBean> {
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
).
filter
{
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
).
filter
{
if
(
context
.
checkStorePermission
())
{
if
(
context
.
checkStorePermission
())
{
true
isUriValid
(
context
,
it
.
uri
)
}
else
{
}
else
{
!
Uri
.
EMPTY
.
equals
(
it
.
uri
)
!
Uri
.
EMPTY
.
equals
(
it
.
uri
)
}
}
...
@@ -140,11 +138,6 @@ fun getAllDocument(context: Context): MutableList<DocumentBean> {
...
@@ -140,11 +138,6 @@ fun getAllDocument(context: Context): MutableList<DocumentBean> {
}
}
documentBean
documentBean
}
}
LogEx
.
logDebug
(
"getAllDocument"
,
"documentList size=${documentList.size}"
)
documentList
.
forEach
{
document
->
LogEx
.
logDebug
(
"getAllDocument"
,
"document=$document"
)
}
val
new
=
documentList
.
toMutableList
()
val
new
=
documentList
.
toMutableList
()
val
pptDemo
=
getPPtDemo
()
val
pptDemo
=
getPPtDemo
()
if
(
File
(
pptDemo
.
path
).
exists
())
{
if
(
File
(
pptDemo
.
path
).
exists
())
{
...
@@ -194,14 +187,19 @@ fun getPdfDocument(context: Context): MutableList<DocumentBean> {
...
@@ -194,14 +187,19 @@ fun getPdfDocument(context: Context): MutableList<DocumentBean> {
val
selectionArgs
=
arrayOf
(
val
selectionArgs
=
arrayOf
(
MIME_TYPE_PDF
MIME_TYPE_PDF
)
)
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
)
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
).
filter
{
if
(
context
.
checkStorePermission
())
{
isUriValid
(
context
,
it
.
uri
)
}
else
{
!
Uri
.
EMPTY
.
equals
(
it
.
uri
)
}
}
val
documentList
=
list
.
map
{
val
documentList
=
list
.
map
{
val
demoDocumentBean
=
DocumentBean
(
it
.
path
,
uri
=
it
.
uri
,
type
=
TYPE_PDF
)
val
demoDocumentBean
=
DocumentBean
(
it
.
path
,
uri
=
it
.
uri
,
type
=
TYPE_PDF
)
context
.
pdfCheck
(
demoDocumentBean
)
context
.
pdfCheck
(
demoDocumentBean
)
demoDocumentBean
demoDocumentBean
}
}
var
new
=
if
(
context
.
checkStorePermission
())
documentList
else
documentList
.
filter
{
it
.
uri
!=
null
}
val
new
=
documentList
.
toMutableList
()
new
=
new
.
toMutableList
()
if
(
context
.
checkStorePermission
())
{
if
(
context
.
checkStorePermission
())
{
val
pdfDemo
=
getPdfDemo
(
context
)
val
pdfDemo
=
getPdfDemo
(
context
)
if
(
File
(
pdfDemo
.
path
).
exists
())
{
if
(
File
(
pdfDemo
.
path
).
exists
())
{
...
@@ -220,12 +218,18 @@ fun getWordDocument(context: Context): MutableList<DocumentBean> {
...
@@ -220,12 +218,18 @@ fun getWordDocument(context: Context): MutableList<DocumentBean> {
MIME_TYPE_DOC
,
MIME_TYPE_DOC
,
MIME_TYPE_DOCX
,
MIME_TYPE_DOCX
,
)
)
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
)
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
).
filter
{
if
(
context
.
checkStorePermission
())
{
isUriValid
(
context
,
it
.
uri
)
}
else
{
!
Uri
.
EMPTY
.
equals
(
it
.
uri
)
}
}
val
documentList
=
list
.
map
{
val
documentList
=
list
.
map
{
DocumentBean
(
it
.
path
,
uri
=
it
.
uri
,
type
=
TYPE_WORD
)
DocumentBean
(
it
.
path
,
uri
=
it
.
uri
,
type
=
TYPE_WORD
)
}
}
va
r
new
=
if
(
context
.
checkStorePermission
())
documentList
else
documentList
.
filter
{
it
.
uri
==
null
}
va
l
new
=
documentList
.
toMutableList
()
new
=
new
.
toMutableList
()
if
(
context
.
checkStorePermission
())
{
if
(
context
.
checkStorePermission
())
{
val
wordDemo
=
getWordDemo
()
val
wordDemo
=
getWordDemo
()
if
(
File
(
wordDemo
.
path
).
exists
())
{
if
(
File
(
wordDemo
.
path
).
exists
())
{
...
@@ -244,12 +248,17 @@ fun getExcelDocument(context: Context): MutableList<DocumentBean> {
...
@@ -244,12 +248,17 @@ fun getExcelDocument(context: Context): MutableList<DocumentBean> {
MIME_TYPE_XLS
,
MIME_TYPE_XLS
,
MIME_TYPE_XLSX
,
MIME_TYPE_XLSX
,
)
)
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
)
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
).
filter
{
if
(
context
.
checkStorePermission
())
{
isUriValid
(
context
,
it
.
uri
)
}
else
{
!
Uri
.
EMPTY
.
equals
(
it
.
uri
)
}
}
val
documentList
=
list
.
map
{
val
documentList
=
list
.
map
{
DocumentBean
(
it
.
path
,
uri
=
it
.
uri
,
type
=
TYPE_EXCEL
)
DocumentBean
(
it
.
path
,
uri
=
it
.
uri
,
type
=
TYPE_EXCEL
)
}
}
var
new
=
if
(
context
.
checkStorePermission
())
documentList
else
documentList
.
filter
{
it
.
uri
==
null
}
val
new
=
documentList
.
toMutableList
()
new
=
new
.
toMutableList
()
if
(
context
.
checkStorePermission
())
{
if
(
context
.
checkStorePermission
())
{
val
excelDemo
=
getExcelDemo
()
val
excelDemo
=
getExcelDemo
()
if
(
File
(
excelDemo
.
path
).
exists
())
{
if
(
File
(
excelDemo
.
path
).
exists
())
{
...
@@ -268,12 +277,17 @@ fun getPptDocument(context: Context): MutableList<DocumentBean> {
...
@@ -268,12 +277,17 @@ fun getPptDocument(context: Context): MutableList<DocumentBean> {
MIME_TYPE_PPT
,
MIME_TYPE_PPT
,
MIME_TYPE_PPTX
,
MIME_TYPE_PPTX
,
)
)
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
)
val
list
=
context
.
getMediaFile
(
selectionArgs
=
selectionArgs
).
filter
{
if
(
context
.
checkStorePermission
())
{
isUriValid
(
context
,
it
.
uri
)
}
else
{
!
Uri
.
EMPTY
.
equals
(
it
.
uri
)
}
}
val
documentList
=
list
.
map
{
val
documentList
=
list
.
map
{
DocumentBean
(
it
.
path
,
uri
=
it
.
uri
,
type
=
TYPE_PPT
)
DocumentBean
(
it
.
path
,
uri
=
it
.
uri
,
type
=
TYPE_PPT
)
}
}
var
new
=
if
(
context
.
checkStorePermission
())
documentList
else
documentList
.
filter
{
it
.
uri
==
null
}
val
new
=
documentList
.
toMutableList
()
new
=
new
.
toMutableList
()
if
(
context
.
checkStorePermission
())
{
if
(
context
.
checkStorePermission
())
{
val
pptDemo
=
getPPtDemo
()
val
pptDemo
=
getPPtDemo
()
if
(
File
(
pptDemo
.
path
).
exists
())
{
if
(
File
(
pptDemo
.
path
).
exists
())
{
...
...
app/src/main/java/com/base/pdfreaderallpdfreader/ui/main/MainActivity.kt
View file @
c13b5df5
...
@@ -110,6 +110,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
...
@@ -110,6 +110,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
launcher
.
launch
(
arrayOf
(
Manifest
.
permission
.
POST_NOTIFICATIONS
))
{}
launcher
.
launch
(
arrayOf
(
Manifest
.
permission
.
POST_NOTIFICATIONS
))
{}
}
}
}
}
updateMediaStore
()
}
}
addDeskShortCut
()
addDeskShortCut
()
...
...
app/src/main/java/com/base/pdfreaderallpdfreader/ui/main/recent/RecentFragment.kt
View file @
c13b5df5
...
@@ -21,6 +21,7 @@ import com.base.pdfreaderallpdfreader.utils.LogEx
...
@@ -21,6 +21,7 @@ import com.base.pdfreaderallpdfreader.utils.LogEx
import
com.base.pdfreaderallpdfreader.utils.PdfBoxUtils.checkPdfEncryption
import
com.base.pdfreaderallpdfreader.utils.PdfBoxUtils.checkPdfEncryption
import
com.base.pdfreaderallpdfreader.utils.SpStringUtils
import
com.base.pdfreaderallpdfreader.utils.SpStringUtils
import
com.base.pdfreaderallpdfreader.utils.SpStringUtils.BOOKMARK_KEY
import
com.base.pdfreaderallpdfreader.utils.SpStringUtils.BOOKMARK_KEY
import
com.base.pdfreaderallpdfreader.utils.updateMediaStore
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
...
@@ -90,6 +91,7 @@ class RecentFragment() : Fragment(), DialogCallBack {
...
@@ -90,6 +91,7 @@ class RecentFragment() : Fragment(), DialogCallBack {
override
fun
deleteDocument
(
item
:
DocumentBean
)
{
override
fun
deleteDocument
(
item
:
DocumentBean
)
{
val
flag
=
File
(
item
.
path
).
delete
()
val
flag
=
File
(
item
.
path
).
delete
()
if
(
flag
)
{
if
(
flag
)
{
requireContext
().
updateMediaStore
()
adapter
?.
remove
(
item
)
adapter
?.
remove
(
item
)
}
}
}
}
...
@@ -107,6 +109,7 @@ class RecentFragment() : Fragment(), DialogCallBack {
...
@@ -107,6 +109,7 @@ class RecentFragment() : Fragment(), DialogCallBack {
val
newFile
=
File
(
file
.
parentFile
,
newName
)
val
newFile
=
File
(
file
.
parentFile
,
newName
)
val
result
=
file
.
renameTo
(
newFile
)
val
result
=
file
.
renameTo
(
newFile
)
if
(
result
)
{
if
(
result
)
{
requireContext
().
updateMediaStore
()
initData
()
initData
()
}
}
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
...
...
app/src/main/java/com/base/pdfreaderallpdfreader/ui/pdf/PdfActivity.kt
View file @
c13b5df5
...
@@ -482,14 +482,14 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() {
...
@@ -482,14 +482,14 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() {
private
fun
createPdfUI
()
{
private
fun
createPdfUI
()
{
if
(
muPDFCore
==
null
)
return
if
(
muPDFCore
==
null
)
return
val
countPages
=
muPDFCore
?.
countPages
()
val
countPages
:
Int
?
=
muPDFCore
?.
countPages
()
binding
.
tvPageCount
.
text
=
"1/${countPages}"
binding
.
tvPageCount
.
text
=
"1/${countPages}"
binding
.
mupdfReaderView
.
setListener
(
object
:
MuPDFReaderViewListener
{
binding
.
mupdfReaderView
.
setListener
(
object
:
MuPDFReaderViewListener
{
@SuppressLint
(
"SetTextI18n"
)
@SuppressLint
(
"SetTextI18n"
)
override
fun
onMoveToChild
(
i
:
Int
)
{
override
fun
onMoveToChild
(
i
:
Int
)
{
binding
.
tvPageCount
.
text
=
"${i + 1}/$countPages
}
"
binding
.
tvPageCount
.
text
=
"${i + 1}/$countPages"
pdfPageAdapter
.
changeSelectPager
(
i
)
pdfPageAdapter
.
changeSelectPager
(
i
)
binding
.
rvPager
.
scrollToPosition
(
i
)
binding
.
rvPager
.
scrollToPosition
(
i
)
setVerticalSeekbar
(
i
+
1
,
countPages
?:
0
)
setVerticalSeekbar
(
i
+
1
,
countPages
?:
0
)
...
@@ -646,7 +646,9 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() {
...
@@ -646,7 +646,9 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() {
if
(
item
.
state
==
0
)
{
if
(
item
.
state
==
0
)
{
activity
.
startActivity
(
Intent
(
activity
,
PdfActivity
::
class
.
java
).
apply
{
activity
.
startActivity
(
Intent
(
activity
,
PdfActivity
::
class
.
java
).
apply
{
putExtra
(
"path"
,
item
.
path
)
putExtra
(
"path"
,
item
.
path
)
putExtra
(
"uri"
,
item
.
uri
.
toString
())
if
(
item
.
path
.
isEmpty
())
{
//处理uri错误的情况
putExtra
(
"uri"
,
item
.
uri
.
toString
())
}
})
})
}
}
if
(
item
.
state
==
1
)
{
if
(
item
.
state
==
1
)
{
...
@@ -664,7 +666,9 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() {
...
@@ -664,7 +666,9 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>() {
fun
jumpSplit
(
activity
:
Activity
,
path
:
String
,
uri
:
String
?
=
null
,
pwd
:
String
?
=
null
)
{
fun
jumpSplit
(
activity
:
Activity
,
path
:
String
,
uri
:
String
?
=
null
,
pwd
:
String
?
=
null
)
{
activity
.
startActivity
(
Intent
(
activity
,
PdfSplitActivity
::
class
.
java
).
apply
{
activity
.
startActivity
(
Intent
(
activity
,
PdfSplitActivity
::
class
.
java
).
apply
{
putExtra
(
"path"
,
path
)
putExtra
(
"path"
,
path
)
putExtra
(
"uri"
,
uri
)
if
(
path
.
isEmpty
())
{
putExtra
(
"uri"
,
uri
)
}
putExtra
(
"pwd"
,
pwd
)
putExtra
(
"pwd"
,
pwd
)
})
})
}
}
...
...
app/src/main/java/com/base/pdfreaderallpdfreader/utils/MediaStoreUtils.kt
View file @
c13b5df5
...
@@ -45,13 +45,6 @@ fun Context.updateMediaStore(
...
@@ -45,13 +45,6 @@ fun Context.updateMediaStore(
)
{
path
:
String
?,
uri
:
Uri
?
->
}
)
{
path
:
String
?,
uri
:
Uri
?
->
}
}
}
fun
Context
.
upDateDemoStore
()
{
val
demoFile
=
File
(
filesDir
,
"demo"
)
MediaScannerConnection
.
scanFile
(
this
,
arrayOf
(
demoFile
.
absolutePath
)
,
null
)
{
path
:
String
?,
uri
:
Uri
?
->
}
}
//图片视频音频不用这个查
//图片视频音频不用这个查
fun
Context
.
getMediaFile
(
selectionArgs
:
Array
<
String
>?
=
null
):
ArrayList
<
MediaBean
>
{
fun
Context
.
getMediaFile
(
selectionArgs
:
Array
<
String
>?
=
null
):
ArrayList
<
MediaBean
>
{
...
...
app/src/main/java/com/base/pdfreaderallpdfreader/utils/UriUtils.kt
View file @
c13b5df5
...
@@ -5,6 +5,7 @@ import android.net.Uri
...
@@ -5,6 +5,7 @@ import android.net.Uri
import
com.tom_roush.pdfbox.io.IOUtils
import
com.tom_roush.pdfbox.io.IOUtils
import
java.io.InputStream
import
java.io.InputStream
object
UriUtils
{
object
UriUtils
{
fun
readFileToByteArray
(
context
:
Context
,
uri
:
Uri
):
ByteArray
?
{
fun
readFileToByteArray
(
context
:
Context
,
uri
:
Uri
):
ByteArray
?
{
...
@@ -26,4 +27,18 @@ object UriUtils {
...
@@ -26,4 +27,18 @@ object UriUtils {
}
}
}
}
}
}
fun
isUriValid
(
context
:
Context
,
uri
:
Uri
?):
Boolean
{
if
(
uri
==
null
)
{
return
false
}
val
contentResolver
=
context
.
contentResolver
val
cursor
=
contentResolver
.
query
(
uri
,
null
,
null
,
null
,
null
)
if
(
cursor
!=
null
)
{
val
hasData
=
cursor
.
moveToFirst
()
cursor
.
close
()
return
hasData
}
return
false
}
}
}
\ No newline at end of file
app/src/main/res/layout/activity_pdf.xml
View file @
c13b5df5
...
@@ -170,9 +170,11 @@
...
@@ -170,9 +170,11 @@
android:layout_marginStart=
"28dp"
android:layout_marginStart=
"28dp"
android:layout_marginTop=
"28dp"
android:layout_marginTop=
"28dp"
android:background=
"@drawable/bg_54585b_5"
android:background=
"@drawable/bg_54585b_5"
android:gravity=
"center"
android:includeFontPadding=
"false"
android:includeFontPadding=
"false"
android:paddingHorizontal=
"2dp"
android:minWidth=
"40dp"
android:paddingVertical=
"2dp"
android:paddingHorizontal=
"5dp"
android:paddingVertical=
"3dp"
android:textColor=
"@color/white"
android:textColor=
"@color/white"
android:textSize=
"12sp"
android:textSize=
"12sp"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment