Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
L
location share 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
location share white
Commits
641b378a
Commit
641b378a
authored
Oct 30, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
1052f0cc
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
37 deletions
+42
-37
MyApplication.kt
.../java/com/base/locationsharewhite/helper/MyApplication.kt
+1
-0
LocationPositionUtils.kt
...base/locationsharewhite/location/LocationPositionUtils.kt
+4
-5
LocationMapActivity.kt
.../locationsharewhite/ui/locationmap/LocationMapActivity.kt
+37
-22
LocationPresenter.kt
...se/locationsharewhite/ui/locationmap/LocationPresenter.kt
+0
-10
No files found.
app/src/main/java/com/base/locationsharewhite/helper/MyApplication.kt
View file @
641b378a
...
...
@@ -51,6 +51,7 @@ class MyApplication : Application() {
AppPreferences
.
getInstance
().
put
(
"uuid"
,
uuid
)
LogEx
.
logDebug
(
TAG
,
"uuid=$uuid"
)
}
LogEx
.
logDebug
(
TAG
,
"uuid=${AppPreferences.getInstance().getString("
uuid
", "")}"
)
}
fun
initApp
()
{
...
...
app/src/main/java/com/base/locationsharewhite/location/LocationPositionUtils.kt
View file @
641b378a
...
...
@@ -37,7 +37,6 @@ object LocationPositionUtils {
fun
uploadMyLocation
(
latLng
:
LatLng
,
power
:
Int
)
{
Thread
{
val
pkg
=
ConfigHelper
.
packageName
val
data
=
JSONObject
()
data
.
put
(
"latitude"
,
latLng
.
latitude
)
data
.
put
(
"longitude"
,
latLng
.
longitude
)
...
...
@@ -54,15 +53,15 @@ object LocationPositionUtils {
.
put
(
"${pkg}_14"
,
BuildConfig
.
VERSION_CODE
)
.
put
(
"${pkg}_15"
,
"google"
)
.
put
(
"${pkg}_24"
,
BuildConfig
.
BUILD_TYPE
)
LogEx
.
logDebug
(
TAG
,
"uuid=${AppPreferences.getInstance().getString("
uuid
", "")}"
)
val
body
=
JSONObject
()
.
put
(
"data"
,
data
)
.
put
(
"bp"
,
bp
)
.
toString
()
val
paramJson
=
AESHelper
.
encrypt
(
body
)
LogEx
.
logDebug
(
TAG
,
"uploadMyLocation paramJson=${paramJson}"
)
runCatching
{
LogEx
.
logDebug
(
TAG
,
"uploadUrl=${uploadUrl}"
)
LogEx
.
logDebug
(
TAG
,
"upload
MyLocation upload
Url=${uploadUrl}"
)
val
result
=
ReportUtils
.
doPost
(
uploadUrl
,
HashMap
(),
paramJson
)
LogEx
.
logDebug
(
TAG
,
"result=$result"
)
}
...
...
@@ -87,7 +86,7 @@ object LocationPositionUtils {
*/
fun
getLocation
(
device
:
String
,
callBack
:
((
locationData
:
LocationData
)
->
Unit
)?
=
null
callBack
:
((
locationData
:
LocationData
?
)
->
Unit
)?
=
null
)
{
Thread
{
val
pkg
=
ConfigHelper
.
packageName
...
...
@@ -121,7 +120,7 @@ object LocationPositionUtils {
val
decryptedData
=
AESHelper
.
decrypt
(
responseData
)
LogEx
.
logDebug
(
TAG
,
"getLocation decryptedData=$decryptedData"
)
val
locationData
:
LocationData
?
=
parseLoginData
(
decryptedData
)
locationData
?.
let
{
callBack
?.
invoke
(
it
)
}
callBack
?.
invoke
(
locationData
)
}
}
}.
start
()
...
...
app/src/main/java/com/base/locationsharewhite/ui/locationmap/LocationMapActivity.kt
View file @
641b378a
...
...
@@ -77,13 +77,16 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
private
fun
initAdapter
()
{
adapter
=
ViewingAdapter
(
itemClick
=
{
itemClick
=
{
viewingBean
->
if
(
currentViewingBean
!=
it
)
{
currentViewingBean
=
it
startGetLocationJob
()
initFriendLocationMarker
(
it
)
if
(
currentViewingBean
!=
viewingBean
)
{
removeOldViewingMarker
()
currentViewingBean
=
viewingBean
setViewingBeanMarker
(
)
}
startGetLocationJob
()
},
moreClick
=
{
anchorView
,
item
->
showViewerMoreDialog
(
anchorView
)
...
...
@@ -101,18 +104,19 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
while
(
isActive
)
{
currentViewingBean
?.
let
{
viewingBean
->
LogEx
.
logDebug
(
TAG
,
"startGetLocationJob"
)
LocationPositionUtils
.
getLocation
(
viewingBean
.
device
)
{
locatDate
->
LogEx
.
logDebug
(
TAG
,
"locatDate=$locatDate"
)
LogEx
.
logDebug
(
TAG
,
"getLocation ${viewingBean.device} locatDate=$locatDate"
)
currentViewingBean
?.
locatDate
=
locatDate
lifecycleScope
.
launch
(
Dispatchers
.
Main
)
{
if
(
BuildConfig
.
DEBUG
)
{
toast
(
"
${locatDate.latitude} ${locatDate
.longitude}"
)
toast
(
"
getLocation ${locatDate?.latitude} ${locatDate?
.longitude}"
)
}
val
viewing
=
adapter
.
items
.
findLast
{
it
.
device
==
viewingBean
.
device
}
viewing
?.
locatDate
=
locatDate
adapter
.
notifyDataSetChanged
()
friendMarker
?.
position
=
LatLng
(
locatDate
.
latitude
,
locatDate
.
longitude
)
setViewingBeanMarker
()
}
}
}
...
...
@@ -262,20 +266,31 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
}
}
private
fun
initFriendLocationMarker
(
viewingBean
:
ViewingBean
)
{
if
(
friendMarker
!=
null
)
{
friendMarker
?.
remove
()
friendMarker
=
null
}
private
fun
setViewingBeanMarker
()
{
currentViewingBean
?.
let
{
viewingBean
->
viewingBean
.
locatDate
?.
let
{
locatDate
->
val
latLng
=
LatLng
(
locatDate
.
latitude
,
locatDate
.
longitude
)
if
(
friendMarker
==
null
)
{
val
friendAvatar
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
avatar_friend
,
null
)
viewingBean
.
locatDate
?.
let
{
val
latLng
=
LatLng
(
it
.
latitude
,
it
.
longitude
)
LogEx
.
logDebug
(
TAG
,
"initViewingBeanMarker locatDate ${locatDate.latitude} ${locatDate.longitude}"
)
friendMarker
=
map
?.
addLocationMarker
(
friendAvatar
,
latLng
,
viewingBean
.
nickname
)
map
?.
moveCamera
(
CameraUpdateFactory
.
newLatLngZoom
(
latLng
,
15f
))
}
if
(
viewingBean
.
locatDate
==
null
)
{
toast
(
"can't get friends location info"
)
setViewBeanLocation
(
latLng
)
}
}
}
private
fun
removeOldViewingMarker
()
{
friendMarker
?.
remove
()
friendMarker
=
null
}
private
fun
setViewBeanLocation
(
latLng
:
LatLng
)
{
map
?.
moveCamera
(
CameraUpdateFactory
.
newLatLngZoom
(
latLng
,
15f
))
myMarker
?.
position
=
latLng
}
...
...
app/src/main/java/com/base/locationsharewhite/ui/locationmap/LocationPresenter.kt
View file @
641b378a
...
...
@@ -37,7 +37,6 @@ class LocationPresenter(
fun
startUploadMyLocation
()
{
if
(
uploadJob
==
null
)
{
LogEx
.
logDebug
(
TAG
,
"startUploadMyLocation"
)
uploadJob
=
lifecycleCoroutineScope
.
launch
(
Dispatchers
.
IO
)
{
while
(
isActive
)
{
getGoogleServiceLocation
()
...
...
@@ -46,15 +45,6 @@ class LocationPresenter(
if
(
latLng
==
null
)
{
latLng
=
googleLocation
}
// if (BuildConfig.DEBUG) {
// latLng = LatLng(22.319275419461, 114.16934747047871)
// launch(Dispatchers.Main) {
// val device = AppPreferences.getInstance().getString("uuid", "")
// activity.toast("device=$device")
// delay(2000)
// activity.toast("Upload ${latLng.latitude} ${latLng.longitude}")
// }
// }
val
power
=
activity
.
getBatteryLevel
()
latLng
?.
let
{
uploadMyLocation
(
latLng
,
power
)
}
delay
(
30
*
1000L
)
...
...
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