@Override public View getView(int position, View convertView, ViewGroup parent) { View view = convertView; if (view == null) { int layoutId = getItemViewType(position) == 1 ? android.R.layout.simple_list_item_1 : R.layout.sample_chooser_inline_header; view = LayoutInflater.from(getContext()).inflate(layoutId, null, false); } Object item = getItem(position); String name = null; if (item instanceof Sample) { name = ((Sample) item).name; } else if (item instanceof Header) { name = ((Header) item).name; } ((TextView) view).setText(name); return view; }
private void onSampleSelected(Sample sample) { Intent mpdIntent = new Intent(this, PlayerActivity.class) .setData(Uri.parse(sample.uri)) .putExtra(PlayerActivity.CONTENT_ID_EXTRA, sample.contentId) .putExtra(PlayerActivity.CONTENT_TYPE_EXTRA, sample.type); startActivity(mpdIntent); }
private void onSampleSelected(Sample sample) { if (Util.SDK_INT < 18 && sample.isEncypted) { Toast.makeText(getApplicationContext(), R.string.drm_not_supported, Toast.LENGTH_SHORT) .show(); return; } Class<?> playerActivityClass = sample.fullPlayer ? FullPlayerActivity.class : SimplePlayerActivity.class; Intent mpdIntent = new Intent(this, playerActivityClass) .setData(Uri.parse(sample.uri)) .putExtra(DemoUtil.CONTENT_ID_EXTRA, sample.contentId) .putExtra(DemoUtil.CONTENT_TYPE_EXTRA, sample.type); startActivity(mpdIntent); }
@Override public int getItemViewType(int position) { return (getItem(position) instanceof Sample) ? 1 : 0; }