Merge branch 'dev-4.8.0' of git.ghzs.com:halo/assistant-android into dev-4.8.0
This commit is contained in:
@ -44,10 +44,14 @@ class GameOffServiceDialogFragment
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
for (site in sites) {
|
||||
// 过滤内容为空的元素
|
||||
val notEmptySite = sites.filter { it.text.isNotBlank() }
|
||||
|
||||
notEmptySite.forEachIndexed { index, site ->
|
||||
val siteTv = TextView(context)
|
||||
siteTv.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT).apply {
|
||||
topMargin = 24F.dip2px()
|
||||
if (index == notEmptySite.size - 1) bottomMargin = 8F.dip2px()
|
||||
}
|
||||
siteTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14F)
|
||||
siteTv.setTextColor(R.color.theme_font.toColor())
|
||||
|
||||
@ -59,7 +59,8 @@ class FilterView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
|
||||
fun updateSelectedMainFilter(filter: String) {
|
||||
mSelectedMainFilter = filter
|
||||
(mBinding?.filterRecyclerView?.adapter as FilterAdapter).updateSelectedFilter(filter)
|
||||
(mBinding?.filterRecyclerView?.adapter as? FilterAdapter)?.updateSelectedFilter(filter)
|
||||
mBinding?.filterRecyclerView?.smoothScrollToPosition(mMainFilterList.indexOf(filter))
|
||||
}
|
||||
|
||||
fun updateSelectedSubFilter(filter: String) {
|
||||
@ -99,9 +100,7 @@ class FilterView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
val flexboxLayout = layout.findViewById<FlexboxLayout>(R.id.flexbox)
|
||||
val backgroundView = layout.findViewById<View>(R.id.background)
|
||||
|
||||
flexboxLayout.layoutParams = (flexboxLayout.layoutParams as LinearLayout.LayoutParams).apply {
|
||||
leftMargin = 16F.dip2px()
|
||||
}
|
||||
flexboxLayout.setPadding(16F.dip2px(), 0, 0, 8F.dip2px())
|
||||
|
||||
backgroundView.setOnClickListener {
|
||||
popupWindow.dismiss()
|
||||
|
||||
@ -15,6 +15,8 @@ import butterknife.BindView;
|
||||
|
||||
public class GameServerTimeViewHolder extends BaseRecyclerViewHolder {
|
||||
|
||||
@BindView(R.id.kaifu_item_time)
|
||||
public View container;
|
||||
@BindView(R.id.kaifu_item_header)
|
||||
public ImageView header;
|
||||
@BindView(R.id.kaifu_item_time_tv)
|
||||
|
||||
@ -6,6 +6,7 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.Nullable
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.constant.ItemViewType
|
||||
import com.gh.common.exposure.ExposureEvent
|
||||
import com.gh.common.exposure.ExposureEvent.Companion.createEvent
|
||||
import com.gh.common.exposure.ExposureSource
|
||||
@ -19,6 +20,7 @@ import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder
|
||||
import com.gh.gamecenter.adapter.viewholder.GameViewHolder
|
||||
import com.gh.gamecenter.databinding.GameItemBinding
|
||||
import com.gh.gamecenter.databinding.ItemTestServerTextBinding
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.game.GameItemViewHolder
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter
|
||||
@ -43,6 +45,8 @@ class GameServersTestAdapter(context: Context,
|
||||
}
|
||||
return if (mDataList[position].time != null) {
|
||||
GameServersContentAdapter.VIEW_TYPE_TOP
|
||||
} else if (mDataList[position].text != null) {
|
||||
ItemViewType.ITEM_EMPTY
|
||||
} else {
|
||||
GameServersContentAdapter.VIEW_TYPE_ITEM
|
||||
}
|
||||
@ -56,6 +60,9 @@ class GameServersTestAdapter(context: Context,
|
||||
GameServersContentAdapter.VIEW_TYPE_TOP -> {
|
||||
GameServerTimeViewHolder(mLayoutInflater.inflate(R.layout.kaifu_item_time, parent, false))
|
||||
}
|
||||
ItemViewType.ITEM_EMPTY -> {
|
||||
TextViewHolder(ItemTestServerTextBinding.inflate(mLayoutInflater, parent, false))
|
||||
}
|
||||
else -> {
|
||||
GameItemViewHolder(GameItemBinding.bind(mLayoutInflater.inflate(R.layout.game_item, parent, false)))
|
||||
}
|
||||
@ -76,7 +83,8 @@ class GameServersTestAdapter(context: Context,
|
||||
width = ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
}
|
||||
|
||||
exposureSources.add(ExposureSource("开测表详情", getExposureSourceValue(gameEntity.testTime ?: "")))
|
||||
exposureSources.add(ExposureSource("开测表详情", getExposureSourceValue(gameEntity.testTime
|
||||
?: "")))
|
||||
|
||||
val exposureEvent = createEvent(gameEntity,
|
||||
exposureSources,
|
||||
@ -85,10 +93,13 @@ class GameServersTestAdapter(context: Context,
|
||||
mExposureEventArray.put(position, exposureEvent)
|
||||
initViewHolder(gameEntity, holder)
|
||||
} else if (holder is GameServerTimeViewHolder) {
|
||||
holder.container.setPadding(0, if (position != 0) 16F.dip2px() else 8F.dip2px(), 0, 4F.dip2px())
|
||||
holder.header.setImageResource(R.drawable.kaifu_time_icon)
|
||||
holder.time.text = mDataList[position].time
|
||||
} else if (holder is FooterViewHolder) {
|
||||
initFooterViewHolder(holder)
|
||||
} else if (holder is TextViewHolder) {
|
||||
holder.binding.contentTv.text = mDataList[position].text
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,7 +111,7 @@ class GameServersTestAdapter(context: Context,
|
||||
viewHolder.binding.gameRating.visibility = View.VISIBLE
|
||||
viewHolder.binding.gameDes.visibility = View.GONE
|
||||
} else if (test?.gameInfo == "star_and_brief") {
|
||||
viewHolder.binding.gameRating.visibility = View.VISIBLE
|
||||
viewHolder.binding.gameRating.visibility = View.VISIBLE
|
||||
viewHolder.binding.gameDes.visibility = View.VISIBLE
|
||||
} else {
|
||||
viewHolder.binding.gameRating.visibility = View.GONE
|
||||
@ -130,7 +141,7 @@ class GameServersTestAdapter(context: Context,
|
||||
private fun getExposureSourceValue(testTime: String): String {
|
||||
val sb = StringBuilder()
|
||||
sb.append(mViewModel.testTitle)
|
||||
if (!mViewModel.getTestEntity()?.remark.isNullOrEmpty()){
|
||||
if (!mViewModel.getTestEntity()?.remark.isNullOrEmpty()) {
|
||||
sb.append("-")
|
||||
sb.append(mViewModel.getTestEntity()?.remark)
|
||||
}
|
||||
@ -176,4 +187,6 @@ class GameServersTestAdapter(context: Context,
|
||||
@Nullable
|
||||
override fun getEventListByPosition(pos: Int) = null
|
||||
|
||||
class TextViewHolder(var binding: ItemTestServerTextBinding) : RecyclerView.ViewHolder(binding.root)
|
||||
|
||||
}
|
||||
@ -139,6 +139,27 @@ class GameServersTestFragment : NormalFragment() {
|
||||
mSubBinding?.recyclerView?.layoutManager = LinearLayoutManager(requireContext())
|
||||
mSubBinding?.recyclerView?.addOnScrollListener(mExposureListener!!)
|
||||
mSubBinding?.recyclerView?.adapter = mAdapter
|
||||
mSubBinding?.recyclerView?.setPadding(0, 8F.dip2px(), 0, 0)
|
||||
mSubBinding?.recyclerView?.clipToPadding = false
|
||||
|
||||
mSubBinding?.recyclerView?.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
super.onScrolled(recyclerView, dx, dy)
|
||||
val layoutManager = recyclerView.layoutManager
|
||||
if (layoutManager is LinearLayoutManager) {
|
||||
val firstVisiblePosition = layoutManager.findFirstVisibleItemPosition()
|
||||
|
||||
val filterDay = mViewModel?.getDayRangeByPosition(firstVisiblePosition)
|
||||
|
||||
if (!filterDay.isNullOrEmpty()) {
|
||||
mViewModel?.updateTimeFilter(filterDay)
|
||||
mBinding?.filterView?.updateSelectedMainFilter(filterDay)
|
||||
mBinding?.serverTime?.text = filterDay
|
||||
mBinding?.serverTime?.setTextColor(R.color.theme_font.toColor())
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
@ -178,23 +199,6 @@ class GameServersTestFragment : NormalFragment() {
|
||||
})
|
||||
|
||||
mBinding?.filterView?.updateSelectedSubFilter(mViewModel!!.typeList.first())
|
||||
|
||||
mSubBinding?.recyclerView?.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
super.onScrolled(recyclerView, dx, dy)
|
||||
val layoutManager = recyclerView.layoutManager
|
||||
if (layoutManager is LinearLayoutManager) {
|
||||
val firstVisiblePosition = layoutManager.findFirstVisibleItemPosition()
|
||||
|
||||
val filterDay = mViewModel?.getDayRangeByPosition(firstVisiblePosition)
|
||||
|
||||
if (!filterDay.isNullOrEmpty()) {
|
||||
mBinding?.filterView?.updateSelectedMainFilter(filterDay)
|
||||
mViewModel?.updateTimeFilter(filterDay)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun showDefaultFilter() {
|
||||
@ -311,7 +315,7 @@ class GameServersTestFragment : NormalFragment() {
|
||||
|
||||
private fun resetFilter() {
|
||||
mType = "全部"
|
||||
mBinding?.serverTime?.text = "开测时间"
|
||||
// mBinding?.serverTime?.text = "开测时间"
|
||||
mBinding?.serverStatus?.text = "测试状态"
|
||||
mBinding?.filterView?.updateSelectedSubFilter(mViewModel!!.typeList.first())
|
||||
mBinding?.serverTime?.setTextColor(R.color.text_333333.toColor())
|
||||
|
||||
@ -20,6 +20,7 @@ import com.halo.assistant.HaloApp
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import kotlin.math.abs
|
||||
|
||||
class GameServersTestViewModel(application: Application, private val mColumnId: String)
|
||||
: AndroidViewModel(application) {
|
||||
@ -141,6 +142,7 @@ class GameServersTestViewModel(application: Application, private val mColumnId:
|
||||
|
||||
mTimePositionSparseArray.clear()
|
||||
|
||||
var isEmptyIndeed = true // 列表是否不含有任何一个游戏,这时隐藏所有
|
||||
for (slice in serverTestEntity.sliceData) {
|
||||
subList.clear()
|
||||
|
||||
@ -178,20 +180,31 @@ class GameServersTestViewModel(application: Application, private val mColumnId:
|
||||
game.sequence = index
|
||||
game.testTime = testTimeInHumanReadableFormat
|
||||
subList.add(ItemData(game = game, readableDaysOffset = readableDaysOffset))
|
||||
|
||||
isEmptyIndeed = false
|
||||
}
|
||||
}
|
||||
|
||||
// 过滤没有游戏的子列表
|
||||
if (subList.size > 1) {
|
||||
// 过滤除昨天今天明天以外没有游戏的子列表
|
||||
if (subList.size > 1 || abs(daysOffset) <= 1) {
|
||||
val isCurrentDaysOffsetExist = mTimePositionSparseArray.get(readableDaysOffset, 999) != 999
|
||||
if (!isCurrentDaysOffsetExist) {
|
||||
mTimePositionSparseArray.put(readableDaysOffset, list.size)
|
||||
}
|
||||
|
||||
list.addAll(subList)
|
||||
|
||||
if (subList.size == 1) {
|
||||
list.add(ItemData(text = "暂无开测游戏", readableDaysOffset = daysOffset))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isEmptyIndeed) {
|
||||
// 没有游戏的列表不显示日期
|
||||
list.clear()
|
||||
}
|
||||
|
||||
initLocationMap(list)
|
||||
|
||||
listLiveData.postValue(list)
|
||||
@ -212,7 +225,10 @@ class GameServersTestViewModel(application: Application, private val mColumnId:
|
||||
UPCOMING_DAY(2)
|
||||
}
|
||||
|
||||
class ItemData(var time: String? = null, var game: GameEntity? = null, var readableDaysOffset: Int = 0)
|
||||
class ItemData(var time: String? = null,
|
||||
var game: GameEntity? = null,
|
||||
var text: String? = null,
|
||||
var readableDaysOffset: Int = 0)
|
||||
|
||||
class Factory(private val mApplication: Application, private val mColumnId: String) : ViewModelProvider.NewInstanceFactory() {
|
||||
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginTop="23dp"
|
||||
android:background="@color/text_eeeeee" />
|
||||
|
||||
<TextView
|
||||
|
||||
@ -13,10 +13,10 @@
|
||||
android:drawableRight="@drawable/server_popup_button_style"
|
||||
android:drawablePadding="8dp"
|
||||
android:includeFontPadding="false"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingRight="50dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:text="开服时间"
|
||||
android:textColor="@color/text_333333"
|
||||
android:textSize="14sp"
|
||||
@ -41,10 +41,10 @@
|
||||
android:drawableRight="@drawable/server_popup_button_style"
|
||||
android:drawablePadding="8dp"
|
||||
android:includeFontPadding="false"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingRight="20dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:text="测试状态"
|
||||
android:textColor="@color/text_333333"
|
||||
android:textSize="14sp"
|
||||
@ -66,7 +66,6 @@
|
||||
layout="@layout/fragment_kaifu_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
|
||||
15
app/src/main/res/layout/item_test_server_text.xml
Normal file
15
app/src/main/res/layout/item_test_server_text.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/contentTv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/text_999999"
|
||||
android:textSize="12sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
@ -4,7 +4,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:background="@color/all_white">
|
||||
android:background="@color/white">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/filterRecyclerView"
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
android:id="@+id/all"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingRight="20dp"
|
||||
android:paddingBottom="12dp"
|
||||
@ -28,7 +28,7 @@
|
||||
android:id="@+id/publish_server"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingBottom="12dp"
|
||||
android:text="公测"
|
||||
@ -39,7 +39,7 @@
|
||||
android:id="@+id/not_delete_server"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingBottom="12dp"
|
||||
android:text="不删档内测"
|
||||
@ -50,7 +50,7 @@
|
||||
android:id="@+id/delete_server"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:text="删档内测"
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingRight="32dp"
|
||||
android:paddingBottom="4dp"
|
||||
|
||||
Reference in New Issue
Block a user