[function]排序优化
This commit is contained in:
parent
26c72e7389
commit
745f02ef99
|
|
@ -14,6 +14,7 @@ const val BASE_URL = "https://api.xintijiao.com/ijustjump/"
|
|||
const val CLASS = "class"
|
||||
const val GRADE = "grade"
|
||||
const val UNFINISHED = "未完成"
|
||||
const val FINISHED = "已完成"
|
||||
|
||||
/**
|
||||
* 账号
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ 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.*
|
||||
import com.skipping.activity.begin.BeginActivity
|
||||
import com.skipping.activity.perform.PerformActivity
|
||||
import com.skipping.activity.setting.SettingActivity
|
||||
import com.skipping.net.ActivityBean
|
||||
import com.skipping.net.GradleBean
|
||||
import com.skipping.utils.DateUtils
|
||||
import com.skipping.utils.ScreenUtil
|
||||
import com.skipping.view.bubblewindow.BubbleWindow
|
||||
import com.skipping.view.dialog.DialogBean
|
||||
|
|
@ -172,7 +172,15 @@ class HomeActivity : BaseActivity<HomePresenter>() {
|
|||
recyclerview.layoutManager = layoutManager
|
||||
adaper = HomeGridAdaper(this, list)
|
||||
adaper.setOnItemChangeClickListener {
|
||||
// PerformActivity.startActivity(this, it.id.toString(), DateUtils.dealDateFormat(it.createdAt))
|
||||
when (it.status) {
|
||||
UNFINISHED -> {
|
||||
|
||||
}
|
||||
FINISHED -> {
|
||||
PerformActivity.startActivity(this, it.id.toString(), DateUtils.dealDateFormat(it.createdAt))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
adaper.setOnItemStartClickListener {
|
||||
LogUtil.e(it)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import android.app.Activity
|
|||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.libs.fragment.BaseActivity
|
||||
|
|
@ -69,6 +70,51 @@ class PerformActivity : BaseActivity<PerformPresenter>() {
|
|||
backBtn.setOnClickListener {
|
||||
finish()
|
||||
}
|
||||
|
||||
code_order.setOnClickListener {
|
||||
adaper.rank(PerformAdaper.Order.CODE)
|
||||
changeImg()
|
||||
}
|
||||
|
||||
time_order.setOnClickListener {
|
||||
adaper.rank(PerformAdaper.Order.TIME)
|
||||
changeImg()
|
||||
}
|
||||
|
||||
num_order.setOnClickListener {
|
||||
adaper.rank(PerformAdaper.Order.NUM)
|
||||
changeImg()
|
||||
}
|
||||
}
|
||||
|
||||
fun changeImg() {
|
||||
code_up.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_up_gray))
|
||||
code_down.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_up_gray))
|
||||
time_up.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_up_gray))
|
||||
time_down.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_up_gray))
|
||||
num_up.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_up_gray))
|
||||
num_down.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_up_gray))
|
||||
when (adaper.rankOrder) {
|
||||
PerformAdaper.Order.CODE -> {
|
||||
code_down.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_down_black))
|
||||
}
|
||||
PerformAdaper.Order.CODE_DEC -> {
|
||||
code_up.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_up_black))
|
||||
}
|
||||
PerformAdaper.Order.TIME -> {
|
||||
time_down.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_down_black))
|
||||
}
|
||||
PerformAdaper.Order.TIME_DEC -> {
|
||||
time_up.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_up_black))
|
||||
}
|
||||
PerformAdaper.Order.NUM -> {
|
||||
num_down.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_down_black))
|
||||
}
|
||||
PerformAdaper.Order.NUM_DEC -> {
|
||||
num_up.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_up_black))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun showDetail(bean: DetailActivityBean) {
|
||||
|
|
|
|||
|
|
@ -6,10 +6,9 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.skipping.NUMBER_NAME
|
||||
import com.skipping.R
|
||||
import com.libs.utils.LogUtil
|
||||
import com.skipping.*
|
||||
import com.skipping.TIMING
|
||||
import com.skipping.TIMING_NAME
|
||||
import com.skipping.net.ActivityBean
|
||||
import com.skipping.net.DetailActivityBean
|
||||
|
||||
|
|
@ -22,23 +21,87 @@ class PerformAdaper(context: Context, bean: DetailActivityBean) : RecyclerView.A
|
|||
var bean = bean
|
||||
var context = context
|
||||
lateinit var onClick: (bean: DetailActivityBean.CandidatesBean) -> Unit
|
||||
var list: MutableList<DetailActivityBean.CandidatesBean> = ArrayList()
|
||||
var rankOrder = Order.CODE
|
||||
|
||||
init {
|
||||
bean.candidates.forEach {
|
||||
it.forEach {
|
||||
list.add(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun rank(order: Order) {
|
||||
when (order) {
|
||||
Order.CODE -> {
|
||||
if (rankOrder == Order.CODE) {
|
||||
rankOrder = Order.CODE_DEC
|
||||
list.sortByDescending { it.studentID }
|
||||
} else {
|
||||
rankOrder = Order.CODE
|
||||
list.sortBy { it.studentID }
|
||||
}
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
Order.TIME -> {
|
||||
if (rankOrder == Order.TIME) {
|
||||
rankOrder = Order.TIME_DEC
|
||||
if (bean.activityType == NUMBER) {
|
||||
list.sortByDescending { it.score }
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
} else {
|
||||
rankOrder = Order.TIME
|
||||
if (bean.activityType == NUMBER) {
|
||||
list.sortBy { it.score }
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
}
|
||||
Order.NUM -> {
|
||||
LogUtil.e("书111",order)
|
||||
if (rankOrder == Order.NUM) {
|
||||
rankOrder = Order.NUM_DEC
|
||||
if (bean.activityType == TIMING) {
|
||||
list.sortByDescending { it.score }
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
} else {
|
||||
rankOrder = Order.NUM
|
||||
if (bean.activityType == TIMING) {
|
||||
list.sortBy { it.score }
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
LogUtil.e("书2222",rankOrder)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun or() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PerformAdaper.Holder {
|
||||
return Holder(LayoutInflater.from(context).inflate(R.layout.perform_item, parent, false))
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: PerformAdaper.Holder, position: Int) {
|
||||
holder.name.text = bean.candidates[0].get(position).name
|
||||
holder.code.text = bean.candidates[0].get(position).studentID
|
||||
holder.name.text = list.get(position).name
|
||||
holder.code.text = list.get(position).studentID
|
||||
holder.time.text = bean.activityValue.toString()
|
||||
holder.num.text = bean.candidates[0].get(position).score.toString()
|
||||
holder.num.text = list.get(position).score.toString()
|
||||
holder.itemView.setOnClickListener {
|
||||
onClick.invoke(bean.candidates[0].get(position))
|
||||
onClick.invoke(list.get(position))
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return bean.candidates[0].size
|
||||
return list.size
|
||||
}
|
||||
|
||||
class Holder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
|
@ -52,4 +115,8 @@ class PerformAdaper(context: Context, bean: DetailActivityBean) : RecyclerView.A
|
|||
fun setOnItemClickListener(onClick: (bean: DetailActivityBean.CandidatesBean) -> Unit) {
|
||||
this.onClick = onClick
|
||||
}
|
||||
|
||||
enum class Order {
|
||||
CODE, CODE_DEC, TIME, TIME_DEC, NUM, NUM_DEC
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.skipping.utils;
|
||||
|
||||
/**
|
||||
* @author Ming
|
||||
* 3/30/22
|
||||
*/
|
||||
class OrderUtil {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M7,10l5,5 5,-5z"/>
|
||||
</vector>
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#d1c7b7"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M7,10l5,5 5,-5z"/>
|
||||
</vector>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M7,14l5,-5 5,5z"/>
|
||||
</vector>
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="50dp" android:tint="#d1c7b7"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="50dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M7,14l5,-5 5,5z"/>
|
||||
</vector>
|
||||
|
|
@ -14,15 +14,15 @@
|
|||
android:paddingRight="40dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/backBtn"
|
||||
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="20dp"
|
||||
android:paddingBottom="20dp"
|
||||
android:id="@+id/backBtn"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
android:paddingBottom="20dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
|
|
@ -167,34 +167,129 @@
|
|||
android:paddingRight="40dp"
|
||||
android:paddingBottom="20dp">
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:text="姓名"
|
||||
android:textColor="@color/color_3d3d3d"
|
||||
android:textSize="20dp" />
|
||||
|
||||
<TextView
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/code_order"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="学号"
|
||||
android:textColor="@color/color_3d3d3d"
|
||||
android:textSize="20dp" />
|
||||
|
||||
<TextView
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/code_up"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_weight="1"
|
||||
android:src="@drawable/ic_up_gray" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/code_down"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_weight="1"
|
||||
android:src="@drawable/ic_down_black" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/time_order"
|
||||
android:layout_width="360dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="跳绳时长(秒)"
|
||||
android:textColor="@color/color_3d3d3d"
|
||||
android:textSize="20dp" />
|
||||
|
||||
<TextView
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/time_up"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_weight="1"
|
||||
android:src="@drawable/ic_up_gray" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/time_down"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_weight="1"
|
||||
android:src="@drawable/ic_down_gray" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/num_order"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="跳绳数量(个)"
|
||||
android:textColor="@color/color_3d3d3d"
|
||||
android:textSize="20dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/num_up"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_weight="1"
|
||||
android:src="@drawable/ic_up_gray" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/num_down"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_weight="1"
|
||||
android:src="@drawable/ic_down_gray" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
|
|
|
|||
|
|
@ -28,4 +28,5 @@
|
|||
<color name="color_70_E6E6E6">#4DE6E6E6</color>
|
||||
<color name="color_45_2C2C2C">#8C2C2C2C</color>
|
||||
<color name="color_1296DB">#1296DB</color>
|
||||
<color name="color_464547">#464547</color>
|
||||
</resources>
|
||||
Loading…
Reference in New Issue