添加左侧面板实现

This commit is contained in:
tongchenfei
2020-07-06 20:14:31 +08:00
parent ad11ae5db1
commit 139de2a0f2
25 changed files with 340 additions and 3 deletions

View File

@@ -0,0 +1,24 @@
package com.zhidao.mogo.module.left.panel
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.zhidao.mogo.module.left.panel.test", appContext.packageName)
}
}

View File

@@ -0,0 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zhidao.mogo.module.left.panel">
/
</manifest>

View File

@@ -0,0 +1,6 @@
package com.zhidao.mogo.module.left.panel
object LeftPanelConst {
const val MODULE_NAME = "MODULE_LEFT_PANEL"
const val PATH_NAME = "/left/panel"
}

View File

@@ -0,0 +1,75 @@
package com.zhidao.mogo.module.left.panel
import android.content.Context
import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.map.listener.IMogoMapListener
import com.mogo.map.location.IMogoLocationListener
import com.mogo.map.location.MogoLocation
import com.mogo.map.marker.IMogoMarkerClickListener
import com.mogo.map.navi.IMogoNaviListener
import com.mogo.service.module.IMogoModuleLifecycle
import com.mogo.service.module.IMogoModuleProvider
import com.mogo.utils.logger.Logger
import com.zhidao.mogo.module.left.panel.LeftPanelConst.MODULE_NAME
import com.zhidao.mogo.module.left.panel.LeftPanelConst.PATH_NAME
import com.zhidao.mogo.module.left.panel.fragment.SimpleSpeedFragment
/**
* 适配1+16增加的位于左侧的面板页provider
*
* @author tongchenfei
*/
@Route(path = PATH_NAME)
class LeftPanelProvider:IMogoModuleProvider {
override fun getNaviListener(): IMogoNaviListener? {
return null
}
override fun getLocationListener(): IMogoLocationListener? {
return null
}
override fun getType(): Int {
return 0
}
override fun getMarkerClickListener(): IMogoMarkerClickListener? {
return null
}
override fun init(context: Context?) {
Logger.d(MODULE_NAME, "左侧面板模块初始化===")
}
override fun getMapListener(): IMogoMapListener? {
return null
}
override fun getAppPackage(): String {
return ""
}
override fun createView(context: Context?): View? {
return null
}
override fun createFragment(context: Context?, data: Bundle?): Fragment? {
return SimpleSpeedFragment()
}
override fun getModuleName(): String {
return MODULE_NAME
}
override fun getAppName(): String {
return ""
}
override fun getCardLifecycle(): IMogoModuleLifecycle? {
return null
}
}

View File

@@ -0,0 +1,28 @@
package com.zhidao.mogo.module.left.panel.fragment
import com.mogo.commons.mvp.MvpFragment
import com.zhidao.mogo.module.left.panel.R
import com.zhidao.mogo.module.left.panel.presenter.SimpleSpeedPresenter
import kotlinx.android.synthetic.main.module_left_panel_simple_speed.*
/**
* 临时车速界面的fragment
*
* @author tongchenfei
*/
class SimpleSpeedFragment: MvpFragment<SimpleSpeedFragment, SimpleSpeedPresenter>() {
override fun getLayoutId(): Int {
return R.layout.module_left_panel_simple_speed
}
override fun initViews() {
}
override fun createPresenter(): SimpleSpeedPresenter {
return SimpleSpeedPresenter(this)
}
fun refreshSpeed(speed: Int) {
tvModuleLeftPanelSpeed.text = speed.toString()
}
}

View File

@@ -0,0 +1,31 @@
package com.zhidao.mogo.module.left.panel.presenter
import android.os.Handler
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.commons.mvp.Presenter
import com.mogo.map.location.IMogoLocationListener
import com.mogo.map.location.MogoLocation
import com.mogo.service.IMogoServiceApis
import com.mogo.service.MogoServicePaths
import com.zhidao.mogo.module.left.panel.LeftPanelConst.MODULE_NAME
import com.zhidao.mogo.module.left.panel.fragment.SimpleSpeedFragment
import java.lang.Thread.sleep
import kotlin.concurrent.thread
/**
* 临时左侧车速逻辑的presenter
*
* @author tongchenfei
*/
class SimpleSpeedPresenter(view: SimpleSpeedFragment) : Presenter<SimpleSpeedFragment>(view) {
private val handler = Handler()
private var mogoApis: IMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(view.context) as IMogoServiceApis
init {
// 注册相关回调,监测速度变化
mogoApis.registerCenterApi.registerMogoLocationListener(MODULE_NAME) {
handler.post {
mView.refreshSpeed(it.speed.toInt())
}
}
}
}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tvModuleLeftPanelSpeed"
android:text="50"
android:gravity="center"
android:textSize="40sp"
android:textColor="#fff"
android:background="#000" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,17 @@
package com.zhidao.mogo.module.left.panel
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}