@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { LinearLayout layout = (LinearLayout) mInflater.inflate(R.layout.tv_gallery_item, null); convertView = layout; } GridItemHold hold = (GridItemHold) convertView.getTag(); if (hold == null) { hold = new GridItemHold(); hold.img = (ImageView) convertView.findViewById(R.id.tv_gallery_item); hold.name = (TextView) convertView.findViewById(R.id.tv_gallery_txt); convertView.setTag(hold); } final int pos = position % mCategoryList.size(); CategoryData data = mCategoryList.get(pos); hold.name.setText(data.getCategoryname()); String url = data.getCategorypic(); hold.position = pos; Picasso.with(context).load(url).placeholder(R.drawable.tv_default).into(hold.img); return convertView; }
public void onEvent(GetTvEvent<AppreciatetvList> event) { aList = event.result; // 处理List返回内容 if (aList == null) return; // init frequency List<Appreciatetv> list = aList.getLists(); List<CategoryData> datas = list.get(list.size() - 1).getData(); mFrequencys.clear(); for (CategoryData data : datas) { mFrequencys.add(data.getCategoryurl()); } setViewsVisiable(View.VISIBLE); mProgressBar.setVisibility(View.GONE); mListViewAdapter.updateData(aList.getLists()); Appreciatetv tv = (Appreciatetv) mListViewAdapter.getItem(0); if (tv != null) { mGalleryAdapter.updateData(tv.getData()); mGallery.setSelection(Integer.MAX_VALUE / 2 - 1); } mListView.requestFocus(); }
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (parent == mListView) { } else { final int pos = position % mGalleryAdapter.getList().size(); CategoryData data = mGalleryAdapter.getItem(pos); final int channel = Integer.valueOf(data.getCategoryurl().trim()); Intent intent = new Intent(getActivity(), HotelTVActivity.class); getActivity().startActivity(intent); } }
@Override public boolean onKeyCenter() { // Log.d("tv", "onKeyCenter selected=" + mGallery.getSelectedItemPosition()); CategoryData data = (CategoryData) mGallery.getSelectedItem(); if (data != null) { Intent intent = new Intent(getActivity(), FullTVActivity.class); String url = data.getCategoryurl(); intent.putStringArrayListExtra( FullTVActivity.INTENT_KEY_DATA, (ArrayList<String>) mFrequencys); intent.putExtra(FullTVActivity.INTENT_KEY_SELECTED, url); getActivity().startActivity(intent); return true; } return false; }