Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
Solar Master Ace
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
Solar Master Ace
Commits
985eb386
Commit
985eb386
authored
Mar 21, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:白包bug修复
parent
bd6767e7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
347 additions
and
205 deletions
+347
-205
deploymentTargetDropDown.xml
.idea/deploymentTargetDropDown.xml
+1
-14
gradle.xml
.idea/gradle.xml
+1
-1
misc.xml
.idea/misc.xml
+1
-1
AdapterCommonDataFunction.kt
.../zxhy/solarmasterace/adapter/AdapterCommonDataFunction.kt
+0
-1
CommonAdapter.kt
...ain/java/com/zxhy/solarmasterace/adapter/CommonAdapter.kt
+5
-14
FileBean.kt
app/src/main/java/com/zxhy/solarmasterace/data/FileBean.kt
+2
-1
FileBrowserActivity.kt
...om/zxhy/solarmasterace/filebrowser/FileBrowserActivity.kt
+237
-133
FileDirectoryAdapter.kt
...hy/solarmasterace/internalstorage/FileDirectoryAdapter.kt
+27
-0
InternalStorageActivity.kt
...solarmasterace/internalstorage/InternalStorageActivity.kt
+14
-5
FileEx.kt
...rc/main/java/com/zxhy/solarmasterace/quicktools/FileEx.kt
+36
-23
FileHelper.kt
...ain/java/com/zxhy/solarmasterace/quicktools/FileHelper.kt
+21
-12
colors.xml
app/src/main/res/values/colors.xml
+2
-0
No files found.
.idea/deploymentTargetDropDown.xml
View file @
985eb386
...
...
@@ -3,20 +3,7 @@
<component
name=
"deploymentTargetDropDown"
>
<value>
<entry
key=
"app"
>
<State>
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type
value=
"RUNNING_DEVICE_TARGET"
/>
<deviceKey>
<Key>
<type
value=
"SERIAL_NUMBER"
/>
<value
value=
"3426369207001D6"
/>
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown
value=
"2024-03-21T08:35:33.717775700Z"
/>
</State>
<State
/>
</entry>
</value>
</component>
...
...
.idea/gradle.xml
View file @
985eb386
...
...
@@ -5,7 +5,7 @@
<option
name=
"linkedExternalProjectsSettings"
>
<GradleProjectSettings>
<option
name=
"externalProjectPath"
value=
"$PROJECT_DIR$"
/>
<option
name=
"gradleJvm"
value=
"
#JAVA_HOME
"
/>
<option
name=
"gradleJvm"
value=
"
jbr-17
"
/>
<option
name=
"modules"
>
<set>
<option
value=
"$PROJECT_DIR$"
/>
...
...
.idea/misc.xml
View file @
985eb386
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ExternalStorageConfigurationManager"
enabled=
"true"
/>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_17"
default=
"true"
project-jdk-name=
"17"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_17"
default=
"true"
project-jdk-name=
"
jbr-
17"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
<component
name=
"ProjectType"
>
...
...
app/src/main/java/com/zxhy/solarmasterace/adapter/AdapterCommonDataFunction.kt
View file @
985eb386
...
...
@@ -6,7 +6,6 @@ interface AdapterCommonDataFunction {
abstract
fun
setData
(
data
:
List
<
FileBean
>)
abstract
fun
addData
(
data
:
List
<
FileBean
>)
abstract
fun
addDataFinish
(
data
:
List
<
FileBean
>)
abstract
fun
clearData
()
abstract
fun
removeData
(
data
:
List
<
FileBean
>)
abstract
fun
getSelectData
():
List
<
FileBean
>
...
...
app/src/main/java/com/zxhy/solarmasterace/adapter/CommonAdapter.kt
View file @
985eb386
...
...
@@ -20,19 +20,11 @@ abstract class CommonAdapter<T : ViewHolder?>() : RecyclerView.Adapter<T>(),
@SuppressLint
(
"NotifyDataSetChanged"
)
override
fun
addData
(
data
:
List
<
FileBean
>)
{
fileList
.
addAll
(
data
)
if
(
firstRefresh
)
{
notifyDataSetChanged
()
firstRefresh
=
false
}
}
@SuppressLint
(
"NotifyDataSetChanged"
)
override
fun
addDataFinish
(
data
:
List
<
FileBean
>)
{
fileList
.
addAll
(
data
)
notifyDataSetChanged
()
}
@SuppressLint
(
"NotifyDataSetChanged"
)
override
fun
clearData
()
{
if
(
fileList
.
size
==
0
)
return
...
...
@@ -61,12 +53,11 @@ abstract class CommonAdapter<T : ViewHolder?>() : RecyclerView.Adapter<T>(),
@SuppressLint
(
"NotifyDataSetChanged"
)
override
fun
toggleSelect
(
select
:
Boolean
)
{
fileList
.
mapIndexed
{
index
,
fileBean
->
if
(
fileBean
.
isSelect
!=
select
)
{
fileBean
.
isSelect
=
select
notifyItemChanged
(
index
,
"单条刷新"
)
}
fileList
.
forEach
{
fileBean
->
fileBean
.
isSelect
=
select
}
notifyDataSetChanged
()
}
...
...
app/src/main/java/com/zxhy/solarmasterace/data/FileBean.kt
View file @
985eb386
...
...
@@ -174,9 +174,10 @@ fun File.isDocument(): Boolean {
return
isWord
()
or
isExcel
()
or
isPPt
()
or
isPdf
()
or
isTxt
()
}
fun
File
.
toFileBean
():
FileBean
{
fun
File
.
toFileBean
(
id
:
Long
=
0
):
FileBean
{
val
timeE
=
SimpleDateFormat
(
"MMM dd, yyyy"
,
Locale
.
ENGLISH
).
format
(
lastModified
())
return
FileBean
(
id
=
id
,
name
=
name
,
path
=
absolutePath
,
size
=
length
(),
...
...
app/src/main/java/com/zxhy/solarmasterace/filebrowser/FileBrowserActivity.kt
View file @
985eb386
This diff is collapsed.
Click to expand it.
app/src/main/java/com/zxhy/solarmasterace/internalstorage/FileDirectoryAdapter.kt
View file @
985eb386
package
com.zxhy.solarmasterace.internalstorage
import
android.annotation.SuppressLint
import
android.content.Context
import
android.os.Environment
import
android.util.Log
import
android.view.View
import
android.view.ViewGroup
import
androidx.core.content.ContextCompat
import
com.zxhy.solarmasterace.R
import
com.zxhy.solarmasterace.adapter.CommonAdapter
import
com.zxhy.solarmasterace.adapter.ItemCardFileViewHolder
...
...
@@ -21,6 +23,7 @@ class FileDirectoryAdapter(
private
var
currentDir
=
Environment
.
getExternalStorageDirectory
()
private
var
isSelectMode
=
false
private
var
pageTurn
=
true
private
var
operationFile
=
arrayListOf
<
FileBean
>()
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
ItemCardFileViewHolder
{
return
ItemCardFileViewHolder
(
R
.
layout
.
item_card_file
.
inflate
(
parent
))
...
...
@@ -68,6 +71,18 @@ class FileDirectoryAdapter(
if
(!
pageTurn
)
return
@setOnClickListener
nextPage
(
data
)
}
//该列表是选中列表
if
(
operationFile
.
map
{
it
.
path
}.
contains
(
data
.
path
))
{
root
.
setOnClickListener
{
}
root
.
setCardBackgroundColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
color_F4F4F4
)
)
}
else
{
root
.
setCardBackgroundColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
white
))
}
}
}
else
{
holder
.
binding
.
apply
{
...
...
@@ -118,4 +133,16 @@ class FileDirectoryAdapter(
return
currentDir
}
//当选中选中的列表,无法复制 移动到自身
fun
notifyCannotSelect
(
data
:
List
<
FileBean
>)
{
val
selectList
=
arrayListOf
<
FileBean
>()
selectList
.
addAll
(
data
)
operationFile
=
selectList
notifyDataSetChanged
()
}
fun
clearCannotSelect
()
{
operationFile
=
arrayListOf
()
}
}
\ No newline at end of file
app/src/main/java/com/zxhy/solarmasterace/internalstorage/InternalStorageActivity.kt
View file @
985eb386
...
...
@@ -31,8 +31,7 @@ class InternalStorageActivity : AppCompatActivity() {
private
val
MODE_BROWSE
=
0
private
val
MODE_SELECT
=
1
private
val
MODE_SELECTED_OPERATION
=
2
private
val
MODE_LOCK
=
-
1
private
var
currentMode
=
MODE_BROWSE
//0普通浏览模式 1可选模式 2选中操作模式 -1无权限锁功能模式
private
var
currentMode
=
MODE_BROWSE
//0普通浏览模式 1可选模式 2选中操作模式
private
lateinit
var
activityLauncher
:
ActivityLauncher
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
...
...
@@ -148,16 +147,21 @@ class InternalStorageActivity : AppCompatActivity() {
val
files
=
fileDirectoryAdapter
.
getSelectData
().
map
{
it
.
file
()
}
deleteFiles
(
files
)
{
showCardTip
(
"Successfully deleted!"
)
switchBrowseMode
()
}
}
binding
.
ivMove
.
setOnClickListener
{
val
moveFile
=
arrayListOf
<
File
>()
fileDirectoryAdapter
.
getSelectData
().
map
{
moveFile
.
add
(
it
.
file
())
}
val
selectList
=
fileDirectoryAdapter
.
getSelectData
()
selectList
.
map
{
moveFile
.
add
(
it
.
file
())
}
fileDirectoryAdapter
.
notifyCannotSelect
(
selectList
)
switchSelectedOperationMode
(
"Motion"
,
moveFile
)
}
binding
.
ivCopy
.
setOnClickListener
{
val
copyFile
=
arrayListOf
<
File
>()
fileDirectoryAdapter
.
getSelectData
().
map
{
copyFile
.
add
(
it
.
file
())
}
val
selectList
=
fileDirectoryAdapter
.
getSelectData
()
selectList
.
map
{
copyFile
.
add
(
it
.
file
())
}
fileDirectoryAdapter
.
notifyCannotSelect
(
selectList
)
switchSelectedOperationMode
(
"Copy"
,
copyFile
)
}
}
...
...
@@ -185,6 +189,7 @@ class InternalStorageActivity : AppCompatActivity() {
binding
.
tvDefine
.
setOnClickListener
{
moveFiles
(
files
)
{
showCardTip
(
"Successfully moved!"
)
fileDirectoryAdapter
.
clearCannotSelect
()
switchBrowseMode
()
}
}
...
...
@@ -193,6 +198,7 @@ class InternalStorageActivity : AppCompatActivity() {
"Copy"
->
{
binding
.
tvDefine
.
setOnClickListener
{
copyFiles
(
files
)
{
fileDirectoryAdapter
.
clearCannotSelect
()
showCardTip
(
"Successfully copied!"
)
switchBrowseMode
()
}
...
...
@@ -210,7 +216,10 @@ class InternalStorageActivity : AppCompatActivity() {
val
dir
=
fileDirectoryAdapter
.
getCurrentDir
()
?:
File
(
""
)
files
.
forEach
{
if
(
it
.
isFile
)
{
it
.
copyTo
(
File
(
dir
,
it
.
name
))
val
destFile
=
File
(
dir
,
it
.
name
)
if
(!
destFile
.
exists
())
{
it
.
copyTo
(
destFile
)
}
}
else
{
FileHelper
.
copyDirectory
(
it
,
File
(
dir
,
it
.
name
))
}
...
...
app/src/main/java/com/zxhy/solarmasterace/quicktools/FileEx.kt
View file @
985eb386
package
com.zxhy.solarmasterace.quicktools
import
android.os.Environment
import
androidx.lifecycle.LifecycleCoroutineScope
import
androidx.lifecycle.lifecycleScope
import
com.zxhy.solarmasterace.data.DupFileBean
import
com.zxhy.solarmasterace.data.FileBean
import
com.zxhy.solarmasterace.data.isApk
...
...
@@ -16,6 +18,8 @@ import com.zxhy.solarmasterace.data.isVideo
import
com.zxhy.solarmasterace.data.isWord
import
com.zxhy.solarmasterace.data.isZip
import
com.zxhy.solarmasterace.data.toFileBean
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
import
java.io.File
import
java.util.Stack
...
...
@@ -52,23 +56,28 @@ fun dupImage(): List<DupFileBean> {
}
fun
largeFile
(
lifecycleScope
:
LifecycleCoroutineScope
,
onDo
:
((
file
:
List
<
FileBean
>)
->
Unit
)?
=
null
,
onFinish
:
((
file
:
List
<
FileBean
>,
count
:
Int
)
->
Unit
)?
=
null
)
{
val
rootDir
=
Environment
.
getExternalStorageDirectory
()
val
tempList
=
arrayListOf
<
FileBean
>()
var
count
=
0
FileHelper
.
linkedLisTraverseFolder
(
rootDir
)
{
if
(
it
.
length
()
>
10
*
1024
*
1024
)
{
tempList
.
add
(
it
.
toFileBean
())
count
++
if
(
tempList
.
size
==
10
)
{
onDo
?.
invoke
(
tempList
)
tempList
.
clear
()
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
val
rootDir
=
Environment
.
getExternalStorageDirectory
()
val
tempList
=
arrayListOf
<
FileBean
>()
var
count
=
0
FileHelper
.
linkedLisTraverseFolder
(
rootDir
)
{
if
(
it
.
length
()
>
10
*
1024
*
1024
)
{
tempList
.
add
(
it
.
toFileBean
())
count
++
if
(
tempList
.
size
==
10
)
{
onDo
?.
invoke
(
tempList
)
tempList
.
clear
()
}
}
}
onFinish
?.
invoke
(
tempList
,
count
)
}
onFinish
?.
invoke
(
tempList
,
count
)
}
fun
audioFile
(
...
...
@@ -295,25 +304,29 @@ fun emptyFile(
}
fun
imageFile
(
lifecycleCoroutineScope
:
LifecycleCoroutineScope
,
onDo
:
((
file
:
List
<
FileBean
>)
->
Unit
)?
=
null
,
onFinish
:
((
file
:
List
<
FileBean
>,
count
:
Int
)
->
Unit
)?
=
null
onFinish
:
((
file
:
List
<
FileBean
>,
count
:
Long
)
->
Unit
)?
=
null
)
{
val
rootDir
=
Environment
.
getExternalStorageDirectory
()
val
tempList
=
arrayListOf
<
FileBean
>()
var
count
=
0
FileHelper
.
linkedLisTraverseFolder
(
rootDir
)
{
if
(
it
.
isImage
())
{
tempList
.
add
(
it
.
toFileBean
())
count
++
if
(
tempList
.
size
==
10
)
{
onDo
?.
invoke
(
tempList
)
tempList
.
clear
()
lifecycleCoroutineScope
.
launch
(
Dispatchers
.
IO
)
{
val
rootDir
=
Environment
.
getExternalStorageDirectory
()
val
tempList
=
arrayListOf
<
FileBean
>()
var
count
=
0L
FileHelper
.
linkedLisTraverseFolder
(
rootDir
)
{
if
(
it
.
isImage
())
{
tempList
.
add
(
it
.
toFileBean
(
count
))
count
++
if
(
tempList
.
size
==
10
)
{
onDo
?.
invoke
(
tempList
)
tempList
.
clear
()
}
}
}
onFinish
?.
invoke
(
tempList
,
count
)
}
onFinish
?.
invoke
(
tempList
,
count
)
}
fun
videoFile
(
onDo
:
((
file
:
List
<
FileBean
>)
->
Unit
)?
=
null
,
onFinish
:
((
file
:
List
<
FileBean
>,
count
:
Int
)
->
Unit
)?
=
null
...
...
app/src/main/java/com/zxhy/solarmasterace/quicktools/FileHelper.kt
View file @
985eb386
...
...
@@ -83,13 +83,15 @@ object FileHelper {
val
currentFile
=
stackFiles
.
peek
()
val
subFiles
=
currentFile
.
listFiles
()
for
(
i
in
subFiles
!!
.
indices
)
{
if
(
subFiles
[
i
].
isFile
)
{
if
(!
subFiles
[
i
].
delete
())
{
return
false
if
(
subFiles
!=
null
)
{
for
(
i
in
subFiles
.
indices
)
{
if
(
subFiles
[
i
].
isFile
)
{
if
(!
subFiles
[
i
].
delete
())
{
return
false
}
}
else
{
stackFiles
.
push
(
subFiles
[
i
])
}
}
else
{
stackFiles
.
push
(
subFiles
[
i
])
}
}
if
(
currentFile
===
stackFiles
.
peek
())
{
...
...
@@ -108,15 +110,22 @@ object FileHelper {
* @param target 目标文件夹
*/
fun
copyDirectory
(
source
:
File
,
target
:
File
)
{
if
(
source
.
isDirectory
)
{
if
(!
target
.
exists
())
target
.
mkdir
()
try
{
if
(
source
.
isDirectory
)
{
if
(!
target
.
exists
())
target
.
mkdir
()
source
.
list
()
?.
map
{
sub
->
copyDirectory
(
File
(
source
,
sub
),
File
(
target
,
sub
))
source
.
list
()
?.
map
{
sub
->
copyDirectory
(
File
(
source
,
sub
),
File
(
target
,
sub
))
}
}
else
{
if
(!
target
.
exists
())
{
source
.
copyTo
(
target
)
}
}
}
else
{
source
.
copyTo
(
target
)
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
(
)
}
}
}
\ No newline at end of file
app/src/main/res/values/colors.xml
View file @
985eb386
...
...
@@ -6,4 +6,6 @@
<color
name=
"color_FF4CE0AB"
>
#FF4CE0AB
</color>
<color
name=
"color_FF333333"
>
#FF333333
</color>
<color
name=
"color_FF999999"
>
#FF999999
</color>
<color
name=
"color_999999"
>
#999999
</color>
<color
name=
"color_F4F4F4"
>
#F4F4F4
</color>
</resources>
\ 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