|
@@ -2,544 +2,40 @@ package com.khmer9.yuki.screen.main
|
|
|
|
|
|
import android.annotation.SuppressLint
|
|
|
import android.content.Intent
|
|
|
-import android.graphics.Color
|
|
|
-import android.graphics.Typeface
|
|
|
-import android.graphics.drawable.AnimationDrawable
|
|
|
-import android.graphics.drawable.Drawable
|
|
|
-import android.media.MediaPlayer
|
|
|
import android.os.Bundle
|
|
|
import android.util.Log
|
|
|
import android.view.View
|
|
|
-import android.view.animation.AlphaAnimation
|
|
|
-import android.view.animation.Animation
|
|
|
-import android.widget.ImageView
|
|
|
-import android.widget.TextView
|
|
|
import android.widget.Toast
|
|
|
-import androidx.constraintlayout.widget.Group
|
|
|
-import androidx.core.content.ContextCompat
|
|
|
-import androidx.core.content.ContextCompat.getColor
|
|
|
-import androidx.core.view.isVisible
|
|
|
-import androidx.fragment.app.Fragment
|
|
|
-import androidx.lifecycle.Observer
|
|
|
-import androidx.recyclerview.widget.ConcatAdapter
|
|
|
-import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
-import com.ahmedelsayed.sunmiprinterutill.PrintMe
|
|
|
-import com.gdtlib.lib.adapter.BaseListItem
|
|
|
-import com.google.android.material.textview.MaterialTextView
|
|
|
import com.khmer9.yuki.R
|
|
|
-import com.khmer9.yuki.adapter.BettingStatementHeaderAdapter
|
|
|
import com.khmer9.yuki.app.App
|
|
|
import com.khmer9.yuki.app.ShareActivity
|
|
|
-import com.khmer9.yuki.app.ShareViewState
|
|
|
import com.khmer9.yuki.base.BaseFragment
|
|
|
-import com.khmer9.yuki.extension.btnClick
|
|
|
-import com.khmer9.yuki.extension.random
|
|
|
-import com.khmer9.yuki.extension.waitingLotto
|
|
|
-import com.khmer9.yuki.extension.zoomIn
|
|
|
-import com.khmer9.yuki.remote.User
|
|
|
-import com.khmer9.yuki.remote.main.SocketClientNewGameDataModel
|
|
|
-import com.khmer9.yuki.remote.main.SocketClientRandomDataModel
|
|
|
-import com.khmer9.yuki.remote.main.SocketClientResultDataModel
|
|
|
-import com.khmer9.yuki.remote.main.SocketClientTimeDataModel
|
|
|
import com.khmer9.yuki.remote.service.ConnectivityStates
|
|
|
-import com.khmer9.yuki.screen.detail.BettingDetailFragment
|
|
|
-import com.khmer9.yuki.screen.play.PlayFragment
|
|
|
-import com.khmer9.yuki.screen.report.StatementFragment
|
|
|
-import com.khmer9.yuki.screen.result.ResultFragment
|
|
|
-import com.khmer9.yuki.screen.setting.SettingFragment
|
|
|
import com.khmer9.yuki.screen.splash.SplashScreenActivity
|
|
|
-import com.khmer9.yuki.view.LottoView
|
|
|
-import com.khmer9.yuki.view.SettingButtonView
|
|
|
-import com.mazenrashed.printooth.Printooth
|
|
|
-import com.squareup.moshi.JsonAdapter
|
|
|
-import com.squareup.moshi.Moshi
|
|
|
-import io.reactivex.Completable
|
|
|
-import kotlinx.android.synthetic.main.fragment_main.*
|
|
|
-import kotlinx.coroutines.Dispatchers
|
|
|
-import kotlinx.coroutines.GlobalScope
|
|
|
-import kotlinx.coroutines.delay
|
|
|
-import kotlinx.coroutines.launch
|
|
|
|
|
|
-/**
|
|
|
- * A simple [Fragment] subclass as the default destination in the navigation.
|
|
|
- */
|
|
|
class MainFragment : BaseFragment(R.layout.layout_fragment_main_yuki) {
|
|
|
private val shareViewModel = App.injectShareViewModel()
|
|
|
private val sharePref = App.injectPrefHelper()
|
|
|
- private lateinit var printMe: PrintMe
|
|
|
- private lateinit var adapter: MainAdapter
|
|
|
- private lateinit var adapterHeader: MainAdapterHeader
|
|
|
- private lateinit var lottoView1: LottoView
|
|
|
- private lateinit var lottoView2: LottoView
|
|
|
- private lateinit var lottoView3: LottoView
|
|
|
- private lateinit var lottoView4: LottoView
|
|
|
- private lateinit var lottoView5: LottoView
|
|
|
- private lateinit var lottoView6: LottoView
|
|
|
- private lateinit var lottoView7: LottoView
|
|
|
- private lateinit var lottoView8: LottoView
|
|
|
- private lateinit var lottoView9: LottoView
|
|
|
- private lateinit var lottoView10: LottoView
|
|
|
- private lateinit var lottoView11: LottoView
|
|
|
- private lateinit var lottoView12: LottoView
|
|
|
- private lateinit var lottoView13: LottoView
|
|
|
- private lateinit var lottoView14: LottoView
|
|
|
- private lateinit var lottoView15: LottoView
|
|
|
- private lateinit var lottoView16: LottoView
|
|
|
- private lateinit var lottoView17: LottoView
|
|
|
- private lateinit var lottoView18: LottoView
|
|
|
- private lateinit var lottoView19: LottoView
|
|
|
- private lateinit var lottoView20: LottoView
|
|
|
- private lateinit var lottoTv1: TextView
|
|
|
- private lateinit var lottoTv2: TextView
|
|
|
- private lateinit var lottoTv3: TextView
|
|
|
- private lateinit var lottoTv4: TextView
|
|
|
- private lateinit var lottoTv5: TextView
|
|
|
- private lateinit var lottoTv6: TextView
|
|
|
- private lateinit var lottoTv7: TextView
|
|
|
- private lateinit var lottoTv8: TextView
|
|
|
- private lateinit var lottoTv9: TextView
|
|
|
- private lateinit var lottoTv10: TextView
|
|
|
- private lateinit var lottoTv11: TextView
|
|
|
- private lateinit var lottoTv12: TextView
|
|
|
- private lateinit var lottoTv13: TextView
|
|
|
- private lateinit var lottoTv14: TextView
|
|
|
- private lateinit var lottoTv15: TextView
|
|
|
- private lateinit var lottoTv16: TextView
|
|
|
- private lateinit var lottoTv17: TextView
|
|
|
- private lateinit var lottoTv18: TextView
|
|
|
- private lateinit var lottoTv19: TextView
|
|
|
- private lateinit var lottoTv20: TextView
|
|
|
- private lateinit var tvResult: TextView
|
|
|
- private lateinit var tvResultSmall: TextView
|
|
|
- private lateinit var vBigSmal: TextView
|
|
|
- private lateinit var vRang: TextView
|
|
|
- private lateinit var ivBigLogo: ImageView
|
|
|
- private lateinit var tvBigLogo: TextView
|
|
|
- private lateinit var lottoGroup: Group
|
|
|
- private lateinit var arrayLottoView: ArrayList<LottoView>
|
|
|
- private lateinit var arrayLottoTextView: ArrayList<TextView>
|
|
|
- private lateinit var user: User
|
|
|
- private var resultLength: Int = 0
|
|
|
- private var lottoAnimationDrawable: AnimationDrawable? = null
|
|
|
- private lateinit var btnPlay: SettingButtonView
|
|
|
- private lateinit var btnPlayFrame: View
|
|
|
- private lateinit var betPlease: MediaPlayer
|
|
|
- private lateinit var stopBet: MediaPlayer
|
|
|
- private lateinit var stopBet2: MediaPlayer
|
|
|
- private lateinit var betTouch: MediaPlayer
|
|
|
- private lateinit var countDown: MediaPlayer
|
|
|
- private lateinit var countDown1: MediaPlayer
|
|
|
- private lateinit var countDown2: MediaPlayer
|
|
|
- private lateinit var countDown3: MediaPlayer
|
|
|
- private lateinit var countDown4: MediaPlayer
|
|
|
- private lateinit var countDown5: MediaPlayer
|
|
|
- private lateinit var countDown6: MediaPlayer
|
|
|
- private lateinit var countDown7: MediaPlayer
|
|
|
- private lateinit var countDown8: MediaPlayer
|
|
|
- private lateinit var countDown9: MediaPlayer
|
|
|
- private lateinit var countDown10: MediaPlayer
|
|
|
- private lateinit var congrat: MediaPlayer
|
|
|
- private lateinit var moshi: Moshi
|
|
|
- private lateinit var goodLuck: MediaPlayer
|
|
|
- lateinit var result: MediaPlayer
|
|
|
- private var bgDefaultLotto: Drawable? = null
|
|
|
- private var bgBlueLotto: Drawable? = null
|
|
|
- private var bgGreenLotto: Drawable? = null
|
|
|
- private var bgPinkLotto: Drawable? = null
|
|
|
- private var bgYellowLotto: Drawable? = null
|
|
|
- private var bgWhiteLotto: Drawable? = null
|
|
|
- private var bgCircleBlue: Drawable? = null
|
|
|
- private var bgCircleRed: Drawable? = null
|
|
|
- private var bgCircleGreen: Drawable? = null
|
|
|
- private var bgCircleYellow: Drawable? = null
|
|
|
- private var bgCirclePink: Drawable? = null
|
|
|
- private var textBig: Drawable? = null
|
|
|
- private var textSmall: Drawable? = null
|
|
|
- private var colorWhite: Int? = null
|
|
|
- private var colorRed: Int? = null
|
|
|
- private var anim: AlphaAnimation? = null
|
|
|
+
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
super.onCreate(savedInstanceState)
|
|
|
- printMe = PrintMe(context)
|
|
|
- //companyInfoId =arguments?.getInt(COM_INTO_ID_KEY) ?: 0
|
|
|
(requireActivity() as ShareActivity).apply {
|
|
|
- betPlease = MediaPlayer.create(this, R.raw.start_betting)
|
|
|
- stopBet = MediaPlayer.create(this, R.raw.time_stop_betting)
|
|
|
- stopBet2 = MediaPlayer.create(this, R.raw.stop_bet)
|
|
|
- goodLuck = MediaPlayer.create(this, R.raw.goodluck)
|
|
|
- betTouch = MediaPlayer.create(this, R.raw.bettouch)
|
|
|
- countDown = MediaPlayer.create(this, R.raw.countdown)
|
|
|
- result = MediaPlayer.create(this, R.raw.result)
|
|
|
-
|
|
|
- countDown1 = MediaPlayer.create(this, R.raw.countdown)
|
|
|
- countDown2 = MediaPlayer.create(this, R.raw.countdown)
|
|
|
- countDown3 = MediaPlayer.create(this, R.raw.countdown)
|
|
|
- countDown4 = MediaPlayer.create(this, R.raw.countdown)
|
|
|
- countDown5 = MediaPlayer.create(this, R.raw.countdown)
|
|
|
- countDown6 = MediaPlayer.create(this, R.raw.countdown)
|
|
|
- countDown7 = MediaPlayer.create(this, R.raw.countdown)
|
|
|
- countDown8 = MediaPlayer.create(this, R.raw.countdown)
|
|
|
- countDown9 = MediaPlayer.create(this, R.raw.countdown)
|
|
|
- countDown10 = MediaPlayer.create(this, R.raw.countdown)
|
|
|
- congrat = MediaPlayer.create(this, R.raw.cong)
|
|
|
-
|
|
|
- user = loginData.user!!
|
|
|
+ //user = loginData.user!!
|
|
|
}
|
|
|
- bgDefaultLotto = ContextCompat.getDrawable(requireContext(), R.drawable.ic_logo)
|
|
|
- bgBlueLotto = ContextCompat.getDrawable(requireContext(), R.drawable.ic_blue_circle)
|
|
|
- bgPinkLotto = ContextCompat.getDrawable(requireContext(), R.drawable.ic_pink_circle)
|
|
|
- bgYellowLotto = ContextCompat.getDrawable(requireContext(), R.drawable.ic_yellow_circle)
|
|
|
- bgGreenLotto = ContextCompat.getDrawable(requireContext(), R.drawable.ic_green_circle)
|
|
|
- bgWhiteLotto = ContextCompat.getDrawable(requireContext(), R.drawable.bg_circle_white)
|
|
|
- bgCircleBlue = ContextCompat.getDrawable(requireContext(), R.drawable.bg_circle_blue_stroke)
|
|
|
- bgCircleRed = ContextCompat.getDrawable(requireContext(), R.drawable.bg_circle_red_stroke)
|
|
|
- bgCirclePink = ContextCompat.getDrawable(requireContext(), R.drawable.bg_circle_pink_stroke)
|
|
|
- bgCircleYellow = ContextCompat.getDrawable(requireContext(), R.drawable.bg_circle_yellow_stroke)
|
|
|
- bgCircleGreen = ContextCompat.getDrawable(requireContext(), R.drawable.bg_circle_green_stroke)
|
|
|
- textBig = ContextCompat.getDrawable(requireContext(), R.drawable.text_main_big)
|
|
|
- textSmall = ContextCompat.getDrawable(requireContext(), R.drawable.text_main_small)
|
|
|
- colorWhite = getColor(requireContext(), R.color.color_white)
|
|
|
- colorRed = getColor(requireContext(), R.color.color_red_600)
|
|
|
- anim = AlphaAnimation(0.0f, 1.0f)
|
|
|
- anim?.duration = 50 //You can manage the blinking time with this parameter
|
|
|
- anim?.startOffset = 50
|
|
|
- anim?.repeatMode = Animation.REVERSE
|
|
|
- anim?.repeatCount = Animation.INFINITE
|
|
|
- moshi = Moshi.Builder().build()
|
|
|
}
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
super.onViewCreated(view, savedInstanceState)
|
|
|
- (requireActivity() as ShareActivity).apply {
|
|
|
- userNameTextView.text = user.userName
|
|
|
- }
|
|
|
- shareViewModel.getConnectivityStates.observe(viewLifecycleOwner, Observer {
|
|
|
- getSocketConnectionStatus(it)
|
|
|
- })
|
|
|
- //------------------------------------------------ New Socket Listener
|
|
|
- shareViewModel.getClientTime.observe(viewLifecycleOwner, Observer {
|
|
|
- if (!it.isNullOrEmpty()) {
|
|
|
- val adapter: JsonAdapter<SocketClientTimeDataModel> = moshi.adapter(
|
|
|
- SocketClientTimeDataModel::class.java
|
|
|
- )
|
|
|
- val socketClientTimeResponse = adapter.fromJson(it)
|
|
|
- if (socketClientTimeResponse != null) {
|
|
|
- getLottoMessage(socketClientTimeResponse)
|
|
|
- btnPlay.isEnabled = true
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- shareViewModel.getClientNewGame.observe(viewLifecycleOwner, Observer {
|
|
|
- if (!it.isNullOrEmpty()) {
|
|
|
- val adapter: JsonAdapter<SocketClientNewGameDataModel> = moshi.adapter(
|
|
|
- SocketClientNewGameDataModel::class.java
|
|
|
- )
|
|
|
- val socketClientNewGameResponse = adapter.fromJson(it)
|
|
|
- if (socketClientNewGameResponse != null) {
|
|
|
- //Split time 2022-04-11T13:46:56.000Z => [2022-04-11] [13:46:56.000Z]
|
|
|
- val date = socketClientNewGameResponse.date.split("T")[0].toString()
|
|
|
- tv_game_number.text = date + "#" + socketClientNewGameResponse.no.toString()
|
|
|
-
|
|
|
- ivBigLogo.setImageResource(R.drawable.ic_logo_big)
|
|
|
- ivBigLogo.invalidate()
|
|
|
- btnPlay.isEnabled = true
|
|
|
-
|
|
|
- // Reset Recyclerview at Current Betting
|
|
|
- this.adapter = MainAdapter()
|
|
|
- shareViewModel.remoteBettingCurrentMobileAPI()
|
|
|
- }
|
|
|
-
|
|
|
- //
|
|
|
- }
|
|
|
- })
|
|
|
- shareViewModel.getClientRandom.observe(viewLifecycleOwner, Observer {
|
|
|
- if (!it.isNullOrEmpty()) {
|
|
|
- val adapter: JsonAdapter<SocketClientRandomDataModel> = moshi.adapter(
|
|
|
- SocketClientRandomDataModel::class.java
|
|
|
- )
|
|
|
- val socketClientRandomResponse = adapter.fromJson(it)
|
|
|
- if (socketClientRandomResponse != null) {
|
|
|
- getLottoRandom(socketClientRandomResponse)
|
|
|
- }
|
|
|
-
|
|
|
- if (btnPlay.isEnabled) {
|
|
|
- btnPlay.isEnabled = false
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- shareViewModel.getClientResult.observe(viewLifecycleOwner, Observer {
|
|
|
- if (!it.isNullOrEmpty()) {
|
|
|
- val adapter: JsonAdapter<SocketClientResultDataModel> = moshi.adapter(
|
|
|
- SocketClientResultDataModel::class.java
|
|
|
- )
|
|
|
- val socketClientResultResponse = adapter.fromJson(it)
|
|
|
- if (socketClientResultResponse != null) {
|
|
|
- getLottoResultMessage(socketClientResultResponse)
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- //------------------------
|
|
|
- shareViewModel.getShareState.observe(viewLifecycleOwner, Observer {
|
|
|
- getMain(it)
|
|
|
- })
|
|
|
- lottoView1 = view.findViewById(R.id.v1)
|
|
|
- lottoView2 = view.findViewById(R.id.v2)
|
|
|
- lottoView3 = view.findViewById(R.id.v3)
|
|
|
- lottoView4 = view.findViewById(R.id.v4)
|
|
|
- lottoView5 = view.findViewById(R.id.v5)
|
|
|
- lottoView6 = view.findViewById(R.id.v6)
|
|
|
- lottoView7 = view.findViewById(R.id.v7)
|
|
|
- lottoView8 = view.findViewById(R.id.v8)
|
|
|
- lottoView9 = view.findViewById(R.id.v9)
|
|
|
- lottoView10 = view.findViewById(R.id.v10)
|
|
|
- lottoView11 = view.findViewById(R.id.v11)
|
|
|
- lottoView12 = view.findViewById(R.id.v12)
|
|
|
- lottoView13 = view.findViewById(R.id.v13)
|
|
|
- lottoView14 = view.findViewById(R.id.v14)
|
|
|
- lottoView15 = view.findViewById(R.id.v15)
|
|
|
- lottoView16 = view.findViewById(R.id.v16)
|
|
|
- lottoView17 = view.findViewById(R.id.v17)
|
|
|
- lottoView18 = view.findViewById(R.id.v18)
|
|
|
- lottoView19 = view.findViewById(R.id.v19)
|
|
|
- lottoView20 = view.findViewById(R.id.v20)
|
|
|
-
|
|
|
- lottoTv1 = view.findViewById(R.id.tv1)
|
|
|
- lottoTv2 = view.findViewById(R.id.tv2)
|
|
|
- lottoTv3 = view.findViewById(R.id.tv3)
|
|
|
- lottoTv4 = view.findViewById(R.id.tv4)
|
|
|
- lottoTv5 = view.findViewById(R.id.tv5)
|
|
|
- lottoTv6 = view.findViewById(R.id.tv6)
|
|
|
- lottoTv7 = view.findViewById(R.id.tv7)
|
|
|
- lottoTv8 = view.findViewById(R.id.tv8)
|
|
|
- lottoTv9 = view.findViewById(R.id.tv9)
|
|
|
- lottoTv10 = view.findViewById(R.id.tv10)
|
|
|
- lottoTv11 = view.findViewById(R.id.tv11)
|
|
|
- lottoTv12 = view.findViewById(R.id.tv12)
|
|
|
- lottoTv13 = view.findViewById(R.id.tv13)
|
|
|
- lottoTv14 = view.findViewById(R.id.tv14)
|
|
|
- lottoTv15 = view.findViewById(R.id.tv15)
|
|
|
- lottoTv16 = view.findViewById(R.id.tv16)
|
|
|
- lottoTv17 = view.findViewById(R.id.tv17)
|
|
|
- lottoTv18 = view.findViewById(R.id.tv18)
|
|
|
- lottoTv19 = view.findViewById(R.id.tv19)
|
|
|
- lottoTv20 = view.findViewById(R.id.tv20)
|
|
|
-
|
|
|
- arrayLottoView = arrayListOf(
|
|
|
- lottoView1,
|
|
|
- lottoView2,
|
|
|
- lottoView3,
|
|
|
- lottoView4,
|
|
|
- lottoView5,
|
|
|
- lottoView6,
|
|
|
- lottoView7,
|
|
|
- lottoView8,
|
|
|
- lottoView9,
|
|
|
- lottoView10,
|
|
|
- lottoView11,
|
|
|
- lottoView12,
|
|
|
- lottoView13,
|
|
|
- lottoView14,
|
|
|
- lottoView15,
|
|
|
- lottoView16,
|
|
|
- lottoView17,
|
|
|
- lottoView18,
|
|
|
- lottoView19,
|
|
|
- lottoView20
|
|
|
- )
|
|
|
-
|
|
|
- arrayLottoTextView = arrayListOf(
|
|
|
- lottoTv1,
|
|
|
- lottoTv2,
|
|
|
- lottoTv3,
|
|
|
- lottoTv4,
|
|
|
- lottoTv5,
|
|
|
- lottoTv6,
|
|
|
- lottoTv7,
|
|
|
- lottoTv8,
|
|
|
- lottoTv9,
|
|
|
- lottoTv10,
|
|
|
- lottoTv11,
|
|
|
- lottoTv12,
|
|
|
- lottoTv13,
|
|
|
- lottoTv14,
|
|
|
- lottoTv15,
|
|
|
- lottoTv16,
|
|
|
- lottoTv17,
|
|
|
- lottoTv18,
|
|
|
- lottoTv19,
|
|
|
- lottoTv20
|
|
|
- )
|
|
|
-
|
|
|
- tvResult = view.findViewById(R.id.tv_result_show)
|
|
|
- tvResultSmall = view.findViewById(R.id.tv_result_number)
|
|
|
- ivBigLogo = view.findViewById(R.id.iv_big_logo)
|
|
|
- tvBigLogo = view.findViewById(R.id.tv_big_logo)
|
|
|
- lottoGroup = view.findViewById(R.id.group_lotto)
|
|
|
- vBigSmal = view.findViewById(R.id.v_big_small)
|
|
|
- vRang = view.findViewById(R.id.v_range)
|
|
|
-
|
|
|
- btnPlay = view.findViewById(R.id.btn_play)
|
|
|
- btnPlayFrame = view.findViewById(R.id.v_frame_play)
|
|
|
-
|
|
|
- btnPlay.setOnClickListener {
|
|
|
- if (!sharePref.getIsMute()) betTouch.start()
|
|
|
- it.btnClick().subscribe {
|
|
|
-
|
|
|
- (requireActivity() as? ShareActivity)?.apply {
|
|
|
- supportFragmentManager.beginTransaction()
|
|
|
- .setCustomAnimations(
|
|
|
- R.anim.slide_in,
|
|
|
- R.anim.slide_out,
|
|
|
- R.anim.slide_in_exit,
|
|
|
- R.anim.slide_out_exit
|
|
|
- )
|
|
|
- .add(R.id.container, PlayFragment().apply {
|
|
|
- arguments =
|
|
|
- Bundle().apply {
|
|
|
- // putInt(Fragment7.COM_INFO_ID_KEY, companyInfoId)
|
|
|
- }
|
|
|
-
|
|
|
- })
|
|
|
- .addToBackStack(null)
|
|
|
- .commit()
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- view.findViewById<SettingButtonView>(R.id.btn_result).setOnClickListener {
|
|
|
- if (!sharePref.getIsMute()) betTouch.start()
|
|
|
- it.btnClick().subscribe {
|
|
|
- (requireActivity() as? ShareActivity)?.apply {
|
|
|
- supportFragmentManager.beginTransaction()
|
|
|
- .setCustomAnimations(
|
|
|
- R.anim.slide_in,
|
|
|
- R.anim.slide_out,
|
|
|
- R.anim.slide_in_exit,
|
|
|
- R.anim.slide_out_exit
|
|
|
- )
|
|
|
- .add(R.id.container, ResultFragment().apply {
|
|
|
- arguments =
|
|
|
- Bundle().apply {
|
|
|
- // putInt(Fragment7.COM_INFO_ID_KEY, companyInfoId)
|
|
|
- }
|
|
|
|
|
|
- })
|
|
|
- .addToBackStack(null)
|
|
|
- .commit()
|
|
|
- }
|
|
|
- }
|
|
|
+ (requireActivity() as ShareActivity).apply {
|
|
|
+ //userNameTextView.text = user.userName
|
|
|
}
|
|
|
|
|
|
- (requireActivity() as? ShareActivity)?.apply {
|
|
|
- groupToolbarIcons.isVisible = true
|
|
|
-
|
|
|
- settingImageView.setOnClickListener {
|
|
|
- if (!sharePref.getIsMute()) betTouch.start()
|
|
|
- it.btnClick().subscribe {
|
|
|
- supportFragmentManager.beginTransaction()
|
|
|
- .setCustomAnimations(
|
|
|
- R.anim.slide_in,
|
|
|
- R.anim.slide_out,
|
|
|
- R.anim.slide_in_exit,
|
|
|
- R.anim.slide_out_exit
|
|
|
- )
|
|
|
- .add(R.id.container, SettingFragment())
|
|
|
- .addToBackStack(null)
|
|
|
- .commit()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- refreshImageView.setOnClickListener {
|
|
|
- shareViewModel.remoteMainScreenAPI()
|
|
|
- }
|
|
|
-
|
|
|
- reportImageView.setOnClickListener {
|
|
|
- if (!sharePref.getIsMute()) betTouch.start()
|
|
|
- it.btnClick().subscribe {
|
|
|
- supportFragmentManager.beginTransaction()
|
|
|
- .setCustomAnimations(
|
|
|
- R.anim.slide_in,
|
|
|
- R.anim.slide_out,
|
|
|
- R.anim.slide_in_exit,
|
|
|
- R.anim.slide_out_exit
|
|
|
- )
|
|
|
- .add(R.id.container, StatementFragment().apply {
|
|
|
- arguments =
|
|
|
- Bundle().apply {
|
|
|
- // putInt(Fragment7.COM_INFO_ID_KEY, companyInfoId)
|
|
|
- }
|
|
|
-
|
|
|
- })
|
|
|
- .addToBackStack(null)
|
|
|
- .commit()
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
@SuppressLint("CheckResult")
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
|
super.onActivityCreated(savedInstanceState)
|
|
|
- //viewModel = ViewModelProvider(this).get(MainViewModel::class.java)
|
|
|
- }
|
|
|
-
|
|
|
- private fun animateSmallLogo() {
|
|
|
- GlobalScope.launch(Dispatchers.Main) {
|
|
|
- var i = 0
|
|
|
- while (i < 20) {
|
|
|
- arrayLottoTextView[i].background = bgDefaultLotto
|
|
|
- arrayLottoTextView[i].waitingLotto().subscribe()
|
|
|
- i++
|
|
|
- delay(5)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private fun animateLottoView(lottoTextView: TextView, number: Int): Completable {
|
|
|
- return Completable.create {
|
|
|
- lottoTextView.setBackgroundResource(R.drawable.spin_animation)
|
|
|
- lottoAnimationDrawable = lottoTextView.background as AnimationDrawable
|
|
|
-
|
|
|
- lottoAnimationDrawable!!.start()
|
|
|
-
|
|
|
- GlobalScope.launch(Dispatchers.Main) {
|
|
|
- var i = 0
|
|
|
- while (i < 12) {
|
|
|
- val rdns = (1..80).random()
|
|
|
- lottoTextView.text = "$rdns"
|
|
|
-
|
|
|
- i++
|
|
|
- delay(100)
|
|
|
- if (i == 12) {
|
|
|
- when (number) {
|
|
|
- in 1..20 -> {
|
|
|
- lottoTextView.background = bgBlueLotto
|
|
|
- }
|
|
|
- in 21..40 -> {
|
|
|
- lottoTextView.background = bgYellowLotto
|
|
|
- }
|
|
|
- in 41..60 -> {
|
|
|
- lottoTextView.background = bgPinkLotto
|
|
|
- }
|
|
|
- else -> {
|
|
|
- lottoTextView.background = bgGreenLotto
|
|
|
- }
|
|
|
- }
|
|
|
- lottoTextView.setText("$number")
|
|
|
- it.onComplete()
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private fun animateALotto(lottoTextView: TextView, number: Int): Completable {
|
|
|
- return animateLottoView(lottoTextView, number)
|
|
|
- .andThen(animateLottoZoom(lottoTextView))
|
|
|
- }
|
|
|
-
|
|
|
- private fun animateLottoZoom(view: View): Completable {
|
|
|
- return view.zoomIn()
|
|
|
}
|
|
|
|
|
|
override fun onDestroyView() {
|
|
@@ -548,136 +44,6 @@ class MainFragment : BaseFragment(R.layout.layout_fragment_main_yuki) {
|
|
|
|
|
|
override fun onResume() {
|
|
|
super.onResume()
|
|
|
- Log.d("MainFagment", "onResume")
|
|
|
- }
|
|
|
-
|
|
|
- @SuppressLint("ResourceAsColor", "CheckResult", "SetTextI18n")
|
|
|
- fun getLottoMessage(lotto: SocketClientTimeDataModel) {
|
|
|
- if (lotto.isCountDowning()) {
|
|
|
- //if (ivBigLogo.isInvisible) ivBigLogo.isVisible = true
|
|
|
- tvResult.text = "${lotto.time}"
|
|
|
- tvResult.setTextColor(Color.WHITE)
|
|
|
-
|
|
|
- when (lotto.time) {
|
|
|
- 48 -> shareViewModel.remoteMainScreenAPI()
|
|
|
- 118 -> if (!sharePref.getIsMute()) betPlease.start()
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private fun getLottoRandom(lotto: SocketClientRandomDataModel) {
|
|
|
- tvResult.text = "${lotto.randomTime}"
|
|
|
- tvResult.setTextColor(Color.RED)
|
|
|
- btnPlay.isEnabled = false
|
|
|
-
|
|
|
- when (lotto.randomTime) {
|
|
|
- 0 -> if (!sharePref.getIsMute()) stopBet2.start()
|
|
|
- 1 -> if (!sharePref.getIsMute()) countDown1.start()
|
|
|
- 2 -> if (!sharePref.getIsMute()) countDown2.start()
|
|
|
- 3 -> if (!sharePref.getIsMute()) countDown3.start()
|
|
|
- 4 -> if (!sharePref.getIsMute()) countDown4.start()
|
|
|
- 5 -> if (!sharePref.getIsMute()) countDown5.start()
|
|
|
- 6 -> if (!sharePref.getIsMute()) countDown6.start()
|
|
|
- 7 -> if (!sharePref.getIsMute()) countDown7.start()
|
|
|
- 8 -> if (!sharePref.getIsMute()) countDown8.start()
|
|
|
- 9 -> if (!sharePref.getIsMute()) countDown9.start()
|
|
|
- 10 -> {
|
|
|
- stopBet.start()
|
|
|
- shareViewModel.remoteMainScreenAPI()
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private fun getLottoResultMessage(lotto: SocketClientResultDataModel) {
|
|
|
- if (!sharePref.getIsMute()) result.start()
|
|
|
-
|
|
|
- if (lotto.bonusBetweenYear.isBonus) {
|
|
|
- tv_bonus.text = "(x${lotto.bonusBetweenYear.payout})"
|
|
|
- tv_bonus.startAnimation(anim)
|
|
|
- }
|
|
|
-
|
|
|
- //setImageBetweenYearResult(lotto.betweenYear.yearNumber)
|
|
|
- animateALotto(lotto.betweenYear.yearNumber)
|
|
|
-
|
|
|
- tvResult.text = lotto.betweenYear.yearNameKh
|
|
|
- vBigSmal.text = lotto.smallLarge.yearNameKh
|
|
|
- vBigSmal.setTypeface(null, Typeface.BOLD)
|
|
|
- vBigSmal.setTextColor(Color.WHITE)
|
|
|
- vRang.text = lotto.range.yearNameEn
|
|
|
- vRang.setTypeface(null, Typeface.BOLD)
|
|
|
- vRang.setTextColor(Color.WHITE)
|
|
|
- tv_result_number.text = lotto.smallLarge.yearNameKh + " " + lotto.range.yearNameKh + "-" + lotto.betweenYear.yearNameKh
|
|
|
- }
|
|
|
-
|
|
|
- fun animateALotto(number: Int) {
|
|
|
- GlobalScope.launch(Dispatchers.Main) {
|
|
|
- var i = 0
|
|
|
- while (i < 12) {
|
|
|
- setImageBetweenYearResult(i + 1)
|
|
|
- i++
|
|
|
- delay(100)
|
|
|
- if (i == 12) {
|
|
|
- setImageBetweenYearResult(number)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private fun setImageBetweenYearResult(yearNumber: Int) {
|
|
|
- when (yearNumber) {
|
|
|
- 1 -> {
|
|
|
- Log.d("between", "1")
|
|
|
- ivBigLogo.setImageResource(R.drawable.animal_one)
|
|
|
- }
|
|
|
- 2 -> {
|
|
|
- Log.d("between", "2")
|
|
|
- ivBigLogo.setImageResource(R.drawable.animal_two)
|
|
|
- }
|
|
|
- 3 -> {
|
|
|
- Log.d("between", "3")
|
|
|
- ivBigLogo.setImageResource(R.drawable.animal_three)
|
|
|
- }
|
|
|
- 4 -> {
|
|
|
- Log.d("between", "4")
|
|
|
- ivBigLogo.setImageResource(R.drawable.animal_four)
|
|
|
- }
|
|
|
- 5 -> {
|
|
|
- Log.d("between", "5")
|
|
|
- ivBigLogo.setImageResource(R.drawable.animal_five)
|
|
|
- }
|
|
|
- 6 -> {
|
|
|
- Log.d("between", "6")
|
|
|
- ivBigLogo.setImageResource(R.drawable.animal_six)
|
|
|
- }
|
|
|
- 7 -> {
|
|
|
- Log.d("between", "7")
|
|
|
- ivBigLogo.setImageResource(R.drawable.animal_seven)
|
|
|
- }
|
|
|
- 8 -> {
|
|
|
- Log.d("between", "8")
|
|
|
- ivBigLogo.setImageResource(R.drawable.animal_eight)
|
|
|
- }
|
|
|
- 9 -> {
|
|
|
- Log.d("between", "9")
|
|
|
- ivBigLogo.setImageResource(R.drawable.animal_nine)
|
|
|
- }
|
|
|
- 10 -> {
|
|
|
- Log.d("between", "10")
|
|
|
- ivBigLogo.setImageResource(R.drawable.animal_ten)
|
|
|
- }
|
|
|
- 11 -> {
|
|
|
- Log.d("between", "11")
|
|
|
- ivBigLogo.setImageResource(R.drawable.animal_eleven)
|
|
|
- }
|
|
|
- 12 -> {
|
|
|
- Log.d("between", "12")
|
|
|
- ivBigLogo.setImageResource(R.drawable.animal_twelve)
|
|
|
- }
|
|
|
- else -> {
|
|
|
- ivBigLogo.setImageResource(R.drawable.ic_logo_big)
|
|
|
- }
|
|
|
- }
|
|
|
- ivBigLogo.invalidate()
|
|
|
}
|
|
|
|
|
|
private fun getSocketConnectionStatus(status: Int) {
|
|
@@ -708,71 +74,5 @@ class MainFragment : BaseFragment(R.layout.layout_fragment_main_yuki) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- private fun getMain(state: ShareViewState) {
|
|
|
- if (!state.previousBettingList.isNullOrEmpty()) {
|
|
|
- adapter = MainAdapter()
|
|
|
- adapterHeader = MainAdapterHeader()
|
|
|
- adapter.submitList(state.previousBettingList as List<BaseListItem>?)
|
|
|
- Log.d("myBettingMobileListMAIN", "" + state.previousBettingList.toString())
|
|
|
- rvCurrentBetting.setHasFixedSize(true)
|
|
|
- rvCurrentBetting.layoutManager = LinearLayoutManager(context)
|
|
|
- val concatAdapter = ConcatAdapter(adapterHeader, adapter)
|
|
|
- rvCurrentBetting.adapter = concatAdapter
|
|
|
- adapter.printButtonListener = { ticketID, gameID, betDate, betType, betCast, winLose ->
|
|
|
- if (Printooth.hasPairedPrinter()) {
|
|
|
- printSomePrintable(
|
|
|
- user.userName,
|
|
|
- ticketID,
|
|
|
- gameID,
|
|
|
- betDate,
|
|
|
- betType,
|
|
|
- betCast,
|
|
|
- winLose
|
|
|
- )
|
|
|
- } else {
|
|
|
- val views = layoutInflater.inflate(R.layout.invoice_print, null)
|
|
|
- views.findViewById<MaterialTextView>(R.id.title).text = user.userName
|
|
|
- views.findViewById<MaterialTextView>(R.id.ticketId).text = ticketID
|
|
|
- views.findViewById<MaterialTextView>(R.id.gameId).text = gameID
|
|
|
- views.findViewById<MaterialTextView>(R.id.date).text = betDate
|
|
|
- views.findViewById<MaterialTextView>(R.id.betType).text = betType
|
|
|
- views.findViewById<MaterialTextView>(R.id.betPoint).text = betCast
|
|
|
- views.findViewById<MaterialTextView>(R.id.winLose).text = winLose
|
|
|
- printMe.sendViewToPrinter(views)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- adapter.detailButtonListener = { invoiceId, invoiceNo ->
|
|
|
- if (!invoiceId.isNullOrEmpty()) {
|
|
|
- (requireActivity() as? ShareActivity)?.apply {
|
|
|
- supportFragmentManager.beginTransaction()
|
|
|
- .setCustomAnimations(
|
|
|
- R.anim.slide_in,
|
|
|
- R.anim.slide_out,
|
|
|
- R.anim.slide_in_exit,
|
|
|
- R.anim.slide_out_exit
|
|
|
- )
|
|
|
- .add(R.id.container, BettingDetailFragment().apply {
|
|
|
- arguments = Bundle().apply {
|
|
|
- putString("INVOICE_ID", invoiceId)
|
|
|
- putString("no", invoiceNo)
|
|
|
- }
|
|
|
- })
|
|
|
- .addToBackStack(null)
|
|
|
- .commit()
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (state.accountBalance != null) {
|
|
|
- (requireActivity() as? ShareActivity)?.apply {
|
|
|
- balanceTextView.text = currencyFormat(state.accountBalance.toDouble())
|
|
|
- }
|
|
|
- }
|
|
|
- tv_game_number.text = shareViewModel.getShareState.value?.nextNo
|
|
|
- tv_result_number.text = shareViewModel.getShareState.value?.lastResult.toString()
|
|
|
- }
|
|
|
}
|
|
|
|