[function]基础功能
This commit is contained in:
parent
9cd5a9d273
commit
b1adea1fdc
|
|
@ -31,7 +31,13 @@
|
|||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".activity.grade.GradeActivity" />
|
||||
<activity android:name=".activity.grade.GradeActivity">
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <action android:name="android.intent.action.MAIN" />-->
|
||||
|
||||
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
|
||||
<!-- </intent-filter>-->
|
||||
</activity>
|
||||
<activity android:name=".activity.clasz.ClassActivity" />
|
||||
<activity android:name=".activity.list.ListActivity" />
|
||||
<activity android:name=".activity.detail.DetailActivity" />
|
||||
|
|
@ -53,6 +59,9 @@
|
|||
<activity
|
||||
android:name=".activity.perform.PerformActivity"
|
||||
android:screenOrientation="landscape" />
|
||||
<activity
|
||||
android:name=".activity.begin.BeginActivity"
|
||||
android:screenOrientation="landscape" />
|
||||
|
||||
<service
|
||||
android:name="com.loop.loopminisdk.LoopMini"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,99 @@
|
|||
package com.skipping.activity.begin
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.libs.fragment.BaseActivity
|
||||
import com.libs.fragment.BasePresenter
|
||||
import com.libs.utils.ActivityManager
|
||||
import com.skipping.*
|
||||
import com.skipping.TIMING_NAME
|
||||
import com.skipping.activity.home.HomeActivity
|
||||
import com.skipping.activity.home.HomeGridAdaper
|
||||
import com.skipping.activity.perform.PerformActivity
|
||||
import com.skipping.activity.setting.SettingActivity
|
||||
import com.skipping.net.DetailActivityBean
|
||||
import com.skipping.utils.ScreenUtil
|
||||
import com.skipping.utils.StatusBarUtil
|
||||
import com.skipping.utils.ThreadPoolUtil
|
||||
import com.tencent.mmkv.MMKV
|
||||
import kotlinx.android.synthetic.main.activity_begin.*
|
||||
import kotlinx.android.synthetic.main.activity_home.*
|
||||
import kotlinx.android.synthetic.main.net_item.view.*
|
||||
import java.util.concurrent.Future
|
||||
import java.util.concurrent.ScheduledFuture
|
||||
|
||||
|
||||
/**
|
||||
* @author Ming
|
||||
* 3/25/22
|
||||
*
|
||||
*/
|
||||
class BeginActivity : BaseActivity<BeginPresenter>() {
|
||||
lateinit var adaper: BeginGridAdaper
|
||||
lateinit var detailBean: DetailActivityBean
|
||||
lateinit var future: ScheduledFuture<*>
|
||||
|
||||
companion object {
|
||||
val ID = "id"
|
||||
val DATA = "data"
|
||||
fun startBegin(activity: Activity, id: String) {
|
||||
val intent = Intent(activity, BeginActivity::class.java)
|
||||
val bundle = Bundle()
|
||||
bundle.putString(ID, id)
|
||||
intent.putExtra(DATA, bundle)
|
||||
activity.startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getContentViewResId(): Int? {
|
||||
return R.layout.activity_begin
|
||||
}
|
||||
|
||||
override fun initStart() {
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
initPresnter()
|
||||
}
|
||||
|
||||
override fun initData() {
|
||||
p.getActivityDetail(intent.getBundleExtra(DATA).getString(ID))
|
||||
begin_back.setOnClickListener {
|
||||
finish()
|
||||
}
|
||||
begin_start.setOnClickListener {
|
||||
if (detailBean.activityType == TIMING) {
|
||||
//定时计数
|
||||
var num = detailBean.activityValue
|
||||
future = ThreadPoolUtil.getSingleton().scheduleWithFixedDelayMain({
|
||||
if (num <= 0) {
|
||||
future.cancel(false)
|
||||
return@scheduleWithFixedDelayMain
|
||||
}
|
||||
num--
|
||||
begin_type.text = TIMING_NAME + ": " + num + " 秒"
|
||||
}, 0, 1000)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun activityDetailResult(bean: DetailActivityBean) {
|
||||
detailBean = bean
|
||||
begin_name.text = bean.activityName
|
||||
if (detailBean.activityType == TIMING) {
|
||||
begin_type.text = TIMING_NAME + ": " + bean.activityValue + " 秒"
|
||||
} else {
|
||||
begin_type.text = NUMBER_NAME + ": " + bean.activityValue + " 个"
|
||||
}
|
||||
beginList.layoutManager = GridLayoutManager(this, 4)
|
||||
adaper = BeginGridAdaper(this, bean.candidates[0])
|
||||
beginList.adapter = adaper
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
package com.skipping.activity.begin
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.libs.utils.LogUtil
|
||||
import com.skipping.*
|
||||
import com.skipping.net.ActivityBean
|
||||
import com.skipping.net.DetailActivityBean
|
||||
import com.skipping.utils.DateUtils
|
||||
|
||||
/**
|
||||
* @author Ming
|
||||
* 3/25/22
|
||||
*
|
||||
*/
|
||||
class BeginGridAdaper(context: Context, list: List<DetailActivityBean.CandidatesBean>) : RecyclerView.Adapter<BeginGridAdaper.Holder>() {
|
||||
var list = list
|
||||
var context = context
|
||||
lateinit var onClick: (bean: DetailActivityBean.CandidatesBean) -> Unit
|
||||
|
||||
fun addData(list: List<DetailActivityBean.CandidatesBean>) {
|
||||
this.list += list
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun setData(list: List<DetailActivityBean.CandidatesBean>) {
|
||||
this.list = list
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BeginGridAdaper.Holder {
|
||||
return Holder(LayoutInflater.from(context).inflate(R.layout.begin_item, parent, false))
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: BeginGridAdaper.Holder, position: Int) {
|
||||
holder.begin_item_name.text = list[position].name
|
||||
holder.begin_item_id.text = list[position].studentID
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return list.size
|
||||
}
|
||||
|
||||
class Holder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
var begin_item_name = itemView.findViewById<TextView>(R.id.begin_item_name)
|
||||
var begin_item_id = itemView.findViewById<TextView>(R.id.begin_item_id)
|
||||
|
||||
}
|
||||
|
||||
fun setOnItemClickListener(onClick: (bean: DetailActivityBean.CandidatesBean) -> Unit) {
|
||||
this.onClick = onClick
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.skipping.activity.begin
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.libs.fragment.BasePresenter
|
||||
import com.libs.network.CallBack
|
||||
import com.libs.network.Concise
|
||||
import com.libs.utils.ToastUtil
|
||||
import com.skipping.ACCOUNT
|
||||
import com.skipping.BASE_URL
|
||||
import com.skipping.PASSWORD
|
||||
import com.skipping.TOKEN
|
||||
import com.skipping.activity.IView
|
||||
import com.skipping.net.*
|
||||
import com.tencent.mmkv.MMKV
|
||||
|
||||
/**
|
||||
* @author Ming
|
||||
* 3/24/22
|
||||
*
|
||||
*/
|
||||
class BeginPresenter() : BasePresenter<BeginActivity>() {
|
||||
val mmkv = MMKV.defaultMMKV()
|
||||
val concise: Concise<API> = object : Concise<API>(BASE_URL) {}.addHeader("Token", mmkv?.decodeString(TOKEN)).build() as Concise<API>
|
||||
|
||||
fun getActivityDetail(id: String) {
|
||||
concise.request(v, concise.api.detailActivity(id), object : CallBack<BaseBean<DetailActivityBean>>{
|
||||
override fun onSuccess(k: BaseBean<DetailActivityBean>?) {
|
||||
v.activityDetailResult(k?.data!!)
|
||||
}
|
||||
|
||||
override fun onFailed(e: Throwable?) {
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ public class DetailActivity extends BaseActivity {
|
|||
|
||||
@Override
|
||||
protected void initData() {
|
||||
connectManager = new ConnectManager(this);
|
||||
// connectManager = new ConnectManager(this,new ConnectManager.DeviceHandler());
|
||||
String id = (String) getIntent().getBundleExtra("id").get("id");
|
||||
recyclerview.setLayoutManager(new LinearLayoutManager(this));
|
||||
adapter = new DetailAdapter(recyclerview);
|
||||
|
|
|
|||
|
|
@ -2,14 +2,12 @@ package com.skipping.activity.home
|
|||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.view.DragEvent
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.drawerlayout.widget.DrawerLayout
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import com.libs.fragment.BaseActivity
|
||||
import com.libs.utils.ActivityManager
|
||||
import com.libs.utils.LogUtil
|
||||
|
|
@ -17,6 +15,7 @@ import com.libs.utils.ToastUtil
|
|||
import com.skipping.NUMBER
|
||||
import com.skipping.R
|
||||
import com.skipping.TIMING
|
||||
import com.skipping.activity.begin.BeginActivity
|
||||
import com.skipping.activity.perform.PerformActivity
|
||||
import com.skipping.activity.setting.SettingActivity
|
||||
import com.skipping.net.ActivityBean
|
||||
|
|
@ -41,6 +40,7 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
var choseCla: GradleBean? = null
|
||||
lateinit var adaper: HomeGridAdaper
|
||||
var position = 0
|
||||
val layoutManager = GridLayoutManager(this, 3)
|
||||
|
||||
companion object {
|
||||
fun startHome(activity: Activity) {
|
||||
|
|
@ -65,7 +65,7 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
create_activity.setOnClickListener {
|
||||
drawerlayout.openDrawer(GravityCompat.START)
|
||||
}
|
||||
p.getActivityList()
|
||||
p.getActivityList(1)
|
||||
p.getClassList()
|
||||
choseClass.setOnClickListener {
|
||||
bubbleWindow.show(chooseIV)
|
||||
|
|
@ -89,7 +89,6 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
}
|
||||
})
|
||||
|
||||
|
||||
ok_btn.setOnClickListener {
|
||||
if (choseCla == null) {
|
||||
ToastUtil.longToast("请选择班级")
|
||||
|
|
@ -129,7 +128,9 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
homeTitle.text = "跳绳数量"
|
||||
}
|
||||
|
||||
refreshLayout.setOnRefreshListener { p.getActivityList() }
|
||||
refreshLayout.setOnRefreshListener {
|
||||
p.getActivityList(1)
|
||||
}
|
||||
|
||||
recyclerview.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
|
|
@ -137,6 +138,13 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
refreshLayout.setEnabled(recyclerView.getChildCount() == 0 || recyclerView.getChildAt(0).getTop() >= 0)
|
||||
}
|
||||
})
|
||||
recyclerview.setOnScrollChangeListener(object : View.OnScrollChangeListener {
|
||||
override fun onScrollChange(v: View?, scrollX: Int, scrollY: Int, oldScrollX: Int, oldScrollY: Int) {
|
||||
if (layoutManager.findLastCompletelyVisibleItemPosition() >= 8 && p.loadBoolean) {
|
||||
p.getActivityList(p.page + 1)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun initStart() {
|
||||
|
|
@ -144,15 +152,24 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
}
|
||||
|
||||
|
||||
fun showList(list: List<ActivityBean>) {
|
||||
fun showList(page: Int, list: List<ActivityBean>) {
|
||||
LogUtil.e(page, list.size)
|
||||
if (refreshLayout.isRefreshing) {
|
||||
refreshLayout.isRefreshing = false
|
||||
}
|
||||
if (page != 1) {
|
||||
adaper.addData(list)
|
||||
return
|
||||
}
|
||||
if (!::adaper.isInitialized) {
|
||||
recyclerview.layoutManager = GridLayoutManager(this, 3)
|
||||
recyclerview.layoutManager = layoutManager
|
||||
adaper = HomeGridAdaper(this, list)
|
||||
adaper.setOnItemClickListener {
|
||||
PerformActivity.startActivity(this, it.id.toString(), DateUtils.dealDateFormat(it.createdAt))
|
||||
adaper.setOnItemChangeClickListener {
|
||||
LogUtil.e("111111")
|
||||
// PerformActivity.startActivity(this, it.id.toString(), DateUtils.dealDateFormat(it.createdAt))
|
||||
}
|
||||
adaper.setOnItemStartClickListener {
|
||||
BeginActivity.startBegin(this, it.id.toString())
|
||||
}
|
||||
recyclerview.adapter = adaper
|
||||
} else {
|
||||
|
|
@ -180,7 +197,7 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
}
|
||||
|
||||
fun addActivityResult() {
|
||||
p.getActivityList()
|
||||
p.getActivityList(1)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
package com.skipping.activity.home
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.skipping.NUMBER_NAME
|
||||
import com.skipping.R
|
||||
import com.skipping.TIMING
|
||||
import com.skipping.TIMING_NAME
|
||||
import com.libs.utils.LogUtil
|
||||
import com.skipping.*
|
||||
import com.skipping.net.ActivityBean
|
||||
import com.skipping.utils.DateUtils
|
||||
|
||||
|
|
@ -21,8 +21,13 @@ import com.skipping.utils.DateUtils
|
|||
class HomeGridAdaper(context: Context, list: List<ActivityBean>) : RecyclerView.Adapter<HomeGridAdaper.Holder>() {
|
||||
var list = list
|
||||
var context = context
|
||||
lateinit var onClick: (bean: ActivityBean) -> Unit
|
||||
lateinit var onClickChange: (bean: ActivityBean) -> Unit
|
||||
lateinit var onClickStart: (bean: ActivityBean) -> Unit
|
||||
|
||||
fun addData(list: List<ActivityBean>) {
|
||||
this.list += list
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun setData(list: List<ActivityBean>) {
|
||||
this.list = list
|
||||
|
|
@ -40,11 +45,25 @@ class HomeGridAdaper(context: Context, list: List<ActivityBean>) : RecyclerView.
|
|||
holder.className.text = list[position].id.toString()
|
||||
if (list[position].activityType == TIMING) {
|
||||
holder.status.text = TIMING_NAME
|
||||
holder.gridItemNum.text = list[position].value.toString() + " 秒"
|
||||
} else {
|
||||
holder.status.text = NUMBER_NAME
|
||||
holder.gridItemNum.text = list[position].value.toString() + " 个"
|
||||
}
|
||||
if (onClick != null) {
|
||||
holder.itemView.setOnClickListener { onClick.invoke(list[position]) }
|
||||
if (onClickChange != null) {
|
||||
holder.gridItemChangeRL.setOnClickListener { onClickChange.invoke(list[position]) }
|
||||
|
||||
}
|
||||
if (onClickStart != null) {
|
||||
holder.gridItemStartRL.setOnClickListener { onClickStart.invoke(list[position]) }
|
||||
}
|
||||
|
||||
if (list[position].status == UNFINISHED) {
|
||||
holder.gridItemChange.setBackgroundResource(R.drawable.grid_chengji_change)
|
||||
holder.gridItemChange.text = "编辑"
|
||||
} else {
|
||||
holder.gridItemChange.setBackgroundResource(R.drawable.grid_chengji)
|
||||
holder.gridItemChange.text = "成绩"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -57,9 +76,18 @@ class HomeGridAdaper(context: Context, list: List<ActivityBean>) : RecyclerView.
|
|||
var time = itemView.findViewById<TextView>(R.id.time)
|
||||
var className = itemView.findViewById<TextView>(R.id.className)
|
||||
var status = itemView.findViewById<TextView>(R.id.status)
|
||||
var gridItemChange = itemView.findViewById<TextView>(R.id.gridItemChange)
|
||||
var gridItemStart = itemView.findViewById<TextView>(R.id.gridItemStart)
|
||||
var gridItemChangeRL = itemView.findViewById<RelativeLayout>(R.id.gridItemChangeRL)
|
||||
var gridItemStartRL = itemView.findViewById<RelativeLayout>(R.id.gridItemStartRL)
|
||||
var gridItemNum = itemView.findViewById<TextView>(R.id.gridItemNum)
|
||||
}
|
||||
|
||||
fun setOnItemClickListener(onClick: (bean: ActivityBean) -> Unit) {
|
||||
this.onClick = onClick
|
||||
fun setOnItemChangeClickListener(onClickChange: (bean: ActivityBean) -> Unit) {
|
||||
this.onClickChange = onClickChange
|
||||
}
|
||||
|
||||
fun setOnItemStartClickListener(onClickStart: (bean: ActivityBean) -> Unit) {
|
||||
this.onClickStart = onClickStart
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,11 @@
|
|||
package com.skipping.activity.home
|
||||
|
||||
import android.text.Editable
|
||||
import com.libs.fragment.BasePresenter
|
||||
import com.libs.network.CallBack
|
||||
import com.libs.network.Concise
|
||||
import com.libs.utils.LogUtil
|
||||
import com.libs.utils.ToastUtil
|
||||
import com.skipping.ACCOUNT
|
||||
import com.skipping.BASE_URL
|
||||
import com.skipping.PASSWORD
|
||||
import com.skipping.TOKEN
|
||||
import com.skipping.activity.IView
|
||||
import com.skipping.net.*
|
||||
import com.tencent.mmkv.MMKV
|
||||
|
||||
|
|
@ -22,21 +17,26 @@ import com.tencent.mmkv.MMKV
|
|||
class HomePresenter() : BasePresenter<HomeActivity>() {
|
||||
val mmkv = MMKV.defaultMMKV()
|
||||
val concise: Concise<API> = object : Concise<API>(BASE_URL) {}.addHeader("Token", mmkv?.decodeString(TOKEN)).build() as Concise<API>
|
||||
var loadBoolean = true
|
||||
var page = 1
|
||||
|
||||
fun getActivityList() {
|
||||
fun getActivityList(page: Int) {
|
||||
this.page = page
|
||||
val bean = ActivityReqBean()
|
||||
bean.index = 1
|
||||
bean.pageSize = 12
|
||||
loadBoolean = false
|
||||
bean.index = page
|
||||
bean.pageSize = 15
|
||||
concise.request(v, concise.api.getActivityList(bean), object : CallBack<BaseBean<List<ActivityBean>>> {
|
||||
override fun onSuccess(k: BaseBean<List<ActivityBean>>?) {
|
||||
loadBoolean = k?.data?.size == 15
|
||||
if (k != null) {
|
||||
v.showList(k.data)
|
||||
v.showList(page, k.data)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailed(e: Throwable?) {
|
||||
loadBoolean = false
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
package com.skipping.fragment.pair
|
||||
|
||||
/**
|
||||
* @author Ming
|
||||
* 3/27/22
|
||||
*
|
||||
*/
|
||||
class DeviceBean {
|
||||
var id: Int? = null
|
||||
var mac: String? = null
|
||||
}
|
||||
|
|
@ -1,10 +1,18 @@
|
|||
package com.skipping.fragment.pair
|
||||
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Message
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.libs.fragment.BaseFragment
|
||||
import com.libs.utils.LogUtil
|
||||
import com.loop.loopminisdk.LoopDevice
|
||||
import com.loop.loopminisdk.LoopHost
|
||||
import com.loop.loopminisdk.LoopMessage
|
||||
import com.loop.loopminisdk.LoopMini
|
||||
import com.skipping.R
|
||||
import com.skipping.utils.ConnectManager
|
||||
import kotlinx.android.synthetic.main.fragment_pair.*
|
||||
|
||||
/**
|
||||
|
|
@ -14,11 +22,16 @@ import kotlinx.android.synthetic.main.fragment_pair.*
|
|||
*/
|
||||
class PairFragment : BaseFragment<PairPresenter>() {
|
||||
var position = 0
|
||||
lateinit var manager: ConnectManager
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.fragment_pair;
|
||||
}
|
||||
|
||||
override fun initView(view: View?, savedInstanceState: Bundle?) {
|
||||
pairStatus.setOnClickListener {
|
||||
manager.pairDevice(1)
|
||||
}
|
||||
|
||||
pair_btn.setOnClickListener {
|
||||
if (position == 0) {
|
||||
|
|
@ -44,5 +57,16 @@ class PairFragment : BaseFragment<PairPresenter>() {
|
|||
}
|
||||
|
||||
override fun initData() {
|
||||
manager = ConnectManager.getSingleton(activity)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
manager.resume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
manager.pause()
|
||||
}
|
||||
}
|
||||
|
|
@ -37,13 +37,26 @@ public class ConnectManager {
|
|||
private LoopMini loopMax;
|
||||
private Set<LoopDevice> loopDeviceSet = new HashSet<>();
|
||||
private LoopDevice loopDevice;
|
||||
private EditText editText;
|
||||
private LoopHost loopHost;
|
||||
private Activity activity;
|
||||
private MyHandler mHandler;
|
||||
private Handler mHandler;
|
||||
private int position;
|
||||
private ScheduledFuture scheduledFuture;
|
||||
private Button btn, btn2, btn3, btn4, btn5;
|
||||
private static volatile ConnectManager connectManager;
|
||||
|
||||
public static ConnectManager getSingleton(Activity activity) {
|
||||
if (connectManager == null) {
|
||||
synchronized (ThreadPoolUtil.class) {
|
||||
if (connectManager == null) {
|
||||
connectManager = new ConnectManager(activity);
|
||||
}
|
||||
}
|
||||
}
|
||||
return connectManager;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
|
@ -69,7 +82,7 @@ public class ConnectManager {
|
|||
|
||||
public ConnectManager(Activity activity) {
|
||||
this.activity = activity;
|
||||
mHandler = new MyHandler();
|
||||
mHandler = new DeviceHandler();
|
||||
}
|
||||
|
||||
private final ServiceConnection usbConnection = new ServiceConnection() {
|
||||
|
|
@ -77,6 +90,13 @@ public class ConnectManager {
|
|||
public void onServiceConnected(ComponentName arg0, IBinder arg1) {
|
||||
loopMax = ((LoopMini.UsbBinder) arg1).getService();
|
||||
loopMax.setHandler(mHandler);
|
||||
ThreadPoolUtil.getSingleton().scheduleMain(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loopMax.getHostInfo();
|
||||
loopMax.openPairMode();
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -156,10 +176,6 @@ public class ConnectManager {
|
|||
}, 0, 10);
|
||||
}
|
||||
|
||||
public interface ConnectInterface {
|
||||
void connect(LoopDevice loopDevice);
|
||||
}
|
||||
|
||||
|
||||
public void resume(){
|
||||
setFilters();
|
||||
|
|
@ -193,7 +209,7 @@ public class ConnectManager {
|
|||
}
|
||||
|
||||
|
||||
private class MyHandler extends Handler {
|
||||
public class DeviceHandler extends Handler {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="24dp"/>
|
||||
<solid android:color="@color/color_F7FFF300" />
|
||||
</shape>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="20dp" />
|
||||
<stroke android:width="2dp"
|
||||
android:color="@color/color_FFE6E6E6"/>
|
||||
</shape>
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/color_F6F6F6"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="130dp"
|
||||
android:background="@color/color_2C2C2C"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingRight="40dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/begin_back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingRight="50dp"
|
||||
android:paddingBottom="20dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="30dp"
|
||||
android:src="@mipmap/back" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:text="返回"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="28dp" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="40dp"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="40dp"
|
||||
android:paddingRight="40dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="60dp"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="28dp" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/begin_name"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="28dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/begin_type"
|
||||
android:layout_width="500dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="28dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/begin_list"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="150dp"
|
||||
android:paddingRight="30dp"
|
||||
android:paddingBottom="30dp"
|
||||
android:text="第一组"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="28dp" />
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/begin_start"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="30dp"
|
||||
android:paddingBottom="30dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginLeft="50dp"
|
||||
android:background="@drawable/grid_24right"
|
||||
android:gravity="center"
|
||||
android:text="开始"
|
||||
android:textColor="@color/color_3d3d3d"
|
||||
android:textSize="28dp" />
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/beginList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
<LinearLayout
|
||||
android:id="@+id/back"
|
||||
android:paddingRight="50dp"
|
||||
android:paddingBottom="30dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="40dp"
|
||||
|
|
@ -40,7 +42,7 @@
|
|||
android:id="@+id/pair"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="150dp"
|
||||
android:layout_marginTop="150dp"
|
||||
android:layout_marginTop="120dp"
|
||||
android:gravity="center"
|
||||
android:text="设备配对"
|
||||
android:textColor="@color/white"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="360dp"
|
||||
android:layout_height="180dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:background="@drawable/grid_item_bg"
|
||||
android:orientation="vertical"
|
||||
android:padding="30dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/begin_item_number"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:gravity="center"
|
||||
android:text="0"
|
||||
android:textColor="@color/color_3d3d3d"
|
||||
android:textSize="72dp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/begin_item_name"
|
||||
android:textColor="@color/color_3d3d3d"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="王一"
|
||||
android:textSize="24dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/begin_item_id"
|
||||
android:textColor="@color/color_3d3d3d"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="15号"
|
||||
android:textSize="24dp" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="180dp"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="90dp"
|
||||
android:paddingLeft="70dp"
|
||||
android:paddingRight="90dp">
|
||||
|
||||
<View
|
||||
|
|
@ -80,10 +80,12 @@
|
|||
android:layout_height="0dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pairStatus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="主机未连接"
|
||||
android:textColor="@color/color_50_FF0000" />
|
||||
android:textColor="@color/color_50_FF0000"
|
||||
android:textSize="20dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
|
|
@ -101,7 +103,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="100dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="80dp"
|
||||
android:paddingLeft="70dp"
|
||||
android:text="手柄信息"
|
||||
android:textColor="@color/color_3d3d3d"
|
||||
android:textSize="24dp" />
|
||||
|
|
@ -114,9 +116,9 @@
|
|||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:paddingLeft="80dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingLeft="80dp"
|
||||
android:text="编号"
|
||||
android:textColor="@color/color_3d3d3d"
|
||||
android:textSize="20dp" />
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
android:textSize="28dp" />
|
||||
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/time"
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -100,8 +99,10 @@
|
|||
android:layout_weight="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gridItemNum"
|
||||
android:layout_width="132dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:text="180"
|
||||
android:textColor="@color/color_3d3d3d"
|
||||
android:textSize="16dp" />
|
||||
|
|
@ -110,30 +111,43 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp">
|
||||
android:paddingLeft="20dp">
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/gridItemChangeRL"
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="80dp"
|
||||
android:gravity="center"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingBottom="20dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gridItemChange"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="40dp"
|
||||
android:background="@drawable/grid_chengji"
|
||||
android:gravity="center"
|
||||
android:text="编辑"
|
||||
android:textColor="@color/color_3d3d3d"
|
||||
android:textSize="20dp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="0dp" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/gridItemStartRL"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="80dp"
|
||||
android:gravity="center"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingBottom="20dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gridItemStart"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="40dp"
|
||||
android:background="@drawable/grid_right"
|
||||
|
|
@ -141,6 +155,8 @@
|
|||
android:text="开始"
|
||||
android:textColor="@color/color_3d3d3d"
|
||||
android:textSize="20dp" />
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
|||
Loading…
Reference in New Issue