|
@@ -3,24 +3,40 @@ package com.swago.app
|
|
import android.Manifest
|
|
import android.Manifest
|
|
import android.os.Build
|
|
import android.os.Build
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
-import android.util.Log
|
|
|
|
|
|
+import android.os.CountDownTimer
|
|
|
|
+import android.text.TextUtils
|
|
|
|
+import android.view.View
|
|
|
|
+import android.widget.ImageView
|
|
|
|
+import android.widget.TextView
|
|
import android.widget.Toast
|
|
import android.widget.Toast
|
|
import androidx.activity.viewModels
|
|
import androidx.activity.viewModels
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import com.alibaba.android.arouter.launcher.ARouter
|
|
import com.alibaba.android.arouter.launcher.ARouter
|
|
-import com.swago.baseswago.constant.ARouteConstant
|
|
|
|
import com.permissionx.guolindev.PermissionX
|
|
import com.permissionx.guolindev.PermissionX
|
|
|
|
+import com.swago.baseswago.constant.ARouteConstant
|
|
import com.swago.baseswago.constant.UrlConstant
|
|
import com.swago.baseswago.constant.UrlConstant
|
|
|
|
+import com.swago.baseswago.model.ConfigModel
|
|
import com.swago.baseswago.util.AppContext
|
|
import com.swago.baseswago.util.AppContext
|
|
import com.swago.baseswago.util.FileUtil
|
|
import com.swago.baseswago.util.FileUtil
|
|
-import com.swago.baseswago.util.MD5Util
|
|
|
|
import com.swago.baseswago.util.SpUtil
|
|
import com.swago.baseswago.util.SpUtil
|
|
|
|
+import com.swago.loadUrl
|
|
import java.io.File
|
|
import java.io.File
|
|
|
|
+import java.text.SimpleDateFormat
|
|
|
|
+import java.util.Date
|
|
|
|
+import java.util.Locale
|
|
|
|
+
|
|
|
|
|
|
class SplashActivity : AppCompatActivity() {
|
|
class SplashActivity : AppCompatActivity() {
|
|
|
|
|
|
private val splashVm by viewModels<SplashVm>()
|
|
private val splashVm by viewModels<SplashVm>()
|
|
|
|
|
|
|
|
+ private val currentDate: String = SimpleDateFormat("yyyyMMdd", Locale.getDefault()).format(Date())
|
|
|
|
+ private var mSplashImage:ImageView ?= null
|
|
|
|
+ private var mSplashTime:TextView ?= null
|
|
|
|
+ private lateinit var countDownTimer: CountDownTimer
|
|
|
|
+ private val totalTimeInMillis: Long = 5000
|
|
|
|
+ private var configModel:ConfigModel ?= null
|
|
|
|
+
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
super.onCreate(savedInstanceState)
|
|
setContentView(R.layout.activity_splash)
|
|
setContentView(R.layout.activity_splash)
|
|
@@ -81,6 +97,65 @@ class SplashActivity : AppCompatActivity() {
|
|
val t = UrlConstant.appGameRootPath + File.separator + 8
|
|
val t = UrlConstant.appGameRootPath + File.separator + 8
|
|
FileUtil.upZipFile(UrlConstant.appGameRootPath + File.separator + 8 + File.separator + "com-swago-magical-piggy.zip" , t + File.separator)
|
|
FileUtil.upZipFile(UrlConstant.appGameRootPath + File.separator + 8 + File.separator + "com-swago-magical-piggy.zip" , t + File.separator)
|
|
}
|
|
}
|
|
|
|
+ setSplashImage()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private fun setSplashImage() {
|
|
|
|
+ mSplashImage = findViewById(R.id.iv_splash)
|
|
|
|
+ mSplashTime = findViewById(R.id.skip_time)
|
|
|
|
+ countDownTimer = object : CountDownTimer(totalTimeInMillis, 1000) {
|
|
|
|
+ override fun onTick(millisUntilFinished: Long) {
|
|
|
|
+ val secondsRemaining = millisUntilFinished / 1000
|
|
|
|
+ mSplashTime?.text = "Skip $secondsRemaining"
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onFinish() {
|
|
|
|
+ splashVm.loginByAuto()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ splashVm.jumpToHomeLiveData.observe(this){
|
|
|
|
+ if (it == null || TextUtils.isEmpty(it.rotation_img_url)){
|
|
|
|
+ splashVm.loginByAuto()
|
|
|
|
+ } else {
|
|
|
|
+ var count = SpUtil.readInt("splashCount")
|
|
|
|
+ val lastDate = SpUtil.readString("lastShowDate")
|
|
|
|
+ configModel = it
|
|
|
|
+ if (currentDate == lastDate){
|
|
|
|
+ if (count <= 3){
|
|
|
|
+ count++
|
|
|
|
+ countDownTimer.start()
|
|
|
|
+ mSplashTime?.visibility = View.VISIBLE
|
|
|
|
+ mSplashImage?.loadUrl(this, it.rotation_img_url,R.drawable.default_splash)
|
|
|
|
+ SpUtil.putInt("splashCount" , count)
|
|
|
|
+ } else {
|
|
|
|
+ splashVm.loginByAuto()
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ SpUtil.putInt("splashCount" , 1)
|
|
|
|
+ SpUtil.putString("lastShowDate",currentDate)
|
|
|
|
+ countDownTimer.start()
|
|
|
|
+ mSplashTime?.visibility = View.VISIBLE
|
|
|
|
+ mSplashImage?.loadUrl(this, it.rotation_img_url,R.drawable.default_splash)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ mSplashImage?.setOnClickListener {
|
|
|
|
+ configModel?.rotation_url?.let {
|
|
|
|
+ ARouter.getInstance().build(ARouteConstant.Base.webView)
|
|
|
|
+ .withString("url", it)
|
|
|
|
+ .navigation()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ mSplashTime?.setOnClickListener {
|
|
|
|
+ splashVm.loginByAuto()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ override fun onDestroy() {
|
|
|
|
+ super.onDestroy()
|
|
|
|
+ countDownTimer.cancel()
|
|
}
|
|
}
|
|
}
|
|
}
|