@@ -0,0 +1,24 @@
|
||||
package com.zhidao.mogo.module.splash
|
||||
|
||||
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.byd.test", appContext.packageName)
|
||||
}
|
||||
}
|
||||
3
modules/mogo-module-splash/src/main/AndroidManifest.xml
Normal file
3
modules/mogo-module-splash/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.zhidao.mogo.module.splash">
|
||||
</manifest>
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.zhidao.mogo.module.splash
|
||||
|
||||
object SplashConst {
|
||||
const val MODULE_NAME = "MODULE_SPLASH"
|
||||
const val PATH_NAME = "/splash/api"
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package com.zhidao.mogo.module.splash
|
||||
|
||||
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.commons.debug.DebugConfig
|
||||
import com.mogo.map.listener.IMogoMapListener
|
||||
import com.mogo.map.location.IMogoLocationListener
|
||||
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.splash.SplashConst.MODULE_NAME
|
||||
import com.zhidao.mogo.module.splash.SplashConst.PATH_NAME
|
||||
import com.zhidao.mogo.module.splash.fragment.BydSplashFragment
|
||||
|
||||
/**
|
||||
* 比亚迪车机provider
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
@Route(path = PATH_NAME)
|
||||
class SplashProvider : 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? = if (DebugConfig.getCarMachineType() == DebugConfig.CAR_MACHINE_TYPE_BYD) {
|
||||
BydSplashFragment()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
override fun getModuleName(): String {
|
||||
return MODULE_NAME
|
||||
}
|
||||
|
||||
override fun getAppName(): String {
|
||||
return ""
|
||||
}
|
||||
|
||||
override fun getCardLifecycle(): IMogoModuleLifecycle? {
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.zhidao.mogo.module.splash.fragment
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Message
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.zhidao.mogo.module.splash.R
|
||||
import com.zhidao.mogo.module.splash.presenter.BydSplashPresenter
|
||||
import kotlinx.android.synthetic.main.fragment_byd_splash.*
|
||||
|
||||
const val DEFAULT_COUNT_DOWN_TIME = 5
|
||||
const val MSG_COUNT_DOWN = 1001
|
||||
const val DEFAULT_COUNT_DOWN_DELAY = 1000L
|
||||
class BydSplashFragment :MvpFragment<BydSplashFragment,BydSplashPresenter>(),Handler.Callback{
|
||||
private val handler = Handler(this)
|
||||
private var countDownTime = DEFAULT_COUNT_DOWN_TIME
|
||||
|
||||
override fun getLayoutId(): Int = R.layout.fragment_byd_splash
|
||||
|
||||
override fun initViews() {
|
||||
startCountDown()
|
||||
tvByd.setOnClickListener {
|
||||
hideSplash()
|
||||
}
|
||||
}
|
||||
|
||||
override fun createPresenter(): BydSplashPresenter = BydSplashPresenter(this)
|
||||
|
||||
private fun startCountDown(){
|
||||
handler.removeMessages(MSG_COUNT_DOWN)
|
||||
countDownTime = DEFAULT_COUNT_DOWN_TIME
|
||||
tvCountDown.text = countDownTime.toString()
|
||||
handler.sendEmptyMessageDelayed(MSG_COUNT_DOWN, DEFAULT_COUNT_DOWN_DELAY)
|
||||
}
|
||||
|
||||
override fun handleMessage(msg: Message): Boolean {
|
||||
if (msg.what == MSG_COUNT_DOWN) {
|
||||
tvCountDown?.also {
|
||||
countDownTime--
|
||||
if(countDownTime>0) {
|
||||
it.text = countDownTime.toString()
|
||||
handler.sendEmptyMessageDelayed(MSG_COUNT_DOWN, DEFAULT_COUNT_DOWN_DELAY)
|
||||
}else{
|
||||
hideSplash()
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private fun hideSplash(){
|
||||
handler.removeMessages(MSG_COUNT_DOWN)
|
||||
activity!!.supportFragmentManager.beginTransaction().remove(this).commit()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.zhidao.mogo.module.splash.presenter
|
||||
|
||||
import com.mogo.commons.mvp.Presenter
|
||||
import com.zhidao.mogo.module.splash.fragment.BydSplashFragment
|
||||
|
||||
class BydSplashPresenter(view: BydSplashFragment) : Presenter<BydSplashFragment>(view) {
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 82 KiB |
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="#000" />
|
||||
<size
|
||||
android:width="@dimen/dp_100"
|
||||
android:height="@dimen/dp_100" />
|
||||
</shape>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<gradient android:startColor="#256BFF" android:endColor="#5CC1FF" android:angle="45" />
|
||||
<corners android:radius="@dimen/dp_46" />
|
||||
<padding android:bottom="@dimen/dp_12" android:left="@dimen/dp_75" android:top="@dimen/dp_12" android:right="@dimen/dp_75" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 82 KiB |
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/module_byd_splash" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvByd"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/byd_enter_btn_bg"
|
||||
android:textColor="#0D172C"
|
||||
android:text="开启行程"
|
||||
android:textSize="@dimen/dp_46"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginStart="@dimen/dp_182"
|
||||
android:layout_marginBottom="@dimen/dp_251"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCountDown"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="5"
|
||||
android:gravity="center"
|
||||
android:textColor="#fff"
|
||||
android:textSize="@dimen/dp_54"
|
||||
android:layout_marginTop="@dimen/dp_48"
|
||||
android:layout_marginEnd="@dimen/dp_60"
|
||||
android:background="@drawable/byd_count_down_bg"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.zhidao.mogo.module.splash
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user