[function]功能完善
This commit is contained in:
parent
8ebf19ae9a
commit
e1494e6ece
|
|
@ -79,7 +79,9 @@ class BeginActivity : BaseActivity<BeginPresenter>() {
|
|||
future.cancel(false)
|
||||
choseGradeBeanList.get(position).bean = showBean
|
||||
choseGradeBeanList.get(position).bean
|
||||
ConnectManager.getSingleton().getCount()
|
||||
score()
|
||||
flushScore()
|
||||
return@scheduleWithFixedDelayMain
|
||||
}
|
||||
ConnectManager.getSingleton().getCount()
|
||||
|
|
@ -87,7 +89,29 @@ class BeginActivity : BaseActivity<BeginPresenter>() {
|
|||
begin_type.text = "${TIMING_NAME}: ${num} 秒"
|
||||
flushScore()
|
||||
}, 1000, 1000)
|
||||
|
||||
} else {
|
||||
//定数计时
|
||||
// future = ThreadPoolUtil.getSingleton().scheduleWithFixedDelayMain({
|
||||
// if(){
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if (num <= 0) {
|
||||
// ConnectManager.getSingleton().stopGetScore()
|
||||
//// ConnectManager.getSingleton().stopJump()
|
||||
// future.cancel(false)
|
||||
// choseGradeBeanList.get(position).bean = showBean
|
||||
// choseGradeBeanList.get(position).bean
|
||||
// score()
|
||||
// ConnectManager.getSingleton().getCount()
|
||||
// return@scheduleWithFixedDelayMain
|
||||
// }
|
||||
// ConnectManager.getSingleton().getCount()
|
||||
// num--
|
||||
// begin_type.text = "${NUMBER_NAME}: ${num} 个"
|
||||
// flushScore()
|
||||
// }, 1000, 1000)
|
||||
}
|
||||
}
|
||||
begin_listRL.setOnClickListener {
|
||||
|
|
@ -145,17 +169,11 @@ class BeginActivity : BaseActivity<BeginPresenter>() {
|
|||
var bean = ScoreReqBean.CandidatesBean()
|
||||
bean.complateTime = (System.currentTimeMillis() / 1000).toInt()
|
||||
var list = mutableListOf<ScoreReqBean.CandidatesBean.InfoBean>()
|
||||
choseGradeBeanList.get(position).bean.forEachIndexed() { position, it ->
|
||||
choseGradeBeanList.get(position).bean.forEachIndexed() { po, it ->
|
||||
var info = ScoreReqBean.CandidatesBean.InfoBean()
|
||||
info.personID = it.personID
|
||||
info.score = it.score
|
||||
cute(position).apply {
|
||||
LogUtil.e("this",this)
|
||||
if (this !== null) {
|
||||
info.detail == this
|
||||
}
|
||||
}
|
||||
LogUtil.e("11", info)
|
||||
info.detail = cute(po)
|
||||
list.add(info)
|
||||
}
|
||||
bean.info = list
|
||||
|
|
@ -172,8 +190,11 @@ class BeginActivity : BaseActivity<BeginPresenter>() {
|
|||
return null
|
||||
}
|
||||
var newList = mutableListOf<Int>()
|
||||
for (i in 0..(list?.size!! / 2 - 1)) {
|
||||
newList.add(list[i * 2])
|
||||
for (i in 0..(list?.size / 4 - 1)) {
|
||||
newList.add(list[i * 4])
|
||||
}
|
||||
if (list?.size % 4 != 0) {
|
||||
newList.add(list[list.size - 1])
|
||||
}
|
||||
return newList
|
||||
}
|
||||
|
|
@ -181,6 +202,9 @@ class BeginActivity : BaseActivity<BeginPresenter>() {
|
|||
override fun onStop() {
|
||||
super.onStop()
|
||||
ConnectManager.getSingleton().stopJump()
|
||||
if (future != null) {
|
||||
future.cancel(true)
|
||||
}
|
||||
}
|
||||
|
||||
fun scoreResult() {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import com.libs.fragment.BaseActivity
|
|||
import com.libs.utils.ActivityManager
|
||||
import com.libs.utils.LogUtil
|
||||
import com.libs.utils.ToastUtil
|
||||
import com.loop.loopminisdk.LoopMini
|
||||
import com.skipping.*
|
||||
import com.skipping.activity.begin.BeginActivity
|
||||
import com.skipping.activity.perform.PerformActivity
|
||||
|
|
@ -42,7 +41,10 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
lateinit var adaper: HomeGridAdaper
|
||||
var position = 0
|
||||
val layoutManager = GridLayoutManager(this, 3)
|
||||
lateinit var manager:ConnectManager
|
||||
lateinit var manager: ConnectManager
|
||||
val CREATE = "活动创建"
|
||||
val CHANGE = "活动编辑"
|
||||
lateinit var changeBean: ActivityBean
|
||||
|
||||
companion object {
|
||||
fun startHome(activity: Activity) {
|
||||
|
|
@ -63,7 +65,7 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
override fun initData() {
|
||||
manager = ConnectManager.getSingleton()
|
||||
setting_btn.setOnClickListener {
|
||||
startActivity(Intent(this@HomeActivity, SettingActivity::class.java))
|
||||
SettingActivity.startActivity(this@HomeActivity, "0")
|
||||
}
|
||||
create_activity.setOnClickListener {
|
||||
drawerlayout.openDrawer(GravityCompat.START)
|
||||
|
|
@ -72,8 +74,7 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
p.getClassList()
|
||||
|
||||
choseClass.setOnClickListener {
|
||||
dialog = DialogTool().buildList(this, choseGradeBeanList){
|
||||
bean, _ ->
|
||||
dialog = DialogTool().buildList(this, choseGradeBeanList) { bean, _ ->
|
||||
choseCla = bean.bean
|
||||
chooseIV.text = bean.bean.groupName + "班"
|
||||
activityNameEdit?.setText(bean.bean.groupName + "班活动")
|
||||
|
|
@ -81,8 +82,6 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
cancel_btn.setOnClickListener {
|
||||
drawerlayout.closeDrawer(GravityCompat.START)
|
||||
}
|
||||
|
|
@ -96,6 +95,8 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
override fun onDrawerClosed(drawerView: View) {
|
||||
chooseIV.text = "选择"
|
||||
choseCla = null
|
||||
titleTV.text = CREATE
|
||||
activityNameEdit.setText("")
|
||||
}
|
||||
|
||||
override fun onDrawerStateChanged(newState: Int) {
|
||||
|
|
@ -114,8 +115,15 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
} else {
|
||||
title = NUMBER
|
||||
}
|
||||
when (titleTV.text) {
|
||||
CREATE -> {
|
||||
p.addActivity(activityNameEdit.text.toString(), title, homeNum.text.toString(), homeAll.text.toString(), choseCla?.groupID!!)
|
||||
}
|
||||
CHANGE -> {
|
||||
p.changeActivity(changeBean.id, activityNameEdit.text.toString(), homeAll.text.toString().toInt(), homeNum.text.toString().toInt())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
timeRL.setOnClickListener {
|
||||
if (position == 0) {
|
||||
|
|
@ -130,15 +138,16 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
}
|
||||
|
||||
numRL.setOnClickListener {
|
||||
if (position == 1) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
position = 1
|
||||
timeTV.setTextColor(ContextCompat.getColor(this, R.color.white))
|
||||
timeTV.setBackgroundResource(R.drawable.left_unclicked)
|
||||
numTV.setTextColor(ContextCompat.getColor(this, R.color.black))
|
||||
numTV.setBackgroundResource(R.drawable.right_clicked)
|
||||
homeTitle.text = "跳绳数量"
|
||||
ToastUtil.longToast(getString(R.string.numchose))
|
||||
// if (position == 1) {
|
||||
// return@setOnClickListener
|
||||
// }
|
||||
// position = 1
|
||||
// timeTV.setTextColor(ContextCompat.getColor(this, R.color.white))
|
||||
// timeTV.setBackgroundResource(R.drawable.left_unclicked)
|
||||
// numTV.setTextColor(ContextCompat.getColor(this, R.color.black))
|
||||
// numTV.setBackgroundResource(R.drawable.right_clicked)
|
||||
// homeTitle.text = "跳绳数量"
|
||||
}
|
||||
|
||||
refreshLayout.setOnRefreshListener {
|
||||
|
|
@ -164,6 +173,19 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
ScreenUtil.setCustomDensity(this)
|
||||
}
|
||||
|
||||
fun changeActivity(bean: ActivityBean) {
|
||||
changeBean = bean
|
||||
choseCla = GradleBean().apply {
|
||||
this.groupID = bean.groupID
|
||||
this.groupName = bean.gradeName
|
||||
}
|
||||
titleTV.text = CHANGE
|
||||
chooseIV.text = bean.className + "班"
|
||||
activityNameEdit.setText(bean.name)
|
||||
homeNum.setText(bean.personNumber.toString())
|
||||
homeAll.setText(bean.value.toString())
|
||||
drawerlayout.open()
|
||||
}
|
||||
|
||||
fun showList(page: Int, list: List<ActivityBean>) {
|
||||
if (refreshLayout.isRefreshing) {
|
||||
|
|
@ -179,7 +201,7 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
adaper.setOnItemChangeClickListener {
|
||||
when (it.status) {
|
||||
UNFINISHED -> {
|
||||
|
||||
changeActivity(it)
|
||||
}
|
||||
FINISHED -> {
|
||||
PerformActivity.startActivity(this, it.id.toString(), DateUtils.dealDateFormat(it.createdAt))
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.libs.utils.LogUtil
|
||||
import com.skipping.*
|
||||
|
|
@ -42,7 +43,7 @@ class HomeGridAdaper(context: Context, list: List<ActivityBean>) : RecyclerView.
|
|||
override fun onBindViewHolder(holder: HomeGridAdaper.Holder, position: Int) {
|
||||
holder.name.text = list[position].name
|
||||
holder.time.text = DateUtils.dealDateFormat(list[position].createdAt)
|
||||
holder.className.text = list[position].gradeName+"年级"+list[position].gradeName
|
||||
holder.className.text = list[position].gradeName + "年级" + list[position].gradeName
|
||||
if (list[position].activityType == TIMING) {
|
||||
holder.status.text = TIMING_NAME
|
||||
holder.gridItemNum.text = list[position].value.toString() + " 秒"
|
||||
|
|
@ -55,15 +56,30 @@ class HomeGridAdaper(context: Context, list: List<ActivityBean>) : RecyclerView.
|
|||
|
||||
}
|
||||
if (onClickStart != null) {
|
||||
holder.gridItemStartRL.setOnClickListener { onClickStart.invoke(list[position]) }
|
||||
holder.gridItemStartRL.setOnClickListener {
|
||||
if (list[position].status == UNFINISHED) {
|
||||
onClickStart.invoke(list[position])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (list[position].status == UNFINISHED) {
|
||||
holder.gridItemChange.setBackgroundResource(R.drawable.grid_chengji_change)
|
||||
holder.gridItemChange.text = "编辑"
|
||||
holder.gridItemChange.setTextColor(ContextCompat.getColor(context, R.color.color_3d3d3d))
|
||||
|
||||
holder.gridItemStart.text = "开始"
|
||||
holder.gridItemStart.setTextColor(ContextCompat.getColor(context, R.color.color_3d3d3d))
|
||||
holder.gridItemStart.setBackgroundResource(R.drawable.grid_right)
|
||||
|
||||
} else {
|
||||
holder.gridItemChange.setBackgroundResource(R.drawable.grid_chengji)
|
||||
holder.gridItemChange.text = "成绩"
|
||||
holder.gridItemChange.setTextColor(ContextCompat.getColor(context, R.color.white))
|
||||
|
||||
holder.gridItemStart.text = "已完成"
|
||||
holder.gridItemStart.setTextColor(ContextCompat.getColor(context, R.color.white))
|
||||
holder.gridItemStart.setBackgroundResource(R.drawable.grid_finish)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.libs.network.CallBack
|
|||
import com.libs.network.Concise
|
||||
import com.libs.utils.ToastUtil
|
||||
import com.skipping.BASE_URL
|
||||
import com.skipping.TIMING
|
||||
import com.skipping.TOKEN
|
||||
import com.skipping.net.*
|
||||
import com.tencent.mmkv.MMKV
|
||||
|
|
@ -75,4 +76,27 @@ class HomePresenter() : BasePresenter<HomeActivity>() {
|
|||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
fun changeActivity(id: Int, name: String, value: Int, personNumber: Int) {
|
||||
var bean = ChangeActivityReqBean()
|
||||
bean.id = id
|
||||
bean.name = name
|
||||
bean.activityType = TIMING
|
||||
bean.value = value
|
||||
bean.personNumber = personNumber
|
||||
concise.request(v, concise.api.changeActivity(bean), object : CallBack<BaseBean<*>> {
|
||||
override fun onSuccess(k: BaseBean<*>?) {
|
||||
if (k?.code == 0) {
|
||||
v.addActivityResult()
|
||||
} else {
|
||||
ToastUtil.longToast(k?.msg)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailed(e: Throwable?) {
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -128,6 +128,21 @@ class PerformActivity : BaseActivity<PerformPresenter>() {
|
|||
recyclerview.layoutManager = LinearLayoutManager(this)
|
||||
adaper = PerformAdaper(this, bean)
|
||||
recyclerview.adapter = adaper
|
||||
|
||||
if (bean.activityType == TIMING) {
|
||||
if (adaper.list.size>0){
|
||||
max.text = "${bean.max}个"
|
||||
min.text = "${adaper.list.minOf { it.score }}个"
|
||||
center.text = "${bean.avg}个"
|
||||
med.text = "${bean.median}个"
|
||||
}
|
||||
} else {
|
||||
max.text = "${bean.max}秒"
|
||||
min.text = "${adaper.list.minOf { it.score }}秒"
|
||||
center.text = "${bean.avg}秒"
|
||||
med.text = "${bean.median}秒"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onRestart() {
|
||||
|
|
|
|||
|
|
@ -25,12 +25,14 @@ class PerformAdaper(context: Context, bean: DetailActivityBean) : RecyclerView.A
|
|||
var rankOrder = Order.CODE
|
||||
|
||||
init {
|
||||
if (bean.candidates != null && bean.candidates.size > 0 && bean.candidates.get(0) != null) {
|
||||
bean.candidates.forEach {
|
||||
it.forEach {
|
||||
list.add(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun rank(order: Order) {
|
||||
when (order) {
|
||||
|
|
@ -60,7 +62,7 @@ class PerformAdaper(context: Context, bean: DetailActivityBean) : RecyclerView.A
|
|||
}
|
||||
}
|
||||
Order.NUM -> {
|
||||
LogUtil.e("书111",order)
|
||||
LogUtil.e("书111", order)
|
||||
if (rankOrder == Order.NUM) {
|
||||
rankOrder = Order.NUM_DEC
|
||||
if (bean.activityType == TIMING) {
|
||||
|
|
@ -74,7 +76,7 @@ class PerformAdaper(context: Context, bean: DetailActivityBean) : RecyclerView.A
|
|||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
LogUtil.e("书2222",rankOrder)
|
||||
LogUtil.e("书2222", rankOrder)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ class SettingActivity : BaseActivity<SettingPresenter>() {
|
|||
fun startActivity(activity: Activity, data: String) {
|
||||
val intent = Intent(activity, SettingActivity::class.java)
|
||||
val bundle = Bundle()
|
||||
bundle.putString(data, data)
|
||||
intent.putExtra(data, bundle)
|
||||
bundle.putString(DATA, data)
|
||||
intent.putExtra(DATA, bundle)
|
||||
activity.startActivity(intent)
|
||||
ActivityManager.getInstance().popActivity(activity)
|
||||
}
|
||||
|
|
@ -49,10 +49,10 @@ class SettingActivity : BaseActivity<SettingPresenter>() {
|
|||
}
|
||||
|
||||
override fun initData() {
|
||||
if (intent.getBundleExtra(DATA) != null) {
|
||||
clickLogin()
|
||||
} else {
|
||||
if (intent.getBundleExtra(DATA).getString(DATA) == "0") {
|
||||
clickPair()
|
||||
} else {
|
||||
clickLogin()
|
||||
}
|
||||
pair.setOnClickListener {
|
||||
clickPair()
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import android.view.Window
|
|||
import android.view.WindowManager
|
||||
import com.libs.fragment.BaseActivity
|
||||
import com.libs.utils.ActivityManager
|
||||
import com.libs.utils.LogUtil
|
||||
import com.skipping.ACCOUNT
|
||||
import com.skipping.PASSWORD
|
||||
import com.skipping.activity.home.HomeActivity
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.skipping.net.API
|
|||
import com.skipping.net.BaseBean
|
||||
import com.skipping.net.TokenBean
|
||||
import com.skipping.net.TokenReqBean
|
||||
import com.skipping.utils.ConnectManager
|
||||
import com.tencent.mmkv.MMKV
|
||||
|
||||
/**
|
||||
|
|
@ -37,6 +38,7 @@ class SplashPresenter() :BasePresenter<SplashActivity>() {
|
|||
mmkv?.encode(PASSWORD, value)
|
||||
mmkv?.encode(TOKEN, k?.data?.token)
|
||||
v.loginResult(1)
|
||||
ConnectManager.getSingleton().getdeviceList()
|
||||
}
|
||||
|
||||
override fun onFailed(e: Throwable?) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.view.View
|
|||
import com.libs.fragment.BaseFragment
|
||||
import com.libs.utils.ToastUtil
|
||||
import com.skipping.R
|
||||
import com.skipping.utils.ConnectManager
|
||||
import kotlinx.android.synthetic.main.fragment_login.*
|
||||
|
||||
/**
|
||||
|
|
@ -29,5 +30,6 @@ class LoginFragment : BaseFragment<LoginPresenter>() {
|
|||
|
||||
fun loginResult() {
|
||||
connectStatusTV.visibility = View.VISIBLE
|
||||
ConnectManager.getSingleton().getdeviceList()
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
package com.skipping.fragment.pair
|
||||
|
||||
import com.libs.utils.LogUtil
|
||||
import com.loop.loopminisdk.LoopDevice
|
||||
import com.loop.loopminisdk.LoopHost
|
||||
import com.loop.loopminisdk.LoopMini
|
||||
|
||||
/**
|
||||
* @author Ming
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import android.widget.TextView
|
|||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.loop.loopminisdk.LoopDevice
|
||||
import com.loop.loopminisdk.LoopMini
|
||||
import com.skipping.R
|
||||
import com.skipping.net.ActivityBean
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ public interface API {
|
|||
|
||||
/**
|
||||
* 登录
|
||||
*
|
||||
* @param tokenReq
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -26,6 +27,7 @@ public interface API {
|
|||
|
||||
/**
|
||||
* 获取年级列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GET("groupmap?genre=grade")
|
||||
|
|
@ -34,6 +36,7 @@ public interface API {
|
|||
|
||||
/**
|
||||
* 获取班级列表
|
||||
*
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -43,6 +46,7 @@ public interface API {
|
|||
|
||||
/**
|
||||
* 获取活动列表
|
||||
*
|
||||
* @param activityReqBean
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -52,14 +56,26 @@ public interface API {
|
|||
|
||||
/**
|
||||
* 添加活动
|
||||
*
|
||||
* @param addActivityReqBean
|
||||
* @return
|
||||
*/
|
||||
@POST("activity/create")
|
||||
Observable<BaseBean<AddActivityBean>> addActivity(@Body AddActivityReqBean addActivityReqBean);
|
||||
|
||||
|
||||
/**
|
||||
* 更新活动
|
||||
* @param changeActivityReqBean
|
||||
* @return
|
||||
*/
|
||||
@POST("activity/update")
|
||||
Observable<BaseBean> changeActivity(@Body ChangeActivityReqBean changeActivityReqBean);
|
||||
|
||||
|
||||
/**
|
||||
* 活动详情
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -68,6 +84,7 @@ public interface API {
|
|||
|
||||
/**
|
||||
* 上报
|
||||
*
|
||||
* @param scoreReqBean
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -77,6 +94,7 @@ public interface API {
|
|||
|
||||
/**
|
||||
* 设备列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GET("rope/list")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
package com.skipping.net;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Ming
|
||||
* 3/15/22
|
||||
*/
|
||||
public class ChangeActivityReqBean implements Serializable {
|
||||
|
||||
|
||||
private Integer ID;
|
||||
private String Name;
|
||||
private String ActivityType;
|
||||
private Integer Value;
|
||||
private Integer PersonNumber;
|
||||
|
||||
public Integer getID() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
public void setID(Integer ID) {
|
||||
this.ID = ID;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return Name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public String getActivityType() {
|
||||
return ActivityType;
|
||||
}
|
||||
|
||||
public void setActivityType(String activityType) {
|
||||
ActivityType = activityType;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return Value;
|
||||
}
|
||||
|
||||
public void setValue(Integer value) {
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public Integer getPersonNumber() {
|
||||
return PersonNumber;
|
||||
}
|
||||
|
||||
public void setPersonNumber(Integer personNumber) {
|
||||
PersonNumber = personNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChangeActivityReqBean{" +
|
||||
"ID='" + ID + '\'' +
|
||||
", Name='" + Name + '\'' +
|
||||
", ActivityType=" + ActivityType +
|
||||
", Value='" + Value + '\'' +
|
||||
", PersonNumber=" + PersonNumber +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ import java.util.stream.Collectors;
|
|||
* 3/21/22
|
||||
*/
|
||||
public class ConnectManager {
|
||||
private LoopMini loopMax;
|
||||
private LoopMini loopMini;
|
||||
private LoopDevice loopDevice;
|
||||
private LoopHost loopHost;
|
||||
private Handler mHandler;
|
||||
|
|
@ -108,26 +108,27 @@ public class ConnectManager {
|
|||
};
|
||||
|
||||
private void connect() {
|
||||
loopMax.setHandler(mHandler);
|
||||
loopMini.setHandler(mHandler);
|
||||
ThreadPoolUtil.getSingleton().scheduleMain(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loopMax.getHostInfo();
|
||||
loopMax.openPairMode();
|
||||
loopMini.getHostInfo();
|
||||
loopMini.openPairMode();
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
public ConnectManager() {
|
||||
mHandler = new DeviceHandler();
|
||||
getdeviceList();
|
||||
}
|
||||
|
||||
|
||||
private final ServiceConnection usbConnection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName arg0, IBinder arg1) {
|
||||
LogUtil.e("连接成功");
|
||||
loopMax = ((LoopMini.UsbBinder) arg1).getService();
|
||||
loopMini = ((LoopMini.UsbBinder) arg1).getService();
|
||||
LogUtil.e("loopMax");
|
||||
connect();
|
||||
// loopMax.setHandler(mHandler);
|
||||
// ThreadPoolUtil.getSingleton().scheduleMain(new Runnable() {
|
||||
|
|
@ -141,7 +142,7 @@ public class ConnectManager {
|
|||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName arg0) {
|
||||
loopMax = null;
|
||||
loopMini = null;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -150,35 +151,35 @@ public class ConnectManager {
|
|||
* 连接主机
|
||||
*/
|
||||
public void getHostInfo() {
|
||||
loopMax.getHostInfo();
|
||||
loopMini.getHostInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启配对模式
|
||||
*/
|
||||
public void openPairMode() {
|
||||
loopMax.openPairMode();
|
||||
loopMini.openPairMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取电量
|
||||
*/
|
||||
public void getpower() {
|
||||
loopMax.getPower();
|
||||
loopMini.getPower();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取电量
|
||||
*/
|
||||
public void getCount() {
|
||||
loopMax.getCount();
|
||||
loopMini.getCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭配对模式
|
||||
*/
|
||||
public void closePairMode() {
|
||||
loopMax.closePairMode();
|
||||
loopMini.closePairMode();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -190,16 +191,22 @@ public class ConnectManager {
|
|||
public void startJumpLimitTime(int n) {
|
||||
getScore = true;
|
||||
scoreMap.clear();
|
||||
loopMax.startJumpLimitTime(n);
|
||||
loopMini.startJumpLimitTime(n);
|
||||
}
|
||||
|
||||
public void start(){
|
||||
getScore = true;
|
||||
scoreMap.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 停止计数
|
||||
*/
|
||||
public void stopJump() {
|
||||
getScore = false;
|
||||
loopMax.stopJump();
|
||||
loopMini.stopJump();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -223,7 +230,7 @@ public class ConnectManager {
|
|||
future = ThreadPoolUtil.getSingleton().scheduleMain(() -> {
|
||||
dialog.setStatus(Status.RESET);
|
||||
}, 3000);
|
||||
loopMax.pairDevice(id);
|
||||
loopMini.pairDevice(id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -250,13 +257,13 @@ public class ConnectManager {
|
|||
scheduledFuture = ThreadPoolUtil.getSingleton().scheduleAtFixedRateMain(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (loopMax != null && deviceBeanList.get(position).getLoopDevice() != null) {
|
||||
if (loopMini != null && deviceBeanList.get(position).getLoopDevice() != null) {
|
||||
if (status == 1) {
|
||||
LogUtil.e("连接设备", deviceBeanList.get(position).getLoopDevice());
|
||||
loopMax.connectDevice(deviceBeanList.get(position).getLoopDevice());
|
||||
loopMini.connectDevice(deviceBeanList.get(position).getLoopDevice());
|
||||
} else if (status == 0) {
|
||||
LogUtil.e("断开设备", deviceBeanList.get(position).getLoopDevice());
|
||||
loopMax.disconnectDevice(deviceBeanList.get(position).getLoopDevice());
|
||||
loopMini.disconnectDevice(deviceBeanList.get(position).getLoopDevice());
|
||||
}
|
||||
}
|
||||
position++;
|
||||
|
|
@ -399,7 +406,7 @@ public class ConnectManager {
|
|||
}
|
||||
|
||||
|
||||
private void getdeviceList() {
|
||||
public void getdeviceList() {
|
||||
MMKV mmkv = MMKV.defaultMMKV();
|
||||
Concise<API> concise = new Concise<API>(Contants.BASE_URL) {
|
||||
}.addHeader("Token", mmkv.decodeString(Contants.TOKEN)).build();
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import java.util.concurrent.TimeUnit;
|
|||
* 线程池管理类
|
||||
*/
|
||||
public class ThreadPoolUtil {
|
||||
private Pool pool;
|
||||
private ScheduledExecutorService scheduledPool;
|
||||
private static volatile ThreadPoolUtil threadPoolManager;
|
||||
|
||||
|
|
@ -35,12 +36,16 @@ public class ThreadPoolUtil {
|
|||
|
||||
|
||||
private void initPool() {
|
||||
scheduledPool = (ScheduledExecutorService) new Pool.Builder()
|
||||
pool = new Pool.Builder()
|
||||
.setThreadType(Type.SCHEDULED)
|
||||
.setLog(new DefLogCallBack())
|
||||
.setSize(12)
|
||||
.build()
|
||||
.getThreadPool();
|
||||
.build();
|
||||
scheduledPool = (ScheduledExecutorService) pool.getThreadPool();
|
||||
}
|
||||
|
||||
public Pool getPool() {
|
||||
return pool;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -70,7 +75,6 @@ public class ThreadPoolUtil {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 重复任务
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="20dp" />
|
||||
<solid android:color="@color/color_999999" />
|
||||
</shape>
|
||||
|
|
@ -175,7 +175,6 @@
|
|||
android:background="@null"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:text="101班活动"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="20dp" />
|
||||
|
||||
|
|
@ -297,7 +296,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="60dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="跳绳数量"
|
||||
android:text="跳绳时间(秒)"
|
||||
android:textColor="@color/color_70_E6E6E6"
|
||||
android:textSize="20dp" />
|
||||
|
||||
|
|
@ -310,6 +309,7 @@
|
|||
android:layout_marginRight="60dp"
|
||||
android:background="@null"
|
||||
android:drawableRight="@mipmap/right"
|
||||
android:inputType="number"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:text="100"
|
||||
|
|
|
|||
|
|
@ -1,23 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<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:orientation="vertical"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
tools:context=".activity.MainActivity">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn"
|
||||
android:text="设备"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn2"
|
||||
android:text="网络"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -53,7 +53,6 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="二年级201班"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="24dp" />
|
||||
|
||||
|
|
@ -78,7 +77,6 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="定时计数"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="24dp" />
|
||||
|
||||
|
|
@ -95,7 +93,6 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="2021-11-10 10:12:15"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="24dp" />
|
||||
</LinearLayout>
|
||||
|
|
@ -117,10 +114,10 @@
|
|||
android:textSize="24dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/max"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="100个"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="24dp" />
|
||||
|
||||
|
|
@ -133,10 +130,10 @@
|
|||
android:textSize="24dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/min"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="100个"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="24dp" />
|
||||
|
||||
|
|
@ -144,15 +141,31 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="50dp"
|
||||
android:text="中位数"
|
||||
android:text="平均"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="24dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="24dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="50dp"
|
||||
android:text="中位"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="24dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/med"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="100个"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="24dp" />
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
<string name="nav_header_desc">Navigation header</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
|
||||
<string name="menu_home">Home</string>
|
||||
<string name="menu_gallery">Gallery</string>
|
||||
<string name="menu_slideshow">Slideshow</string>
|
||||
<string name="numchose">该硬件不支持此操作</string>
|
||||
|
||||
</resources>
|
||||
Loading…
Reference in New Issue