Merge branch 'master' of https://gitlab.navinfo.com/CollectVehicle/OneMapQS
Conflicts: app/src/main/java/com/navinfo/omqs/ui/activity/map/MainActivity.kt
This commit is contained in:
@@ -1,239 +0,0 @@
|
||||
package com.navinfo.omqs.ui.activity.console
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.View.OnClickListener
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.transition.AutoTransition
|
||||
import androidx.transition.Scene
|
||||
import androidx.transition.TransitionManager
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.databinding.ActivityConsoleBinding
|
||||
import com.navinfo.omqs.ui.activity.BaseActivity
|
||||
import com.navinfo.omqs.ui.activity.map.MainActivity
|
||||
import com.navinfo.omqs.ui.fragment.layermanager.LayermanagerFragment
|
||||
import com.navinfo.omqs.ui.fragment.offlinemap.OfflineMapFragment
|
||||
import com.navinfo.omqs.ui.fragment.personalcenter.PersonalCenterFragment
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
@AndroidEntryPoint
|
||||
class ConsoleActivity : BaseActivity(), OnClickListener {
|
||||
|
||||
private var _binding: ActivityConsoleBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
private var sceneFlag = true
|
||||
private val aTransition = AutoTransition()
|
||||
private val bTransition = AutoTransition()
|
||||
private var mFragment: Fragment? = null
|
||||
private val fragmentId = R.id.console_fragment
|
||||
|
||||
// 创建a场景
|
||||
private val aScene by lazy {
|
||||
Scene.getSceneForLayout(
|
||||
binding.consoleRoot, R.layout.console_on, this
|
||||
)
|
||||
}
|
||||
|
||||
// 创建b场景
|
||||
private val bScene by lazy {
|
||||
Scene.getSceneForLayout(
|
||||
binding.consoleRoot, R.layout.console_off, this
|
||||
)
|
||||
}
|
||||
|
||||
// private val mTransitionAManager: TransitionManager by lazy {
|
||||
// TransitionInflater.from(this)
|
||||
// .inflateTransitionManager(R.transition.transitionmanager_console, binding.consoleRoot)
|
||||
// }
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
_binding = ActivityConsoleBinding.inflate(layoutInflater)
|
||||
setContentView(_binding!!.root)
|
||||
// mTransitionAManager.setTransition(bScene, transition)
|
||||
|
||||
aTransition.addListener(object : androidx.transition.Transition.TransitionListener {
|
||||
override fun onTransitionStart(transition: androidx.transition.Transition) {
|
||||
if (mFragment != null) {
|
||||
Log.e("jingo", "动画开始B mFragment 不为null")
|
||||
supportFragmentManager.beginTransaction().remove(mFragment!!).commit()
|
||||
mFragment = null
|
||||
}
|
||||
}
|
||||
|
||||
override fun onTransitionEnd(transition: androidx.transition.Transition) {
|
||||
Log.e("jingo", "动画A结束")
|
||||
initOnClickListener()
|
||||
}
|
||||
|
||||
override fun onTransitionCancel(transition: androidx.transition.Transition) {
|
||||
}
|
||||
|
||||
override fun onTransitionPause(transition: androidx.transition.Transition) {
|
||||
}
|
||||
|
||||
override fun onTransitionResume(transition: androidx.transition.Transition) {
|
||||
}
|
||||
|
||||
})
|
||||
bTransition.addListener(object : androidx.transition.Transition.TransitionListener {
|
||||
override fun onTransitionStart(transition: androidx.transition.Transition) {
|
||||
if (mFragment != null) {
|
||||
Log.e("jingo", "动画开始A mFragment 不为null")
|
||||
supportFragmentManager.beginTransaction().replace(fragmentId, mFragment!!)
|
||||
.commit()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onTransitionEnd(transition: androidx.transition.Transition) {
|
||||
initOnClickListener()
|
||||
}
|
||||
|
||||
override fun onTransitionCancel(transition: androidx.transition.Transition) {
|
||||
}
|
||||
|
||||
override fun onTransitionPause(transition: androidx.transition.Transition) {
|
||||
}
|
||||
|
||||
override fun onTransitionResume(transition: androidx.transition.Transition) {
|
||||
}
|
||||
|
||||
})
|
||||
initOnClickListener()
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置点击事件
|
||||
*/
|
||||
private fun initOnClickListener() {
|
||||
/**
|
||||
* 地图按钮
|
||||
*/
|
||||
binding.consoleRoot.findViewById<View>(R.id.console_map_icon_bg)?.setOnClickListener(
|
||||
this
|
||||
)
|
||||
binding.consoleRoot.findViewById<View>(R.id.console_map_bg)?.setOnClickListener(this)
|
||||
/**
|
||||
* 离线地图按钮
|
||||
*/
|
||||
binding.consoleRoot.findViewById<View>(R.id.console_offline_map_icon_bg)
|
||||
?.setOnClickListener(this)
|
||||
binding.consoleRoot.findViewById<View>(R.id.console_offline_map_bg)
|
||||
?.setOnClickListener(this)
|
||||
/**
|
||||
* 图层设置按钮
|
||||
*/
|
||||
binding.consoleRoot.findViewById<View>(R.id.console_layer_setting_icon_bg)
|
||||
?.setOnClickListener(this)
|
||||
binding.consoleRoot.findViewById<View>(R.id.console_layer_setting_bg)
|
||||
?.setOnClickListener(this)
|
||||
/**
|
||||
* 个人中心
|
||||
*/
|
||||
binding.consoleRoot.findViewById<View>(R.id.console_personal_center_icon_bg)
|
||||
?.setOnClickListener(this)
|
||||
binding.consoleRoot.findViewById<View>(R.id.console_personal_center_bg)
|
||||
?.setOnClickListener(this)
|
||||
/**
|
||||
* 测评结果列表
|
||||
*/
|
||||
binding.consoleRoot.findViewById<View>(R.id.console_evaluation_icon_bg)
|
||||
?.setOnClickListener(this)
|
||||
binding.consoleRoot.findViewById<View>(R.id.console_evaluation_bg)
|
||||
?.setOnClickListener(this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
_binding = null
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
v?.let {
|
||||
when (it.id) {
|
||||
/**
|
||||
* 地图点击事件
|
||||
*/
|
||||
R.id.console_map_bg, R.id.console_map_icon_bg -> {
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
/**
|
||||
* 离线地图点击
|
||||
*/
|
||||
R.id.console_offline_map_icon_bg, R.id.console_offline_map_bg -> {
|
||||
if (sceneFlag) {
|
||||
mFragment = OfflineMapFragment()
|
||||
sceneFlag = false
|
||||
TransitionManager.go(bScene, bTransition)
|
||||
} else {
|
||||
if (mFragment !is OfflineMapFragment) {
|
||||
mFragment = OfflineMapFragment()
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(fragmentId, mFragment!!).commit()
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 个人中心点击
|
||||
*/
|
||||
R.id.console_personal_center_bg, R.id.console_personal_center_icon_bg -> {
|
||||
if (sceneFlag) {
|
||||
mFragment = PersonalCenterFragment()
|
||||
sceneFlag = false
|
||||
TransitionManager.go(bScene, bTransition)
|
||||
} else {
|
||||
if (mFragment !is PersonalCenterFragment) {
|
||||
mFragment = PersonalCenterFragment()
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(fragmentId, mFragment!!).commit()
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 图层设置
|
||||
*/
|
||||
R.id.console_layer_setting_bg, R.id.console_layer_setting_icon_bg -> {
|
||||
if (sceneFlag) {
|
||||
mFragment = LayermanagerFragment()
|
||||
sceneFlag = false
|
||||
TransitionManager.go(bScene, bTransition)
|
||||
} else {
|
||||
if (mFragment !is LayermanagerFragment) {
|
||||
mFragment = LayermanagerFragment()
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(fragmentId, mFragment!!).commit()
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 测评结果列表
|
||||
*/
|
||||
R.id.console_evaluation_icon_bg,
|
||||
R.id.console_evaluation_bg -> {
|
||||
// if (sceneFlag) {
|
||||
// mFragment = LayermanagerFragment()
|
||||
// sceneFlag = false
|
||||
// TransitionManager.go(bScene, bTransition)
|
||||
// } else {
|
||||
// if (mFragment !is LayermanagerFragment) {
|
||||
// mFragment = LayermanagerFragment()
|
||||
// supportFragmentManager.beginTransaction()
|
||||
// .replace(fragmentId, mFragment!!).commit()
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,8 +13,6 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.databinding.ActivityLoginBinding
|
||||
import com.navinfo.omqs.ui.activity.CheckPermissionsActivity
|
||||
import com.navinfo.omqs.ui.activity.PermissionsActivity
|
||||
import com.navinfo.omqs.ui.activity.console.ConsoleActivity
|
||||
import com.navinfo.omqs.ui.activity.map.MainActivity
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
@@ -90,7 +88,7 @@ class LoginActivity : CheckPermissionsActivity() {
|
||||
LoginStatus.LOGIN_STATUS_SUCCESS -> {
|
||||
loginDialog?.dismiss()
|
||||
loginDialog = null
|
||||
val intent = Intent(this@LoginActivity, ConsoleActivity::class.java)
|
||||
val intent = Intent(this@LoginActivity, MainActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
|
||||
@@ -12,12 +12,9 @@ import android.widget.EditText
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.activity.viewModels
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavDestination
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@@ -30,6 +27,10 @@ import com.navinfo.omqs.databinding.ActivityMainBinding
|
||||
import com.navinfo.omqs.http.offlinemapdownload.OfflineMapDownloadManager
|
||||
import com.navinfo.omqs.tools.LayerConfigUtils
|
||||
import com.navinfo.omqs.ui.activity.BaseActivity
|
||||
import com.navinfo.omqs.ui.fragment.console.ConsoleFragment
|
||||
import com.navinfo.omqs.ui.fragment.offlinemap.OfflineMapFragment
|
||||
import com.navinfo.omqs.ui.fragment.qsrecordlist.QsRecordListFragment
|
||||
import com.navinfo.omqs.ui.fragment.tasklist.TaskManagerFragment
|
||||
import com.navinfo.omqs.ui.widget.RecyclerViewSpacesItemDecoration
|
||||
import com.navinfo.omqs.util.FlowEventBus
|
||||
import com.navinfo.omqs.util.SpeakMode
|
||||
@@ -49,6 +50,14 @@ class MainActivity : BaseActivity() {
|
||||
private lateinit var binding: ActivityMainBinding
|
||||
private val viewModel by viewModels<MainViewModel>()
|
||||
|
||||
/**
|
||||
* 左侧fragment
|
||||
*/
|
||||
private var leftFragment: Fragment? = null
|
||||
|
||||
/**
|
||||
* 是否开启右侧面板
|
||||
*/
|
||||
var switchFragment = false
|
||||
|
||||
/**
|
||||
@@ -79,7 +88,7 @@ class MainActivity : BaseActivity() {
|
||||
* 提前显示要素看板
|
||||
*/
|
||||
private val signAdapter by lazy {
|
||||
SignAdapter { position, autoSave,signBean ->
|
||||
SignAdapter { _, autoSave, signBean ->
|
||||
rightController.currentDestination?.let {
|
||||
if (it.id == R.id.RightEmptyFragment) {
|
||||
val bundle = Bundle()
|
||||
@@ -95,7 +104,7 @@ class MainActivity : BaseActivity() {
|
||||
* 道路信息看板
|
||||
*/
|
||||
private val topSignAdapter by lazy {
|
||||
TopSignAdapter { position, signBean ->
|
||||
TopSignAdapter { _, signBean ->
|
||||
rightController.currentDestination?.let {
|
||||
if (it.id == R.id.RightEmptyFragment) {
|
||||
val bundle = Bundle()
|
||||
@@ -108,7 +117,6 @@ class MainActivity : BaseActivity() {
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
val checkIntent = Intent()
|
||||
@@ -138,22 +146,19 @@ class MainActivity : BaseActivity() {
|
||||
//给xml传递viewModel对象
|
||||
binding.viewModel = viewModel
|
||||
|
||||
binding.mainActivityVoice.setOnTouchListener(object : View.OnTouchListener {
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
override fun onTouch(v: View?, event: MotionEvent?): Boolean {
|
||||
when (event?.action) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
voiceOnTouchStart()//Do Something
|
||||
Log.e("qj", "voiceOnTouchStart")
|
||||
}
|
||||
MotionEvent.ACTION_UP -> {
|
||||
voiceOnTouchStop()//Do Something
|
||||
Log.e("qj", "voiceOnTouchStop")
|
||||
}
|
||||
binding.mainActivityVoice.setOnTouchListener { v, event ->
|
||||
when (event?.action) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
voiceOnTouchStart()//Do Something
|
||||
Log.e("qj", "voiceOnTouchStart")
|
||||
}
|
||||
MotionEvent.ACTION_UP -> {
|
||||
voiceOnTouchStop()//Do Something
|
||||
Log.e("qj", "voiceOnTouchStop")
|
||||
}
|
||||
return v?.onTouchEvent(event) ?: true
|
||||
}
|
||||
})
|
||||
v?.onTouchEvent(event) ?: true
|
||||
}
|
||||
|
||||
viewModel.liveDataQsRecordIdList.observe(this) {
|
||||
//处理页面跳转
|
||||
@@ -224,7 +229,7 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
findNavController(R.id.main_activity_right_fragment).addOnDestinationChangedListener { controller, destination, arguments ->
|
||||
findNavController(R.id.main_activity_right_fragment).addOnDestinationChangedListener { _, destination, arguments ->
|
||||
if (destination.id == R.id.RightEmptyFragment) {
|
||||
binding.mainActivityRightVisibilityButtonsGroup.visibility = View.VISIBLE
|
||||
} else {
|
||||
@@ -233,6 +238,9 @@ class MainActivity : BaseActivity() {
|
||||
binding.mainActivitySelectLine.isSelected = false
|
||||
}
|
||||
}
|
||||
|
||||
supportFragmentManager.beginTransaction()
|
||||
.add(R.id.console_fragment_layout, ConsoleFragment()).commit()
|
||||
}
|
||||
|
||||
//根据输入的经纬度跳转坐标
|
||||
@@ -296,7 +304,15 @@ class MainActivity : BaseActivity() {
|
||||
* 打开个人中菜单
|
||||
*/
|
||||
fun openMenu() {
|
||||
binding.mainActivityDrawer.open()
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.console_fragment_layout, ConsoleFragment()).commit()
|
||||
if (leftFragment != null) {
|
||||
supportFragmentManager.beginTransaction().remove(leftFragment!!).commit()
|
||||
leftFragment = null
|
||||
binding.mainActivityBottomSheetGroup.visibility = View.GONE
|
||||
binding.mainActivityLeftFragment.visibility = View.GONE
|
||||
}
|
||||
// binding.mainActivityDrawer.open()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -332,7 +348,7 @@ class MainActivity : BaseActivity() {
|
||||
/**
|
||||
* 点击搜索
|
||||
*/
|
||||
fun onClickSerach() {
|
||||
fun onClickSearch() {
|
||||
|
||||
}
|
||||
|
||||
@@ -393,14 +409,89 @@ class MainActivity : BaseActivity() {
|
||||
binding.mainActivitySelectLine.isSelected = viewModel.isSelectRoad()
|
||||
}
|
||||
|
||||
fun voiceOnTouchStart() {
|
||||
|
||||
/**
|
||||
* 打开或关闭底部导航栏
|
||||
*/
|
||||
fun onSwitchSheet() {
|
||||
if (binding.mainActivityBottomSheetGroup.visibility == View.VISIBLE) {
|
||||
binding.mainActivityBottomSheetGroup.visibility = View.GONE
|
||||
} else {
|
||||
binding.mainActivityBottomSheetGroup.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
private fun voiceOnTouchStart() {
|
||||
viewModel.startSoundMetter(this, binding.mainActivityVoice)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
fun voiceOnTouchStop() {
|
||||
private fun voiceOnTouchStop() {
|
||||
if (Constant.IS_VIDEO_SPEED) {
|
||||
viewModel.stopSoundMeter()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
viewModel.stopSoundMeter()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开测评任务面板
|
||||
*/
|
||||
fun onClickTaskFragment() {
|
||||
if (leftFragment !is TaskManagerFragment) {
|
||||
if (leftFragment == null) {
|
||||
binding.mainActivityBottomSheetGroup.visibility = View.VISIBLE
|
||||
binding.mainActivityLeftFragment.visibility = View.VISIBLE
|
||||
}
|
||||
leftFragment = TaskManagerFragment {
|
||||
binding.mainActivityLeftFragment.visibility = View.GONE
|
||||
supportFragmentManager.beginTransaction()
|
||||
.remove(leftFragment!!).commit()
|
||||
leftFragment = null
|
||||
null
|
||||
}
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.main_activity_left_fragment, leftFragment!!).commit()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开测评结果面板
|
||||
*/
|
||||
fun onClickResFragment() {
|
||||
if (leftFragment !is QsRecordListFragment) {
|
||||
if (leftFragment == null) {
|
||||
binding.mainActivityBottomSheetGroup.visibility = View.VISIBLE
|
||||
binding.mainActivityLeftFragment.visibility = View.VISIBLE
|
||||
}
|
||||
leftFragment = QsRecordListFragment {
|
||||
binding.mainActivityLeftFragment.visibility = View.GONE
|
||||
supportFragmentManager.beginTransaction()
|
||||
.remove(leftFragment!!).commit()
|
||||
leftFragment = null
|
||||
null
|
||||
}
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.main_activity_left_fragment, leftFragment!!).commit()
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 打开离线地图
|
||||
*/
|
||||
fun onClickOfflineMapFragment(){
|
||||
if (leftFragment !is OfflineMapFragment) {
|
||||
if (leftFragment == null) {
|
||||
binding.mainActivityBottomSheetGroup.visibility = View.VISIBLE
|
||||
binding.mainActivityLeftFragment.visibility = View.VISIBLE
|
||||
}
|
||||
leftFragment = OfflineMapFragment {
|
||||
binding.mainActivityLeftFragment.visibility = View.GONE
|
||||
supportFragmentManager.beginTransaction()
|
||||
.remove(leftFragment!!).commit()
|
||||
leftFragment = null
|
||||
null
|
||||
}
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.main_activity_left_fragment, leftFragment!!).commit()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user