细节修复、部分bug修复
This commit is contained in:
@ -127,6 +127,7 @@ public class ConcernActivity extends BaseActivity implements OnClickListener {
|
||||
Type listType = new TypeToken<ArrayList<GameEntity>>() {}.getType();
|
||||
Gson gson = new Gson();
|
||||
List<GameEntity> list = gson.fromJson(response.toString(), listType);
|
||||
recommendList.clear();
|
||||
for (int i = 0, size = list.size(); i < size; i++) {
|
||||
if (!manager.isConcern(list.get(i).getId())) {
|
||||
recommendList.add(list.get(i));
|
||||
@ -186,6 +187,7 @@ public class ConcernActivity extends BaseActivity implements OnClickListener {
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
gameList.add(gson.fromJson(data.get(i).toString(), GameEntity.class));
|
||||
}
|
||||
concernList.clear();
|
||||
for (int i = 0, sizei = list.size(); i < sizei; i++) {
|
||||
for (int j = 0, sizej = gameList.size(); j < sizej; j++) {
|
||||
if (list.get(i).getId().equals(gameList.get(j).getId())) {
|
||||
@ -197,79 +199,16 @@ public class ConcernActivity extends BaseActivity implements OnClickListener {
|
||||
concern_rv_show.getAdapter().notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private class ConcernViewHolder extends RecyclerView.ViewHolder implements
|
||||
OnClickListener {
|
||||
private class ConcernViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private ImageView concern_item_icon;
|
||||
private TextView concern_item_name, concern_item_btn;
|
||||
private View view;
|
||||
|
||||
public ConcernViewHolder(View convertView) {
|
||||
super(convertView);
|
||||
concern_item_icon = (ImageView) convertView.findViewById(R.id.concern_item_icon);
|
||||
concern_item_name = (TextView) convertView.findViewById(R.id.concern_item_name);
|
||||
concern_item_btn = (TextView) convertView.findViewById(R.id.concern_item_btn);
|
||||
concern_item_btn.setOnClickListener(this);
|
||||
convertView.setOnClickListener(this);
|
||||
view = convertView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final int position = getPosition();
|
||||
if (v == concern_item_btn) {
|
||||
// 删除关注表中的数据,并更新界面
|
||||
DialogUtils.showCancelDialog(ConcernActivity.this, new DialogUtils.ConfiremListener() {
|
||||
@Override
|
||||
public void onConfirem() {
|
||||
if (manager.findConcernById(list.get(position).getId()) != null) {
|
||||
ConcernInfo concernInfo = list.remove(position);
|
||||
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
kv.put("状态", "取消关注");
|
||||
DataUtils.onEvent(ConcernActivity.this, "游戏关注", concernInfo.getGameName(), kv);
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("game", concernInfo.getGameName());
|
||||
map.put("game_id", concernInfo.getId());
|
||||
map.put("type", "取消关注");
|
||||
DataCollectionManager.onEvent(ConcernActivity.this, "concern", map);
|
||||
|
||||
manager.deleteConcern(concernInfo.getId());
|
||||
concernList.remove(position);
|
||||
concern_rv_show.getAdapter().notifyItemRemoved(position);
|
||||
if (list.isEmpty()) {
|
||||
reuse_none_data.setVisibility(View.VISIBLE);
|
||||
concern_rv_show.setVisibility(View.GONE);
|
||||
}
|
||||
concern_item_btn.setClickable(false);
|
||||
view.setClickable(false);
|
||||
|
||||
recommendList = new ArrayList<>();
|
||||
initRecommendGame();
|
||||
} else {
|
||||
toast("取消失败,请稍后再试");
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (concernList != null && !concernList.isEmpty()) {
|
||||
GameEntity gameEntity = concernList.get(position);
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("location", "关注列表");
|
||||
map.put("game", gameEntity.getName());
|
||||
map.put("game_id", gameEntity.getId());
|
||||
map.put("page", "我的关注");
|
||||
DataCollectionManager.onEvent(ConcernActivity.this, "click-item", map);
|
||||
|
||||
AppController.put("GameEntity", gameEntity);
|
||||
Intent intent = new Intent(ConcernActivity.this, GameDetailActivity.class);
|
||||
intent.putExtra("entrance", "我的关注-列表");
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -283,7 +222,7 @@ public class ConcernActivity extends BaseActivity implements OnClickListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ConcernViewHolder holder, int position) {
|
||||
public void onBindViewHolder(final ConcernViewHolder holder, int position) {
|
||||
ConcernInfo concernEntity = list.get(position);
|
||||
ImageUtils.getInstance(getApplicationContext()).display(
|
||||
concernEntity.getIcon(), holder.concern_item_icon);
|
||||
@ -291,7 +230,67 @@ public class ConcernActivity extends BaseActivity implements OnClickListener {
|
||||
holder.concern_item_btn.setText("取消关注");
|
||||
holder.concern_item_btn.setBackgroundResource(R.drawable.textview_cancel_style);
|
||||
holder.concern_item_btn.setClickable(true);
|
||||
holder.view.setClickable(true);
|
||||
holder.concern_item_btn.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// 删除关注表中的数据,并更新界面
|
||||
DialogUtils.showCancelDialog(ConcernActivity.this, new DialogUtils.ConfiremListener() {
|
||||
@Override
|
||||
public void onConfirem() {
|
||||
if (manager.findConcernById(list.get(holder.getPosition()).getId()) != null) {
|
||||
ConcernInfo concernInfo = list.remove(holder.getPosition());
|
||||
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
kv.put("状态", "取消关注");
|
||||
DataUtils.onEvent(ConcernActivity.this, "游戏关注", concernInfo.getGameName(), kv);
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("game", concernInfo.getGameName());
|
||||
map.put("game_id", concernInfo.getId());
|
||||
map.put("type", "取消关注");
|
||||
DataCollectionManager.onEvent(ConcernActivity.this, "concern", map);
|
||||
|
||||
manager.deleteConcern(concernInfo.getId());
|
||||
concernList.remove(holder.getPosition());
|
||||
concern_rv_show.getAdapter().notifyItemRemoved(holder.getPosition());
|
||||
if (list.isEmpty()) {
|
||||
reuse_none_data.setVisibility(View.VISIBLE);
|
||||
concern_rv_show.setVisibility(View.GONE);
|
||||
}
|
||||
holder.concern_item_btn.setClickable(false);
|
||||
view.setClickable(false);
|
||||
|
||||
recommendList = new ArrayList<>();
|
||||
initRecommendGame();
|
||||
} else {
|
||||
toast("取消失败,请稍后再试");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
holder.itemView.setClickable(true);
|
||||
holder.itemView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (concernList != null && !concernList.isEmpty()) {
|
||||
GameEntity gameEntity = concernList.get(holder.getPosition());
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("location", "关注列表");
|
||||
map.put("game", gameEntity.getName());
|
||||
map.put("game_id", gameEntity.getId());
|
||||
map.put("page", "我的关注");
|
||||
DataCollectionManager.onEvent(ConcernActivity.this, "click-item", map);
|
||||
|
||||
AppController.put("GameEntity", gameEntity);
|
||||
Intent intent = new Intent(ConcernActivity.this, GameDetailActivity.class);
|
||||
intent.putExtra("entrance", "我的关注-列表");
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -448,7 +447,6 @@ public class ConcernActivity extends BaseActivity implements OnClickListener {
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
concernList = new ArrayList<>();
|
||||
if (!list.isEmpty()) {
|
||||
reuse_none_data.setVisibility(View.GONE);
|
||||
concern_rv_show.setVisibility(View.VISIBLE);
|
||||
|
||||
Reference in New Issue
Block a user