Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
Super PDF 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
Super PDF Reader
Commits
41d9bd85
Commit
41d9bd85
authored
Jun 19, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...提交部分ui...
parent
8ad6118d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
0 deletions
+67
-0
MediaStoreHelp.kt
...main/java/com/base/superpdfreader/helps/MediaStoreHelp.kt
+67
-0
No files found.
app/src/main/java/com/base/superpdfreader/helps/MediaStoreHelp.kt
View file @
41d9bd85
package
com.base.superpdfreader.helps
package
com.base.superpdfreader.helps
import
android.annotation.SuppressLint
import
android.content.Context
import
android.database.Cursor
import
android.media.MediaScannerConnection
import
android.net.Uri
import
android.os.Environment
import
android.provider.MediaStore
import
com.base.superpdfreader.bean.DocumentBean
object
MediaStoreHelp
{
object
MediaStoreHelp
{
@SuppressLint
(
"Range"
)
fun
Context
.
geFileMedia
(
list
:
ArrayList
<
DocumentBean
>,
selectionArgs
:
Array
<
String
>):
ArrayList
<
DocumentBean
>
{
val
projection
=
arrayOf
(
MediaStore
.
Files
.
FileColumns
.
_ID
,
MediaStore
.
Files
.
FileColumns
.
DATA
,
MediaStore
.
Files
.
FileColumns
.
MIME_TYPE
,
MediaStore
.
Files
.
FileColumns
.
TITLE
,
MediaStore
.
Files
.
FileColumns
.
SIZE
,
)
// 选择条件,筛选出MIME类型为application/zip的文件
val
selection
=
MediaStore
.
Files
.
FileColumns
.
MIME_TYPE
+
"=?"
// val selectionArgs = arrayOf("application/zip")
var
cursor
:
Cursor
?
=
null
try
{
cursor
=
contentResolver
.
query
(
MediaStore
.
Files
.
getContentUri
(
"external"
),
// 你也可以使用INTERNAL_CONTENT_URI来查询内部存储
projection
,
selection
,
selectionArgs
,
null
// 无排序
)
if
(
cursor
!=
null
)
{
while
(
cursor
.
moveToNext
())
{
val
tittle
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
MediaStore
.
Files
.
FileColumns
.
TITLE
))
val
path
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
MediaStore
.
Files
.
FileColumns
.
DATA
))
val
size
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
MediaStore
.
Files
.
FileColumns
.
SIZE
)).
toLong
()
// 其他属性...
}
cursor
.
close
()
}
}
catch
(
e
:
Exception
)
{
}
finally
{
cursor
?.
close
()
}
return
list
}
val
commonMediaDir
=
arrayOf
(
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_DCIM
).
absolutePath
,
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_DOWNLOADS
).
absolutePath
,
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_MOVIES
).
absolutePath
,
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_MUSIC
).
absolutePath
,
)
fun
Context
.
updateMediaStore
(
filePath
:
Array
<
String
>
=
commonMediaDir
)
{
MediaScannerConnection
.
scanFile
(
this
,
filePath
,
null
)
{
path
:
String
?,
uri
:
Uri
?
->
}
}
}
}
\ No newline at end of file
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