| | |
| | | package com.dayu.general.activity |
| | | |
| | | import android.os.Bundle |
| | | import android.view.KeyEvent |
| | | import android.view.LayoutInflater |
| | | import android.widget.Toast |
| | | import androidx.core.content.ContextCompat |
| | | import androidx.fragment.app.Fragment |
| | | import com.dayu.baselibrary.net.subscribers.SubscriberListener |
| | |
| | | import com.dayu.general.BaseApplication |
| | | import com.dayu.general.R |
| | | import com.dayu.general.adapter.TabAdapter |
| | | import com.dayu.general.bean.net.LoginResult |
| | | import com.dayu.general.bean.net.UserInfoResult |
| | | import com.dayu.general.databinding.ActivityMainBinding |
| | | import com.dayu.general.net.ApiManager |
| | |
| | | |
| | | var binding: ActivityMainBinding? = null |
| | | private val fragments: ArrayList<Fragment> = ArrayList() |
| | | var mExitTime: Long = 0 |
| | | |
| | | override fun onCreate(savedInstanceState: Bundle?) { |
| | | super.onCreate(savedInstanceState) |
| | | binding = ActivityMainBinding.inflate(LayoutInflater.from(this)) |
| | |
| | | setupFragments() |
| | | initView() |
| | | initTab() |
| | | getUserInfo(); |
| | | getUserInfo() |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | private fun initView() { |
| | | binding!!.BSCardLL.setOnClickListener { v -> changeBottomState(Tab.BSC) } |
| | | binding!!.rechargeLL.setOnClickListener { v -> changeBottomState(Tab.RECHARGE) } |
| | | binding!!.myLL.setOnClickListener { v -> changeBottomState(Tab.MY) } |
| | | binding!!.BSCardLL.setOnClickListener { changeBottomState(Tab.BSC) } |
| | | binding!!.rechargeLL.setOnClickListener { changeBottomState(Tab.RECHARGE) } |
| | | binding!!.myLL.setOnClickListener { changeBottomState(Tab.MY) } |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | //点击两次退出程序 有时间间隔 间隔内点击则退出程序 否则 则提示 |
| | | override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { |
| | | if (keyCode == KeyEvent.KEYCODE_BACK) { |
| | | if ((System.currentTimeMillis() - mExitTime) > 2000) { |
| | | Toast.makeText(this@MainActivity, "再按一次退出程序", Toast.LENGTH_SHORT) |
| | | .show() |
| | | mExitTime = System.currentTimeMillis() |
| | | } else { |
| | | this@MainActivity.finish() |
| | | } |
| | | return true |
| | | } |
| | | return super.onKeyDown(keyCode, event) |
| | | } |
| | | |
| | | |
| | | } |