版本升为3.3 新增开服新增/修改完成数据同步
This commit is contained in:
@ -145,6 +145,7 @@ public class BindingAdapters {
|
||||
|| dataMark == 3 && view.getId() == R.id.kaifu_add_remark
|
||||
|| dataMark == 4 && (view.getId() == R.id.kaifu_add_time || view.getId() == R.id.kaifu_add_name)) {
|
||||
view.setTextColor(ContextCompat.getColor(view.getContext(), R.color.red));
|
||||
view.setHintTextColor(ContextCompat.getColor(view.getContext(), R.color.red));
|
||||
} else if (position == 0) {
|
||||
view.setTextColor(ContextCompat.getColor(view.getContext(), R.color.hint));
|
||||
} else {
|
||||
|
||||
@ -11,6 +11,7 @@ import com.gh.gamecenter.R;
|
||||
public class KaiFuUtils {
|
||||
|
||||
public static void setKaiFuType(TextView textView, String type) {
|
||||
if (type == null) return;
|
||||
textView.setText(type);
|
||||
switch (type) {
|
||||
case "不删档内测":
|
||||
|
||||
@ -69,7 +69,6 @@ public class FuLiAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
|
||||
private GameDetailEntity mGameDetailEntity;
|
||||
private GameEntity mGameEntity;
|
||||
private String entrance;
|
||||
|
||||
private int position_news = -1;
|
||||
private int position_tools = -1;
|
||||
@ -86,7 +85,6 @@ public class FuLiAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
GameDetailEntity detailEntity, OnListClickListener listener) {
|
||||
super(context);
|
||||
|
||||
this.entrance = entrance;
|
||||
this.mListListener = listener;
|
||||
isOpenLiBaoList = false;
|
||||
|
||||
@ -569,12 +567,12 @@ public class FuLiAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
binding.kaifuDes.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
GameDetailKaiFuAdapter adapter = new GameDetailKaiFuAdapter(mContext, serverEntity.getCalendar(), binding, mGameEntity, mGameDetailEntity.getMe());
|
||||
binding.kaifuRv.setNestedScrollingEnabled(false);
|
||||
if (binding.kaifuRv.getAdapter() == null) {
|
||||
binding.kaifuRv.setLayoutManager(new GridLayoutManager(mContext, 7));
|
||||
binding.kaifuRv.addItemDecoration(new GridDivider(mContext, 1, 7, Color.BLACK));
|
||||
binding.kaifuRv.setAdapter(new GameDetailKaiFuAdapter(mContext, serverEntity.getCalendar(), binding, mGameEntity, mGameDetailEntity.getMe()));
|
||||
}
|
||||
binding.kaifuRv.setLayoutManager(new GridLayoutManager(mContext, 7));
|
||||
binding.kaifuRv.addItemDecoration(new GridDivider(mContext, 1, 7, Color.BLACK));
|
||||
binding.kaifuRv.setAdapter(adapter);
|
||||
adapter.showKaiFuDetail(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
package com.gh.gamecenter.gamedetail;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import com.gh.base.fragment.BaseFragment;
|
||||
@ -22,6 +24,7 @@ import com.gh.gamecenter.NewsDetailActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.entity.GameDetailEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.KaiFuCalendarEntity;
|
||||
import com.gh.gamecenter.entity.LibaoEntity;
|
||||
import com.gh.gamecenter.entity.NewsEntity;
|
||||
import com.gh.gamecenter.eventbus.EBReuse;
|
||||
@ -30,6 +33,7 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -48,6 +52,10 @@ public class FuliFragment extends BaseFragment {
|
||||
private GameDetailEntity mDetailEntity;
|
||||
|
||||
private final static int GAME_DETAIL_LIBAO_REQUEST = 23;
|
||||
public final static int GAME_DETAIL_PATCH_KAIFU_REQUEST = 51;
|
||||
public final static int GAME_DETAIL_ADD_KAIFU_REQUEST = 50;
|
||||
public final static String GAME_DETAIL_ADD_KAIFU_KEY = "GAME_DETAIL_ADD_KAIFU_KEY";
|
||||
public final static String GAME_DETAIL_PATCH_KAIFU_KEY = "GAME_DETAIL_PATCH_KAIFU_KEY";
|
||||
|
||||
private boolean isCanScroll;
|
||||
private boolean isCanShowKaiFuHint;
|
||||
@ -59,6 +67,35 @@ public class FuliFragment extends BaseFragment {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == GAME_DETAIL_LIBAO_REQUEST) {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
} else if (requestCode == GAME_DETAIL_ADD_KAIFU_REQUEST && resultCode == Activity.RESULT_OK) { // 新增开服
|
||||
ArrayList<KaiFuCalendarEntity> dataList = data.getParcelableArrayListExtra(GAME_DETAIL_ADD_KAIFU_KEY);
|
||||
if (dataList != null && mDetailEntity.getServerEntity() != null && mDetailEntity.getServerEntity().getCalendar() != null) {
|
||||
mDetailEntity.getServerEntity().getCalendar().addAll(dataList);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
} else if (requestCode == GAME_DETAIL_PATCH_KAIFU_REQUEST && resultCode == Activity.RESULT_OK) { // 修改开服
|
||||
KaiFuCalendarEntity dataEntity = data.getParcelableExtra(GAME_DETAIL_PATCH_KAIFU_KEY);
|
||||
if (dataEntity != null && mDetailEntity.getServerEntity() != null && mDetailEntity.getServerEntity().getCalendar() != null) {
|
||||
List<KaiFuCalendarEntity> calendar = mDetailEntity.getServerEntity().getCalendar();
|
||||
if (TextUtils.isEmpty(dataEntity.getNote())) { // 删除
|
||||
for (KaiFuCalendarEntity entity : calendar) {
|
||||
if (dataEntity.getId().equals(entity.getId())) {
|
||||
calendar.remove(entity);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else { // 更改
|
||||
for (KaiFuCalendarEntity entity : calendar) {
|
||||
if (dataEntity.getId().equals(entity.getId())) {
|
||||
entity.setNote(dataEntity.getNote());
|
||||
entity.setRemark(dataEntity.getRemark());
|
||||
mAdapter.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.gamecenter.gamedetail;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
@ -135,6 +136,14 @@ public class GameDetailFragment extends NormalFragment {
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
for (Fragment fragment : getChildFragmentManager().getFragments()) {
|
||||
fragment.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
private DetailViewHolder getDetailViewHolder() {
|
||||
// 每次获取需要重新创建, 防止数据刷新
|
||||
//TODO 更改为监听数据刷新,哪有每次new对象的
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.gamecenter.gamedetail;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
@ -32,6 +33,7 @@ import com.gh.gamecenter.kaifu.add.AddKaiFuActivity;
|
||||
import com.gh.gamecenter.kaifu.patch.PatchKaifuActivity;
|
||||
import com.gh.gamecenter.retrofit.Response;
|
||||
import com.lightgame.adapter.BaseRecyclerAdapter;
|
||||
import com.lightgame.utils.Utils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
@ -204,20 +206,21 @@ public class GameDetailKaiFuAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
if (((TextView) v).getText().equals("有奖反馈")) {
|
||||
if (mMeEntity != null && mMeEntity.isPartTime()) {
|
||||
mBinding.setIsReadyPatch(true);
|
||||
Utils.toast(mContext, "修改开服请直接点击表格上的内容");
|
||||
} else {
|
||||
SuggestionActivity.startSuggestionActivity(mContext, 1, "service"
|
||||
, StringUtils.buildString(mGameEntity.getName(), ",", suggestTime, "开服信息有误:"));
|
||||
}
|
||||
} else {
|
||||
mContext.startActivity(AddKaiFuActivity.Companion.getIntent(mContext,
|
||||
mOpenCalendarEntity, (ArrayList<KaiFuCalendarEntity>) mServerList, mGameEntity.getId()));
|
||||
((Activity) mContext).startActivityForResult(AddKaiFuActivity.Companion.getIntent(mContext, mOpenCalendarEntity
|
||||
, (ArrayList<KaiFuCalendarEntity>) mServerList, mGameEntity.getId()), FuliFragment.GAME_DETAIL_ADD_KAIFU_REQUEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showKaiFuDetail(boolean openKaiFuDetail) {
|
||||
void showKaiFuDetail(boolean openKaiFuDetail) {
|
||||
mBinding.kaifuDetail.setVisibility(openKaiFuDetail ? View.VISIBLE : View.GONE);
|
||||
mBinding.kaifuDetailTime.setVisibility(openKaiFuDetail ? View.VISIBLE : View.GONE);
|
||||
mBinding.kaifuMonthContainer.setVisibility(openKaiFuDetail ? View.GONE : View.VISIBLE);
|
||||
@ -459,8 +462,8 @@ public class GameDetailKaiFuAdapter extends BaseRecyclerAdapter<ViewHolder> {
|
||||
@Override
|
||||
public void onClick(View v, Object data) {
|
||||
if (data instanceof KaiFuCalendarEntity) {
|
||||
mContext.startActivity(PatchKaifuActivity.Companion.getIntent(mContext,
|
||||
(KaiFuCalendarEntity) data, mGameEntity.getId()));
|
||||
((Activity) mContext).startActivityForResult(PatchKaifuActivity.Companion.getIntent(mContext,
|
||||
(KaiFuCalendarEntity) data, mGameEntity.getId()), FuliFragment.GAME_DETAIL_PATCH_KAIFU_REQUEST);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -258,12 +258,12 @@ public class KaiFuVpAdapter extends BaseRecyclerAdapter {
|
||||
String note = entity.getNote();
|
||||
String remark = entity.getRemark();
|
||||
if ("不删档内测".equals(type) || "删档内测".equals(type)) {
|
||||
KaiFuUtils.setKaiFuType(noteTv, gameEntity.getType());
|
||||
KaiFuUtils.setKaiFuType(noteTv, type);
|
||||
} else if ("公测".equals(type)) {
|
||||
if (TextUtils.isEmpty(note)) {
|
||||
KaiFuUtils.setKaiFuType(noteTv, gameEntity.getType());
|
||||
KaiFuUtils.setKaiFuType(noteTv, type);
|
||||
} else {
|
||||
KaiFuUtils.setKaiFuType(noteTv, gameEntity.getType() + ":" + note);
|
||||
KaiFuUtils.setKaiFuType(noteTv, type + ":" + note);
|
||||
}
|
||||
} else {
|
||||
KaiFuUtils.setKaiFuType(noteTv, note);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.gh.gamecenter.kaifu.add
|
||||
|
||||
import android.app.Activity
|
||||
import android.arch.lifecycle.ViewModelProviders
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
@ -18,6 +19,8 @@ import com.gh.common.util.EntranceUtils
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.ActivityKaifuAddBinding
|
||||
import com.gh.gamecenter.entity.KaiFuCalendarEntity
|
||||
import com.gh.gamecenter.gamedetail.FuliFragment
|
||||
import com.lightgame.utils.Utils
|
||||
import java.util.*
|
||||
|
||||
|
||||
@ -45,6 +48,10 @@ class AddKaiFuActivity : BaseActivity() {
|
||||
if (it == null) {
|
||||
toast(R.string.post_failure_hint)
|
||||
} else {
|
||||
Utils.log("===========1111::" + it.size)
|
||||
val intent = Intent()
|
||||
intent.putParcelableArrayListExtra(FuliFragment.GAME_DETAIL_ADD_KAIFU_KEY, it)
|
||||
setResult(Activity.RESULT_OK, intent)
|
||||
toast("提交成功")
|
||||
finish()
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ class AddKaiFuViewModel(application: Application) : AndroidViewModel(application
|
||||
for (i in 1 until calendarList.size) {
|
||||
val entity = calendarList[i]
|
||||
if (!entity.remark.isNullOrEmpty() && entity.getTime() == 0L && entity.getNote().isNullOrEmpty()) {
|
||||
entity.setDataMark(3)
|
||||
entity.setDataMark(4)
|
||||
isSuccess = false
|
||||
}
|
||||
if (i == calendarList.size - 1 && !isSuccess) {
|
||||
@ -99,7 +99,7 @@ class AddKaiFuViewModel(application: Application) : AndroidViewModel(application
|
||||
val entity = calendarList[i]
|
||||
if (entity.getTime() != 0L && entity.getNote().isNullOrEmpty() || entity.getTime() == 0L && !entity.getNote().isNullOrEmpty()) {
|
||||
isSuccess = false
|
||||
entity.setDataMark(if (entity.getTime() != 0L) 1 else 2)
|
||||
entity.setDataMark(if (entity.getTime() != 0L) 2 else 1)
|
||||
}
|
||||
if (i == calendarList.size - 1 && !isSuccess) {
|
||||
toast(getApplication(), "时间和名字必须同时填写")
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.gh.gamecenter.kaifu.patch
|
||||
|
||||
import android.app.Activity
|
||||
import android.arch.lifecycle.Observer
|
||||
import android.arch.lifecycle.ViewModelProviders
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
@ -10,6 +12,7 @@ import com.gh.common.util.EntranceUtils
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.databinding.ActivityKaifuPatchBinding
|
||||
import com.gh.gamecenter.entity.KaiFuCalendarEntity
|
||||
import com.gh.gamecenter.gamedetail.FuliFragment
|
||||
|
||||
class PatchKaifuActivity : BaseActivity() {
|
||||
|
||||
@ -28,11 +31,11 @@ class PatchKaifuActivity : BaseActivity() {
|
||||
|
||||
mViewModel = ViewModelProviders.of(this).get(PatchKaifuViewModel::class.java)
|
||||
mViewModel?.initData(intent.getParcelableExtra(KaiFuCalendarEntity.TAG), intent.getStringExtra(EntranceUtils.KEY_GAMEID))
|
||||
mViewModel?.postResult?.observe(this, android.arch.lifecycle.Observer { it ->
|
||||
if (it == null) { // 删除
|
||||
toast("提交成功")
|
||||
finish()
|
||||
} else { // 修改
|
||||
mViewModel?.postResult?.observe(this, Observer { it ->
|
||||
if (it != null) {
|
||||
val intent = Intent()
|
||||
intent.putExtra(FuliFragment.GAME_DETAIL_PATCH_KAIFU_KEY, it)
|
||||
setResult(Activity.RESULT_OK, intent)
|
||||
toast("提交成功")
|
||||
finish()
|
||||
}
|
||||
|
||||
@ -46,14 +46,15 @@ class PatchKaifuViewModel(application: Application) : AndroidViewModel(applicati
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
val kaiFuCalendarEntity = KaiFuCalendarEntity()
|
||||
kaiFuCalendarEntity.id = serverEntity?.id
|
||||
if (isPatch) {
|
||||
val kaiFuCalendarEntity = KaiFuCalendarEntity()
|
||||
kaiFuCalendarEntity.setNote(patchName)
|
||||
kaiFuCalendarEntity.remark = patchRemark
|
||||
kaiFuCalendarEntity.setTime(serverEntity?.getTime()!!)
|
||||
postResult.postValue(kaiFuCalendarEntity)
|
||||
} else {
|
||||
postResult.postValue(null)
|
||||
postResult.postValue(kaiFuCalendarEntity)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ public class GamePluginAdapter extends BaseRecyclerAdapter {
|
||||
|
||||
private int mItemCount;
|
||||
|
||||
private boolean mIsOpenList;
|
||||
private Boolean mIsOpenList = null;
|
||||
|
||||
public GamePluginAdapter(Context context, List<GameEntity> pluginList) {
|
||||
super(context);
|
||||
@ -103,7 +103,7 @@ public class GamePluginAdapter extends BaseRecyclerAdapter {
|
||||
}
|
||||
|
||||
public void openList(boolean isOpen) {
|
||||
if (mIsOpenList != isOpen) {
|
||||
if (mIsOpenList == null || mIsOpenList != isOpen) {
|
||||
if (isOpen) {
|
||||
mItemCount = mPluginList.size();
|
||||
} else {
|
||||
@ -112,7 +112,7 @@ public class GamePluginAdapter extends BaseRecyclerAdapter {
|
||||
mIsOpenList = isOpen;
|
||||
notifyDataSetChanged();
|
||||
} else {
|
||||
notifyItemChanged(0);
|
||||
notifyItemRangeChanged(0, getItemCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user