[function]基础功能
This commit is contained in:
parent
481e22455a
commit
9cd5a9d273
|
|
@ -52,4 +52,5 @@ dependencies {
|
|||
implementation 'com.github.felHR85:UsbSerial:6.1.0'
|
||||
implementation 'androidx.paging:paging-runtime:3.0.0-alpha07'
|
||||
implementation 'com.tencent:mmkv-static:1.2.7'
|
||||
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
|
||||
}
|
||||
|
|
@ -35,6 +35,11 @@ const val TOKEN = "token"
|
|||
*/
|
||||
const val TIMING = "timing"
|
||||
|
||||
/**
|
||||
* 定数计时
|
||||
*/
|
||||
const val NUMBER = "number"
|
||||
|
||||
const val TIMING_NAME = "定时计数(秒)"
|
||||
|
||||
const val NUMBER_NAME = "定数计数(个)"
|
||||
|
|
|
|||
|
|
@ -153,13 +153,13 @@ public class NetActivity extends BaseActivity {
|
|||
AddActivityReqBean bean = new AddActivityReqBean();
|
||||
bean.setName("test001");
|
||||
bean.setActivityType("timing");
|
||||
bean.setValue(60);
|
||||
// bean.setValue(60);
|
||||
bean.setGroupID("77bba9124a4281bc9f92f965561cd5");
|
||||
bean.setPersonNumber(6);
|
||||
// bean.setPersonNumber(6);
|
||||
bean.setStep(2);
|
||||
concise.request(NetActivity.this, concise.api.addActivity(bean), new CallBack<BaseBean<List<AddActivityBean>>>() {
|
||||
concise.request(NetActivity.this, concise.api.addActivity(bean), new CallBack<BaseBean<AddActivityBean>>() {
|
||||
@Override
|
||||
public void onSuccess(BaseBean<List<AddActivityBean>> listBaseBean) {
|
||||
public void onSuccess(BaseBean<AddActivityBean> listBaseBean) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,15 +2,21 @@ package com.skipping.activity.home
|
|||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
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 com.google.android.material.navigation.NavigationView
|
||||
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
|
||||
import com.libs.utils.ToastUtil
|
||||
import com.skipping.NUMBER
|
||||
import com.skipping.R
|
||||
import com.skipping.TIMING
|
||||
import com.skipping.activity.perform.PerformActivity
|
||||
import com.skipping.activity.setting.SettingActivity
|
||||
import com.skipping.net.ActivityBean
|
||||
|
|
@ -32,6 +38,9 @@ import kotlinx.android.synthetic.main.activity_home.*
|
|||
class HomeActivity : BaseActivity<HomePresenter>() {
|
||||
lateinit var classList: List<GradleBean>
|
||||
lateinit var bubbleWindow: BubbleWindow
|
||||
var choseCla: GradleBean? = null
|
||||
lateinit var adaper: HomeGridAdaper
|
||||
var position = 0
|
||||
|
||||
companion object {
|
||||
fun startHome(activity: Activity) {
|
||||
|
|
@ -61,6 +70,73 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
choseClass.setOnClickListener {
|
||||
bubbleWindow.show(chooseIV)
|
||||
}
|
||||
cancel_btn.setOnClickListener {
|
||||
drawerlayout.closeDrawer(GravityCompat.START)
|
||||
}
|
||||
drawerlayout.addDrawerListener(object : DrawerLayout.DrawerListener {
|
||||
override fun onDrawerSlide(drawerView: View, slideOffset: Float) {
|
||||
}
|
||||
|
||||
override fun onDrawerOpened(drawerView: View) {
|
||||
}
|
||||
|
||||
override fun onDrawerClosed(drawerView: View) {
|
||||
chooseIV.text = "选择"
|
||||
choseCla = null
|
||||
}
|
||||
|
||||
override fun onDrawerStateChanged(newState: Int) {
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
ok_btn.setOnClickListener {
|
||||
if (choseCla == null) {
|
||||
ToastUtil.longToast("请选择班级")
|
||||
return@setOnClickListener
|
||||
}
|
||||
drawerlayout.closeDrawer(GravityCompat.START)
|
||||
var title: String
|
||||
if (position == 0) {
|
||||
title = TIMING
|
||||
} else {
|
||||
title = NUMBER
|
||||
}
|
||||
p.addActivity(activityNameEdit.text.toString(), title, homeNum.text.toString(), homeAll.text.toString(), choseCla?.groupID!!)
|
||||
}
|
||||
|
||||
timeRL.setOnClickListener {
|
||||
if (position == 0) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
position = 0
|
||||
timeTV.setTextColor(ContextCompat.getColor(this, R.color.black))
|
||||
timeTV.setBackgroundResource(R.drawable.left_clicked)
|
||||
numTV.setTextColor(ContextCompat.getColor(this, R.color.white))
|
||||
numTV.setBackgroundResource(R.drawable.right_unclicked)
|
||||
homeTitle.text = "跳绳时间(秒)"
|
||||
}
|
||||
|
||||
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 = "跳绳数量"
|
||||
}
|
||||
|
||||
refreshLayout.setOnRefreshListener { p.getActivityList() }
|
||||
|
||||
recyclerview.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
super.onScrolled(recyclerView, dx, dy)
|
||||
refreshLayout.setEnabled(recyclerView.getChildCount() == 0 || recyclerView.getChildAt(0).getTop() >= 0)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun initStart() {
|
||||
|
|
@ -69,12 +145,20 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
|
||||
|
||||
fun showList(list: List<ActivityBean>) {
|
||||
if(refreshLayout.isRefreshing){
|
||||
refreshLayout.isRefreshing = false
|
||||
}
|
||||
if (!::adaper.isInitialized) {
|
||||
recyclerview.layoutManager = GridLayoutManager(this, 3)
|
||||
val adaper = HomeGridAdaper(this, list)
|
||||
adaper = HomeGridAdaper(this, list)
|
||||
adaper.setOnItemClickListener {
|
||||
PerformActivity.startActivity(this, it.id.toString(), DateUtils.dealDateFormat(it.createdAt))
|
||||
}
|
||||
recyclerview.adapter = adaper
|
||||
} else {
|
||||
adaper.setData(list)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun showClassList(list: List<GradleBean>) {
|
||||
|
|
@ -85,13 +169,18 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
}
|
||||
}.setOnItemClick(object : OnItemClick {
|
||||
override fun onClick(tag: String?, position: Int, bubbleWindow: BubbleWindow?) {
|
||||
choseCla = list[position]
|
||||
chooseIV.text = list[position].groupName + "班"
|
||||
activityNameEdit?.setText(list[position].groupName + "班活动")
|
||||
bubbleWindow?.dismiss()
|
||||
}
|
||||
}).setMargining(com.libs.utils.ScreenUtil.getActionBarHeight(this))
|
||||
.setDirection(Direction.BOTTOM)
|
||||
.build()
|
||||
}
|
||||
|
||||
fun addActivityResult() {
|
||||
p.getActivityList()
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,14 @@ class HomeGridAdaper(context: Context, list: List<ActivityBean>) : RecyclerView.
|
|||
var list = list
|
||||
var context = context
|
||||
lateinit var onClick: (bean: ActivityBean) -> Unit
|
||||
|
||||
|
||||
fun setData(list: List<ActivityBean>) {
|
||||
this.list = list
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HomeGridAdaper.Holder {
|
||||
return Holder(LayoutInflater.from(context).inflate(R.layout.grid_item, parent, false))
|
||||
}
|
||||
|
|
@ -54,8 +62,4 @@ class HomeGridAdaper(context: Context, list: List<ActivityBean>) : RecyclerView.
|
|||
fun setOnItemClickListener(onClick: (bean: ActivityBean) -> Unit) {
|
||||
this.onClick = onClick
|
||||
}
|
||||
|
||||
interface OnClick {
|
||||
fun onClick(bean: ActivityBean)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package com.skipping.activity.home
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
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
|
||||
|
|
@ -26,7 +26,7 @@ class HomePresenter() : BasePresenter<HomeActivity>() {
|
|||
fun getActivityList() {
|
||||
val bean = ActivityReqBean()
|
||||
bean.index = 1
|
||||
bean.pageSize = 9
|
||||
bean.pageSize = 12
|
||||
concise.request(v, concise.api.getActivityList(bean), object : CallBack<BaseBean<List<ActivityBean>>> {
|
||||
override fun onSuccess(k: BaseBean<List<ActivityBean>>?) {
|
||||
if (k != null) {
|
||||
|
|
@ -52,4 +52,27 @@ class HomePresenter() : BasePresenter<HomeActivity>() {
|
|||
|
||||
})
|
||||
}
|
||||
|
||||
fun addActivity(name: String, type: String, number: String, value: String, groupID: String) {
|
||||
var bean = AddActivityReqBean()
|
||||
bean.name = name
|
||||
bean.activityType = type
|
||||
bean.personNumber = number.toInt()
|
||||
bean.value = value.toInt()
|
||||
bean.step = 2
|
||||
bean.groupID = groupID
|
||||
concise.request(v, concise.api.addActivity(bean), object : CallBack<BaseBean<AddActivityBean>> {
|
||||
override fun onSuccess(k: BaseBean<AddActivityBean>?) {
|
||||
if (k?.code == 0) {
|
||||
v.addActivityResult()
|
||||
} else {
|
||||
ToastUtil.longToast(k?.msg)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailed(e: Throwable?) {
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ public interface API {
|
|||
* @return
|
||||
*/
|
||||
@POST("activity/create")
|
||||
Observable<BaseBean<List<AddActivityBean>>> addActivity(@Body AddActivityReqBean addActivityReqBean);
|
||||
Observable<BaseBean<AddActivityBean>> addActivity(@Body AddActivityReqBean addActivityReqBean);
|
||||
|
||||
/**
|
||||
* 活动详情
|
||||
|
|
|
|||
|
|
@ -9,15 +9,16 @@ import java.util.List;
|
|||
* @author Ming
|
||||
* 3/15/22
|
||||
*/
|
||||
public class AddActivityBean implements Serializable {
|
||||
public class AddActivityBean{
|
||||
|
||||
|
||||
/**
|
||||
* ID : 14
|
||||
* ActivityName : test001
|
||||
* ID : 22
|
||||
* ActivityName : 测试5
|
||||
* ActivityType : timing
|
||||
* ActivityValue : 60
|
||||
* ActivityValue : 100
|
||||
* Step : 2
|
||||
* Candidates : [[{"PersonID":"4414550b40b38fd171ba2e319dc2","Name":"xiaowang","StudentID":"1005","Score":0,"Detail":[]},{"PersonID":"8d34508b457780a298efba2a9c28","Name":"xiaohua","StudentID":"1006","Score":0,"Detail":[]}]]
|
||||
* Candidates : [[{"PersonID":"329b20b046f5888bcd5165d115f1","Name":"xiaofang","StudentID":"1002","Score":0,"Detail":[]},{"PersonID":"4557de13408aaf9057752285c81a","Name":"xiaohai","StudentID":"1003","Score":0,"Detail":[]},{"PersonID":"4dee38df466fa8469f0e62f672fb","Name":"xiaoli","StudentID":"1004","Score":0,"Detail":[]},{"PersonID":"a12e6f5a4383855caa2bd36958a2","Name":"xiaoming","StudentID":"1001","Score":0,"Detail":[]}]]
|
||||
*/
|
||||
|
||||
private Integer id;
|
||||
|
|
@ -89,9 +90,9 @@ public class AddActivityBean implements Serializable {
|
|||
|
||||
public static class CandidatesBean implements Serializable {
|
||||
/**
|
||||
* PersonID : 4414550b40b38fd171ba2e319dc2
|
||||
* Name : xiaowang
|
||||
* StudentID : 1005
|
||||
* PersonID : 329b20b046f5888bcd5165d115f1
|
||||
* Name : xiaofang
|
||||
* StudentID : 1002
|
||||
* Score : 0
|
||||
* Detail : []
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -11,14 +11,18 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appbarlayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="130dp"
|
||||
|
|
@ -64,26 +68,32 @@
|
|||
android:src="@mipmap/setting" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/refreshLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/color_F6F6F6"/>
|
||||
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
android:background="@color/color_F6F6F6" />
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
|
||||
<com.google.android.material.navigation.NavigationView
|
||||
android:id="@+id/nav_view"
|
||||
android:layout_width="560dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:background="@color/color_2C2C2C"
|
||||
android:fitsSystemWindows="true" >
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -131,11 +141,11 @@
|
|||
|
||||
<LinearLayout
|
||||
android:id="@+id/choseClass"
|
||||
android:padding="20dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="horizontal"
|
||||
android:padding="20dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/chooseIV"
|
||||
|
|
@ -148,7 +158,7 @@
|
|||
<ImageView
|
||||
android:layout_width="18dp"
|
||||
android:layout_height="12dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginRight="60dp"
|
||||
android:src="@mipmap/down" />
|
||||
</LinearLayout>
|
||||
|
|
@ -191,11 +201,13 @@
|
|||
android:textSize="20dp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/homeNum"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:gravity="right"
|
||||
android:inputType="number"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:text="8"
|
||||
|
|
@ -235,9 +247,18 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="30dp">
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/timeRL"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="30dp"
|
||||
android:paddingTop="30dp"
|
||||
android:paddingBottom="30dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/timeTV"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/left_clicked"
|
||||
|
|
@ -246,7 +267,18 @@
|
|||
android:textColor="@color/black"
|
||||
android:textSize="20dp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/numRL"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="30dp"
|
||||
android:paddingRight="30dp"
|
||||
android:paddingBottom="30dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/numTV"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/right_unclicked"
|
||||
|
|
@ -254,18 +286,23 @@
|
|||
android:text="定数计时"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="20dp" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/homeTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="60dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="跳绳数量"
|
||||
android:textColor="@color/color_70_E6E6E6"
|
||||
android:textSize="20dp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/homeAll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="60dp"
|
||||
|
|
@ -294,6 +331,7 @@
|
|||
android:gravity="center_horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/cancel_btn"
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="60dp"
|
||||
android:background="@drawable/cancel"
|
||||
|
|
@ -307,6 +345,7 @@
|
|||
android:layout_height="0dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/ok_btn"
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="60dp"
|
||||
android:background="@drawable/ok"
|
||||
|
|
|
|||
Loading…
Reference in New Issue