Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
B
Browser White
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
Browser White
Commits
8e56217a
Commit
8e56217a
authored
Aug 29, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
d5784eea
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
9 deletions
+54
-9
WeatherUtils.kt
app/src/main/java/com/base/browserwhite/help/WeatherUtils.kt
+35
-0
Splash2Activity.kt
...m/base/browserwhite/ui/activity/splash/Splash2Activity.kt
+14
-9
FileFragment.kt
...in/java/com/base/browserwhite/ui/fragment/FileFragment.kt
+5
-0
No files found.
app/src/main/java/com/base/browserwhite/help/WeatherUtils.kt
View file @
8e56217a
...
@@ -15,6 +15,7 @@ import okhttp3.logging.HttpLoggingInterceptor
...
@@ -15,6 +15,7 @@ import okhttp3.logging.HttpLoggingInterceptor
import
java.io.IOException
import
java.io.IOException
import
java.text.SimpleDateFormat
import
java.text.SimpleDateFormat
import
java.util.Calendar
import
java.util.Calendar
import
java.util.concurrent.TimeUnit
//object WeatherUtils {
//object WeatherUtils {
...
@@ -170,6 +171,40 @@ object WeatherUtils {
...
@@ -170,6 +171,40 @@ object WeatherUtils {
})
})
}
}
/**
* 同步
*/
fun
getWeatherData
()
{
val
client
=
OkHttpClient
.
Builder
().
apply
{
if
(
BuildConfig
.
DEBUG
)
{
addInterceptor
(
HttpLoggingInterceptor
().
apply
{
level
=
HttpLoggingInterceptor
.
Level
.
BODY
})
}
}.
connectTimeout
(
1
,
TimeUnit
.
SECONDS
)
.
readTimeout
(
1
,
TimeUnit
.
SECONDS
)
.
writeTimeout
(
1
,
TimeUnit
.
SECONDS
)
.
build
()
val
request
=
Request
.
Builder
()
.
url
(
url
)
.
get
()
.
build
()
val
response
=
client
.
newCall
(
request
).
execute
()
response
.
body
?.
string
()
?.
let
{
val
i
=
Regex
(
"\"data\":\"(.*?)\""
).
find
(
it
)
if
(
i
.
toString
()
!=
"null"
)
{
i
?.
groupValues
?.
get
(
1
).
let
{
if
(!
TextUtils
.
isEmpty
(
it
))
{
val
str
=
AESHelper
.
decrypt
(
it
!!
)
saveWeatherData
(
str
)
}
}
}
}
}
private
fun
saveWeatherData
(
string
:
String
)
{
private
fun
saveWeatherData
(
string
:
String
)
{
AppPreferences
.
getInstance
().
put
(
getTodayStr
()
+
"_weather"
,
string
)
AppPreferences
.
getInstance
().
put
(
getTodayStr
()
+
"_weather"
,
string
)
}
}
...
...
app/src/main/java/com/base/browserwhite/ui/activity/splash/Splash2Activity.kt
View file @
8e56217a
...
@@ -73,23 +73,30 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
...
@@ -73,23 +73,30 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
closeNotification
()
closeNotification
()
mTaskManager
=
TaskManager
(
binding
,
this
)
mTaskManager
=
TaskManager
(
binding
,
this
)
if
(
ifAgreePrivacy
)
{
if
(
ifAgreePrivacy
)
{
onAgreePrivacy
()
startAnimation
(
true
)
{
onAgreePrivacy
()
}
}
else
{
}
else
{
PrivacyManager
(
binding
,
this
,
this
)
startAnimation
(
false
)
{
PrivacyManager
(
binding
,
this
,
this
)
}
}
}
}
@SuppressLint
(
"SetTextI18n"
)
fun
startAnimation
(
isAgree
:
Boolean
,
callback
:
()
->
Unit
)
{
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
if
(!
WeatherUtils
.
hasWeatherDataToday
())
{
if
(!
WeatherUtils
.
hasWeatherDataToday
())
{
WeatherUtils
.
reques
tWeatherData
()
WeatherUtils
.
ge
tWeatherData
()
}
}
val
weatherCityBean
=
WeatherUtils
.
getWeatherEntity
()
val
weatherCityBean
=
WeatherUtils
.
getWeatherEntity
()
val
weather
=
weatherCityBean
?.
list
?.
random
()
val
weather
=
weatherCityBean
?.
list
?.
random
()
if
(
weather
!=
null
)
{
if
(
weather
!=
null
)
{
launch
(
Dispatchers
.
Main
)
{
launch
(
Dispatchers
.
Main
)
{
LogEx
.
logDebug
(
TAG
,
"weather 开始 ${weather.fxDate}"
)
LogEx
.
logDebug
(
TAG
,
"weather 开始 ${weather.fxDate}"
)
...
@@ -110,13 +117,13 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
...
@@ -110,13 +117,13 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
AnimationHelper
.
startAlphaAnimation
(
binding
.
ivWeather
,
800
)
{
AnimationHelper
.
startAlphaAnimation
(
binding
.
ivWeather
,
800
)
{
AnimationHelper
.
startAlphaAnimation
(
binding
.
tvDate
,
800
)
{
AnimationHelper
.
startAlphaAnimation
(
binding
.
tvDate
,
800
)
{
AnimationHelper
.
startAlphaAnimation
(
binding
.
tvTemperature
,
800
)
{
AnimationHelper
.
startAlphaAnimation
(
binding
.
tvTemperature
,
800
)
{
if
(
i
fAgreePrivacy
)
{
if
(
i
sAgree
)
{
AnimationHelper
.
startAlphaAnimation
(
binding
.
pb
,
800
)
{
AnimationHelper
.
startAlphaAnimation
(
binding
.
pb
,
800
)
{
callback
.
invoke
()
}
}
}
else
{
}
else
{
AnimationHelper
.
startAlphaAnimation
(
binding
.
idTvStart
,
800
)
{
AnimationHelper
.
startAlphaAnimation
(
binding
.
idTvStart
,
800
)
{
callback
.
invoke
()
}
}
}
}
...
@@ -129,8 +136,6 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
...
@@ -129,8 +136,6 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
}.
start
()
}.
start
()
}
}
private
fun
closeNotification
()
{
private
fun
closeNotification
()
{
...
...
app/src/main/java/com/base/browserwhite/ui/fragment/FileFragment.kt
View file @
8e56217a
...
@@ -142,10 +142,15 @@ class FileFragment : BaseFragment<FragmentFileBinding>() {
...
@@ -142,10 +142,15 @@ class FileFragment : BaseFragment<FragmentFileBinding>() {
binding
.
llPermission
.
visibility
=
View
.
GONE
binding
.
llPermission
.
visibility
=
View
.
GONE
initData
()
initData
()
}
else
{
}
else
{
simulateProgress
()
binding
.
llPermission
.
visibility
=
View
.
VISIBLE
binding
.
llPermission
.
visibility
=
View
.
VISIBLE
}
}
}
}
private
fun
simulateProgress
()
{
}
private
fun
initData
()
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
private
fun
initData
()
=
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
val
picturePair
=
requireContext
().
getMediaPhotoCountSize
()
val
picturePair
=
requireContext
().
getMediaPhotoCountSize
()
...
...
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