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
Hide 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() {
...
@@ -51,6 +51,7 @@ class MyApplication : Application() {
AppPreferences
.
getInstance
().
put
(
"uuid"
,
uuid
)
AppPreferences
.
getInstance
().
put
(
"uuid"
,
uuid
)
LogEx
.
logDebug
(
TAG
,
"uuid=$uuid"
)
LogEx
.
logDebug
(
TAG
,
"uuid=$uuid"
)
}
}
LogEx
.
logDebug
(
TAG
,
"uuid=${AppPreferences.getInstance().getString("
uuid
", "")}"
)
}
}
fun
initApp
()
{
fun
initApp
()
{
...
...
app/src/main/java/com/base/locationsharewhite/location/LocationPositionUtils.kt
View file @
641b378a
...
@@ -37,7 +37,6 @@ object LocationPositionUtils {
...
@@ -37,7 +37,6 @@ object LocationPositionUtils {
fun
uploadMyLocation
(
latLng
:
LatLng
,
power
:
Int
)
{
fun
uploadMyLocation
(
latLng
:
LatLng
,
power
:
Int
)
{
Thread
{
Thread
{
val
pkg
=
ConfigHelper
.
packageName
val
pkg
=
ConfigHelper
.
packageName
val
data
=
JSONObject
()
val
data
=
JSONObject
()
data
.
put
(
"latitude"
,
latLng
.
latitude
)
data
.
put
(
"latitude"
,
latLng
.
latitude
)
data
.
put
(
"longitude"
,
latLng
.
longitude
)
data
.
put
(
"longitude"
,
latLng
.
longitude
)
...
@@ -54,15 +53,15 @@ object LocationPositionUtils {
...
@@ -54,15 +53,15 @@ object LocationPositionUtils {
.
put
(
"${pkg}_14"
,
BuildConfig
.
VERSION_CODE
)
.
put
(
"${pkg}_14"
,
BuildConfig
.
VERSION_CODE
)
.
put
(
"${pkg}_15"
,
"google"
)
.
put
(
"${pkg}_15"
,
"google"
)
.
put
(
"${pkg}_24"
,
BuildConfig
.
BUILD_TYPE
)
.
put
(
"${pkg}_24"
,
BuildConfig
.
BUILD_TYPE
)
LogEx
.
logDebug
(
TAG
,
"uuid=${AppPreferences.getInstance().getString("
uuid
", "")}"
)
val
body
=
JSONObject
()
val
body
=
JSONObject
()
.
put
(
"data"
,
data
)
.
put
(
"data"
,
data
)
.
put
(
"bp"
,
bp
)
.
put
(
"bp"
,
bp
)
.
toString
()
.
toString
()
val
paramJson
=
AESHelper
.
encrypt
(
body
)
val
paramJson
=
AESHelper
.
encrypt
(
body
)
LogEx
.
logDebug
(
TAG
,
"uploadMyLocation paramJson=${paramJson}"
)
runCatching
{
runCatching
{
LogEx
.
logDebug
(
TAG
,
"uploadUrl=${uploadUrl}"
)
LogEx
.
logDebug
(
TAG
,
"upload
MyLocation upload
Url=${uploadUrl}"
)
val
result
=
ReportUtils
.
doPost
(
uploadUrl
,
HashMap
(),
paramJson
)
val
result
=
ReportUtils
.
doPost
(
uploadUrl
,
HashMap
(),
paramJson
)
LogEx
.
logDebug
(
TAG
,
"result=$result"
)
LogEx
.
logDebug
(
TAG
,
"result=$result"
)
}
}
...
@@ -87,7 +86,7 @@ object LocationPositionUtils {
...
@@ -87,7 +86,7 @@ object LocationPositionUtils {
*/
*/
fun
getLocation
(
fun
getLocation
(
device
:
String
,
device
:
String
,
callBack
:
((
locationData
:
LocationData
)
->
Unit
)?
=
null
callBack
:
((
locationData
:
LocationData
?
)
->
Unit
)?
=
null
)
{
)
{
Thread
{
Thread
{
val
pkg
=
ConfigHelper
.
packageName
val
pkg
=
ConfigHelper
.
packageName
...
@@ -121,7 +120,7 @@ object LocationPositionUtils {
...
@@ -121,7 +120,7 @@ object LocationPositionUtils {
val
decryptedData
=
AESHelper
.
decrypt
(
responseData
)
val
decryptedData
=
AESHelper
.
decrypt
(
responseData
)
LogEx
.
logDebug
(
TAG
,
"getLocation decryptedData=$decryptedData"
)
LogEx
.
logDebug
(
TAG
,
"getLocation decryptedData=$decryptedData"
)
val
locationData
:
LocationData
?
=
parseLoginData
(
decryptedData
)
val
locationData
:
LocationData
?
=
parseLoginData
(
decryptedData
)
locationData
?.
let
{
callBack
?.
invoke
(
it
)
}
callBack
?.
invoke
(
locationData
)
}
}
}
}
}.
start
()
}.
start
()
...
...
app/src/main/java/com/base/locationsharewhite/ui/locationmap/LocationMapActivity.kt
View file @
641b378a
...
@@ -77,13 +77,16 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
...
@@ -77,13 +77,16 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
private
fun
initAdapter
()
{
private
fun
initAdapter
()
{
adapter
=
ViewingAdapter
(
adapter
=
ViewingAdapter
(
itemClick
=
{
itemClick
=
{
viewingBean
->
if
(
currentViewingBean
!=
it
)
{
if
(
currentViewingBean
!=
viewingBean
)
{
currentViewingBean
=
it
removeOldViewingMarker
()
startGetLocationJob
()
currentViewingBean
=
viewingBean
initFriendLocationMarker
(
it
)
setViewingBeanMarker
(
)
}
}
startGetLocationJob
()
},
},
moreClick
=
{
anchorView
,
item
->
moreClick
=
{
anchorView
,
item
->
showViewerMoreDialog
(
anchorView
)
showViewerMoreDialog
(
anchorView
)
...
@@ -101,18 +104,19 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
...
@@ -101,18 +104,19 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
while
(
isActive
)
{
while
(
isActive
)
{
currentViewingBean
?.
let
{
viewingBean
->
currentViewingBean
?.
let
{
viewingBean
->
LogEx
.
logDebug
(
TAG
,
"startGetLocationJob"
)
LocationPositionUtils
.
getLocation
(
viewingBean
.
device
)
{
locatDate
->
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
)
{
lifecycleScope
.
launch
(
Dispatchers
.
Main
)
{
if
(
BuildConfig
.
DEBUG
)
{
if
(
BuildConfig
.
DEBUG
)
{
toast
(
"
${locatDate.latitude} ${locatDate
.longitude}"
)
toast
(
"
getLocation ${locatDate?.latitude} ${locatDate?
.longitude}"
)
}
}
val
viewing
=
adapter
.
items
.
findLast
{
it
.
device
==
viewingBean
.
device
}
val
viewing
=
adapter
.
items
.
findLast
{
it
.
device
==
viewingBean
.
device
}
viewing
?.
locatDate
=
locatDate
viewing
?.
locatDate
=
locatDate
adapter
.
notifyDataSetChanged
()
adapter
.
notifyDataSetChanged
()
friendMarker
?.
position
=
LatLng
(
locatDate
.
latitude
,
locatDate
.
longitude
)
setViewingBeanMarker
()
}
}
}
}
}
}
...
@@ -262,22 +266,33 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
...
@@ -262,22 +266,33 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
}
}
}
}
private
fun
initFriendLocationMarker
(
viewingBean
:
ViewingBean
)
{
private
fun
setViewingBeanMarker
()
{
if
(
friendMarker
!=
null
)
{
currentViewingBean
?.
let
{
viewingBean
->
friendMarker
?.
remove
()
viewingBean
.
locatDate
?.
let
{
locatDate
->
friendMarker
=
null
}
val
latLng
=
LatLng
(
locatDate
.
latitude
,
locatDate
.
longitude
)
val
friendAvatar
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
avatar_friend
,
null
)
viewingBean
.
locatDate
?.
let
{
if
(
friendMarker
==
null
)
{
val
latLng
=
LatLng
(
it
.
latitude
,
it
.
longitude
)
val
friendAvatar
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
avatar_friend
,
null
)
friendMarker
=
map
?.
addLocationMarker
(
friendAvatar
,
latLng
,
viewingBean
.
nickname
)
LogEx
.
logDebug
(
TAG
,
"initViewingBeanMarker locatDate ${locatDate.latitude} ${locatDate.longitude}"
)
map
?.
moveCamera
(
CameraUpdateFactory
.
newLatLngZoom
(
latLng
,
15f
))
friendMarker
=
map
?.
addLocationMarker
(
friendAvatar
,
latLng
,
viewingBean
.
nickname
)
}
}
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
}
override
fun
onPause
()
{
override
fun
onPause
()
{
super
.
onPause
()
super
.
onPause
()
...
...
app/src/main/java/com/base/locationsharewhite/ui/locationmap/LocationPresenter.kt
View file @
641b378a
...
@@ -37,7 +37,6 @@ class LocationPresenter(
...
@@ -37,7 +37,6 @@ class LocationPresenter(
fun
startUploadMyLocation
()
{
fun
startUploadMyLocation
()
{
if
(
uploadJob
==
null
)
{
if
(
uploadJob
==
null
)
{
LogEx
.
logDebug
(
TAG
,
"startUploadMyLocation"
)
uploadJob
=
lifecycleCoroutineScope
.
launch
(
Dispatchers
.
IO
)
{
uploadJob
=
lifecycleCoroutineScope
.
launch
(
Dispatchers
.
IO
)
{
while
(
isActive
)
{
while
(
isActive
)
{
getGoogleServiceLocation
()
getGoogleServiceLocation
()
...
@@ -46,15 +45,6 @@ class LocationPresenter(
...
@@ -46,15 +45,6 @@ class LocationPresenter(
if
(
latLng
==
null
)
{
if
(
latLng
==
null
)
{
latLng
=
googleLocation
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
()
val
power
=
activity
.
getBatteryLevel
()
latLng
?.
let
{
uploadMyLocation
(
latLng
,
power
)
}
latLng
?.
let
{
uploadMyLocation
(
latLng
,
power
)
}
delay
(
30
*
1000L
)
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