解决合并产生的bug
This commit is contained in:
@ -328,7 +328,7 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
}
|
||||
}
|
||||
|
||||
DownloadItemUtils.updateItem(context, holder.labelList,
|
||||
DownloadItemUtils.updateItem(context, holder.gameDes,
|
||||
holder.game_progressbar, holder.game_ll_info, holder.download_speed,
|
||||
holder.download_percentage, holder.downloadBtn, entity, platformMap,
|
||||
statusMap);
|
||||
@ -375,7 +375,7 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
entity, position, this,
|
||||
statusMap, platformMap, "热门卡牌", dismissEntity, "hotcard:" + entity.getName());
|
||||
|
||||
DownloadItemUtils.updateItem(context, holder.labelList,
|
||||
DownloadItemUtils.updateItem(context, holder.gameDes,
|
||||
holder.game_progressbar, holder.game_ll_info,
|
||||
holder.download_speed, holder.download_percentage,
|
||||
holder.downloadBtn, entity, platformMap, statusMap);
|
||||
|
||||
@ -1,180 +0,0 @@
|
||||
package com.gh.gamecenter.search;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.RecyclerView.ViewHolder;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.View.OnLongClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.db.SearchHistoryDao;
|
||||
import com.gh.gamecenter.eventbus.EBSearch;
|
||||
import com.gh.gamecenter.manager.DataCollectionManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
public class Search3HistoryFragmentAdapter extends RecyclerView.Adapter<ViewHolder> {
|
||||
|
||||
private Context context;
|
||||
|
||||
private SearchHistoryDao dao;
|
||||
|
||||
private List<String> historyList;
|
||||
|
||||
public Search3HistoryFragmentAdapter(Context context) {
|
||||
|
||||
this.context = context;
|
||||
|
||||
dao = new SearchHistoryDao(context);
|
||||
historyList = dao.getAll();
|
||||
if (historyList == null) {
|
||||
historyList = new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public void clearSearchResult() {
|
||||
if (historyList != null) {
|
||||
historyList.clear();
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (historyList.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
return historyList.size() + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
if (viewType == historyList.size()) {
|
||||
View itemView = LayoutInflater.from(context).inflate(
|
||||
R.layout.search3_history_delete_item, viewGroup, false);
|
||||
return new DeleteHistoryViewHolder(itemView);
|
||||
} else {
|
||||
View itemView = LayoutInflater.from(context).inflate(
|
||||
R.layout.search3_history_fragment_item, viewGroup, false);
|
||||
return new SearchHistoryViewHolder(itemView);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder viewHolder, final int position) {
|
||||
if (viewHolder instanceof SearchHistoryViewHolder) {
|
||||
SearchHistoryViewHolder holder = (SearchHistoryViewHolder) viewHolder;
|
||||
holder.tv_hisName.setText(historyList.get(position));
|
||||
}
|
||||
}
|
||||
|
||||
private void showCancelDialog() {
|
||||
final Dialog dialog = new Dialog(context);
|
||||
View view = View.inflate(context, R.layout.search_history_delete_dialog, null);
|
||||
|
||||
view.findViewById(R.id.delete_dialog_cancel)
|
||||
.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
view.findViewById(R.id.delete_dialog_confirm)
|
||||
.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dao.deleteAll();
|
||||
clearSearchResult();
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public class SearchHistoryViewHolder extends ViewHolder
|
||||
implements OnClickListener, OnLongClickListener {
|
||||
|
||||
private View itemView;
|
||||
private TextView tv_hisName;
|
||||
private ImageView iv_hisAdd;
|
||||
|
||||
public SearchHistoryViewHolder(View view) {
|
||||
super(view);
|
||||
itemView = view;
|
||||
|
||||
tv_hisName = (TextView) view.findViewById(R.id.search_history_name);
|
||||
iv_hisAdd = (ImageView) view.findViewById(R.id.search_history_add);
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
iv_hisAdd.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
if (v == itemView) {
|
||||
// TODO: alert a dialog and delete just one
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == itemView) {
|
||||
String str = tv_hisName.getText().toString();
|
||||
|
||||
DataUtils.onEvent(context, "搜索页面", str);
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("key", str);
|
||||
map.put("from", "搜索页面");
|
||||
map.put("createdOn", System.currentTimeMillis() / 1000);
|
||||
DataCollectionManager.onEvent(context, "search", map);
|
||||
|
||||
EventBus.getDefault().post(new EBSearch(str, true));
|
||||
dao.add(tv_hisName.getText().toString());
|
||||
} else if (v.getId() == R.id.search_history_add) {
|
||||
String str = tv_hisName.getText().toString();
|
||||
EventBus.getDefault().post(new EBSearch(str, false));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class DeleteHistoryViewHolder extends ViewHolder {
|
||||
|
||||
public DeleteHistoryViewHolder(View view) {
|
||||
super(view);
|
||||
view.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showCancelDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user