Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
F
FileManager
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
yanglin
FileManager
Commits
fa4e93cf
Commit
fa4e93cf
authored
Apr 18, 2024
by
yanglin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean功能完善
parent
7756c502
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
168 additions
and
46 deletions
+168
-46
CleanActivity.kt
...n/java/com/xm/test/myfilemaster/activity/CleanActivity.kt
+4
-4
ScanResultActivity.kt
...a/com/xm/test/myfilemaster/activity/ScanResultActivity.kt
+35
-3
CleanAdapter2.kt
...in/java/com/xm/test/myfilemaster/adapter/CleanAdapter2.kt
+56
-32
ScanResultAdapter.kt
...ava/com/xm/test/myfilemaster/adapter/ScanResultAdapter.kt
+6
-0
RotatingImageView.kt
...n/java/com/xm/test/myfilemaster/view/RotatingImageView.kt
+58
-0
activity_clean.xml
MyDemo3/app/src/main/res/layout/activity_clean.xml
+3
-3
clean_list_item_layout.xml
MyDemo3/app/src/main/res/layout/clean_list_item_layout.xml
+4
-4
loading.png
MyDemo3/app/src/main/res/mipmap-hdpi/loading.png
+0
-0
loading.png
MyDemo3/app/src/main/res/mipmap-mdpi/loading.png
+0
-0
loading.png
MyDemo3/app/src/main/res/mipmap-xhdpi/loading.png
+0
-0
loading.png
MyDemo3/app/src/main/res/mipmap-xxhdpi/loading.png
+0
-0
loading.png
MyDemo3/app/src/main/res/mipmap-xxxhdpi/loading.png
+0
-0
kaishi.json
MyDemo3/app/src/main/res/raw/kaishi.json
+1
-0
xunhuan.json
MyDemo3/app/src/main/res/raw/xunhuan.json
+1
-0
No files found.
MyDemo3/app/src/main/java/com/xm/test/myfilemaster/activity/CleanActivity.kt
View file @
fa4e93cf
...
...
@@ -27,11 +27,9 @@ import com.xm.test.myfilemaster.MyApplication
import
com.xm.test.myfilemaster.R
import
com.xm.test.myfilemaster.adapter.CleanAdapter
import
com.xm.test.myfilemaster.adapter.CleanAdapter2
import
com.xm.test.myfilemaster.antivirus.AntivirusActivity
import
com.xm.test.myfilemaster.model.CleanBean
import
com.xm.test.myfilemaster.model.FileBean
import
com.xm.test.myfilemaster.util.FileUtil
import
kotlinx.coroutines.runInterruptible
import
java.io.File
class
CleanActivity
:
AppCompatActivity
(),
CleanAdapter2
.
IClean
{
...
...
@@ -145,8 +143,10 @@ class CleanActivity : AppCompatActivity(), CleanAdapter2.IClean {
mAnimation
.
visibility
=
View
.
VISIBLE
Thread
(
Runnable
{
Thread
.
sleep
(
1000
)
mCleanAdapter2
?.
mFileCheckedItemList
?.
forEach
{
MyApplication
.
mCleanSdk
?.
delete
(
File
(
it
.
filePath
))
mCleanAdapter2
?.
mFileCheckedItemLists
?.
forEach
{
it
.
forEach
{
MyApplication
.
mCleanSdk
?.
delete
(
File
(
it
.
filePath
))
}
}
runOnUiThread
{
val
intent
=
Intent
(
this
,
ResultPageActivity
::
class
.
java
)
...
...
MyDemo3/app/src/main/java/com/xm/test/myfilemaster/activity/ScanResultActivity.kt
View file @
fa4e93cf
...
...
@@ -68,9 +68,20 @@ class ScanResultActivity : AppCompatActivity() {
customDialog
.
setsCancel
(
View
.
OnClickListener
{
customDialog
.
dismiss
()
}).
setsConfirm
(
View
.
OnClickListener
{
Intent
(
Intent
.
ACTION_DELETE
,
Uri
.
parse
(
"package:${mCurrentAppInfo!!.packageName}"
))
val
packageName
=
mCurrentAppInfo
!!
.
packageName
// 要卸载的应用包名
val
intent
=
Intent
(
Intent
.
ACTION_UNINSTALL_PACKAGE
)
intent
.
data
=
Uri
.
parse
(
"package:$packageName"
)
startActivity
(
intent
)
mResult
?.
remove
(
mCurrentAppInfo
!!
)
mAppinfoPage
.
visibility
=
View
.
GONE
mDeleteGroupView
.
visibility
=
View
.
GONE
mGoItBtn
.
visibility
=
View
.
VISIBLE
mScanResultListLyout
.
visibility
=
View
.
VISIBLE
customDialog
.
dismiss
()
// Intent(Intent.ACTION_DELETE, Uri.parse("package:${mCurrentAppInfo!!.packageName}"))
// startActivity(intent)
// mResult?.remove(mCurrentAppInfo!!)
}).
show
()
customDialog
.
isShowEditText
(
false
)
customDialog
.
setsTitle
(
"Delete"
)
...
...
@@ -108,7 +119,14 @@ class ScanResultActivity : AppCompatActivity() {
mAntivirusSuccessView
.
visibility
=
View
.
VISIBLE
}
findViewById
<
View
>(
R
.
id
.
scan_result_quit_btn
).
setOnClickListener
{
finish
()
if
(
mAppinfoPage
.
isVisible
){
mAppinfoPage
.
visibility
=
View
.
GONE
mDeleteGroupView
.
visibility
=
View
.
GONE
mGoItBtn
.
visibility
=
View
.
VISIBLE
mScanResultListLyout
.
visibility
=
View
.
VISIBLE
}
else
{
finish
()
}
}
findViewById
<
View
>(
R
.
id
.
scan_result_finish_text
).
setOnClickListener
{
...
...
@@ -148,4 +166,18 @@ class ScanResultActivity : AppCompatActivity() {
super
.
onBackPressed
()
}
}
override
fun
onResume
()
{
super
.
onResume
()
if
(
mCurrentAppInfo
!=
null
){
try
{
packageManager
.
getPackageInfo
(
mCurrentAppInfo
!!
.
packageName
,
PackageManager
.
GET_ACTIVITIES
)
mResult
?.
remove
(
mCurrentAppInfo
!!
)
mScanResultAdapter
?.
setDatas
(
mResult
!!
)
}
catch
(
e
:
PackageManager
.
NameNotFoundException
){
println
(
e
.
message
)
}
}
}
}
\ No newline at end of file
MyDemo3/app/src/main/java/com/xm/test/myfilemaster/adapter/CleanAdapter2.kt
View file @
fa4e93cf
package
com.xm.test.myfilemaster.adapter
import
android.util.Log
import
android.util.SparseBooleanArray
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.ListView
import
androidx.recyclerview.widget.RecyclerView
import
com.xm.test.myfilemaster.R
import
com.xm.test.myfilemaster.activity.CleanActivity
import
com.xm.test.myfilemaster.databinding.CleanListItemLayoutBinding
import
com.xm.test.myfilemaster.databinding.FilesItemLayoutBinding
import
com.xm.test.myfilemaster.model.CleanBean
...
...
@@ -17,9 +16,8 @@ class CleanAdapter2(mIClean: IClean) : RecyclerView.Adapter<CleanAdapter2.AAA>()
private
val
list
=
ArrayList
<
CleanBean
>()
var
mFileCheckedItemList
=
ArrayList
<
FileBean
>()
private
var
sparseBooleanArray
=
ArrayList
<
SparseBooleanArray
>()
var
mFileCheckedItemLists
=
ArrayList
<
ArrayList
<
FileBean
>>()
private
var
mCheckedBooleanArrays
=
ArrayList
<
SparseBooleanArray
>()
private
var
itemAdapters
=
ArrayList
<
SubAdapter
>()
var
mAllSizes
=
ArrayList
<
Long
>()
var
mSwitchAll
=
ArrayList
<
Boolean
>()
...
...
@@ -47,15 +45,11 @@ class CleanAdapter2(mIClean: IClean) : RecyclerView.Adapter<CleanAdapter2.AAA>()
override
fun
onBindViewHolder
(
holder
:
AAA
,
position
:
Int
)
{
val
data
=
list
[
position
]
sparseBooleanArray
.
add
(
SparseBooleanArray
())
itemAdapters
.
add
(
SubAdapter
(
position
))
mSwitchAll
.
add
(
false
)
itemAdapters
.
add
(
SubAdapter
(
position
,
mCheckedBooleanArrays
[
position
]))
mSwitchAll
.
add
(
true
)
holder
.
binding
.
cleanItemName
.
text
=
data
.
typeName
holder
.
binding
.
cleanItemCheckBox
.
isChecked
=
mSwitchAll
[
position
]
holder
.
binding
.
cleanItemList
.
visibility
=
if
(!
CleanAdapter
.
isCleanOver
)
View
.
GONE
else
View
.
VISIBLE
holder
.
binding
.
cleanItemUnfold
.
visibility
=
if
(!
CleanAdapter
.
isCleanOver
)
View
.
GONE
else
View
.
VISIBLE
holder
.
binding
.
fileItemSize
.
visibility
=
if
(!
CleanAdapter
.
isCleanOver
)
View
.
GONE
else
View
.
VISIBLE
...
...
@@ -89,29 +83,34 @@ class CleanAdapter2(mIClean: IClean) : RecyclerView.Adapter<CleanAdapter2.AAA>()
data
.
isListViewShow
=
!
data
.
isListViewShow
notifyItemChanged
(
position
)
}
holder
.
binding
.
cleanItemCheckBox
.
isChecked
=
mSwitchAll
[
position
]
selectAll
(
mSwitchAll
[
position
],
position
)
holder
.
binding
.
cleanItemCheckBox
.
setOnClickListener
{
if
(
CleanAdapter
.
isCleanOver
){
mSwitchAll
[
position
]
=
!
mSwitchAll
[
position
]
list
[
position
].
fileBeans
.
forEach
{
it
.
isChecked
=
holder
.
binding
.
cleanItemCheckBox
.
isChecked
}
if
(
holder
.
binding
.
cleanItemCheckBox
.
isChecked
){
mFileCheckedItemList
.
addAll
(
list
[
position
].
fileBeans
)
}
else
{
mFileCheckedItemList
.
removeAll
(
list
[
position
].
fileBeans
)
}
itemAdapters
[
position
].
setData
(
list
[
position
].
fileBeans
)
selectAll
(
mSwitchAll
[
position
],
position
)
notifyItemChanged
(
position
)
changeSwitchSize
()
}
}
//选中的逻辑,先外层通过data的属性值是否选中,点击事假更新子类表选中状态下
}
fun
selectAll
(
isChecked
:
Boolean
,
position
:
Int
){
mFileCheckedItemLists
[
position
].
clear
()
if
(
isChecked
)
mFileCheckedItemLists
[
position
].
addAll
(
list
[
position
].
fileBeans
)
for
(
i
in
list
[
position
].
fileBeans
.
indices
){
mCheckedBooleanArrays
[
position
].
put
(
i
,
isChecked
)
}
itemAdapters
[
position
].
notifyDataSetChanged
()
changeSwitchSize
()
}
private
fun
changeSwitchSize
()
{
var
size
:
Long
=
0
mFileCheckedItemList
.
forEach
{
size
+=
it
.
fileSize
mFileCheckedItemLists
.
forEach
{
it
.
forEach
{
size
+=
it
.
fileSize
}
}
mIClean
.
OnChekedItemListener
(
size
)
...
...
@@ -120,16 +119,27 @@ class CleanAdapter2(mIClean: IClean) : RecyclerView.Adapter<CleanAdapter2.AAA>()
fun
setData
(
datas
:
List
<
CleanBean
>)
{
list
.
clear
()
list
.
addAll
(
datas
)
notifyDataSetChanged
()
mCheckedBooleanArrays
.
clear
()
mFileCheckedItemLists
.
clear
()
for
(
i
in
datas
.
indices
)
{
mCheckedBooleanArrays
.
add
(
SparseBooleanArray
())
mFileCheckedItemLists
.
add
(
ArrayList
())
for
(
j
in
0
..
<
datas
[
i
].
fileBeans
.
size
){
mCheckedBooleanArrays
[
i
].
put
(
j
,
false
)
}
notifyItemChanged
(
i
)
}
}
inner
class
SubAdapter
(
itemPosition
:
Int
)
:
RecyclerView
.
Adapter
<
SubAdapter
.
BBB
>()
{
inner
class
SubAdapter
(
itemPosition
:
Int
,
sparseBooleanArray
:
SparseBooleanArray
)
:
RecyclerView
.
Adapter
<
SubAdapter
.
BBB
>()
{
private
val
sibList
=
ArrayList
<
FileBean
>()
private
var
itemPosition
:
Int
private
var
sparseBooleanArray
:
SparseBooleanArray
init
{
this
.
itemPosition
=
itemPosition
this
.
sparseBooleanArray
=
sparseBooleanArray
}
inner
class
BBB
(
view
:
View
)
:
RecyclerView
.
ViewHolder
(
view
)
{
...
...
@@ -153,20 +163,34 @@ class CleanAdapter2(mIClean: IClean) : RecyclerView.Adapter<CleanAdapter2.AAA>()
holder
.
binding
.
fileJoinToImg
.
visibility
=
View
.
GONE
holder
.
binding
.
fileSelectSwitch
.
visibility
=
if
(!
CleanAdapter
.
isCleanOver
)
View
.
GONE
else
View
.
VISIBLE
holder
.
binding
.
fileSelectSwitch
.
isChecked
=
sibList
[
position
].
isChecked
holder
.
binding
.
fileSelectSwitch
.
isChecked
=
mCheckedBooleanArrays
[
itemPosition
][
position
]
holder
.
binding
.
fileSelectSwitch
.
setOnClickListener
{
sibList
[
position
].
isChecked
=
!
sibList
[
position
].
isChecked
if
(
holder
.
binding
.
fileSelectSwitch
.
isChecked
){
mFileCheckedItemList
.
add
(
sibList
[
position
])
holder
.
binding
.
itemLayout
.
setOnClickListener
{
Log
.
e
(
"yanglin"
,
"onBindViewHolder: $itemPosition $position"
,
)
mCheckedBooleanArrays
[
itemPosition
].
put
(
position
,
!
mCheckedBooleanArrays
[
itemPosition
][
position
])
if
(
mCheckedBooleanArrays
[
itemPosition
][
position
]){
mFileCheckedItemLists
[
itemPosition
].
add
(
sibList
[
position
])
}
else
{
mFileCheckedItemList
.
remove
(
sibList
[
position
])
mSwitchAll
[
itemPosition
]
=
false
mFileCheckedItemLists
[
itemPosition
].
remove
(
sibList
[
position
])
}
mSwitchAll
[
itemPosition
]
=
false
changeSwitchSize
()
notifyItemChanged
(
position
)
// holder.binding.fileSelectSwitch.isChecked = !holder.binding.fileSelectSwitch.isChecked
}
// holder.binding.fileSelectSwitch.setOnClickListener {
// sibList[position].isChecked = !sibList[position].isChecked
// if (holder.binding.fileSelectSwitch.isChecked){
// mFileCheckedItemList.add(sibList[position])
// }else{
// mFileCheckedItemList.remove(sibList[position])
// mSwitchAll[itemPosition] = false
// }
// changeSwitchSize()
// notifyItemChanged(position)
// }
when
(
itemPosition
){
0
->{
holder
.
binding
.
fileItemName
.
text
=
sibList
[
position
].
fileName
...
...
MyDemo3/app/src/main/java/com/xm/test/myfilemaster/adapter/ScanResultAdapter.kt
View file @
fa4e93cf
...
...
@@ -34,6 +34,12 @@ class ScanResultAdapter(dataList: ArrayList<AppInfo>,
return
position
.
toLong
()
}
fun
setDatas
(
dataList
:
ArrayList
<
AppInfo
>){
this
.
dataList
.
clear
()
this
.
dataList
.
addAll
(
dataList
)
notifyDataSetChanged
()
}
override
fun
getView
(
position
:
Int
,
convertView
:
View
?,
parent
:
ViewGroup
?):
View
{
var
view
:
View
var
viewHolder
:
ScanResultViewHolder
...
...
MyDemo3/app/src/main/java/com/xm/test/myfilemaster/view/RotatingImageView.kt
0 → 100644
View file @
fa4e93cf
package
com.xm.test.myfilemaster.view
import
android.animation.ValueAnimator
import
android.content.Context
import
android.graphics.Bitmap
import
android.graphics.BitmapFactory
import
android.graphics.Canvas
import
android.graphics.Matrix
import
android.util.AttributeSet
import
android.view.View
import
com.xm.test.myfilemaster.R
class
RotatingImageView
@JvmOverloads
constructor
(
context
:
Context
,
attrs
:
AttributeSet
?
=
null
,
defStyleAttr
:
Int
=
0
)
:
View
(
context
,
attrs
,
defStyleAttr
)
{
private
var
bitmap
:
Bitmap
?
=
null
private
var
matrix
:
Matrix
=
Matrix
()
private
var
rotationAnimator
:
ValueAnimator
?
=
null
private
var
rotationAngle
:
Float
=
0f
init
{
// 加载图片
bitmap
=
BitmapFactory
.
decodeResource
(
resources
,
R
.
mipmap
.
loading
)
// 创建旋转动画
rotationAnimator
=
ValueAnimator
.
ofFloat
(
0f
,
360f
)
rotationAnimator
?.
apply
{
repeatCount
=
ValueAnimator
.
INFINITE
duration
=
2000
// 旋转一周的时间
addUpdateListener
{
animation
->
rotationAngle
=
animation
.
animatedValue
as
Float
invalidate
()
}
start
()
}
}
override
fun
onDraw
(
canvas
:
Canvas
)
{
super
.
onDraw
(
canvas
)
// 如果没有图片,直接返回
bitmap
?.
let
{
// 保存画布状态
canvas
.
save
()
// 旋转图片
matrix
.
setRotate
(
rotationAngle
,
it
.
width
/
2f
,
it
.
height
/
2f
)
canvas
.
drawBitmap
(
it
,
matrix
,
null
)
// 恢复画布状态
canvas
.
restore
()
}
}
}
MyDemo3/app/src/main/res/layout/activity_clean.xml
View file @
fa4e93cf
...
...
@@ -93,11 +93,11 @@
<com.airbnb.lottie.LottieAnimationView
android:id=
"@+id/battery_animation_btn"
android:layout_width=
"match_parent"
android:layout_height=
"
160
dp"
android:layout_marginTop=
"
20
dp"
android:layout_height=
"
248
dp"
android:layout_marginTop=
"
-46
dp"
app:lottie_autoPlay=
"true"
app:lottie_loop=
"true"
app:lottie_rawRes=
"@raw/
qinglisaomiao
"
/>
app:lottie_rawRes=
"@raw/
xunhuan
"
/>
<LinearLayout
android:id=
"@+id/ad_layout"
...
...
MyDemo3/app/src/main/res/layout/clean_list_item_layout.xml
View file @
fa4e93cf
...
...
@@ -37,13 +37,13 @@
android:button=
"@null"
android:drawableEnd=
"@drawable/bg_item_switch_selector"
/>
<ImageView
<
com.xm.test.myfilemaster.view.Rotating
ImageView
android:id=
"@+id/clean_item_more"
android:layout_width=
"
wrap_content
"
android:layout_height=
"
wrap_content
"
android:layout_width=
"
30dp
"
android:layout_height=
"
30dp
"
android:layout_alignParentEnd=
"true"
android:layout_centerVertical=
"true"
android:src=
"@mipmap/
more
"
/>
android:src=
"@mipmap/
loading
"
/>
<TextView
android:id=
"@+id/file_item_size"
...
...
MyDemo3/app/src/main/res/mipmap-hdpi/loading.png
0 → 100644
View file @
fa4e93cf
471 Bytes
MyDemo3/app/src/main/res/mipmap-mdpi/loading.png
0 → 100644
View file @
fa4e93cf
264 Bytes
MyDemo3/app/src/main/res/mipmap-xhdpi/loading.png
0 → 100644
View file @
fa4e93cf
640 Bytes
MyDemo3/app/src/main/res/mipmap-xxhdpi/loading.png
0 → 100644
View file @
fa4e93cf
1.26 KB
MyDemo3/app/src/main/res/mipmap-xxxhdpi/loading.png
0 → 100644
View file @
fa4e93cf
1.09 KB
MyDemo3/app/src/main/res/raw/kaishi.json
0 → 100644
View file @
fa4e93cf
This diff is collapsed.
Click to expand it.
MyDemo3/app/src/main/res/raw/xunhuan.json
0 → 100644
View file @
fa4e93cf
This diff is collapsed.
Click to expand it.
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