| | |
| | | /** |
| | | * 初始热门搜索化缓存 |
| | | */ |
| | | public void initCacheData(DiskLruCache cache, FlowLayout fl_hot_search, final int id, List<HotSearch> hList) { |
| | | public void initCacheData(DiskLruCache cache, FlowLayout fl_container, final int id, List<HotSearch> hList) { |
| | | //进入缓存 |
| | | if (cache != null) { |
| | | fl_hot_search.removeAllViews(); |
| | | fl_container.removeAllViews(); |
| | | //热门搜索 |
| | | DiskLruCache.Snapshot snapshot = null; |
| | | try { |
| | |
| | | }.getType()); |
| | | for (int i = 0; i < homeTypes.size(); i++) { |
| | | final TextView tv = new TextView(mContext); |
| | | tv.setTextSize(13); |
| | | FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); |
| | | params.setMargins(0, DimenUtils.dip2px(mContext, 8), DimenUtils.dip2px(mContext, 12), 0); |
| | | tv.setLayoutParams(params); |
| | | tv.setLines(1); |
| | | tv.setTextColor(mContext.getResources().getColor(R.color.text_black_1)); |
| | | tv.setTextColor(mContext.getResources().getColor(R.color.search_content_text_color)); |
| | | tv.setEllipsize(TextUtils.TruncateAt.END); |
| | | tv.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.shape_search1)); |
| | | tv.setBackground(mContext.getResources().getDrawable(R.drawable.shape_search_history_item_bg)); |
| | | tv.setPadding(DimenUtils.dip2px(mContext, 20), DimenUtils.dip2px(mContext, 5), DimenUtils.dip2px(mContext, 20), DimenUtils.dip2px(mContext, 5)); |
| | | tv.setText(homeTypes.get(i).getName()); |
| | | tv.setOnClickListener(new View.OnClickListener() { |
| | |
| | | addSearchResultActivity(tv.getText().toString(), id); |
| | | } |
| | | }); |
| | | fl_hot_search.addView(tv); |
| | | fl_container.addView(tv); |
| | | } |
| | | hList.addAll(homeTypes); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public void fillFlowData(List<String> list, FlowLayout fl_container, final ISearchItemClick clickListener) { |
| | | fl_container.removeAllViews(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | final int p = i; |
| | | final TextView tv = new TextView(mContext); |
| | | FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); |
| | | params.setMargins(0, DimenUtils.dip2px(mContext, 8), DimenUtils.dip2px(mContext, 12), 0); |
| | | tv.setLayoutParams(params); |
| | | tv.setLines(1); |
| | | tv.setTextColor(mContext.getResources().getColor(R.color.text_black_1)); |
| | | tv.setEllipsize(TextUtils.TruncateAt.END); |
| | | tv.setBackground(mContext.getResources().getDrawable(R.drawable.shape_search_history_item_bg)); |
| | | tv.setPadding(DimenUtils.dip2px(mContext, 20), DimenUtils.dip2px(mContext, 5), DimenUtils.dip2px(mContext, 20), DimenUtils.dip2px(mContext, 5)); |
| | | tv.setText(list.get(i)); |
| | | tv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (clickListener != null) { |
| | | clickListener.onClick(tv.getText() + "", p); |
| | | } |
| | | } |
| | | }); |
| | | fl_container.addView(tv); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | public static void fillFlowData(Context context, List<String> list, FlowLayout fl_container, final ISearchItemClick clickListener) { |
| | | fl_container.removeAllViews(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | final int p = i; |
| | | final TextView tv = new TextView(context); |
| | | FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); |
| | | params.setMargins(0, DimenUtils.dip2px(context, 8), DimenUtils.dip2px(context, 12), 0); |
| | | tv.setLayoutParams(params); |
| | | // tv.setTextSize(13); |
| | | tv.setLines(1); |
| | | tv.setTextColor(context.getResources().getColor(R.color.search_content_text_color)); |
| | | tv.setEllipsize(TextUtils.TruncateAt.END); |
| | | tv.setBackground(context.getResources().getDrawable(R.drawable.shape_search_history_item_bg)); |
| | | tv.setPadding(DimenUtils.dip2px(context, 20), DimenUtils.dip2px(context, 5), DimenUtils.dip2px(context, 20), DimenUtils.dip2px(context, 5)); |
| | | tv.setText(list.get(i)); |
| | | tv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (clickListener != null) { |
| | | clickListener.onClick(tv.getText() + "", p); |
| | | } |
| | | } |
| | | }); |
| | | fl_container.addView(tv); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | public String getKey(String method) { |
| | | return new Md5FileNameGenerator().generate(method); |
| | | } |
| | |
| | | /** |
| | | * 显示历史记录 |
| | | */ |
| | | public void setHistoricalRecords(int id, List<String> mList, FragmentSearch.HistoryAdapter adapter, |
| | | public void setHistoricalRecords(int id, List<String> mList, |
| | | LinearLayout ll_search_history_hint, LinearLayout ll_guide, RelativeLayout ll_guidevideo |
| | | , String videoPicture) { |
| | | SharedPreferences sp; |
| | |
| | | mList.add(formItem); |
| | | // Log.e("mResult", "onResume();" + mList.get(i)); |
| | | } |
| | | adapter.notifyDataSetChanged(); |
| | | |
| | | if (mList.size() > 0) { |
| | | ll_search_history_hint.setVisibility(View.VISIBLE); |
| | |
| | | tv.setLines(1); |
| | | tv.setTextColor(mContext.getResources().getColor(R.color.text_black_1)); |
| | | tv.setEllipsize(TextUtils.TruncateAt.END); |
| | | tv.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.shape_search1)); |
| | | tv.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.shape_search_history_item_bg)); |
| | | tv.setPadding(DimenUtils.dip2px(mContext, 20), DimenUtils.dip2px(mContext, 5), DimenUtils.dip2px(mContext, 20), DimenUtils.dip2px(mContext, 5)); |
| | | tv.setText(list.get(i).getName()); |
| | | tv.setOnClickListener(new View.OnClickListener() { |
| | |
| | | .load(uir) |
| | | .into(iv_guide1); |
| | | } |
| | | |
| | | public interface ISearchItemClick { |
| | | |
| | | public void onClick(String text, int position); |
| | | |
| | | } |
| | | } |