Browse Source

feat: 转盘本地化

tongmengxiao 3 months ago
parent
commit
1b3890c27f
25 changed files with 632 additions and 98 deletions
  1. 32 0
      baseswago/src/main/java/com/swago/baseswago/LotteryVm.kt
  2. 0 10
      baseswago/src/main/java/com/swago/baseswago/constant/UrlConstant.kt
  3. 154 0
      baseswago/src/main/java/com/swago/baseswago/cusview/LotteryView.kt
  4. 29 75
      baseswago/src/main/java/com/swago/baseswago/dialog/TodayTrafficDialog.kt
  5. 51 0
      baseswago/src/main/java/com/swago/baseswago/dialog/TrafficResultDialog.kt
  6. 13 0
      baseswago/src/main/java/com/swago/baseswago/inter/UserApi.kt
  7. 1 1
      baseswago/src/main/java/com/swago/baseswago/model/live/OnlineRewardsModel.kt
  8. 8 0
      baseswago/src/main/java/com/swago/baseswago/model/mine/LotteryListModel.kt
  9. 30 0
      baseswago/src/main/java/com/swago/glide.kt
  10. 76 0
      baseswago/src/main/res/layout/dialog_result_traffic.xml
  11. 12 4
      baseswago/src/main/res/layout/dialog_today_traffic.xml
  12. 36 0
      baseswago/src/main/res/layout/item_lottery.xml
  13. 186 0
      baseswago/src/main/res/layout/view_lottery.xml
  14. BIN
      baseswago/src/main/res/mipmap-xxhdpi/background_lottery.png
  15. BIN
      baseswago/src/main/res/mipmap-xxhdpi/background_lottery_purple.png
  16. BIN
      baseswago/src/main/res/mipmap-xxhdpi/bg_result_lottery.png
  17. BIN
      baseswago/src/main/res/mipmap-xxhdpi/bg_start_traffic.png
  18. BIN
      baseswago/src/main/res/mipmap-xxhdpi/bg_traffic.png
  19. BIN
      baseswago/src/main/res/mipmap-xxhdpi/bt_result_traffic.png
  20. BIN
      baseswago/src/main/res/mipmap-xxhdpi/footer_traffic.png
  21. BIN
      baseswago/src/main/res/mipmap-xxhdpi/head_traffic.png
  22. BIN
      baseswago/src/main/res/mipmap-xxhdpi/ic_start_traffic.png
  23. BIN
      baseswago/src/main/res/mipmap-xxhdpi/icon_exp.png
  24. 3 7
      home/src/main/java/com/swago/home/HomeFragment.kt
  25. 1 1
      room/src/main/java/com/swago/room/reward/RewardView.kt

+ 32 - 0
baseswago/src/main/java/com/swago/baseswago/LotteryVm.kt

@@ -0,0 +1,32 @@
+package com.swago.baseswago
+
+import android.app.Application
+import androidx.lifecycle.MutableLiveData
+import com.swago.baseswago.inter.ApiManager
+import com.swago.baseswago.model.mine.LotteryListModel
+import com.swago.baseswago.util.BaseViewModel
+
+class LotteryVm(application: Application) : BaseViewModel(application) {
+
+    val resultLottery  by lazy {
+        MutableLiveData<LotteryListModel>()
+    }
+
+    fun getResultLottery(){
+        requestData {
+            resultLottery.value = ApiManager.userApi.resultLottery()
+        }
+    }
+    val lotteryListData  by lazy {
+        MutableLiveData<List<LotteryListModel>>()
+    }
+
+    fun getLotteryList(){
+        requestData2 {
+            requestData{
+                lotteryListData.value = ApiManager.userApi.getLotteryList()
+            }
+        }
+    }
+
+}

+ 0 - 10
baseswago/src/main/java/com/swago/baseswago/constant/UrlConstant.kt

@@ -29,14 +29,6 @@ object UrlConstant {
         }
     }
 
-    private val TRAFFIC_URL by lazy {
-        if (BuildConfig.DEBUG) {
-            "http://test-h5.swago.cn"
-        } else {
-            "https://web-view.me-live.cn"
-        }
-    }
-
     private val gson by lazy {
         Gson()
     }
@@ -92,8 +84,6 @@ object UrlConstant {
     val WITHDRAW_CUSTOMER = "${BASE_WEB_URL}/withdrawal/customer"//所有用户都跳跳这个 1.2.0版本改的
     //排行榜
     val RANKING = "${BASE_WEB_URL}/goldCoinRank"
-    //转盘
-    val TRAFFIC = "${TRAFFIC_URL}/checkIn"
     var appGameRootPath =
         AppContext.getContext().getExternalFilesDir("")?.absolutePath + File.separator + "gameFile"
 

+ 154 - 0
baseswago/src/main/java/com/swago/baseswago/cusview/LotteryView.kt

@@ -0,0 +1,154 @@
+package com.swago.baseswago.cusview
+
+import android.animation.ObjectAnimator
+import android.annotation.SuppressLint
+import android.content.Context
+import android.os.Handler
+import android.os.Looper
+import android.util.AttributeSet
+import android.view.LayoutInflater
+import android.view.View
+import android.widget.FrameLayout
+import com.bumptech.glide.Glide
+import com.swago.baseswago.R
+import com.swago.baseswago.databinding.ItemLotteryBinding
+import com.swago.baseswago.databinding.ViewLotteryBinding
+import com.swago.baseswago.model.mine.LotteryListModel
+import com.swago.loadNoPlaceUrlSrc
+import com.swago.loadUrl
+
+class LotteryView : FrameLayout {
+    private var binding:ViewLotteryBinding? = null
+
+    private var items = mutableListOf<ItemLotteryBinding>() // 保存16个格子
+    private var lotteryData = mutableListOf<LotteryListModel>() // 保存16个格子
+    private var animatorCount = 0 //当前动画刷新次数
+    private var rotationSpeed = 50L //动画速度
+    private var mResult : LotteryListModel ?= null
+
+    private var currentIndex = 0 // 当前选中的格子索引
+    private var isAnimating = false // 判断是否正在执行动画
+    private val handler = Handler(Looper.getMainLooper())  // 用于定时控制的 Handler
+    var startGetResultFun: (() -> Unit)?= null
+    var imageLoadSuccessFun: ((success:Boolean) -> Unit)?= null
+    var showGetResultFun: ((result:LotteryListModel?) -> Unit)?= null
+    constructor(context: Context) : this(context, null)
+    constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
+
+    constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
+        context,
+        attrs,
+        defStyleAttr
+    ){
+        initView()
+    }
+
+    private fun initView() {
+        binding = ViewLotteryBinding.inflate(LayoutInflater.from(context),this,true)
+        binding?.apply {
+            items.add(view1)
+            items.add(view2)
+            items.add(view3)
+            items.add(view4)
+            items.add(view5)
+            items.add(view6)
+            items.add(view7)
+            items.add(view8)
+            items.add(view9)
+            items.add(view10)
+            items.add(view11)
+            items.add(view12)
+        }
+        binding?.ivStart?.setOnClickListener {
+            startGetResultFun?.invoke()
+//            startLottery(null)
+        }
+    }
+
+    fun setLotteryData(list:List<LotteryListModel>){
+        if (list.size < 12)
+            return
+        lotteryData.clear()
+        lotteryData.addAll(list)
+        items.forEachIndexed { index, view ->
+            view.ivIcon.loadNoPlaceUrlSrc(context,list[index].icon){
+                imageLoadSuccessFun?.invoke(it)
+            }
+            view.tvName.text = list[index].number
+            if (index %2 ==1){
+                view.clItem.setBackgroundResource(R.mipmap.background_lottery)
+            } else {
+                view.clItem.setBackgroundResource(R.mipmap.background_lottery_purple)
+            }
+        }
+    }
+
+    // 开始旋转动画
+    fun startLottery(result : LotteryListModel?) {
+        if (isAnimating) return  // 防止重复启动
+        mResult = result
+        currentIndex = 0
+        isAnimating = true
+        currentIndex = -1
+        rotationSpeed = 100L  // 初始旋转速度
+        animatorCount = 0
+
+        handler.post(runnable)
+    }
+
+    // 定义 Runnable 控制动画循环
+    private val runnable = object : Runnable {
+        override fun run() {
+            // 重置上一个格子的高亮状态
+            if (currentIndex >= 0) {
+                items[currentIndex].clItem.isSelected = false
+            }
+
+            // 更新当前格子的索引
+            currentIndex = (currentIndex + 1) % items.size
+            if (currentIndex == 0){
+                animatorCount ++
+            }
+
+            // 高亮当前格子
+            items[currentIndex].clItem.isSelected = true
+            playHighlightAnimation(items[currentIndex].clItem)
+
+            // 判断是否到达目标格子并减速
+            if (isAnimating) {
+                // 动态增加延迟时间,模拟逐渐减速
+                if (animatorCount == 3){
+                    rotationSpeed = (rotationSpeed * 1.1).toLong()  // 每次增加10%的时间
+                }
+
+                // 停止动画条件:到达目标格子且速度足够慢
+                if (lotteryData[currentIndex].id == mResult?.id && animatorCount > 3) {
+                    onLotteryFinished()
+                } else {
+                    // 继续下一次高亮
+                    handler.postDelayed(this, rotationSpeed)
+                }
+            }
+        }
+    }
+
+
+    // 播放高亮动画(例如背景颜色闪烁)
+    private fun playHighlightAnimation(view: View) {
+        val animator = ObjectAnimator.ofFloat(view, "alpha", 1f, 0.5f, 1f)
+        animator.duration = 500  // 每个格子的高亮持续时间
+        animator.start()
+    }
+
+
+    // 抽奖结束时的逻辑
+    private fun onLotteryFinished() {
+        isAnimating = false
+        // 处理中奖逻辑,例如显示中奖信息或奖励
+        showGetResultFun?.invoke(mResult)
+    }
+
+    fun onDestroy(){
+        handler.removeCallbacksAndMessages(null)
+    }
+}

+ 29 - 75
baseswago/src/main/java/com/swago/baseswago/dialog/TodayTrafficDialog.kt

@@ -1,31 +1,14 @@
 package com.swago.baseswago.dialog
 
-import android.graphics.Bitmap
-import android.graphics.Color
-import android.os.Build
 import android.os.Bundle
 import android.view.Gravity
-import android.view.ViewGroup
-import android.webkit.JavascriptInterface
-import android.webkit.WebChromeClient
-import android.webkit.WebSettings
-import android.webkit.WebView
-import android.webkit.WebViewClient
-import androidx.constraintlayout.widget.ConstraintLayout
-import androidx.transition.Visibility
-import com.google.firebase.firestore.core.View
-import com.swago.baseswago.constant.UrlConstant
+import androidx.fragment.app.viewModels
+import com.swago.baseswago.LotteryVm
 import com.swago.baseswago.databinding.DialogTodayTrafficBinding
-import com.swago.baseswago.util.DpPxUtil
-import com.swago.baseswago.util.SwagoInfo
-import com.swago.baseswago.util.UserInfo
-import org.json.JSONObject
 
 class TodayTrafficDialog : BaseStoreDFragment<DialogTodayTrafficBinding>() {
-    private var showDialog:Boolean = true
-    private val jsLoad by lazy {
-        JSLoad()
-    }
+    private val lotteryVm by viewModels<LotteryVm>()
+
     init {
         setGravity(Gravity.CENTER)
         setDimAmount(0.6f)
@@ -43,70 +26,41 @@ class TodayTrafficDialog : BaseStoreDFragment<DialogTodayTrafficBinding>() {
     }
 
     override fun initOther() {
-        binding?.loadingProgress?.visibility = android.view.View.VISIBLE
-        binding?.webview?.apply {
-            //设置大小
-            val params = ConstraintLayout.LayoutParams(
-                ViewGroup.LayoutParams.MATCH_PARENT,
-                ViewGroup.LayoutParams.MATCH_PARENT
-            )
-            params.topMargin =  DpPxUtil.getScreenHeight()/6
-            this.layoutParams = params
-            try {
-                val jsonObject = JSONObject()
-                jsonObject.put("TokenParam", UserInfo.getLoginModel()?.token?:"")
-                jsonObject.put("UserIdParam", UserInfo.getUserInfo()?.id?:"")
-                jsonObject.put("LocaleParam", SwagoInfo.getLanguageCode())
-                jsonObject.put("AppVersionParam", SwagoInfo.getVersionCode())
-                jsonObject.put("ClientParam", SwagoInfo.getAppClient())
-                jsonObject.put("ChannelParam", SwagoInfo.getChannel())
-                jsonObject.put("DeviceParam", SwagoInfo.getDeviceInfo())
-                settings.userAgentString = settings.userAgentString + jsonObject.toString()
-            } catch (e: Exception) {
-                e.printStackTrace()
+        binding?.lotteryView?.apply {
+            imageLoadSuccessFun = {
+                binding?.loadingProgress?.visibility = android.view.View.GONE
             }
-
-            if (Build.VERSION.SDK_INT >= 21) {
-                settings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
+            startGetResultFun = {
+                lotteryVm.getResultLottery()
             }
-            settings.javaScriptEnabled = true
-            addJavascriptInterface(jsLoad, "melive")
-            settings.allowUniversalAccessFromFileURLs = true
-            settings.allowFileAccess = true
-            settings.allowFileAccessFromFileURLs = true
-            settings.useWideViewPort = true
-            settings.loadWithOverviewMode = true
-            settings.javaScriptCanOpenWindowsAutomatically = true//设置允许JS弹窗
-            settings.domStorageEnabled = true
-            settings.cacheMode = WebSettings.LOAD_CACHE_ELSE_NETWORK
-            settings.domStorageEnabled = true
-            isHorizontalScrollBarEnabled = true
-            isVerticalScrollBarEnabled = true
-            settings.databaseEnabled = true
-            setBackgroundColor(Color.TRANSPARENT)
-            webViewClient = object : WebViewClient(){
-                override fun onPageFinished(view: WebView?, url: String?) {
-                    super.onPageFinished(view, url)
-                    binding?.loadingProgress?.visibility = android.view.View.GONE
-
+            showGetResultFun = {
+                it?.let { model ->
+                    this@TodayTrafficDialog.dismissAllowingStateLoss()
+                    TrafficResultDialog.newInstance(model.number , model.icon).show(parentFragmentManager,"TrafficResultDialog")
                 }
             }
-            loadUrl(UrlConstant.TRAFFIC)
+        }
+
+        binding?.finish?.setOnClickListener {
+            dismissAllowingStateLoss()
+        }
+        lotteryVm.resultLottery.observe(this){
+            binding?.lotteryView?.startLottery(it)
+        }
+
+        lotteryVm.getLotteryList()
+
+        lotteryVm.lotteryListData.observe(this){
+            binding?.lotteryView?.setLotteryData(it)
         }
     }
 
     override fun initLiveData() {
 
     }
-    inner class JSLoad {
-        @JavascriptInterface
-        fun HtmlcallNative(s:String) {
-            dismissAllowingStateLoss()
-        }
-    }
 
-    override fun dismiss() {
-        super.dismiss()
-        showDialog = true
+    override fun onDestroyView() {
+        binding?.lotteryView?.onDestroy()
+        super.onDestroyView()
     }
 }

+ 51 - 0
baseswago/src/main/java/com/swago/baseswago/dialog/TrafficResultDialog.kt

@@ -0,0 +1,51 @@
+package com.swago.baseswago.dialog
+
+
+import android.os.Bundle
+import android.view.Gravity
+import com.swago.baseswago.databinding.DialogResultTrafficBinding
+import com.swago.loadNoPlaceUrlSrc
+
+class TrafficResultDialog : BaseStoreDFragment<DialogResultTrafficBinding>() {
+
+    init {
+        setGravity(Gravity.CENTER)
+        setDimAmount(0.6f)
+        setCanCancel(true)
+        setHeightMatchParent()
+    }
+
+    companion object {
+        fun newInstance(name:String,icon:String): TrafficResultDialog {
+            val args = Bundle()
+            val fragment = TrafficResultDialog()
+            args.putString("name",name)
+            args.putString("icon",icon)
+            fragment.arguments = args
+            return fragment
+        }
+    }
+
+    override fun initOther() {
+        arguments?.let{
+            val name = it.getString("name")
+            val icon = it.getString("icon","")
+            binding?.tvName?.text= name
+            activity?.let {activity ->
+                binding?.ivIcon?.loadNoPlaceUrlSrc(activity,icon){}
+            }
+
+        }
+        binding?.ivGet?.setOnClickListener {
+            dismissAllowingStateLoss()
+        }
+
+    }
+
+    override fun initLiveData() {
+
+    }
+    override fun dismiss() {
+        super.dismiss()
+    }
+}

+ 13 - 0
baseswago/src/main/java/com/swago/baseswago/inter/UserApi.kt

@@ -179,4 +179,17 @@ interface UserApi {
     @FormUrlEncoded
     @POST("/v1/user/exist/product/chose")
     suspend fun choseProduct(@Field("product_id") product_id: Long):Any
+
+
+    /**
+     * 转盘抽奖
+     * */
+    @POST("/v1/app/zhuanpan/everyday/sign")
+    suspend fun resultLottery():LotteryListModel
+
+    /**
+     * 转盘商品列表
+     * */
+    @POST("/v1/zhuanpan/everyday/goods/get")
+    suspend fun getLotteryList():List<LotteryListModel>
 }

+ 1 - 1
baseswago/src/main/java/com/swago/baseswago/model/live/OnlineRewardsModel.kt

@@ -5,7 +5,7 @@ data class OnlineRewardsModel (
     var ten:Boolean,
     var fifteen:Boolean,
     var thirty:Boolean,
-    var onlineDuration:Int,
+    var onlineDuration:Long,
     val coin:CoinOnlineBean,
     )
 

+ 8 - 0
baseswago/src/main/java/com/swago/baseswago/model/mine/LotteryListModel.kt

@@ -0,0 +1,8 @@
+package com.swago.baseswago.model.mine
+
+data class LotteryListModel(
+    val id:Int,
+    val name:String="",
+    val number:String="",
+    val icon:String=""
+)

+ 30 - 0
baseswago/src/main/java/com/swago/glide.kt

@@ -92,6 +92,36 @@ fun ImageView.loadNoPlaceUrl(context: Context,url:String,call: (success:Boolean)
         })
 }
 
+fun ImageView.loadNoPlaceUrlSrc(context: Context,url:String,call: (success:Boolean) -> Unit){
+    Glide.with(context)
+        .load(url)
+        .centerCrop()
+        .listener(object :RequestListener<Drawable>{
+            override fun onLoadFailed(
+                e: GlideException?,
+                model: Any?,
+                target: Target<Drawable>?,
+                isFirstResource: Boolean
+            ): Boolean {
+                call.invoke(false)
+                return false
+            }
+
+            override fun onResourceReady(
+                resource: Drawable?,
+                model: Any?,
+                target: Target<Drawable>?,
+                dataSource: DataSource?,
+                isFirstResource: Boolean
+            ): Boolean {
+                call.invoke(true)
+                return false
+            }
+
+        })
+        .into(this)
+}
+
 fun ImageView.loadUrlCache(context: Context,url:String){
     Glide.with(context)
         .load(url)

+ 76 - 0
baseswago/src/main/res/layout/dialog_result_traffic.xml

@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/cl"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    xmlns:tools="http://schemas.android.com/tools"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        android:layout_marginStart="30dp"
+        android:layout_marginEnd="30dp"
+        android:paddingBottom="32dp"
+        android:background="@mipmap/bg_result_lottery"
+        app:layout_constraintBottom_toBottomOf="parent">
+        <TextView
+            android:id="@+id/tvGet"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textColor="@color/_ffffff"
+            android:textSize="@dimen/sp_16"
+            android:text="You get"
+            android:layout_marginTop="60dp"
+            android:textStyle="bold"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toTopOf="parent"/>
+
+        <ImageView
+            android:id="@+id/ivIcon"
+            android:layout_width="100dp"
+            android:layout_height="100dp"
+            android:layout_marginTop="14dp"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/tvGet"/>
+        <TextView
+            android:id="@+id/tvName"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textColor="@color/_ffffff"
+            android:textSize="@dimen/sp_16"
+            tools:text="×10000 Coins"
+            android:textStyle="bold"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/ivIcon"/>
+        <TextView
+            android:id="@+id/tvHint"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textColor="#99ffffff"
+            android:textSize="14sp"
+            android:layout_marginTop="@dimen/dp_10"
+            android:text="Come and play again tomorrow."
+            android:textStyle="bold"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/tvName"/>
+
+        <ImageView
+            android:id="@+id/ivGet"
+            android:layout_width="183dp"
+            android:layout_height="47dp"
+            android:src="@mipmap/bt_result_traffic"
+            android:layout_marginTop="@dimen/dp_40"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/tvHint"/>
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 12 - 4
baseswago/src/main/res/layout/dialog_today_traffic.xml

@@ -5,11 +5,10 @@
     android:layout_height="match_parent"
     xmlns:app="http://schemas.android.com/apk/res-auto">
 
-    <WebView
-        android:id="@+id/webview"
+    <com.swago.baseswago.cusview.LotteryView
+        android:id="@+id/lotteryView"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_marginTop="80dp"/>
+        android:layout_height="match_parent"/>
 
     <ProgressBar
         app:layout_constraintStart_toStartOf="parent"
@@ -24,5 +23,14 @@
         android:padding="6dp"
         android:background="@drawable/shape_80000000_20"/>
 
+    <ImageView
+        android:id="@+id/finish"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:src="@mipmap/benefit_close"
+        android:layout_marginBottom="60dp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"/>
 
 </androidx.constraintlayout.widget.ConstraintLayout>

+ 36 - 0
baseswago/src/main/res/layout/item_lottery.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:id="@+id/clItem"
+        android:layout_margin="2dp"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:background="@mipmap/background_lottery">
+        <ImageView
+            android:id="@+id/iv_icon"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toTopOf="parent"
+            app:layout_constraintBottom_toBottomOf="parent"
+            android:src="@mipmap/icon_exp"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"/>
+
+        <TextView
+            android:id="@+id/tvName"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintBottom_toBottomOf="parent"
+            android:text="×3 Days"
+            android:textSize="11sp"
+            android:textColor="@color/_ffffff"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginBottom="@dimen/dp_4"/>
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 186 - 0
baseswago/src/main/res/layout/view_lottery.xml

@@ -0,0 +1,186 @@
+<?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"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <ImageView
+        android:layout_width="match_parent"
+        android:layout_height="132dp"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"
+        android:layout_marginBottom="360dp"
+        android:background="@mipmap/head_traffic"/>
+
+    <ImageView
+        android:layout_width="match_parent"
+        android:layout_height="132dp"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent"
+        android:layout_marginTop="320dp"
+        android:background="@mipmap/footer_traffic"/>
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:id="@+id/cl_content"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingStart="40dp"
+        android:paddingEnd="42dp"
+        android:paddingTop="12dp"
+        android:paddingBottom="14dp"
+        android:background="@mipmap/bg_traffic"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintBottom_toBottomOf="parent">
+        <LinearLayout
+            android:id="@+id/layout_1"
+            android:layout_width="match_parent"
+            android:layout_height="80dp"
+            android:orientation="horizontal"
+            android:weightSum="4"
+            app:layout_constraintTop_toTopOf="parent">
+
+            <include
+                android:id="@+id/view_1"
+                layout="@layout/item_lottery"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="1" />
+
+            <include
+                android:id="@+id/view_2"
+                layout="@layout/item_lottery"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="1" />
+
+            <include
+                android:id="@+id/view_3"
+                layout="@layout/item_lottery"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="1" />
+
+            <include
+                android:id="@+id/view_4"
+                layout="@layout/item_lottery"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="1" />
+
+        </LinearLayout>
+        <LinearLayout
+            android:id="@+id/layout_2"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal"
+            android:weightSum="4"
+            app:layout_constraintTop_toBottomOf="@+id/layout_1">
+            <LinearLayout
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:orientation="vertical"
+                android:layout_weight="1">
+                <include
+                    android:id="@+id/view_12"
+                    layout="@layout/item_lottery"
+                    android:layout_width="match_parent"
+                    android:layout_height="80dp" />
+                <include
+                    android:id="@+id/view_11"
+                    layout="@layout/item_lottery"
+                    android:layout_width="match_parent"
+                    android:layout_height="80dp"/>
+            </LinearLayout>
+            <androidx.constraintlayout.widget.ConstraintLayout
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="2">
+                <ImageView
+                    android:id="@+id/ivStart"
+                    android:layout_marginBottom="38dp"
+                    android:layout_marginTop="10dp"
+                    android:layout_marginStart="@dimen/dp_10"
+                    android:layout_marginEnd="@dimen/dp_10"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:background="@mipmap/bg_start_traffic"/>
+                <ImageView
+                    android:layout_marginBottom="38dp"
+                    android:layout_marginTop="45dp"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintEnd_toEndOf="parent"
+                    app:layout_constraintTop_toTopOf="parent"
+                    android:layout_width="96dp"
+                    android:layout_height="41dp"
+                    android:background="@mipmap/ic_start_traffic"/>
+                <TextView
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    app:layout_constraintBottom_toBottomOf="parent"
+                    android:text="Login daily to get Spin×1"
+                    android:textColor="@color/_ffffff"
+                    android:gravity="center"
+                    android:textSize="11sp"
+                    android:textStyle="bold"
+                    android:layout_marginBottom="@dimen/dp_10"/>
+            </androidx.constraintlayout.widget.ConstraintLayout>
+
+            <LinearLayout
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:orientation="vertical"
+                android:layout_weight="1">
+                <include
+                    android:id="@+id/view_5"
+                    layout="@layout/item_lottery"
+                    android:layout_width="match_parent"
+                    android:layout_height="80dp"/>
+                <include
+                    android:id="@+id/view_6"
+                    layout="@layout/item_lottery"
+                    android:layout_width="match_parent"
+                    android:layout_height="80dp" />
+            </LinearLayout>
+
+        </LinearLayout>
+        <LinearLayout
+            android:id="@+id/layout_3"
+            android:layout_width="match_parent"
+            android:layout_height="80dp"
+            android:orientation="horizontal"
+            android:weightSum="4"
+            app:layout_constraintTop_toBottomOf="@+id/layout_2">
+
+            <include
+                android:id="@+id/view_10"
+                layout="@layout/item_lottery"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="1" />
+
+            <include
+                android:id="@+id/view_9"
+                layout="@layout/item_lottery"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="1" />
+
+            <include
+                android:id="@+id/view_8"
+                layout="@layout/item_lottery"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="1" />
+
+            <include
+                android:id="@+id/view_7"
+                layout="@layout/item_lottery"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="1" />
+
+        </LinearLayout>
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+</androidx.constraintlayout.widget.ConstraintLayout>

BIN
baseswago/src/main/res/mipmap-xxhdpi/background_lottery.png


BIN
baseswago/src/main/res/mipmap-xxhdpi/background_lottery_purple.png


BIN
baseswago/src/main/res/mipmap-xxhdpi/bg_result_lottery.png


BIN
baseswago/src/main/res/mipmap-xxhdpi/bg_start_traffic.png


BIN
baseswago/src/main/res/mipmap-xxhdpi/bg_traffic.png


BIN
baseswago/src/main/res/mipmap-xxhdpi/bt_result_traffic.png


BIN
baseswago/src/main/res/mipmap-xxhdpi/footer_traffic.png


BIN
baseswago/src/main/res/mipmap-xxhdpi/head_traffic.png


BIN
baseswago/src/main/res/mipmap-xxhdpi/ic_start_traffic.png


BIN
baseswago/src/main/res/mipmap-xxhdpi/icon_exp.png


+ 3 - 7
home/src/main/java/com/swago/home/HomeFragment.kt

@@ -57,13 +57,9 @@ class HomeFragment : BaseXFragment<FragmentHomeBinding>() {
 
 
     override fun loadData() {
-//        UserInfo.getUserInfo()?.let{
-//            if (!it.is_zhuanpan_every_day){
-//                TodayTrafficDialog.newInstance().show(childFragmentManager,"TodayTrafficDialog")
-//            }
-//        }.also {
-//            TodayTrafficDialog.newInstance().show(childFragmentManager,"TodayTrafficDialog")
-//        }
+        if (UserInfo.getUserInfo() == null ||UserInfo.getUserInfo()?.is_zhuanpan_every_day == false){
+            TodayTrafficDialog.newInstance().show(childFragmentManager,"TodayTrafficDialog")
+        }
     }
 
     override fun initOther() {

+ 1 - 1
room/src/main/java/com/swago/room/reward/RewardView.kt

@@ -140,7 +140,7 @@ class RewardView : FrameLayout, IRoomActiveListener, RoomTimer.TimeTickListener
         }
         rewardsModel = model
         visibility = View.VISIBLE
-        totalTime = model.onlineDuration * 60L
+        totalTime = model.onlineDuration
         nextReward()
     }