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
4a2e9f27
Commit
4a2e9f27
authored
Oct 24, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
bd2488f7
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
282 additions
and
155 deletions
+282
-155
build.gradle.kts
app/build.gradle.kts
+2
-0
Viewing.kt
...src/main/java/com/base/locationsharewhite/bean/Viewing.kt
+2
-1
LocationPositionUtils.kt
...base/locationsharewhite/location/LocationPositionUtils.kt
+1
-0
MapUtils.kt
...src/main/java/com/base/locationsharewhite/map/MapUtils.kt
+18
-10
LocationMapActivity.kt
.../locationsharewhite/ui/locationmap/LocationMapActivity.kt
+52
-123
LocationPresenter.kt
...se/locationsharewhite/ui/locationmap/LocationPresenter.kt
+34
-7
ViewingAdapter.kt
.../base/locationsharewhite/ui/locationmap/ViewingAdapter.kt
+29
-1
aaaaa.kt
.../java/com/base/locationsharewhite/ui/locationmap/aaaaa.kt
+97
-0
MainActivity.kt
.../java/com/base/locationsharewhite/ui/main/MainActivity.kt
+8
-8
KotlinExt.kt
.../main/java/com/base/locationsharewhite/utils/KotlinExt.kt
+4
-0
item_viewing.xml
app/src/main/res/layout/item_viewing.xml
+34
-5
dianchi1.png
app/src/main/res/mipmap-xxhdpi/dianchi1.png
+0
-0
dianchi2.png
app/src/main/res/mipmap-xxhdpi/dianchi2.png
+0
-0
dianchi3.png
app/src/main/res/mipmap-xxhdpi/dianchi3.png
+0
-0
dianchi4.png
app/src/main/res/mipmap-xxhdpi/dianchi4.png
+0
-0
dianchi5.png
app/src/main/res/mipmap-xxhdpi/dianchi5.png
+0
-0
shoucang_n.png
app/src/main/res/mipmap-xxhdpi/shoucang_n.png
+0
-0
shoucang_s.png
app/src/main/res/mipmap-xxhdpi/shoucang_s.png
+0
-0
strings.xml
app/src/main/res/values/strings.xml
+1
-0
No files found.
app/build.gradle.kts
View file @
4a2e9f27
...
...
@@ -61,6 +61,8 @@ dependencies {
//google地图
implementation
(
libs
.
play
.
services
.
maps
)
//google位置服务
implementation
(
"com.google.android.gms:play-services-location:21.0.1"
)
//广告
...
...
app/src/main/java/com/base/locationsharewhite/bean/Viewing.kt
View file @
4a2e9f27
...
...
@@ -12,5 +12,6 @@ data class ViewingBean(
data class
LocationDate
(
val
longitude
:
Double
,
val
latitude
:
Double
,
val
power
:
Double
,
val
power
:
Int
,
val
timezone
:
Long
,
)
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/location/LocationPositionUtils.kt
View file @
4a2e9f27
...
...
@@ -40,6 +40,7 @@ object LocationPositionUtils {
data
.
put
(
"latitude"
,
latLng
.
latitude
)
data
.
put
(
"longitude"
,
latLng
.
longitude
)
data
.
put
(
"power"
,
power
)
data
.
put
(
"timezone"
,
System
.
currentTimeMillis
())
LogEx
.
logDebug
(
TAG
,
"latitude=${latLng.latitude} longitude=${latLng.longitude} power=$power"
)
val
bp
=
JSONObject
()
// .put("${pkg}_1", "")
...
...
app/src/main/java/com/base/locationsharewhite/map/MapUtils.kt
View file @
4a2e9f27
...
...
@@ -2,7 +2,6 @@ package com.base.locationsharewhite.map
import
android.annotation.SuppressLint
import
android.content.Context
import
android.graphics.Color
import
android.location.Criteria
import
android.location.Location
import
android.location.LocationManager
...
...
@@ -14,30 +13,36 @@ import com.google.android.gms.maps.model.LatLng
import
com.google.android.gms.maps.model.LatLngBounds
import
com.google.android.gms.maps.model.Marker
import
com.google.android.gms.maps.model.MarkerOptions
import
com.google.android.gms.maps.model.PolylineOptions
import
kotlin.math.abs
object
MapUtils
{
private
val
TAG
=
"MapUtils"
@SuppressLint
(
"MissingPermission"
)
fun
Context
.
getLastKnowLatLng
():
LatLng
{
fun
Context
.
getLatLngByLocationManager
():
LatLng
?
{
var
latitude
:
Double
=
-
1.0
var
longitude
:
Double
=
-
1.0
val
locationManager
=
getSystemService
(
Context
.
LOCATION_SERVICE
)
as
LocationManager
?
if
(
locationManager
!=
null
)
{
val
provider
:
String
?
=
locationManager
.
getBestProvider
(
Criteria
(),
true
)
if
(
provider
!=
null
)
{
val
lastKnownLocation
:
Location
?
=
locationManager
.
getLastKnownLocation
(
provider
)
val
latitude
:
Double
=
lastKnownLocation
?.
latitude
?:
0.0
//维度
val
longitude
:
Double
=
lastKnownLocation
?.
longitude
?:
0.0
//经度
return
LatLng
(
latitude
,
longitude
)
latitude
=
lastKnownLocation
?.
latitude
?:
-
1.0
//维度
longitude
=
lastKnownLocation
?.
longitude
?:
-
1.0
//经度
}
}
return
if
(
latitude
==
-
1.0
||
longitude
==
-
1.0
)
{
null
}
else
{
LatLng
(
latitude
,
longitude
)
}
return
LatLng
(
0.0
,
0.0
)
}
/**
* 添加view为Marker
*/
...
...
@@ -55,6 +60,9 @@ object MapUtils {
)
}
/**
* 多个经纬度相机移动合适位置
*/
fun
GoogleMap
.
cameraMovePointsBounds
(
point1
:
LatLng
,
point2
:
LatLng
,
padding
:
Int
)
{
// 创建包含两个点的边界
val
bounds
=
LatLngBounds
.
Builder
().
include
(
point1
).
include
(
point2
).
build
()
...
...
app/src/main/java/com/base/locationsharewhite/ui/locationmap/LocationMapActivity.kt
View file @
4a2e9f27
...
...
@@ -2,11 +2,13 @@ package com.base.locationsharewhite.ui.locationmap
import
android.animation.ValueAnimator
import
android.graphics.Color
import
android.os.Build
import
android.view.LayoutInflater
import
android.view.View
import
android.view.animation.LinearInterpolator
import
androidx.activity.addCallback
import
androidx.lifecycle.lifecycleScope
import
com.base.locationsharewhite.BuildConfig
import
com.base.locationsharewhite.R
import
com.base.locationsharewhite.bean.ConstObject
import
com.base.locationsharewhite.bean.ViewingBean
...
...
@@ -15,26 +17,22 @@ import com.base.locationsharewhite.helper.BaseActivity
import
com.base.locationsharewhite.helper.MyApplication
import
com.base.locationsharewhite.location.LocationShareListUtils
import
com.base.locationsharewhite.map.MapUtils.addLocationMarker
import
com.base.locationsharewhite.map.MapUtils.cameraMovePointsBounds
import
com.base.locationsharewhite.map.MapUtils.getLastKnowLatLng
import
com.base.locationsharewhite.ui.main.ViewerAdapter
import
com.base.locationsharewhite.map.MapUtils.getLatLngByLocationManager
import
com.base.locationsharewhite.ui.views.DialogView.showMapTypeDialog
import
com.base.locationsharewhite.utils.BarUtils
import
com.base.locationsharewhite.utils.BitmapUtils
import
com.base.locationsharewhite.utils.LogEx
import
com.base.locationsharewhite.utils.PermissionUtils.checkLocationPermission
import
com.base.locationsharewhite.utils.ToastUtils.toast
import
com.google.android.gms.location.FusedLocationProviderClient
import
com.google.android.gms.location.LocationServices
import
com.google.android.gms.maps.CameraUpdateFactory
import
com.google.android.gms.maps.GoogleMap
import
com.google.android.gms.maps.OnMapReadyCallback
import
com.google.android.gms.maps.SupportMapFragment
import
com.google.android.gms.maps.model.LatLng
import
com.google.android.gms.maps.model.Marker
import
com.google.android.gms.maps.model.MarkerOptions
import
com.google.android.gms.maps.model.PolylineOptions
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Job
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.isActive
import
kotlinx.coroutines.launch
...
...
@@ -51,6 +49,7 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
private
var
myMarker
:
Marker
?
=
null
private
var
friendMarker
:
Marker
?
=
null
private
var
currentViewingBean
:
ViewingBean
?
=
null
override
fun
initView
()
{
...
...
@@ -74,9 +73,13 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
private
fun
initAdapter
()
{
adapter
=
ViewingAdapter
()
adapter
=
ViewingAdapter
{
if
(
currentViewingBean
!=
it
)
{
currentViewingBean
=
it
initFriendLocationMarker
(
it
)
}
}
binding
.
rvViewing
.
adapter
=
adapter
}
private
fun
showFriendGuideOrNoFriend
()
{
...
...
@@ -106,6 +109,7 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
)
}
override
fun
initListener
()
{
super
.
initListener
()
if
(
isLanguageRecreate
(
MyApplication
.
locationMapLanguage
))
{
...
...
@@ -135,14 +139,7 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
}
binding
.
ivLocation
.
setOnClickListener
{
val
i
=
2
if
(
i
==
2
)
{
val
chunxilu
=
LatLng
(
30.655782251943407
,
104.07701072527895
)
upDateMeAndFriendLocation
(
chunxilu
)
}
else
{
resetMyLocation
()
}
resetMyLocation
()
}
binding
.
ivRefresh
.
setOnClickListener
{
startRefreshAnimation
()
...
...
@@ -150,6 +147,7 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
delay
(
2000
)
stopRefreshAnimation
()
}
initViewingData
()
}
binding
.
bottomSheet
.
setOnClickListener
{
}
...
...
@@ -181,127 +179,58 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
override
fun
onMapReady
(
googleMap
:
GoogleMap
)
{
map
=
googleMap
LogEx
.
logDebug
(
TAG
,
"onMapReady"
)
val
sydney
=
LatLng
(-
33.87365
,
151.20689
)
val
chunxilu
=
LatLng
(
30.655782251943407
,
104.07701072527895
)
initMyAndFriendLocation
(
chunxilu
)
// sharingLocationJob()
initMyLocationMarker
()
resetMyLocation
()
}
private
fun
resetMyLocation
()
{
val
myLatLng
:
LatLng
=
getLastKnowLatLng
()
myMarker
?.
position
=
myLatLng
map
?.
moveCamera
(
CameraUpdateFactory
.
newLatLngZoom
(
myLatLng
,
15f
))
}
private
fun
initMyAndFriendLocation
(
friendLatLng
:
LatLng
)
{
val
myLatLng
:
LatLng
=
getLastKnowLatLng
()
LogEx
.
logDebug
(
TAG
,
"getLastKnowLocation ${myLatLng.latitude} ${myLatLng.longitude}"
)
val
myAvatar
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
avatar_me
,
null
)
val
friendAvatar
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
avatar_friend
,
null
)
myMarker
=
map
?.
addLocationMarker
(
myAvatar
,
myLatLng
,
"my"
)
friendMarker
=
map
?.
addLocationMarker
(
friendAvatar
,
friendLatLng
,
"friend"
)
val
padding
=
resources
.
getDimensionPixelOffset
(
R
.
dimen
.
dp_150
)
map
?.
cameraMovePointsBounds
(
myLatLng
,
friendLatLng
,
padding
)
// val list = arrayListOf<LatLng>()
// list.addAll(friendTestLine)
// list.add(friendLatLng)
// addFriendPolyline(list)
}
private
fun
upDateMeAndFriendLocation
(
friendLatLng
:
LatLng
)
{
val
myLatLng
:
LatLng
=
getLastKnowLatLng
()
myMarker
?.
position
=
myLatLng
friendMarker
?.
position
=
friendLatLng
val
padding
=
resources
.
getDimensionPixelOffset
(
R
.
dimen
.
dp_150
)
map
?.
cameraMovePointsBounds
(
myLatLng
,
friendLatLng
,
padding
)
}
val
friendTestLine
=
listOf
(
LatLng
(
30.65988197028939
,
104.07775588286886
),
//總府皇冠假日酒店
LatLng
(
30.658174607262318
,
104.06581096754789
),
//天府广场
LatLng
(
30.6531557462031
,
104.06660595172475
),
//航天科技大廈
LatLng
(
30.64867742925485
,
104.06548317653692
),
//錦江賓館
LatLng
(
30.654908885860806
,
104.08053620625755
),
//ifs
)
fun
rotateMarker
()
{
val
myAvatar
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
avatar_me
,
null
)
val
myPair
:
LatLng
=
getLastKnowLatLng
()
val
bitmapDescriptor
=
BitmapUtils
.
getBitmapDescriptorFromLayoutResId
(
myAvatar
)
val
marker
:
Marker
?
=
map
?.
addMarker
(
MarkerOptions
()
.
icon
(
bitmapDescriptor
)
.
position
(
myPair
)
.
anchor
(
0.5f
,
0.5f
)
// 设置锚点为中心
.
rotation
(
90.0f
)
// 设置旋转角度
.
flat
(
true
)
)
// 设置为平面Marker
lifecycleScope
.
launch
{
for
(
i
in
0
..
360
)
{
marker
?.
rotation
=
i
.
toFloat
()
delay
(
200
)
var
myLatLng
:
LatLng
?
=
getLatLngByLocationManager
()
if
(
myLatLng
==
null
)
{
myLatLng
=
locationPresenter
.
googleLocation
}
if
(
BuildConfig
.
DEBUG
)
{
if
(
myLatLng
==
null
)
{
toast
(
"can't get LatLng"
)
}
}
initMyLocationMarker
()
myLatLng
?.
let
{
myMarker
?.
position
=
myLatLng
map
?.
moveCamera
(
CameraUpdateFactory
.
newLatLngZoom
(
myLatLng
,
15f
))
}
}
fun
addFriendPolyline
(
list
:
List
<
LatLng
>)
{
map
?.
addPolyline
(
PolylineOptions
().
apply
{
list
.
forEach
{
add
(
it
)
}
width
(
5
.
toFloat
())
color
(
Color
.
BLUE
)
geodesic
(
true
)
clickable
(
true
)
})
}
private
var
sharingJob
:
Job
?
=
null
fun
sharingLocationJob
()
{
if
(
sharingJob
==
null
)
{
myMarker
?:
return
friendMarker
?:
return
var
i
=
0f
var
j
=
0f
sharingJob
=
lifecycleScope
.
launch
{
while
(
isActive
)
{
i
+=
0.001f
j
+=
0.001f
val
myLatLng
=
getLastKnowLatLng
()
myMarker
?.
position
=
myLatLng
//上传我的位置,获取friend位置
val
friendLatLng
=
LatLng
(
30.655782251943407
+
i
,
104.07701072527895
+
j
)
friendMarker
?.
position
=
friendLatLng
delay
(
1
*
1000L
)
}
private
fun
initMyLocationMarker
()
{
if
(
myMarker
==
null
)
{
var
myLatLng
:
LatLng
?
=
getLatLngByLocationManager
()
if
(
myLatLng
==
null
)
{
myLatLng
=
locationPresenter
.
googleLocation
}
myLatLng
?.
let
{
LogEx
.
logDebug
(
TAG
,
"getLastKnowLocation ${myLatLng.latitude} ${myLatLng.longitude}"
)
val
myAvatar
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
avatar_me
,
null
)
myMarker
=
map
?.
addLocationMarker
(
myAvatar
,
myLatLng
,
getString
(
R
.
string
.
me
))
}
}
}
private
fun
cancelSharingJob
()
{
sharingJob
?.
cancel
()
sharingJob
=
null
private
fun
initFriendLocationMarker
(
viewingBean
:
ViewingBean
)
{
if
(
friendMarker
!=
null
)
{
friendMarker
?.
remove
()
friendMarker
=
null
}
val
friendAvatar
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
avatar_friend
,
null
)
viewingBean
.
locatDate
?.
let
{
val
latLng
=
LatLng
(
viewingBean
.
locatDate
.
latitude
,
viewingBean
.
locatDate
.
longitude
)
friendMarker
=
map
?.
addLocationMarker
(
friendAvatar
,
latLng
,
viewingBean
.
nickname
)
map
?.
moveCamera
(
CameraUpdateFactory
.
newLatLngZoom
(
latLng
,
15f
))
}
}
override
fun
onPause
()
{
super
.
onPause
()
cancelSharingJob
()
locationPresenter
.
cancelUploadJob
()
}
...
...
app/src/main/java/com/base/locationsharewhite/ui/locationmap/LocationPresenter.kt
View file @
4a2e9f27
package
com.base.locationsharewhite.ui.locationmap
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.content.Context
import
android.location.Location
import
androidx.lifecycle.LifecycleCoroutineScope
import
com.base.locationsharewhite.
location.LocationPositionUtils
import
com.base.locationsharewhite.
helper.BaseActivity
import
com.base.locationsharewhite.location.LocationPositionUtils.uploadMyLocation
import
com.base.locationsharewhite.map.MapUtils.getLa
stKnowLatLng
import
com.base.locationsharewhite.map.MapUtils.getLa
tLngByLocationManager
import
com.base.locationsharewhite.utils.BatteryUtils.getBatteryLevel
import
com.base.locationsharewhite.utils.LogEx
import
com.google.android.gms.location.FusedLocationProviderClient
import
com.google.android.gms.location.LocationServices
import
com.google.android.gms.maps.model.LatLng
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Job
import
kotlinx.coroutines.delay
...
...
@@ -14,26 +20,47 @@ import kotlinx.coroutines.isActive
import
kotlinx.coroutines.launch
class
LocationPresenter
(
val
context
:
Context
,
val
activity
:
Activity
,
val
lifecycleCoroutineScope
:
LifecycleCoroutineScope
)
{
private
var
TAG
=
"LocationPresenter"
private
var
uploadJob
:
Job
?
=
null
//google的地理位置服务
private
var
fusedLocationClient
:
FusedLocationProviderClient
=
LocationServices
.
getFusedLocationProviderClient
(
activity
)
var
googleLocation
:
LatLng
?
=
null
fun
startUploadMyLocation
()
{
if
(
uploadJob
==
null
)
{
LogEx
.
logDebug
(
TAG
,
"startUploadMyLocation"
)
LogEx
.
logDebug
(
TAG
,
"startUploadMyLocation"
)
uploadJob
=
lifecycleCoroutineScope
.
launch
(
Dispatchers
.
IO
)
{
while
(
isActive
)
{
val
latLng
=
context
.
getLastKnowLatLng
()
val
power
=
context
.
getBatteryLevel
()
uploadMyLocation
(
latLng
,
power
)
getGoogleServiceLocation
()
var
latLng
=
activity
.
getLatLngByLocationManager
()
if
(
latLng
==
null
)
{
latLng
=
googleLocation
}
val
power
=
activity
.
getBatteryLevel
()
latLng
?.
let
{
uploadMyLocation
(
latLng
,
power
)
}
delay
(
30
*
1000L
)
}
}
}
}
@SuppressLint
(
"MissingPermission"
)
fun
getGoogleServiceLocation
()
{
fusedLocationClient
.
lastLocation
.
addOnSuccessListener
{
location
:
Location
?
->
if
(
location
!=
null
)
{
googleLocation
=
LatLng
(
location
.
latitude
,
location
.
longitude
)
}
}
}
fun
cancelUploadJob
()
{
uploadJob
?.
cancel
()
uploadJob
=
null
...
...
app/src/main/java/com/base/locationsharewhite/ui/locationmap/ViewingAdapter.kt
View file @
4a2e9f27
...
...
@@ -8,15 +8,43 @@ import com.base.locationsharewhite.R
import
com.base.locationsharewhite.bean.ViewingBean
import
com.base.locationsharewhite.databinding.ItemViewingBinding
import
com.base.locationsharewhite.ui.views.XmlEx.inflate
import
com.base.locationsharewhite.utils.KotlinExt.toFormatHHMinute
import
com.chad.library.adapter4.BaseQuickAdapter
class
ViewingAdapter
:
BaseQuickAdapter
<
ViewingBean
,
ViewingAdapter
.
ViewingViewHolder
>()
{
class
ViewingAdapter
(
val
itemClick
:
(
item
:
ViewingBean
)
->
Unit
)
:
BaseQuickAdapter
<
ViewingBean
,
ViewingAdapter
.
ViewingViewHolder
>()
{
inner
class
ViewingViewHolder
(
view
:
View
)
:
ViewHolder
(
view
)
override
fun
onBindViewHolder
(
holder
:
ViewingViewHolder
,
position
:
Int
,
item
:
ViewingBean
?)
{
item
?:
return
val
binding
=
ItemViewingBinding
.
bind
(
holder
.
itemView
)
binding
.
tvNameLetters
.
text
=
item
.
nickname
.
substring
(
0
,
1
)
binding
.
tvNameCode
.
text
=
item
.
nickname
when
(
item
.
locatDate
?.
power
)
{
in
0
..
20
->
{
binding
.
ivPower
.
setImageResource
(
R
.
mipmap
.
dianchi5
)
}
in
21
..
40
->
{
binding
.
ivPower
.
setImageResource
(
R
.
mipmap
.
dianchi4
)
}
in
41
..
60
->
{
binding
.
ivPower
.
setImageResource
(
R
.
mipmap
.
dianchi3
)
}
in
61
..
80
->
{
binding
.
ivPower
.
setImageResource
(
R
.
mipmap
.
dianchi2
)
}
in
81
..
100
->
{
binding
.
ivPower
.
setImageResource
(
R
.
mipmap
.
dianchi1
)
}
}
val
time
=
item
.
locatDate
?.
timezone
?:
0
binding
.
tvTime
.
text
=
time
.
toFormatHHMinute
()
binding
.
root
.
setOnClickListener
{
itemClick
.
invoke
(
item
)
}
}
override
fun
onCreateViewHolder
(
context
:
Context
,
parent
:
ViewGroup
,
viewType
:
Int
):
ViewingViewHolder
{
...
...
app/src/main/java/com/base/locationsharewhite/ui/locationmap/aaaaa.kt
0 → 100644
View file @
4a2e9f27
package
com.base.locationsharewhite.ui.locationmap
//import android.graphics.Color
//import android.view.LayoutInflater
//import androidx.lifecycle.lifecycleScope
//import com.base.locationsharewhite.R
//import com.base.locationsharewhite.map.MapUtils.cameraMovePointsBounds
//import com.base.locationsharewhite.utils.BitmapUtils
//import com.google.android.gms.maps.model.LatLng
//import com.google.android.gms.maps.model.Marker
//import com.google.android.gms.maps.model.MarkerOptions
//import com.google.android.gms.maps.model.PolylineOptions
//import kotlinx.coroutines.Job
//import kotlinx.coroutines.delay
//import kotlinx.coroutines.isActive
//import kotlinx.coroutines.launch
//val friendTestLine = listOf(
// LatLng(30.65988197028939, 104.07775588286886),//總府皇冠假日酒店
// LatLng(30.658174607262318, 104.06581096754789),//天府广场
// LatLng(30.6531557462031, 104.06660595172475),//航天科技大廈
// LatLng(30.64867742925485, 104.06548317653692),//錦江賓館
// LatLng(30.654908885860806, 104.08053620625755),//ifs
//)
//
//fun rotateMarker() {
//
// val myAvatar = LayoutInflater.from(this).inflate(R.layout.avatar_me, null)
//
// val myPair: LatLng = getLastKnowLatLng()
// val bitmapDescriptor = BitmapUtils.getBitmapDescriptorFromLayoutResId(myAvatar)
//
// val marker: Marker? = map?.addMarker(
// MarkerOptions()
// .icon(bitmapDescriptor)
// .position(myPair)
// .anchor(0.5f, 0.5f) // 设置锚点为中心
// .rotation(90.0f) // 设置旋转角度
// .flat(true)
// ) // 设置为平面Marker
//
// lifecycleScope.launch {
// for (i in 0..360) {
// marker?.rotation = i.toFloat()
// delay(200)
// }
// }
//}
//
//fun addFriendPolyline(list: List<LatLng>) {
// map?.addPolyline(PolylineOptions().apply {
// list.forEach { add(it) }
// width(5.toFloat())
// color(Color.BLUE)
// geodesic(true)
// clickable(true)
// })
//}
//private fun upDateMeAndFriendLocation(friendLatLng: LatLng) {
// val myLatLng: LatLng = getLastKnowLatLng()
// myMarker?.position = myLatLng
// friendMarker?.position = friendLatLng
// val padding = resources.getDimensionPixelOffset(R.dimen.dp_150)
// map?.cameraMovePointsBounds(myLatLng, friendLatLng, padding)
//}
//private var sharingJob: Job? = null
//fun sharingLocationJob() {
// if (sharingJob == null) {
//
// myMarker ?: return
// friendMarker ?: return
//
// var i = 0f
// var j = 0f
// sharingJob = lifecycleScope.launch {
// while (isActive) {
// i += 0.001f
// j += 0.001f
//
// val myLatLng = getLastKnowLatLng()
// myMarker?.position = myLatLng
// //上传我的位置,获取friend位置
// val friendLatLng = LatLng(30.655782251943407 + i, 104.07701072527895 + j)
// friendMarker?.position = friendLatLng
//
// delay(1 * 1000L)
// }
// }
// }
//}
//private fun cancelSharingJob() {
// sharingJob?.cancel()
// sharingJob = null
//}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/ui/main/MainActivity.kt
View file @
4a2e9f27
...
...
@@ -13,7 +13,7 @@ import com.base.locationsharewhite.helper.BaseActivity
import
com.base.locationsharewhite.helper.MyApplication
import
com.base.locationsharewhite.location.LocationLoginUtils
import
com.base.locationsharewhite.map.MapUtils.addLocationMarker
import
com.base.locationsharewhite.map.MapUtils.getLa
stKnowLatLng
import
com.base.locationsharewhite.map.MapUtils.getLa
tLngByLocationManager
import
com.base.locationsharewhite.ui.howuse.HowUseActivity
import
com.base.locationsharewhite.ui.locationmap.LocationMapActivity
import
com.base.locationsharewhite.ui.set.SettingActivity
...
...
@@ -112,12 +112,12 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
override
fun
onMapReady
(
googleMap
:
GoogleMap
)
{
map
=
googleMap
val
latLng
=
getLa
stKnowLatLng
()
LogEx
.
logDebug
(
TAG
,
"getLastKnowLocation ${latLng.latitude} ${latLng.longitude}"
)
val
myAvatar
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
avatar_me
,
null
)
map
?.
moveCamera
(
CameraUpdateFactory
.
newLatLngZoom
(
latLng
,
15f
)
)
map
?.
addLocationMarker
(
myAvatar
,
latLng
,
"my"
)
val
latLng
=
getLa
tLngByLocationManager
()
latLng
?.
let
{
LogEx
.
logDebug
(
TAG
,
"getLastKnowLocation ${latLng.latitude} ${latLng.longitude}"
)
val
myAvatar
=
LayoutInflater
.
from
(
this
).
inflate
(
R
.
layout
.
avatar_me
,
null
)
map
?.
moveCamera
(
CameraUpdateFactory
.
newLatLngZoom
(
latLng
,
15f
))
map
?.
addLocationMarker
(
myAvatar
,
latLng
,
"my"
)
}
}
}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/utils/KotlinExt.kt
View file @
4a2e9f27
...
...
@@ -44,6 +44,10 @@ object KotlinExt {
return
SimpleDateFormat
(
"mm"
,
Locale
.
ENGLISH
).
format
(
this
)
}
fun
Long
.
toFormatHHMinute
():
String
{
return
SimpleDateFormat
(
"HH:mm"
,
Locale
.
ENGLISH
).
format
(
this
)
}
fun
Array
<
String
>.
array2String
():
String
{
val
stringBuilder
=
StringBuilder
()
...
...
app/src/main/res/layout/item_viewing.xml
View file @
4a2e9f27
...
...
@@ -37,17 +37,18 @@
</FrameLayout>
<
Linear
Layout
<
androidx.constraintlayout.widget.Constraint
Layout
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginHorizontal=
"8dp"
android:layout_marginStart=
"8dp"
android:layout_marginEnd=
"24dp"
android:layout_weight=
"1"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/tv_name_code"
android:layout_width=
"
match_parent
"
android:layout_width=
"
0dp
"
android:layout_height=
"wrap_content"
android:ellipsize=
"end"
android:includeFontPadding=
"false"
...
...
@@ -55,17 +56,45 @@
android:textColor=
"#001725"
android:textSize=
"16sp"
android:textStyle=
"bold"
app:layout_constraintEnd_toStartOf=
"@id/tv_time"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
tools:text=
"V0OC3RJK"
/>
<TextView
android:id=
"@+id/tv_time"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
android:layout_marginHorizontal=
"8dp"
android:includeFontPadding=
"false"
android:textColor=
"#81888D"
android:textSize=
"14sp"
app:layout_constraintBottom_toBottomOf=
"@id/tv_name_code"
app:layout_constraintEnd_toStartOf=
"@id/iv_power"
app:layout_constraintStart_toEndOf=
"@id/tv_name_code"
app:layout_constraintTop_toTopOf=
"@id/tv_name_code"
tools:text=
"20:27"
/>
</LinearLayout>
<ImageView
android:id=
"@+id/iv_power"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:src=
"@mipmap/dianchi1"
app:layout_constraintBottom_toBottomOf=
"@id/tv_name_code"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toEndOf=
"@id/tv_time"
app:layout_constraintTop_toTopOf=
"@id/tv_name_code"
tools:ignore=
"ContentDescription"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginEnd=
"18dp"
android:src=
"@mipmap/shoucang_n"
tools:ignore=
"ContentDescription"
/>
<ImageView
...
...
app/src/main/res/mipmap-xxhdpi/dianchi1.png
0 → 100644
View file @
4a2e9f27
965 Bytes
app/src/main/res/mipmap-xxhdpi/dianchi2.png
0 → 100644
View file @
4a2e9f27
983 Bytes
app/src/main/res/mipmap-xxhdpi/dianchi3.png
0 → 100644
View file @
4a2e9f27
998 Bytes
app/src/main/res/mipmap-xxhdpi/dianchi4.png
0 → 100644
View file @
4a2e9f27
932 Bytes
app/src/main/res/mipmap-xxhdpi/dianchi5.png
0 → 100644
View file @
4a2e9f27
879 Bytes
app/src/main/res/mipmap-xxhdpi/shoucang_n.png
0 → 100644
View file @
4a2e9f27
2.56 KB
app/src/main/res/mipmap-xxhdpi/shoucang_s.png
0 → 100644
View file @
4a2e9f27
2.51 KB
app/src/main/res/values/strings.xml
View file @
4a2e9f27
...
...
@@ -53,4 +53,5 @@
<string
name=
"a_simple_name_can_make_nothers_find_you_faster"
>
A simple name can make\nothers find you faster!
</string>
<string
name=
"enter_your_name"
>
Enter your name
</string>
<string
name=
"name_is_empty"
>
Name is empty
</string>
<string
name=
"me"
>
me
</string>
</resources>
\ 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