Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
E
Easy Cleaner Junk
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
Easy Cleaner Junk
Commits
4b752859
Commit
4b752859
authored
Jul 01, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
30939b41
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
9 deletions
+24
-9
BatteryInfoActivity.kt
...test/easy/easycleanerjunk/activity/BatteryInfoActivity.kt
+22
-3
BaseApplication.kt
...va/com/test/easy/easycleanerjunk/helps/BaseApplication.kt
+0
-5
BatteryReceiver.kt
.../com/test/easy/easycleanerjunk/service/BatteryReceiver.kt
+2
-1
No files found.
app/src/main/java/com/test/easy/easycleanerjunk/activity/BatteryInfoActivity.kt
View file @
4b752859
...
...
@@ -2,6 +2,7 @@ package com.test.easy.easycleanerjunk.activity
import
android.annotation.SuppressLint
import
android.content.Intent
import
android.content.IntentFilter
import
androidx.activity.addCallback
import
androidx.core.content.ContextCompat
import
androidx.core.view.isVisible
...
...
@@ -18,21 +19,34 @@ class BatteryInfoActivity : BaseActivity<ActivityLayoutBatteryInfoBinding>() {
override
val
binding
:
ActivityLayoutBatteryInfoBinding
by
lazy
{
ActivityLayoutBatteryInfoBinding
.
inflate
(
layoutInflater
)
}
private
lateinit
var
batteryReceiver
:
BatteryReceiver
@SuppressLint
(
"SetTextI18n"
)
override
fun
initView
()
{
batteryReceiver
=
BatteryReceiver
{
aa
()
}
registerReceiver
(
batteryReceiver
,
IntentFilter
().
apply
{
addAction
(
"android.intent.action.BATTERY_CHANGED"
)
})
AdmobUtils
.
showNativeAd
(
this
,
binding
.
idFlAd
)
binding
.
idBatteryLottie
.
imageAssetsFolder
=
"battery_scan/images/"
binding
.
idBatteryLottie
.
setAnimation
(
"battery_scan/data.json"
)
binding
.
idBatteryLottie
.
playAnimation
()
binding
.
root
.
postDelayed
({
AdmobUtils
.
showInterstitialAd
(
this
){
AdmobUtils
.
showInterstitialAd
(
this
)
{
binding
.
idBatteryLottie
.
clearAnimation
()
binding
.
idConsOne
.
isVisible
=
false
}
},
Random
.
nextLong
(
3000
,
4500
))
},
Random
.
nextLong
(
3000
,
4500
))
}
@SuppressLint
(
"SetTextI18n"
)
fun
aa
()
{
val
percent
=
BatteryReceiver
.
level
/
BatteryReceiver
.
scale
.
toFloat
()
binding
.
idChongdian
.
isVisible
=
BatteryReceiver
.
status
==
2
binding
.
idChongdian
.
isVisible
=
BatteryReceiver
.
status
==
2
binding
.
idTvDl
.
text
=
"${(percent * 100).toInt()}%"
val
p
=
(
percent
*
100
).
toInt
()
if
(
p
in
21
..
49
)
{
...
...
@@ -75,4 +89,9 @@ class BatteryInfoActivity : BaseActivity<ActivityLayoutBatteryInfoBinding>() {
}
}
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
unregisterReceiver
(
batteryReceiver
)
}
}
\ No newline at end of file
app/src/main/java/com/test/easy/easycleanerjunk/helps/BaseApplication.kt
View file @
4b752859
package
com.test.easy.easycleanerjunk.helps
import
android.app.Application
import
android.content.IntentFilter
import
com.test.easy.easycleanerjunk.service.BatteryReceiver
abstract
class
BaseApplication
:
Application
()
{
companion
object
{
...
...
@@ -13,9 +11,6 @@ abstract class BaseApplication : Application() {
super
.
onCreate
()
context
=
this
init
()
registerReceiver
(
BatteryReceiver
(),
IntentFilter
().
apply
{
addAction
(
"android.intent.action.BATTERY_CHANGED"
)
})
}
abstract
fun
init
()
...
...
app/src/main/java/com/test/easy/easycleanerjunk/service/BatteryReceiver.kt
View file @
4b752859
...
...
@@ -5,7 +5,7 @@ import android.content.Context
import
android.content.Intent
import
android.os.BatteryManager
class
BatteryReceiver
:
BroadcastReceiver
()
{
class
BatteryReceiver
(
val
change
:
()
->
Unit
)
:
BroadcastReceiver
()
{
companion
object
{
var
level
=
0
var
scale
=
0
...
...
@@ -33,6 +33,7 @@ class BatteryReceiver : BroadcastReceiver() {
if
(
chargeCounter
!=
Int
.
MIN_VALUE
&&
propertyCapacity
!=
Int
.
MIN_VALUE
)
{
mAh
=
(
chargeCounter
/
(
propertyCapacity
.
toFloat
()
/
100f
))
/
1000f
}
change
.
invoke
()
}
}
}
\ 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