From cced6b703523dd02f5b2deaa65ea3e95c877ff4a Mon Sep 17 00:00:00 2001 From: kehaoyuan Date: Mon, 8 Jun 2020 16:47:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=89=E7=8E=AF=E5=8A=A9=E6=89=8BV4.0.2-?= =?UTF-8?q?=E5=BC=80=E6=9C=8D=E6=97=A5=E5=8E=86=E8=A1=A8=E4=BC=98=E5=8C=96?= =?UTF-8?q?(2(1),2(2))https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/?= =?UTF-8?q?893?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gh/gamecenter/entity/CalendarEntity.kt | 2 + .../fuli/kaifu/ServersCalendarActivity.kt | 2 +- .../fuli/kaifu/ServersCalendarAdapter.kt | 31 +- .../servers/add/AddKaiFuActivity.kt | 2 +- .../main/res/layout/activity_kaifu_patch.xml | 354 +++++++++--------- app/src/main/res/layout/kaifu_add_item.xml | 146 ++++---- 6 files changed, 279 insertions(+), 258 deletions(-) diff --git a/app/src/main/java/com/gh/gamecenter/entity/CalendarEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/CalendarEntity.kt index b98a9fc8a9..58452dbcea 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/CalendarEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/CalendarEntity.kt @@ -7,5 +7,7 @@ class CalendarEntity { var day: Int = 0 + var month: Int = 0 + var server: MutableList = ArrayList() } diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/fuli/kaifu/ServersCalendarActivity.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/fuli/kaifu/ServersCalendarActivity.kt index 4b625a6e27..086f0e21e9 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/fuli/kaifu/ServersCalendarActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/fuli/kaifu/ServersCalendarActivity.kt @@ -255,7 +255,7 @@ class ServersCalendarActivity : ToolBarActivity() { feedback.setOnClickListener { if (mViewModel.meEntity?.isPartTime == true) { startActivityForResult(AddKaiFuActivity.getIntent(this, - mViewModel.serverCalendarLiveData.value!!.last(), + calendarEntity.server.last(), mViewModel.serverCalendarLiveData.value as ArrayList, mViewModel.game.id), GAME_DETAIL_ADD_KAIFU_REQUEST) } else { diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/fuli/kaifu/ServersCalendarAdapter.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/fuli/kaifu/ServersCalendarAdapter.kt index 1de3fa5a93..58039ec93f 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/fuli/kaifu/ServersCalendarAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/fuli/kaifu/ServersCalendarAdapter.kt @@ -9,18 +9,18 @@ import android.view.ViewGroup import android.widget.TextView import androidx.core.content.ContextCompat import androidx.recyclerview.widget.RecyclerView -import com.gh.common.util.MtaHelper -import com.gh.common.util.dip2px -import com.gh.common.util.toColor +import com.gh.common.util.* import com.gh.common.view.DrawableView import com.gh.gamecenter.R import com.gh.gamecenter.adapter.viewholder.GameDetailCalenderViewHolder import com.gh.gamecenter.entity.CalendarEntity import com.gh.gamecenter.entity.ServerCalendarEntity -import com.gh.gamecenter.gamedetail.fuli.FuLiFragment import com.gh.gamecenter.servers.add.AddKaiFuActivity.Companion.getIntent import com.lightgame.adapter.BaseRecyclerAdapter +import java.text.SimpleDateFormat import java.util.* +import kotlin.collections.HashMap +import kotlin.math.abs class ServersCalendarAdapter(context: Context, val viewModel: ServersCalendarViewModel, @@ -101,7 +101,7 @@ class ServersCalendarAdapter(context: Context, if (meEntity?.isPartTime == true) { (mContext as Activity).startActivityForResult( getIntent(mContext, - viewModel.serverCalendarLiveData.value!!.last(), + getRecentServerByPosition(day), viewModel.serverCalendarLiveData.value as ArrayList, mGameEntity.id), ServersCalendarActivity.GAME_DETAIL_ADD_KAIFU_REQUEST) @@ -119,6 +119,27 @@ class ServersCalendarAdapter(context: Context, } } + // 获取当前位置(时间)最近的开服信息 + private fun getRecentServerByPosition(day: Int): ServerCalendarEntity { + tryCatchInRelease { + val formatDay = SimpleDateFormat("dd", Locale.CHINA) + val offsetAndServerMap = HashMap() + + for (calendarEntity in calendarList) { + val servers = calendarEntity.server + if (servers.isNotEmpty()) { + val server = servers.last() + offsetAndServerMap[abs(formatDay.format(server.getTime() * 1000).toInt() - day)] = server + } + } + + val toList = offsetAndServerMap.keys.toMutableList() + toList.sortWith(Comparator { o1, o2 -> o1 - o2 }) + return offsetAndServerMap[toList.first()]!! + } + return viewModel.serverCalendarLiveData.value!!.last() + } + private class WeekViewHolder(val week: TextView) : RecyclerView.ViewHolder(week) companion object { diff --git a/app/src/main/java/com/gh/gamecenter/servers/add/AddKaiFuActivity.kt b/app/src/main/java/com/gh/gamecenter/servers/add/AddKaiFuActivity.kt index bb123e0ed3..deabd7e666 100644 --- a/app/src/main/java/com/gh/gamecenter/servers/add/AddKaiFuActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/servers/add/AddKaiFuActivity.kt @@ -51,7 +51,7 @@ class AddKaiFuActivity : ToolBarActivity() { // initViewModel mViewModel = ViewModelProviders.of(this).get(AddKaiFuViewModel::class.java) mViewModel?.initData(intent.getParcelableExtra(ServerCalendarEntity.TAG) - , intent.getParcelableArrayListExtra(EntranceUtils.KEY_KAIFU_LIST) + , intent.getParcelableArrayListExtra(EntranceUtils.KEY_KAIFU_LIST) , intent.getStringExtra(EntranceUtils.KEY_GAMEID)) mViewModel?.postResult?.observe(this, androidx.lifecycle.Observer { it -> if (it == null) { diff --git a/app/src/main/res/layout/activity_kaifu_patch.xml b/app/src/main/res/layout/activity_kaifu_patch.xml index b512637464..fee1c60fdf 100644 --- a/app/src/main/res/layout/activity_kaifu_patch.xml +++ b/app/src/main/res/layout/activity_kaifu_patch.xml @@ -1,228 +1,226 @@ - + - + + name="entity" + type="com.gh.gamecenter.entity.ServerCalendarEntity" /> - + - + - + + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_marginTop="8dp" + android:layout_weight="1" + android:background="@android:color/white" + android:orientation="vertical" + android:padding="20dp"> + layout="@layout/kaifu_add_item_title" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@color/title" + android:orientation="horizontal" + android:paddingLeft="1dp" + android:paddingTop="1dp" + android:paddingRight="1dp" + android:paddingBottom="1dp"> + android:layout_width="0dp" + android:layout_height="50dp" + android:layout_marginRight="1dp" + android:layout_weight="15" + android:background="@android:color/white" + android:gravity="center" + android:maxLines="2" + android:text="@{entity.getFormatTime(`yyyy-MM-dd HH:mm`)}" + android:textColor="@color/title" + android:textColorHint="@color/title" + android:textSize="11sp" /> + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_marginRight="1dp" + android:layout_weight="29" + android:background="@android:color/white" + android:gravity="center" + android:maxLines="2" + android:text="@{entity.note}" + android:textColor="@color/title" + android:textColorHint="@color/title" + android:textSize="12sp" /> - - + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="15" + android:background="@android:color/white" + android:gravity="center" + android:maxLines="2" + android:text="@{entity.remark}" + android:textColor="@color/title" + android:textColorHint="@color/title" + android:textSize="12sp" /> + + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="15dp" + android:background="@color/theme" + android:orientation="horizontal" + android:paddingLeft="1dp" + android:paddingTop="1dp" + android:paddingRight="1dp" + android:paddingBottom="1dp"> + android:layout_width="0dp" + android:layout_height="50dp" + android:layout_marginRight="1dp" + android:layout_weight="15" + android:background="@android:color/white" + android:gravity="center" + android:orientation="horizontal"> + android:id="@+id/patch_btn" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:button="@drawable/kaifu_amend_selector" + android:paddingLeft="7dp" + android:text="修改" + android:textColor="@color/title" + android:textSize="11sp" /> - + + android:id="@+id/patch_name" + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_marginRight="1dp" + android:layout_weight="29" + android:background="@android:color/white" + android:gravity="center" + android:hint="点击填写" + android:singleLine="true" + android:text="@{entity.note}" + android:textColor="@color/title" + android:textColorHint="@color/title" + android:textSize="12sp" /> - - + android:id="@+id/patch_remark" + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="15" + android:background="@android:color/white" + android:enabled="false" + android:gravity="center" + android:maxLength="4" + android:maxLines="2" + android:text="@{entity.remark}" + android:textColor="@color/hint" + android:textColorHint="@color/hint" + android:textSize="12sp" /> + + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="15dp" + android:background="@color/red" + android:orientation="horizontal" + android:paddingLeft="1dp" + android:paddingTop="1dp" + android:paddingRight="1dp" + android:paddingBottom="1dp"> + android:layout_width="0dp" + android:layout_height="50dp" + android:layout_marginRight="1dp" + android:layout_weight="15" + android:background="@android:color/white" + android:gravity="center" + android:orientation="horizontal"> - + android:id="@+id/delete_btn" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:button="@drawable/kaifu_delete_selector" + android:paddingLeft="7dp" + android:text="删除" + android:textColor="@color/title" + android:textSize="11sp" /> + + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_marginRight="1dp" + android:layout_weight="29" + android:background="@android:color/white" + android:gravity="center" + android:maxLines="2" + android:text="@{entity.note}" + android:textColor="@color/hint" + android:textColorHint="@color/hint" + android:textSize="12sp" /> + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="15" + android:background="@android:color/white" + android:gravity="center" + android:maxLines="2" + android:text="@{entity.remark}" + android:textColor="@color/hint" + android:textColorHint="@color/hint" + android:textSize="12sp" /> - - + + + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="1dp" + android:background="@android:color/white"> - + android:background="@drawable/game_item_btn_download_up" + android:gravity="center" + android:text="提交" + android:textColor="@android:color/white" /> - - + + + diff --git a/app/src/main/res/layout/kaifu_add_item.xml b/app/src/main/res/layout/kaifu_add_item.xml index 6a8c432d9c..00385c626b 100644 --- a/app/src/main/res/layout/kaifu_add_item.xml +++ b/app/src/main/res/layout/kaifu_add_item.xml @@ -1,93 +1,93 @@ - + - + + name="entity" + type="com.gh.gamecenter.entity.ServerCalendarEntity" /> + name="isCloseBottom" + type="Boolean" /> + name="position" + type="Integer" /> + name="clickListener" + type="com.gh.base.OnViewClickListener" /> - + - - + + - + + android:id="@+id/kaifu_add_time" + addKaiFuPosition="@{position}" + addKaiFuTime="@{entity.time}" + kaiFuTextColor="@{entity.dataMark}" + kaiFuTextPosition="@{position}" + android:layout_width="0dp" + android:layout_height="50dp" + android:layout_marginRight="1dp" + android:layout_weight="15" + android:background="@android:color/white" + android:focusable="false" + android:gravity="center" + android:maxLines="2" + android:onClick="@{(v)-> clickListener.onClick(v, position)}" + android:textSize="11sp" /> + android:id="@+id/kaifu_add_name" + kaiFuTextColor="@{entity.dataMark}" + kaiFuTextPosition="@{position}" + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_marginRight="1dp" + android:layout_weight="29" + android:background="@android:color/white" + android:focusable="@{position == 0? false: true}" + android:gravity="center" + android:hint="点击填写" + android:onClick="@{(v)-> clickListener.onClick(v, position)}" + android:singleLine="true" + android:text="@={entity.note}" + android:textColorHint="@color/title" + android:textSize="12sp" /> + android:id="@+id/kaifu_add_remark" + kaiFuTextColor="@{entity.dataMark}" + kaiFuTextPosition="@{position}" + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="15" + android:background="@android:color/white" + android:enabled="false" + android:focusable="@{position == 0? false: true}" + android:gravity="center" + android:hint="点击填写" + android:maxLength="4" + android:maxLines="2" + android:text="@={entity.remark}" + android:textColorHint="@{position == 0? @color/hint:@color/title}" + android:textSize="12sp" /> - - + +