Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
HTAnticollision
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
马乐
HTAnticollision
Commits
1cbb240c
Commit
1cbb240c
authored
May 26, 2023
by
马乐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.解决地图异步加载车辆图片被遮挡问题
2.优化地图相关类依赖关系
parent
2c0c90f1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
125 additions
and
25 deletions
+125
-25
BaseMapFragment.kt
...main/java/com/waytous/anticollision/ui/BaseMapFragment.kt
+5
-6
HomeNoVideoFragment.kt
.../com/waytous/anticollision/ui/home/HomeNoVideoFragment.kt
+4
-8
HomeVideoFragment.kt
...a/com/waytous/anticollision/ui/video/HomeVideoFragment.kt
+106
-0
VideoHomeFragment.kt
...a/com/waytous/anticollision/ui/video/VideoHomeFragment.kt
+0
-0
fragment_base.xml
app/src/main/res/layout/fragment_base.xml
+1
-1
fragment_collect.xml
app/src/main/res/layout/fragment_collect.xml
+1
-1
fragment_home.xml
app/src/main/res/layout/fragment_home.xml
+3
-3
fragment_video_home.xml
app/src/main/res/layout/fragment_video_home.xml
+3
-4
mobile_navigation.xml
app/src/main/res/navigation/mobile_navigation.xml
+2
-2
No files found.
app/src/main/java/com/waytous/anticollision/ui/BaseFragment.kt
→
app/src/main/java/com/waytous/anticollision/ui/Base
Map
Fragment.kt
View file @
1cbb240c
...
@@ -17,7 +17,6 @@ import com.mapbox.maps.ViewAnnotationAnchor
...
@@ -17,7 +17,6 @@ import com.mapbox.maps.ViewAnnotationAnchor
import
com.mapbox.maps.extension.style.layers.properties.generated.IconAnchor
import
com.mapbox.maps.extension.style.layers.properties.generated.IconAnchor
import
com.mapbox.maps.extension.style.style
import
com.mapbox.maps.extension.style.style
import
com.mapbox.maps.plugin.annotation.AnnotationConfig
import
com.mapbox.maps.plugin.annotation.AnnotationConfig
import
com.mapbox.maps.plugin.annotation.AnnotationPlugin
import
com.mapbox.maps.plugin.annotation.annotations
import
com.mapbox.maps.plugin.annotation.annotations
import
com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager
import
com.mapbox.maps.plugin.annotation.generated.PointAnnotationManager
import
com.mapbox.maps.plugin.annotation.generated.PointAnnotationOptions
import
com.mapbox.maps.plugin.annotation.generated.PointAnnotationOptions
...
@@ -78,7 +77,7 @@ import kotlinx.coroutines.flow.last
...
@@ -78,7 +77,7 @@ import kotlinx.coroutines.flow.last
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
import
java.math.BigDecimal
import
java.math.BigDecimal
open
class
BaseFragment
:
Fragment
()
{
open
class
Base
Map
Fragment
:
Fragment
()
{
private
val
mapModel
:
MainViewModel
by
viewModels
{
private
val
mapModel
:
MainViewModel
by
viewModels
{
MainViewModel
.
MainViewModelFactory
(
MainRepository
(
requireContext
()))
MainViewModel
.
MainViewModelFactory
(
MainRepository
(
requireContext
()))
...
@@ -142,15 +141,15 @@ open class BaseFragment : Fragment() {
...
@@ -142,15 +141,15 @@ open class BaseFragment : Fragment() {
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
layoutMapBoxBinding
=
LayoutMapBoxBinding
.
inflate
(
LayoutInflater
.
from
(
requireContext
()))
layoutMapBoxBinding
=
LayoutMapBoxBinding
.
inflate
(
LayoutInflater
.
from
(
requireContext
()))
}
fun
setupMapBox
()
{
LogUtils
.
d
(
"setupMapBox"
)
layoutMapBoxBinding
.
mapView
.
run
{
layoutMapBoxBinding
.
mapView
.
run
{
logo
.
enabled
=
false
logo
.
enabled
=
false
compass
.
enabled
=
false
compass
.
enabled
=
false
attribution
.
enabled
=
false
attribution
.
enabled
=
false
}
}
}
fun
setupMapBox
()
{
LogUtils
.
d
(
"setupMapBox"
)
mapboxMap
=
layoutMapBoxBinding
.
mapView
.
getMapboxMap
().
also
{
mapboxMap
=
layoutMapBoxBinding
.
mapView
.
getMapboxMap
().
also
{
it
.
setCamera
(
cameraOptions
)
it
.
setCamera
(
cameraOptions
)
}
}
...
...
app/src/main/java/com/waytous/anticollision/ui/home/HomeFragment.kt
→
app/src/main/java/com/waytous/anticollision/ui/home/Home
NoVideo
Fragment.kt
View file @
1cbb240c
...
@@ -8,18 +8,17 @@ import android.view.View
...
@@ -8,18 +8,17 @@ import android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
androidx.fragment.app.viewModels
import
androidx.fragment.app.viewModels
import
androidx.lifecycle.ViewModelProvider
import
androidx.lifecycle.ViewModelProvider
import
com.blankj.utilcode.util.LogUtils
import
com.mapbox.maps.MapView
import
com.mapbox.maps.MapView
import
com.waytous.anticollision.R
import
com.waytous.anticollision.R
import
com.waytous.anticollision.databinding.FragmentHomeBinding
import
com.waytous.anticollision.databinding.FragmentHomeBinding
import
com.waytous.anticollision.repository.MainRepository
import
com.waytous.anticollision.repository.MainRepository
import
com.waytous.anticollision.ui.BaseFragment
import
com.waytous.anticollision.ui.Base
Map
Fragment
import
com.waytous.anticollision.ui.MainViewModel
import
com.waytous.anticollision.ui.MainViewModel
import
com.waytous.anticollision.ui.view.MoreFeaturesPopup
import
com.waytous.anticollision.ui.view.MoreFeaturesPopup
import
com.waytous.anticollision.ui.view.WorkStatusEditPopup
import
com.waytous.anticollision.ui.view.WorkStatusEditPopup
import
com.waytous.anticollision.utils.setTextSize
import
com.waytous.anticollision.utils.setTextSize
class
Home
Fragment
:
Base
Fragment
()
{
class
Home
NoVideoFragment
:
BaseMap
Fragment
()
{
private
var
_binding
:
FragmentHomeBinding
?
=
null
private
var
_binding
:
FragmentHomeBinding
?
=
null
...
@@ -33,8 +32,6 @@ class HomeFragment : BaseFragment() {
...
@@ -33,8 +32,6 @@ class HomeFragment : BaseFragment() {
private
lateinit
var
workStatusEditPopup
:
WorkStatusEditPopup
private
lateinit
var
workStatusEditPopup
:
WorkStatusEditPopup
private
val
mapModel
:
MainViewModel
by
viewModels
{
private
val
mapModel
:
MainViewModel
by
viewModels
{
MainViewModel
.
MainViewModelFactory
(
MainRepository
(
requireContext
()))
MainViewModel
.
MainViewModelFactory
(
MainRepository
(
requireContext
()))
}
}
...
@@ -59,9 +56,8 @@ class HomeFragment : BaseFragment() {
...
@@ -59,9 +56,8 @@ class HomeFragment : BaseFragment() {
it
.
maskOffsetY
=
20
it
.
maskOffsetY
=
20
it
.
setBackgroundColor
(
R
.
color
.
color_99000000
)
it
.
setBackgroundColor
(
R
.
color
.
color_99000000
)
}
}
LogUtils
.
d
(
"HomeFragment.onCreateView"
)
setupMapBox
()
setupMapBox
()
binding
.
defaultMapLayout
.
addView
(
layoutMapBoxBinding
.
root
)
binding
.
noVideoMapWrapper
.
addView
(
layoutMapBoxBinding
.
root
)
setTodayCarriedNum
(
18
)
setTodayCarriedNum
(
18
)
setTodayIllegallyNum
(
1
)
setTodayIllegallyNum
(
1
)
binding
.
workStatusEdit
.
setOnClickListener
{
binding
.
workStatusEdit
.
setOnClickListener
{
...
@@ -87,7 +83,7 @@ class HomeFragment : BaseFragment() {
...
@@ -87,7 +83,7 @@ class HomeFragment : BaseFragment() {
override
fun
onDestroyView
()
{
override
fun
onDestroyView
()
{
super
.
onDestroyView
()
super
.
onDestroyView
()
binding
.
defaultMapLayout
.
removeView
(
layoutMapBoxBinding
.
root
)
binding
.
noVideoMapWrapper
.
removeView
(
layoutMapBoxBinding
.
root
)
_binding
=
null
_binding
=
null
}
}
...
...
app/src/main/java/com/waytous/anticollision/ui/video/HomeVideoFragment.kt
0 → 100644
View file @
1cbb240c
package
com.waytous.anticollision.ui.video
import
android.net.Uri
import
android.os.Bundle
import
android.text.SpannableString
import
android.view.Gravity
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
androidx.appcompat.widget.AppCompatTextView
import
androidx.fragment.app.viewModels
import
androidx.navigation.fragment.findNavController
import
com.google.android.exoplayer2.ExoPlayer
import
com.google.android.exoplayer2.MediaItem
import
com.waytous.anticollision.R
import
com.waytous.anticollision.databinding.FragmentVideoHomeBinding
import
com.waytous.anticollision.ui.BaseMapFragment
import
com.waytous.anticollision.ui.view.MoreFeaturesPopup
import
com.waytous.anticollision.ui.view.WorkStatusEditPopup
import
com.waytous.anticollision.utils.setTextSize
import
java.io.File
class
HomeVideoFragment
:
BaseMapFragment
()
{
private
lateinit
var
binding
:
FragmentVideoHomeBinding
private
var
player1
:
ExoPlayer
?
=
null
private
var
player2
:
ExoPlayer
?
=
null
private
lateinit
var
workStatusEditPopup
:
WorkStatusEditPopup
private
lateinit
var
moreFeaturesPopup
:
MoreFeaturesPopup
companion
object
{
fun
newInstance
()
=
HomeVideoFragment
()
}
private
val
viewModel
:
VideoHomeViewModel
by
viewModels
()
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?
):
View
?
{
binding
=
FragmentVideoHomeBinding
.
inflate
(
inflater
,
container
,
false
)
context
?:
return
binding
.
root
workStatusEditPopup
=
WorkStatusEditPopup
(
context
).
also
{
it
.
setOutSideDismiss
(
true
)
it
.
popupGravity
=
Gravity
.
TOP
or
Gravity
.
CENTER
it
.
setBackgroundColor
(
R
.
color
.
color_99000000
)
}
moreFeaturesPopup
=
MoreFeaturesPopup
(
context
).
also
{
pupop
->
pupop
.
setOutSideDismiss
(
true
)
pupop
.
popupGravity
=
Gravity
.
TOP
or
Gravity
.
CENTER
pupop
.
maskOffsetY
=
20
pupop
.
setBackgroundColor
(
R
.
color
.
color_99000000
)
pupop
.
contentView
.
findViewById
<
AppCompatTextView
>(
R
.
id
.
moreFeatureCollect
).
setOnClickListener
{
findNavController
().
navigate
(
R
.
id
.
action_navigation_video_Home_to_collectFragment
)
pupop
.
dismiss
()
}
}
val
templateString
=
getString
(
R
.
string
.
current_speed
,
36
)
val
spannableString
=
SpannableString
(
templateString
)
binding
.
workStatusEdit
.
setOnClickListener
{
workStatusEditPopup
.
showPopupWindow
(
binding
.
currentWorkStatusLayout
)
}
binding
.
speedText
.
setTextSize
(
spannableString
,
templateString
)
setupMapBox
()
binding
.
videoMapWrapper
.
addView
(
layoutMapBoxBinding
.
root
)
initPlayer
()
binding
.
toggleMore
.
setOnClickListener
{
moreFeaturesPopup
.
showPopupWindow
(
it
)
}
return
binding
.
root
}
private
fun
initPlayer
()
{
val
uri1
=
Uri
.
fromFile
(
File
(
requireActivity
().
filesDir
,
"飞书20230420-181456.mp4"
))
player1
=
activity
?.
let
{
ExoPlayer
.
Builder
(
it
).
build
().
apply
{
setMediaItem
(
MediaItem
.
Builder
().
setUri
(
uri1
).
build
())
}
}
binding
.
videoView1
.
player
=
player1
player1
?.
prepare
()
val
uri2
=
Uri
.
fromFile
(
File
(
requireActivity
().
filesDir
,
"飞书20230420-181512.mp4"
))
player2
=
activity
?.
let
{
ExoPlayer
.
Builder
(
it
).
build
().
apply
{
setMediaItem
(
MediaItem
.
Builder
().
setUri
(
uri2
).
build
())
}
}
binding
.
videoView2
.
player
=
player2
player2
?.
prepare
()
player1
?.
play
()
player2
?.
play
()
}
override
fun
onDestroyView
()
{
binding
.
videoMapWrapper
.
removeView
(
layoutMapBoxBinding
.
root
)
player1
?.
release
()
player2
?.
release
()
super
.
onDestroyView
()
}
}
\ No newline at end of file
app/src/main/java/com/waytous/anticollision/ui/video/VideoHomeFragment.kt
deleted
100644 → 0
View file @
2c0c90f1
This diff is collapsed.
Click to expand it.
app/src/main/res/layout/fragment_base.xml
View file @
1cbb240c
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".ui.BaseFragment"
>
tools:context=
".ui.Base
Map
Fragment"
>
<!-- TODO: Update blank fragment layout -->
<!-- TODO: Update blank fragment layout -->
<TextView
<TextView
...
...
app/src/main/res/layout/fragment_collect.xml
View file @
1cbb240c
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
app:layout_constraintTop_toBottomOf=
"@id/collectRadioGroup"
app:layout_constraintTop_toBottomOf=
"@id/collectRadioGroup"
app:layout_constraintStart_toStartOf=
"@id/collectRadioGroup"
/>
app:layout_constraintStart_toStartOf=
"@id/collectRadioGroup"
/>
<include
<include
android:id=
"@+id/
defaultMapLayout
"
android:id=
"@+id/
noVideoMapWrapper
"
layout=
"@layout/layout_map_box"
layout=
"@layout/layout_map_box"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:layout_height=
"0dp"
...
...
app/src/main/res/layout/fragment_home.xml
View file @
1cbb240c
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".ui.home.HomeFragment"
>
tools:context=
".ui.home.Home
NoVideo
Fragment"
>
<androidx.appcompat.widget.AppCompatImageView
<androidx.appcompat.widget.AppCompatImageView
android:id=
"@+id/defaultWorkingAvatar"
android:id=
"@+id/defaultWorkingAvatar"
...
@@ -280,10 +280,10 @@
...
@@ -280,10 +280,10 @@
android:clickable=
"true"
android:clickable=
"true"
android:textColor=
"@drawable/color_text_btn"
android:textColor=
"@drawable/color_text_btn"
app:layout_constraintTop_toTopOf=
"@id/defaultToggleMore"
app:layout_constraintTop_toTopOf=
"@id/defaultToggleMore"
app:layout_constraintEnd_toEndOf=
"@id/
defaultMapLayout
"
/>
app:layout_constraintEnd_toEndOf=
"@id/
noVideoMapWrapper
"
/>
<FrameLayout
<FrameLayout
android:id=
"@+id/
defaultMapLayout
"
android:id=
"@+id/
noVideoMapWrapper
"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:layout_height=
"0dp"
android:layout_marginEnd=
"16dp"
android:layout_marginEnd=
"16dp"
...
...
app/src/main/res/layout/fragment_video_home.xml
View file @
1cbb240c
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".ui.video.
VideoHome
Fragment"
>
tools:context=
".ui.video.
HomeVideo
Fragment"
>
<androidx.appcompat.widget.AppCompatImageView
<androidx.appcompat.widget.AppCompatImageView
android:id=
"@+id/workingAvatar"
android:id=
"@+id/workingAvatar"
...
@@ -94,9 +94,8 @@
...
@@ -94,9 +94,8 @@
app:layout_constraintTop_toTopOf=
"@id/dispatchedCommTime"
app:layout_constraintTop_toTopOf=
"@id/dispatchedCommTime"
tools:ignore=
"SmallSp"
/>
tools:ignore=
"SmallSp"
/>
<include
<FrameLayout
android:id=
"@+id/videoHomeMapLayout"
android:id=
"@+id/videoMapWrapper"
layout=
"@layout/layout_map_box"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:layout_height=
"0dp"
android:layout_marginTop=
"18dp"
android:layout_marginTop=
"18dp"
...
...
app/src/main/res/navigation/mobile_navigation.xml
View file @
1cbb240c
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
<fragment
<fragment
android:id=
"@+id/navigation_home"
android:id=
"@+id/navigation_home"
android:name=
"com.waytous.anticollision.ui.home.HomeFragment"
android:name=
"com.waytous.anticollision.ui.home.Home
NoVideo
Fragment"
android:label=
"@string/title_home"
android:label=
"@string/title_home"
tools:layout=
"@layout/fragment_home"
>
tools:layout=
"@layout/fragment_home"
>
<action
<action
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
</fragment>
</fragment>
<fragment
<fragment
android:id=
"@+id/navigation_video_Home"
android:id=
"@+id/navigation_video_Home"
android:name=
"com.waytous.anticollision.ui.video.
VideoHome
Fragment"
android:name=
"com.waytous.anticollision.ui.video.
HomeVideo
Fragment"
android:label=
"fragment_video_home"
android:label=
"fragment_video_home"
tools:layout=
"@layout/fragment_video_home"
>
tools:layout=
"@layout/fragment_video_home"
>
<action
<action
...
...
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