List of usage examples for android.view ViewGroup removeViewAt
public void removeViewAt(int index)
From source file:org.orange.querysystem.content.ListPostsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View layout = super.onCreateView(inflater, container, savedInstanceState); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { View lv = layout.findViewById(android.R.id.list); ViewGroup parent = (ViewGroup) lv.getParent(); // Remove ListView and add CustomView in its place int lvIndex = parent.indexOfChild(lv); parent.removeViewAt(lvIndex); mLinearLayout = new LinearLayout(getActivity()); mLinearLayout.setOrientation(LinearLayout.VERTICAL); if (mFilter != null) { insertSearchEditText().setText(mFilter); }//from w w w . j av a 2 s . com mLinearLayout.addView(lv); parent.addView(mLinearLayout, lvIndex, lv.getLayoutParams()); } return layout; }
From source file:wseemann.media.demo.FMMRFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View layout = super.onCreateView(inflater, container, savedInstanceState); ListView lv = (ListView) layout.findViewById(android.R.id.list); ViewGroup parent = (ViewGroup) lv.getParent(); View v = inflater.inflate(R.layout.fragment, container, false); // Remove ListView and add my view in its place int lvIndex = parent.indexOfChild(lv); parent.removeViewAt(lvIndex); parent.addView(v, lvIndex, lv.getLayoutParams()); final EditText uriText = (EditText) v.findViewById(R.id.uri); // Uncomment for debugging //uriText.setText("http://..."); //uriText.setText("http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_60fps_stereo_abl.mp4"); //https://ia700401.us.archive.org/19/items/ksnn_compilation_master_the_internet/ksnn_compilation_master_the_internet_512kb.mp4 Intent intent = getActivity().getIntent(); // Populate the edit text field with the intent uri, if available Uri uri = intent.getData();// w w w. j a va 2s . c o m if (intent.getExtras() != null && intent.getExtras().getCharSequence(Intent.EXTRA_TEXT) != null) { uri = Uri.parse(intent.getExtras().getCharSequence(Intent.EXTRA_TEXT).toString()); } if (uri != null) { try { uriText.setText(URLDecoder.decode(uri.toString(), "UTF-8")); } catch (UnsupportedEncodingException e1) { } } getActivity().setIntent(null); Button goButton = (Button) v.findViewById(R.id.go_button); goButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Clear the error message uriText.setError(null); // Hide the keyboard InputMethodManager imm = (InputMethodManager) FMMRFragment.this.getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(uriText.getWindowToken(), 0); String uri = uriText.getText().toString(); if (uri.equals("")) { uriText.setError(getString(R.string.uri_error)); return; } // Start out with a progress indicator. setListShown(false); String uriString = uriText.getText().toString(); Bundle bundle = new Bundle(); try { bundle.putString("uri", URLDecoder.decode(uriString, "UTF-8")); mId++; FMMRFragment.this.getLoaderManager().initLoader(mId, bundle, FMMRFragment.this); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } // mAdapter.add(new Metadata("test", "test")); // mAdapter.notifyDataSetChanged(); } }); return layout; }
From source file:org.sufficientlysecure.keychain.remote.ui.AccountsListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View layout = super.onCreateView(inflater, container, savedInstanceState); ListView lv = (ListView) layout.findViewById(android.R.id.list); ViewGroup parent = (ViewGroup) lv.getParent(); /*//w w w. jav a 2 s . com * http://stackoverflow.com/a/15880684 * Remove ListView and add FixedListView in its place. * This is done here programatically to be still able to use the progressBar of ListFragment. * * We want FixedListView to be able to put this ListFragment inside a ScrollView */ int lvIndex = parent.indexOfChild(lv); parent.removeViewAt(lvIndex); FixedListView newLv = new FixedListView(getActivity()); newLv.setId(android.R.id.list); parent.addView(newLv, lvIndex, lv.getLayoutParams()); return layout; }
From source file:connect.app.com.connect.calendar.DayPickerView.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public DayPickerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); // final TypedArray a = context.obtainStyledAttributes(attrs, // R.styleable.CalendarView, defStyleAttr, defStyleRes); ///*from ww w.j a v a 2s . com*/ // final int firstDayOfWeek = a.getInt(R.styleable.CalendarView_firstDayOfWeek, // LocaleData.get(Locale.getDefault()).firstDayOfWeek); final int firstDayOfWeek = 1; // // final String minDate = a.getString(R.styleable.CalendarView_minDate); final String minDate = null; // final String maxDate = a.getString(R.styleable.CalendarView_maxDate); final String maxDate = null; // // final int monthTextAppearanceResId = a.getResourceId( // R.styleable.CalendarView_monthTextAppearance, // R.style.TextAppearance_Material_Widget_Calendar_Month); // final int dayOfWeekTextAppearanceResId = a.getResourceId( // R.styleable.CalendarView_weekDayTextAppearance, // R.style.TextAppearance_Material_Widget_Calendar_DayOfWeek); // final int dayTextAppearanceResId = a.getResourceId( // R.styleable.CalendarView_dateTextAppearance, // R.style.TextAppearance_Material_Widget_Calendar_Day); // // final ColorStateList daySelectorColor = a.getColorStateList( // R.styleable.CalendarView_daySelectorColor); // // a.recycle(); // Set up adapter. mAdapter = new DayPickerPagerAdapter(context, R.layout.layout_test, com.retrofit.R.id.scrollView); // mAdapter.setMonthTextAppearance(monthTextAppearanceResId); // mAdapter.setDayOfWeekTextAppearance(dayOfWeekTextAppearanceResId); // mAdapter.setDayTextAppearance(dayTextAppearanceResId); // mAdapter.setDaySelectorColor(daySelectorColor); final LayoutInflater inflater = LayoutInflater.from(context); final ViewGroup content = (ViewGroup) inflater.inflate(DEFAULT_LAYOUT, this, false); // Transfer all children from content to here. while (content.getChildCount() > 0) { final View child = content.getChildAt(0); content.removeViewAt(0); addView(child); } mPrevButton = (ImageButton) findViewById(R.id.prev); mPrevButton.setOnClickListener(mOnClickListener); mNextButton = (ImageButton) findViewById(R.id.next); mNextButton.setOnClickListener(mOnClickListener); mViewPager = (ViewPager) findViewById(R.id.day_picker_view_pager); mViewPager.setAdapter(mAdapter); mViewPager.setOnPageChangeListener(mOnPageChangedListener); // Proxy the month text color into the previous and next buttons. // if (monthTextAppearanceResId != 0) { // final TypedArray ta = mContext.obtainStyledAttributes(null, // ATTRS_TEXT_COLOR, 0, monthTextAppearanceResId); // final ColorStateList monthColor = ta.getColorStateList(0); // if (monthColor != null) { // mPrevButton.setImageTintList(monthColor); // mNextButton.setImageTintList(monthColor); // } // ta.recycle(); // } // Set up min and max dates. final Calendar tempDate = Calendar.getInstance(); if (!CalendarView.parseDate(minDate, tempDate)) { tempDate.set(DEFAULT_START_YEAR, Calendar.JANUARY, 1); } final long minDateMillis = tempDate.getTimeInMillis(); if (!CalendarView.parseDate(maxDate, tempDate)) { tempDate.set(DEFAULT_END_YEAR, Calendar.DECEMBER, 31); } final long maxDateMillis = tempDate.getTimeInMillis(); if (maxDateMillis < minDateMillis) { throw new IllegalArgumentException("maxDate must be >= minDate"); } final long setDateMillis = MathUtils.constrain(System.currentTimeMillis(), minDateMillis, maxDateMillis); setFirstDayOfWeek(firstDayOfWeek); setMinDate(minDateMillis); setMaxDate(maxDateMillis); setDate(setDateMillis, false); // Proxy selection callbacks to our own listener. mAdapter.setOnDaySelectedListener(new DayPickerPagerAdapter.OnDaySelectedListener() { @Override public void onDaySelected(DayPickerPagerAdapter adapter, Calendar day) { if (mOnDaySelectedListener != null) { mOnDaySelectedListener.onDaySelected(DayPickerView.this, day); } } }); }
From source file:com.rowland.hashtrace.ui.fragments.subfragment.TweetListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // The ArrayAdapter will take data from a source and use it to populate the ListView it's attached to. mTweetListAdapter = new TweetListAdapter(getActivity(), null, 0); creator = new SwipeMenuCreator() { @Override//from www . j a va 2 s . c o m public void create(SwipeMenu menu) { // create "share" item SwipeMenuItem shareItem = new SwipeMenuItem(getActivity().getApplicationContext()); // set item background shareItem.setBackground(new ColorDrawable(Color.rgb(211, 214, 219))); // set item width shareItem.setWidth(Utility.convertDpToPixel(100, getResources().getDisplayMetrics())); // set icon resource shareItem.setIcon(R.drawable.selector_swipemenuitem_share); // set item title shareItem.setTitle("Share"); // set item title fontsize shareItem.setTitleSize(18); // set item title font color shareItem.setTitleColor(Color.WHITE); // add to menu menu.addMenuItem(shareItem); // create "favour" item SwipeMenuItem favourItem = new SwipeMenuItem(getActivity().getApplicationContext()); // set item background favourItem.setBackground(new ColorDrawable(Color.rgb(211, 214, 219))); // set item width favourItem.setWidth(Utility.convertDpToPixel(100, getResources().getDisplayMetrics())); // set icon resource favourItem.setIcon(R.drawable.selector_swipemenuitem_favorite); // set item title favourItem.setTitle("Like"); // set item title fontsize favourItem.setTitleSize(18); // set item title font color favourItem.setTitleColor(Color.WHITE); // add to menu menu.addMenuItem(favourItem); } }; View rootView = inflater.inflate(R.layout.fragment_tweet_list, container, false); mListView = (SwipeMenuListView) rootView.findViewById(android.R.id.list); ViewGroup parent = (ViewGroup) mListView.getParent(); int lvIndex = parent.indexOfChild(mListView); if (mListView.getParent() != null) { parent.removeViewAt(lvIndex); } mListView.setVisibility(View.GONE); mPullToRefreshListView = new PullToRefreshSwipeMenuListView(getActivity()); mPullToRefreshListView.setLayoutParams(mListView.getLayoutParams()); parent.addView(mPullToRefreshListView, lvIndex, mListView.getLayoutParams()); View emptyView = rootView.findViewById(R.id.empty_text_view); mPullToRefreshListView.setEmptyView(emptyView); mPullToRefreshListView.setAdapter(mTweetListAdapter); mPullToRefreshListView.setMenuCreator(creator); mPullToRefreshListView.setVerticalFadingEdgeEnabled(true); mPullToRefreshListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<SwipeMenuListView>() { @Override public void onRefresh(final PullToRefreshBase<SwipeMenuListView> refreshView) { // Do work to refresh the list here. updateTweet(); // Call onRefreshComplete when the list has been refreshed. refreshView.onRefreshComplete(); //mPullToRefreshListView.onRefreshComplete(); } }); //This somehow refuses to work , I really have no idea why /* mPullToRefreshListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long rowId) { Cursor cursor = mTweetListAdapter.getCursor(); if (cursor != null && cursor.moveToPosition(position)) { ((onTweetItemSelectedCallback) getActivity()).onTweetItemSelected(cursor.getString(COL_TWEET_TEXT_DATE)); Log.d("ROWSELECT", "" + rowId ); } mPosition = position; } });*/ mPullToRefreshListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long rowId) { // Do the onItemLongClick action mPullToRefreshListView.smoothOpenMenu(position); return true; } }); mPullToRefreshListView.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(int position, SwipeMenu menu, int index) { switch (index) { case 0: // Share shareTweet(); break; case 1: // Favourite favouriteTweet(); break; } // false : close the menu; true : not close the menu return false; } }); /** * Add Sound Event Listener */ SoundPullEventListener<SwipeMenuListView> soundListener = new SoundPullEventListener<SwipeMenuListView>( getActivity()); soundListener.addSoundEvent(State.PULL_TO_REFRESH, R.raw.pull_event_mp3); soundListener.addSoundEvent(State.RESET, R.raw.reset_sound_mp3); soundListener.addSoundEvent(State.REFRESHING, R.raw.refreshing_sound_mp3); mPullToRefreshListView.setOnPullEventListener(soundListener); mPullToRefreshListView.setCloseInterpolator(new BounceInterpolator()); // If there's instance state, mine it for useful information. The end-goal here is that // the user never knows that turning their device sideways does crazy lifecycle related things. if (savedInstanceState != null && savedInstanceState.containsKey(SELECTED_KEY)) { // The listview probably hasn't even been populated yet. Actually // perform the swapout in onLoadFinished. mPosition = savedInstanceState.getInt(SELECTED_KEY); } return rootView; }
From source file:com.tr4android.support.extension.picker.date.DayPickerView.java
public DayPickerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DatePickerDialog, defStyleAttr, 0); //TODO: add default style res final int firstDayOfWeek = a.getInt(R.styleable.DatePickerDialog_firstDayOfWeek, Calendar.getInstance(Locale.getDefault()).getFirstDayOfWeek()); final String minDate = a.getString(R.styleable.DatePickerDialog_minDate); final String maxDate = a.getString(R.styleable.DatePickerDialog_maxDate); final int monthTextAppearanceResId = a.getResourceId(R.styleable.DatePickerDialog_monthTextAppearance, R.style.TextAppearance_Material_Widget_Calendar_Month); final int dayOfWeekTextAppearanceResId = a.getResourceId(R.styleable.DatePickerDialog_weekDayTextAppearance, R.style.TextAppearance_Material_Widget_Calendar_DayOfWeek); final int dayTextAppearanceResId = a.getResourceId(R.styleable.DatePickerDialog_dateTextAppearance, R.style.TextAppearance_Material_Widget_Calendar_Day); // Set up day selected color, if available. final ColorStateList daySelectorColor; if (a.hasValue(R.styleable.DatePickerDialog_daySelectorColor)) { daySelectorColor = a.getColorStateList(R.styleable.DatePickerDialog_daySelectorColor); } else {/*from ww w. ja v a 2 s. co m*/ final TypedArray ta = context.obtainStyledAttributes(new int[] { R.attr.colorControlActivated }); daySelectorColor = ta.getColorStateList(0); ta.recycle(); } // Set up day highlight color, if available. final ColorStateList dayHighlightColor; if (a.hasValue(R.styleable.DatePickerDialog_dayHighlightColor)) { dayHighlightColor = a.getColorStateList(R.styleable.DatePickerDialog_dayHighlightColor); } else { final TypedArray ta = context.obtainStyledAttributes(new int[] { R.attr.colorControlHighlight }); dayHighlightColor = ta.getColorStateList(0); ta.recycle(); } a.recycle(); // Set up adapter. mAdapter = new DayPickerPagerAdapter(context, R.layout.day_picker_month_item_material, R.id.month_view); mAdapter.setMonthTextAppearance(monthTextAppearanceResId); mAdapter.setDayOfWeekTextAppearance(dayOfWeekTextAppearanceResId); mAdapter.setDayTextAppearance(dayTextAppearanceResId); mAdapter.setDaySelectorColor(daySelectorColor); mAdapter.setDayHighlightColor(dayHighlightColor); final LayoutInflater inflater = LayoutInflater.from(context); final ViewGroup content = (ViewGroup) inflater.inflate(DEFAULT_LAYOUT, this, false); // Transfer all children from content to here. while (content.getChildCount() > 0) { final View child = content.getChildAt(0); content.removeViewAt(0); addView(child); } mPrevButton = (ImageButton) findViewById(R.id.prev); mPrevButton.setOnClickListener(mOnClickListener); mNextButton = (ImageButton) findViewById(R.id.next); mNextButton.setOnClickListener(mOnClickListener); mViewPager = (ViewPager) findViewById(R.id.day_picker_view_pager); mViewPager.setAdapter(mAdapter); mViewPager.addOnPageChangeListener(mOnPageChangedListener); // Set up background of the previous and next buttons. ViewCompatUtils.setBackground(mPrevButton, PickerThemeUtils.getNavButtonBackground(context)); ViewCompatUtils.setBackground(mNextButton, PickerThemeUtils.getNavButtonBackground(context)); // Set up min and max dates. final Calendar tempDate = Calendar.getInstance(); if (!parseDate(minDate, tempDate)) { tempDate.set(DEFAULT_START_YEAR, Calendar.JANUARY, 1); } final long minDateMillis = tempDate.getTimeInMillis(); if (!parseDate(maxDate, tempDate)) { tempDate.set(DEFAULT_END_YEAR, Calendar.DECEMBER, 31); } final long maxDateMillis = tempDate.getTimeInMillis(); if (maxDateMillis < minDateMillis) { throw new IllegalArgumentException("maxDate must be >= minDate"); } final long setDateMillis = MathUtils.constrain(System.currentTimeMillis(), minDateMillis, maxDateMillis); setFirstDayOfWeek(firstDayOfWeek); setMinDate(minDateMillis); setMaxDate(maxDateMillis); setDate(setDateMillis, false); // Proxy selection callbacks to our own listener. mAdapter.setOnDaySelectedListener(new DayPickerPagerAdapter.OnDaySelectedListener() { @Override public void onDaySelected(DayPickerPagerAdapter adapter, Calendar day) { if (mOnDaySelectedListener != null) { mOnDaySelectedListener.onDaySelected(DayPickerView.this, day); } } }); }
From source file:loon.LGame.java
public void safeguardAndroidADView(android.view.View view) { try {// ww w .ja v a2s.c o m final android.view.ViewGroup vgp = (android.view.ViewGroup) view.getParent().getParent(); if (vgp.getChildAt(1) != null) { vgp.removeViewAt(1); } } catch (Exception ex) { } }
From source file:com.conferenceengineer.android.iosched.ui.SessionDetailFragment.java
private void onSpeakersQueryComplete(Cursor cursor) { mSpeakersCursor = true;//from www .j a va2 s . co m final ViewGroup speakersGroup = (ViewGroup) mRootView.findViewById(R.id.session_speakers_block); // Remove all existing speakers (everything but first child, which is the header) for (int i = speakersGroup.getChildCount() - 1; i >= 1; i--) { speakersGroup.removeViewAt(i); } final LayoutInflater inflater = getActivity().getLayoutInflater(); boolean hasSpeakers = false; while (cursor.moveToNext()) { final String speakerName = cursor.getString(SpeakersQuery.SPEAKER_NAME); if (TextUtils.isEmpty(speakerName)) { continue; } final String speakerImageUrl = cursor.getString(SpeakersQuery.SPEAKER_IMAGE_URL); final String speakerCompany = cursor.getString(SpeakersQuery.SPEAKER_COMPANY); final String speakerUrl = cursor.getString(SpeakersQuery.SPEAKER_URL); final String speakerAbstract = cursor.getString(SpeakersQuery.SPEAKER_ABSTRACT); String speakerHeader = speakerName; if (!TextUtils.isEmpty(speakerCompany)) { speakerHeader += ", " + speakerCompany; } final View speakerView = inflater.inflate(R.layout.speaker_detail, speakersGroup, false); final TextView speakerHeaderView = (TextView) speakerView.findViewById(R.id.speaker_header); final ImageView speakerImageView = (ImageView) speakerView.findViewById(R.id.speaker_image); final TextView speakerAbstractView = (TextView) speakerView.findViewById(R.id.speaker_abstract); if (!TextUtils.isEmpty(speakerImageUrl) && mImageLoader != null) { mImageLoader.get(UIUtils.getConferenceImageUrl(speakerImageUrl), speakerImageView); } speakerHeaderView.setText(speakerHeader); speakerImageView.setContentDescription(getString(R.string.speaker_googleplus_profile, speakerHeader)); UIUtils.setTextMaybeHtml(speakerAbstractView, speakerAbstract); if (!TextUtils.isEmpty(speakerUrl)) { speakerImageView.setEnabled(true); speakerImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Intent speakerProfileIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(speakerUrl)); speakerProfileIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); startActivity(speakerProfileIntent); } }); } else { speakerImageView.setEnabled(false); speakerImageView.setOnClickListener(null); } speakersGroup.addView(speakerView); hasSpeakers = true; mHasSummaryContent = true; } speakersGroup.setVisibility(hasSpeakers ? View.VISIBLE : View.GONE); // Show empty message when all data is loaded, and nothing to show if (mSessionCursor && !mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } }
From source file:com.gdgdevfest.android.apps.devfestbcn.ui.SessionDetailFragment.java
private void onSpeakersQueryComplete(Cursor cursor) { mSpeakersCursor = true;//from w w w.java 2 s .c o m final ViewGroup speakersGroup = (ViewGroup) mRootView.findViewById(R.id.session_speakers_block); // Remove all existing speakers (everything but first child, which is the header) for (int i = speakersGroup.getChildCount() - 1; i >= 1; i--) { speakersGroup.removeViewAt(i); } final LayoutInflater inflater = getActivity().getLayoutInflater(); boolean hasSpeakers = false; while (cursor.moveToNext()) { final String speakerName = cursor.getString(SpeakersQuery.SPEAKER_NAME); if (TextUtils.isEmpty(speakerName)) { continue; } final String speakerImageUrl = cursor.getString(SpeakersQuery.SPEAKER_IMAGE_URL); final String speakerCompany = cursor.getString(SpeakersQuery.SPEAKER_COMPANY); final String speakerUrl = cursor.getString(SpeakersQuery.SPEAKER_URL); final String speakerAbstract = cursor.getString(SpeakersQuery.SPEAKER_ABSTRACT); String speakerHeader = speakerName; if (!TextUtils.isEmpty(speakerCompany)) { speakerHeader += ", " + speakerCompany; } final View speakerView = inflater.inflate(R.layout.speaker_detail, speakersGroup, false); final TextView speakerHeaderView = (TextView) speakerView.findViewById(R.id.speaker_header); final ImageView speakerImageView = (ImageView) speakerView.findViewById(R.id.speaker_image); final TextView speakerAbstractView = (TextView) speakerView.findViewById(R.id.speaker_abstract); if (!TextUtils.isEmpty(speakerImageUrl) && mImageLoader != null) { mImageLoader.get(UIUtils.getConferenceImageUrl(speakerImageUrl), speakerImageView); } speakerHeaderView.setText(speakerHeader); speakerImageView.setContentDescription(getString(R.string.speaker_googleplus_profile, speakerHeader)); UIUtils.setTextMaybeHtml(speakerAbstractView, speakerAbstract); if (!TextUtils.isEmpty(speakerUrl)) { speakerImageView.setEnabled(true); speakerImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Intent speakerProfileIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(speakerUrl)); speakerProfileIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); UIUtils.preferPackageForIntent(getActivity(), speakerProfileIntent, UIUtils.GOOGLE_PLUS_PACKAGE_NAME); startActivity(speakerProfileIntent); } }); } else { speakerImageView.setEnabled(false); speakerImageView.setOnClickListener(null); } speakersGroup.addView(speakerView); hasSpeakers = true; mHasSummaryContent = true; } speakersGroup.setVisibility(hasSpeakers ? View.VISIBLE : View.GONE); // Show empty message when all data is loaded, and nothing to show if (mSessionCursor && !mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } }
From source file:com.google.samples.apps.iosched.session.SessionDetailFragment.java
private void displaySpeakersData(SessionDetailModel data) { final ViewGroup speakersGroup = (ViewGroup) getActivity().findViewById(R.id.session_speakers_block); // Remove all existing speakers (everything but first child, which is the header) for (int i = speakersGroup.getChildCount() - 1; i >= 1; i--) { speakersGroup.removeViewAt(i); }/* w ww. j a v a 2s.c o m*/ final LayoutInflater inflater = getActivity().getLayoutInflater(); boolean hasSpeakers = false; List<SessionDetailModel.Speaker> speakers = data.getSpeakers(); for (final SessionDetailModel.Speaker speaker : speakers) { String speakerHeader = speaker.getName(); if (!TextUtils.isEmpty(speaker.getCompany())) { speakerHeader += ", " + speaker.getCompany(); } final View speakerView = inflater.inflate(R.layout.speaker_detail, speakersGroup, false); final TextView speakerHeaderView = (TextView) speakerView.findViewById(R.id.speaker_header); final ImageView speakerImageView = (ImageView) speakerView.findViewById(R.id.speaker_image); final TextView speakerAbstractView = (TextView) speakerView.findViewById(R.id.speaker_abstract); final ImageView plusOneIcon = (ImageView) speakerView.findViewById(R.id.gplus_icon_box); final ImageView twitterIcon = (ImageView) speakerView.findViewById(R.id.twitter_icon_box); setUpSpeakerSocialIcon(speaker, twitterIcon, speaker.getTwitterUrl(), UIUtils.TWITTER_COMMON_NAME, UIUtils.TWITTER_PACKAGE_NAME); setUpSpeakerSocialIcon(speaker, plusOneIcon, speaker.getPlusoneUrl(), UIUtils.GOOGLE_PLUS_COMMON_NAME, UIUtils.GOOGLE_PLUS_PACKAGE_NAME); // A speaker may have both a Twitter and GPlus page, only a Twitter page or only a // GPlus page, or neither. By default, align the Twitter icon to the right and the GPlus // icon to its left. If only a single icon is displayed, align it to the right. determineSocialIconPlacement(plusOneIcon, twitterIcon); if (!TextUtils.isEmpty(speaker.getImageUrl()) && mSpeakersImageLoader != null) { mSpeakersImageLoader.loadImage(speaker.getImageUrl(), speakerImageView); } speakerHeaderView.setText(speakerHeader); speakerImageView.setContentDescription(getString(R.string.speaker_googleplus_profile, speakerHeader)); UIUtils.setTextMaybeHtml(speakerAbstractView, speaker.getAbstract()); if (!TextUtils.isEmpty(speaker.getUrl())) { speakerImageView.setEnabled(true); speakerImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent speakerProfileIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(speaker.getUrl())); speakerProfileIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); UIUtils.preferPackageForIntent(getActivity(), speakerProfileIntent, UIUtils.GOOGLE_PLUS_PACKAGE_NAME); startActivity(speakerProfileIntent); } }); } else { speakerImageView.setEnabled(false); speakerImageView.setOnClickListener(null); } speakersGroup.addView(speakerView); hasSpeakers = true; } speakersGroup.setVisibility(hasSpeakers ? View.VISIBLE : View.GONE); updateEmptyView(data); }