List of usage examples for android.view ViewGroup removeAllViews
public void removeAllViews()
From source file:de.stkl.gbgvertretungsplan.fragments.MainFragment.java
private void fillTable(View view, SubstitutionTable.Table day) { NavigationDrawerFragment ndf = mCallback.getNavigationDrawerFragment(); NavigationListAdapter.SubItem o = (NavigationListAdapter.SubItem) ndf.getItemByCId(CId); TextView textPlaceholder = (TextView) view.findViewById(R.id.placeholder); TableFixHeaders tableFixHeaders = (TableFixHeaders) view.findViewById(R.id.table2); TextView updateTime = (TextView) view.findViewById(R.id.updateTime); // init values SubstitutionTable.Table newDay;/* ww w . j a v a 2 s. com*/ // filter, if a particular class is selected if (o != null) newDay = Storage.filter(day, Storage.FilterType.FILTER_CLASS_TEACHER, o.text); else newDay = Storage.filter(day, Storage.FilterType.FILTER_NONE, null); // display substitution info only if display width is greater than treshold int width; int threshold = getResources().getDimensionPixelSize(R.dimen.table_substitutioninfo_threshold); // LayoutMeasureView.w is ALWAYS the width in portrait mode! if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) width = LayoutMeasureView.screenH; else width = LayoutMeasureView.screenW; if (width < threshold) newDay.generalData.flags.add(SubstitutionTable.GeneralData.Flags.HIDE_SUBSTITUTIONINFO); int columnWidth[] = new int[day.getHeaderCount()]; if (newDay.getEntryCount() > 0) { SubstitutionPlanAdapter adapter = new SubstitutionPlanAdapter(getActivity(), newDay, columnWidth); // initial calculation of column width for (int i = 0; i < day.getHeaderCount(); i++) { columnWidth[i] = calculateTableColWidth(newDay, adapter, i, tableFixHeaders); } // assign adapter tableFixHeaders.setAdapter(adapter); tableFixHeaders.setVisibility(View.VISIBLE); textPlaceholder.setVisibility(View.GONE); } else { tableFixHeaders.setVisibility(View.GONE); textPlaceholder.setVisibility(View.VISIBLE); } // set update time updateTime.setText(newDay.generalData.updateTime); ViewGroup container = (ViewGroup) view.findViewById(R.id.dailyInfos); container.removeAllViews(); // set daily infos int i = 0; int c = newDay.generalData.dailyInfos.size(); View v = null; for (SubstitutionTable.GeneralData.DailyInfo info : newDay.generalData.dailyInfos) { v = getActivity().getLayoutInflater().inflate(R.layout.table_dailyinfo, container, false); TextView tvTitle = (TextView) v.findViewById(R.id.title); TextView tvDescription = (TextView) v.findViewById(R.id.description); tvTitle.setText(info.title); if (info.description.equals("")) { ((ViewGroup) v).removeViewInLayout(tvDescription); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) tvTitle.getLayoutParams(); params.weight = 1f; } else tvDescription.setText(info.description); container.addView(v); i++; } }
From source file:net.abcdroid.devfest12.ui.SessionDetailFragment.java
/** * Handle {@link SessionsQuery} {@link Cursor}. *//*from w ww . j ava 2 s. com*/ private void onSessionQueryComplete(Cursor cursor) { mSessionCursor = true; if (!cursor.moveToFirst()) { return; } mTitleString = cursor.getString(SessionsQuery.TITLE); // Format time block this session occupies mSessionBlockStart = cursor.getLong(SessionsQuery.BLOCK_START); mSessionBlockEnd = cursor.getLong(SessionsQuery.BLOCK_END); mRoomName = cursor.getString(SessionsQuery.ROOM_NAME); final String subtitle = UIUtils.formatSessionSubtitle(mTitleString, mSessionBlockStart, mSessionBlockEnd, mRoomName, getActivity()); mTitle.setText(mTitleString); mUrl = cursor.getString(SessionsQuery.URL); if (TextUtils.isEmpty(mUrl)) { mUrl = ""; } mHashtags = cursor.getString(SessionsQuery.HASHTAGS); if (!TextUtils.isEmpty(mHashtags)) { enableSocialStreamMenuItemDeferred(); } mRoomId = cursor.getString(SessionsQuery.ROOM_ID); setupShareMenuItemDeferred(); showStarredDeferred(mInitStarred = (cursor.getInt(SessionsQuery.STARRED) != 0)); final String sessionAbstract = cursor.getString(SessionsQuery.ABSTRACT); if (!TextUtils.isEmpty(sessionAbstract)) { UIUtils.setTextMaybeHtml(mAbstract, sessionAbstract); mAbstract.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { mAbstract.setVisibility(View.GONE); } mPlusOneButton.setSize(PlusOneButton.Size.TALL); String url = cursor.getString(SessionsQuery.URL); if (TextUtils.isEmpty(url)) { mPlusOneButton.setVisibility(View.GONE); } else { mPlusOneButton.setUrl(url); } final View requirementsBlock = mRootView.findViewById(R.id.session_requirements_block); final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS); if (!TextUtils.isEmpty(sessionRequirements)) { UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements); requirementsBlock.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { requirementsBlock.setVisibility(View.GONE); } // Show empty message when all data is loaded, and nothing to show if (mSpeakersCursor && !mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } ViewGroup linksContainer = (ViewGroup) mRootView.findViewById(R.id.links_container); linksContainer.removeAllViews(); LayoutInflater inflater = getLayoutInflater(null); boolean hasLinks = false; final Context context = mRootView.getContext(); // Render I/O live link final boolean hasLivestream = !TextUtils.isEmpty(cursor.getString(SessionsQuery.LIVESTREAM_URL)); long currentTimeMillis = UIUtils.getCurrentTime(context); if (UIUtils.hasHoneycomb() // Needs Honeycomb+ for the live stream && hasLivestream && currentTimeMillis > mSessionBlockStart && currentTimeMillis <= mSessionBlockEnd) { hasLinks = true; // Create the link item ViewGroup linkContainer = (ViewGroup) inflater.inflate(R.layout.list_item_session_link, linksContainer, false); ((TextView) linkContainer.findViewById(R.id.link_text)).setText(R.string.session_link_livestream); linkContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { fireLinkEvent(R.string.session_link_livestream); Intent livestreamIntent = new Intent(Intent.ACTION_VIEW, mSessionUri); livestreamIntent.setClass(context, SessionLivestreamActivity.class); startActivity(livestreamIntent); } }); linksContainer.addView(linkContainer); } // Render normal links for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) { final String linkUrl = cursor.getString(SessionsQuery.LINKS_INDICES[i]); if (!TextUtils.isEmpty(linkUrl)) { hasLinks = true; // Create the link item ViewGroup linkContainer = (ViewGroup) inflater.inflate(R.layout.list_item_session_link, linksContainer, false); ((TextView) linkContainer.findViewById(R.id.link_text)).setText(SessionsQuery.LINKS_TITLES[i]); final int linkTitleIndex = i; linkContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { fireLinkEvent(SessionsQuery.LINKS_TITLES[linkTitleIndex]); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl)); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); UIUtils.safeOpenLink(context, intent); } }); linksContainer.addView(linkContainer); } } // Show past/present/future and livestream status for this block. UIUtils.updateTimeAndLivestreamBlockUI(context, mSessionBlockStart, mSessionBlockEnd, hasLivestream, null, null, mSubtitle, subtitle); mRootView.findViewById(R.id.session_links_block).setVisibility(hasLinks ? View.VISIBLE : View.GONE); EasyTracker.getTracker().trackView("Session: " + mTitleString); LOGD("Tracker", "Session: " + mTitleString); }
From source file:com.gh4a.fragment.PullRequestFragment.java
private void fillStatus(List<CommitStatus> statuses) { Map<String, CommitStatus> statusByContext = new HashMap<>(); for (CommitStatus status : statuses) { if (!statusByContext.containsKey(status.getContext())) { statusByContext.put(status.getContext(), status); }/*from w ww . jav a 2 s. c om*/ } final int statusIconDrawableAttrId, statusLabelResId; if (PullRequest.MERGEABLE_STATE_CLEAN.equals(mPullRequest.getMergeableState())) { statusIconDrawableAttrId = R.attr.pullRequestMergeOkIcon; statusLabelResId = R.string.pull_merge_status_clean; } else if (PullRequest.MERGEABLE_STATE_UNSTABLE.equals(mPullRequest.getMergeableState())) { statusIconDrawableAttrId = R.attr.pullRequestMergeUnstableIcon; statusLabelResId = R.string.pull_merge_status_unstable; } else if (PullRequest.MERGEABLE_STATE_DIRTY.equals(mPullRequest.getMergeableState())) { statusIconDrawableAttrId = R.attr.pullRequestMergeDirtyIcon; statusLabelResId = R.string.pull_merge_status_dirty; } else if (statusByContext.isEmpty()) { // unknwon status, no commit statuses -> nothing to display return; } else { statusIconDrawableAttrId = R.attr.pullRequestMergeUnknownIcon; statusLabelResId = R.string.pull_merge_status_unknown; } ImageView statusIcon = (ImageView) mListHeaderView.findViewById(R.id.iv_merge_status_icon); statusIcon.setImageResource(UiUtils.resolveDrawable(getActivity(), statusIconDrawableAttrId)); TextView statusLabel = (TextView) mListHeaderView.findViewById(R.id.merge_status_label); statusLabel.setText(statusLabelResId); ViewGroup statusContainer = (ViewGroup) mListHeaderView.findViewById(R.id.merge_commit_status_container); LayoutInflater inflater = getLayoutInflater(null); statusContainer.removeAllViews(); for (CommitStatus status : statusByContext.values()) { View statusRow = inflater.inflate(R.layout.row_commit_status, statusContainer, false); String state = status.getState(); final int iconDrawableAttrId; if (CommitStatus.STATE_ERROR.equals(state) || CommitStatus.STATE_FAILURE.equals(state)) { iconDrawableAttrId = R.attr.commitStatusFailIcon; } else if (CommitStatus.STATE_SUCCESS.equals(state)) { iconDrawableAttrId = R.attr.commitStatusOkIcon; } else { iconDrawableAttrId = R.attr.commitStatusUnknownIcon; } ImageView icon = (ImageView) statusRow.findViewById(R.id.iv_status_icon); icon.setImageResource(UiUtils.resolveDrawable(getActivity(), iconDrawableAttrId)); TextView context = (TextView) statusRow.findViewById(R.id.tv_context); context.setText(status.getContext()); TextView description = (TextView) statusRow.findViewById(R.id.tv_desc); description.setText(status.getDescription()); statusContainer.addView(statusRow); } mListHeaderView.findViewById(R.id.merge_commit_no_status) .setVisibility(statusByContext.isEmpty() ? View.VISIBLE : View.GONE); mListHeaderView.findViewById(R.id.merge_status_container).setVisibility(View.VISIBLE); }
From source file:org.hfoss.posit.android.functionplugin.reminder.SetReminder.java
/** * Called from FindActivity.onActivityResult(). Used to * update the Find's View, specifically the date, lat, long, * and alarm icon fields./*from ww w . j a va 2s. c o m*/ * * @param context, the calling Activity * @param find, the current Find * @param view, the FindActivity's content view * @param intent, the Intent that is passed to the menu activity */ public void onActivityResultCallback(Context context, Find find, View view, Intent intent) { Log.i(TAG, "onActivityResultCallbac"); // Intent is NOT null, meaning it includes reminder // date and location information set by the user if (intent != null) { Bundle bundle = intent.getExtras(); // Get date, longitude, and latitude String date = bundle.getString(Find.TIME); Double longitude = bundle.getDouble(Find.LONGITUDE); Double latitude = bundle.getDouble(Find.LATITUDE); TextView tv = (TextView) view.findViewById(R.id.isAdhocTextView); Integer is_adhoc = bundle.getInt(Find.IS_ADHOC); Log.i(TAG, "is_adhoc = " + is_adhoc); if (tv != null) { Log.i(TAG, "Setting isAdhocTextView to " + is_adhoc); tv.setText("" + is_adhoc); } // Display user specified longitude and latitude tv = (TextView) view.findViewById(R.id.longitudeValueTextView); tv.setText(String.valueOf(longitude)); tv = (TextView) view.findViewById(R.id.latitudeValueTextView); tv.setText(String.valueOf(latitude)); // Remove the old row that displays time and replace it // with a new row that include an alarm clock icon to // visually indicate this find has a reminder attached ViewGroup parent = (ViewGroup) view.findViewById(R.id.timeValueTextView).getParent(); parent.removeAllViews(); ImageView alarmIcon = new ImageView(context); alarmIcon.setImageResource(R.drawable.reminder_alarm); TableRow.LayoutParams lp1 = new TableRow.LayoutParams(30, 30); lp1.setMargins(0, 6, 80, 0); parent.addView(alarmIcon, lp1); TextView mCloneTimeTV = new TextView(context); mCloneTimeTV.setId(R.id.timeValueTextView); mCloneTimeTV.setText(date); mCloneTimeTV.setTextSize(12); TextView mTimeTV = (TextView) view.findViewById(R.id.timeValueTextView); mTimeTV = mCloneTimeTV; TableRow.LayoutParams lp2 = new TableRow.LayoutParams(); lp2.setMargins(6, 6, 0, 0); parent.addView(mTimeTV, lp2); } }
From source file:org.sufficientlysecure.keychain.ui.SettingsActivity.java
/** * Hack to get Toolbar in PreferenceActivity. See http://stackoverflow.com/a/26614696 *//* w w w. ja va 2 s . c o m*/ private void setupToolbar() { ViewGroup root = (ViewGroup) findViewById(android.R.id.content); LinearLayout content = (LinearLayout) root.getChildAt(0); LinearLayout toolbarContainer = (LinearLayout) View.inflate(this, R.layout.preference_toolbar, null); root.removeAllViews(); toolbarContainer.addView(content); root.addView(toolbarContainer); Toolbar toolbar = (Toolbar) toolbarContainer.findViewById(R.id.toolbar); toolbar.setTitle(R.string.title_preferences); // noinspection deprecation, TODO use alternative in API level 21 toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp)); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //What to do on back clicked finish(); } }); }
From source file:ua.org.gdg.devfest.iosched.ui.SessionDetailFragment.java
/** * Handle {@link SessionsQuery} {@link Cursor}. *///from w w w . ja va2 s . c o m private void onSessionQueryComplete(Cursor cursor) { mSessionCursor = true; if (!cursor.moveToFirst()) { if (isAdded()) { // TODO: Remove this in favor of a callbacks interface that the activity // can implement. getActivity().finish(); } return; } mTitleString = cursor.getString(SessionsQuery.TITLE); // Format time block this session occupies mSessionBlockStart = cursor.getLong(SessionsQuery.BLOCK_START); mSessionBlockEnd = cursor.getLong(SessionsQuery.BLOCK_END); String roomName = cursor.getString(SessionsQuery.ROOM_NAME); final String subtitle = UIUtils.formatSessionSubtitle(mTitleString, mSessionBlockStart, mSessionBlockEnd, roomName, mBuffer, getActivity()); mTitle.setText(mTitleString); mUrl = cursor.getString(SessionsQuery.URL); if (TextUtils.isEmpty(mUrl)) { mUrl = ""; } mHashtags = cursor.getString(SessionsQuery.HASHTAGS); if (!TextUtils.isEmpty(mHashtags)) { enableSocialStreamMenuItemDeferred(); } mRoomId = cursor.getString(SessionsQuery.ROOM_ID); setupShareMenuItemDeferred(); showStarredDeferred(mInitStarred = (cursor.getInt(SessionsQuery.STARRED) != 0), false); final String sessionAbstract = cursor.getString(SessionsQuery.ABSTRACT); if (!TextUtils.isEmpty(sessionAbstract)) { UIUtils.setTextMaybeHtml(mAbstract, sessionAbstract); mAbstract.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { mAbstract.setVisibility(View.GONE); } final View requirementsBlock = mRootView.findViewById(R.id.session_requirements_block); final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS); if (!TextUtils.isEmpty(sessionRequirements)) { UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements); requirementsBlock.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { requirementsBlock.setVisibility(View.GONE); } // Show empty message when all data is loaded, and nothing to show if (mSpeakersCursor && !mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } // Compile list of links (submit feedback, and normal links) ViewGroup linkContainer = (ViewGroup) mRootView.findViewById(R.id.links_container); linkContainer.removeAllViews(); final Context context = mRootView.getContext(); List<Pair<Integer, Intent>> links = new ArrayList<Pair<Integer, Intent>>(); // Add session feedback link if (getResources().getBoolean(R.bool.has_feedback_enabled)) { links.add(new Pair<Integer, Intent>(R.string.session_feedback_submitlink, new Intent(Intent.ACTION_VIEW, mSessionUri, getActivity(), SessionFeedbackActivity.class))); } for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) { final String linkUrl = cursor.getString(SessionsQuery.LINKS_INDICES[i]); if (TextUtils.isEmpty(linkUrl)) { continue; } links.add(new Pair<Integer, Intent>(SessionsQuery.LINKS_TITLES[i], new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl)) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET))); } // Render links if (links.size() > 0) { LayoutInflater inflater = LayoutInflater.from(context); int columns = context.getResources().getInteger(R.integer.links_columns); LinearLayout currentLinkRowView = null; for (int i = 0; i < links.size(); i++) { final Pair<Integer, Intent> link = links.get(i); // Create link view TextView linkView = (TextView) inflater.inflate(R.layout.list_item_session_link, linkContainer, false); linkView.setText(getString(link.first)); linkView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { fireLinkEvent(link.first); try { startActivity(link.second); } catch (ActivityNotFoundException ignored) { } } }); // Place it inside a container if (columns == 1) { linkContainer.addView(linkView); } else { // create a new link row if (i % columns == 0) { currentLinkRowView = (LinearLayout) inflater.inflate(R.layout.include_link_row, linkContainer, false); currentLinkRowView.setWeightSum(columns); linkContainer.addView(currentLinkRowView); } ((LinearLayout.LayoutParams) linkView.getLayoutParams()).width = 0; ((LinearLayout.LayoutParams) linkView.getLayoutParams()).weight = 1; currentLinkRowView.addView(linkView); } } mRootView.findViewById(R.id.session_links_header).setVisibility(View.VISIBLE); mRootView.findViewById(R.id.links_container).setVisibility(View.VISIBLE); } else { mRootView.findViewById(R.id.session_links_header).setVisibility(View.GONE); mRootView.findViewById(R.id.links_container).setVisibility(View.GONE); } // Show past/present/future and livestream status for this block. UIUtils.updateTimeBlockUI(context, mSessionBlockStart, mSessionBlockEnd, null, mSubtitle, subtitle); LOGD("Tracker", "Session: " + mTitleString); }
From source file:com.conferenceengineer.android.iosched.ui.SessionDetailFragment.java
/** * Handle {@link SessionsQuery} {@link Cursor}. *///from w w w.jav a 2 s .com private void onSessionQueryComplete(Cursor cursor) { mSessionCursor = true; if (!cursor.moveToFirst()) { if (isAdded()) { // TODO: Remove this in favor of a callbacks interface that the activity // can implement. getActivity().finish(); } return; } mTitleString = cursor.getString(SessionsQuery.TITLE); // Format time block this session occupies mType = cursor.getString(SessionsQuery.TYPE); mSessionBlockStart = cursor.getLong(SessionsQuery.BLOCK_START); mSessionBlockEnd = cursor.getLong(SessionsQuery.BLOCK_END); String roomName = cursor.getString(SessionsQuery.ROOM_NAME); final String subtitle = UIUtils.formatSessionSubtitle(mTitleString, mSessionBlockStart, mSessionBlockEnd, roomName, mBuffer, getActivity()); mTitle.setText(mTitleString); mUrl = cursor.getString(SessionsQuery.URL); if (TextUtils.isEmpty(mUrl)) { mUrl = ""; } mHashtags = cursor.getString(SessionsQuery.HASHTAGS); if (!TextUtils.isEmpty(mHashtags)) { enableSocialStreamMenuItemDeferred(); } mRoomId = cursor.getString(SessionsQuery.ROOM_ID); setupShareMenuItemDeferred(); showStarredDeferred(mInitStarred = (cursor.getInt(SessionsQuery.STARRED) != 0), false); final String sessionAbstract = cursor.getString(SessionsQuery.ABSTRACT); if (!TextUtils.isEmpty(sessionAbstract)) { UIUtils.setTextMaybeHtml(mAbstract, sessionAbstract); mAbstract.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { mAbstract.setVisibility(View.GONE); } final View requirementsBlock = mRootView.findViewById(R.id.session_requirements_block); final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS); if (!TextUtils.isEmpty(sessionRequirements)) { UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements); requirementsBlock.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { requirementsBlock.setVisibility(View.GONE); } // Show empty message when all data is loaded, and nothing to show if (mSpeakersCursor && !mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } // Compile list of links (submit feedback, and normal links) ViewGroup linkContainer = (ViewGroup) mRootView.findViewById(R.id.links_container); linkContainer.removeAllViews(); final Context context = mRootView.getContext(); List<Pair<Integer, Intent>> links = new ArrayList<Pair<Integer, Intent>>(); // Add session feedback link if (getResources().getBoolean(R.bool.has_session_feedback_enabled)) { links.add(new Pair<Integer, Intent>(R.string.session_feedback_submitlink, new Intent(Intent.ACTION_VIEW, mSessionUri, getActivity(), SessionFeedbackActivity.class))); } for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) { final String linkUrl = cursor.getString(SessionsQuery.LINKS_INDICES[i]); if (TextUtils.isEmpty(linkUrl)) { continue; } links.add(new Pair<Integer, Intent>(SessionsQuery.LINKS_TITLES[i], new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl)) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET))); } // Render links if (links.size() > 0) { LayoutInflater inflater = LayoutInflater.from(context); int columns = context.getResources().getInteger(R.integer.links_columns); LinearLayout currentLinkRowView = null; for (int i = 0; i < links.size(); i++) { final Pair<Integer, Intent> link = links.get(i); // Create link view TextView linkView = (TextView) inflater.inflate(R.layout.list_item_session_link, linkContainer, false); linkView.setText(getString(link.first)); linkView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { fireLinkEvent(link.first); try { startActivity(link.second); } catch (ActivityNotFoundException ignored) { } } }); // Place it inside a container if (columns == 1) { linkContainer.addView(linkView); } else { // create a new link row if (i % columns == 0) { currentLinkRowView = (LinearLayout) inflater.inflate(R.layout.include_link_row, linkContainer, false); currentLinkRowView.setWeightSum(columns); linkContainer.addView(currentLinkRowView); } ((LinearLayout.LayoutParams) linkView.getLayoutParams()).width = 0; ((LinearLayout.LayoutParams) linkView.getLayoutParams()).weight = 1; currentLinkRowView.addView(linkView); } } mRootView.findViewById(R.id.session_links_header).setVisibility(View.VISIBLE); mRootView.findViewById(R.id.links_container).setVisibility(View.VISIBLE); } else { mRootView.findViewById(R.id.session_links_header).setVisibility(View.GONE); mRootView.findViewById(R.id.links_container).setVisibility(View.GONE); } // Show past/present/future and livestream status for this block. UIUtils.updateTimeBlockUI(context, mSessionBlockStart, mSessionBlockEnd, null, mSubtitle, subtitle); LOGD("Tracker", "Session: " + mTitleString); }
From source file:com.gdgdevfest.android.apps.devfestbcn.ui.SessionDetailFragment.java
/** * Handle {@link SessionsQuery} {@link Cursor}. *///from ww w . ja va2s . c o m private void onSessionQueryComplete(Cursor cursor) { mSessionCursor = true; if (!cursor.moveToFirst()) { if (isAdded()) { // TODO: Remove this in favor of a callbacks interface that the activity // can implement. getActivity().finish(); } return; } mTitleString = cursor.getString(SessionsQuery.TITLE); // Format time block this session occupies mSessionBlockStart = cursor.getLong(SessionsQuery.BLOCK_START); mSessionBlockEnd = cursor.getLong(SessionsQuery.BLOCK_END); String roomName = cursor.getString(SessionsQuery.ROOM_NAME); final String subtitle = UIUtils.formatSessionSubtitle(mTitleString, mSessionBlockStart, mSessionBlockEnd, roomName, mBuffer, getActivity()); mTitle.setText(mTitleString); mUrl = cursor.getString(SessionsQuery.URL); if (TextUtils.isEmpty(mUrl)) { mUrl = ""; } mHashtags = cursor.getString(SessionsQuery.HASHTAGS); if (!TextUtils.isEmpty(mHashtags)) { enableSocialStreamMenuItemDeferred(); } mRoomId = cursor.getString(SessionsQuery.ROOM_ID); setupShareMenuItemDeferred(); showStarredDeferred(mInitStarred = (cursor.getInt(SessionsQuery.STARRED) != 0), false); final String sessionAbstract = cursor.getString(SessionsQuery.ABSTRACT); if (!TextUtils.isEmpty(sessionAbstract)) { UIUtils.setTextMaybeHtml(mAbstract, sessionAbstract); mAbstract.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { mAbstract.setVisibility(View.GONE); } updatePlusOneButton(); final View requirementsBlock = mRootView.findViewById(R.id.session_requirements_block); final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS); if (!TextUtils.isEmpty(sessionRequirements)) { UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements); requirementsBlock.setVisibility(View.VISIBLE); mHasSummaryContent = true; } else { requirementsBlock.setVisibility(View.GONE); } // Show empty message when all data is loaded, and nothing to show if (mSpeakersCursor && !mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } // Compile list of links (I/O live link, submit feedback, and normal links) ViewGroup linkContainer = (ViewGroup) mRootView.findViewById(R.id.links_container); linkContainer.removeAllViews(); final Context context = mRootView.getContext(); List<Pair<Integer, Intent>> links = new ArrayList<Pair<Integer, Intent>>(); final boolean hasLivestream = !TextUtils.isEmpty(cursor.getString(SessionsQuery.LIVESTREAM_URL)); long currentTimeMillis = UIUtils.getCurrentTime(context); if (UIUtils.hasHoneycomb() // Needs Honeycomb+ for the live stream && hasLivestream && currentTimeMillis > mSessionBlockStart && currentTimeMillis <= mSessionBlockEnd) { links.add(new Pair<Integer, Intent>(R.string.session_link_livestream, new Intent(Intent.ACTION_VIEW, mSessionUri).setClass(context, SessionLivestreamActivity.class))); } // Add session feedback link // links.add(new Pair<Integer, Intent>( // R.string.session_feedback_submitlink, // new Intent(Intent.ACTION_VIEW, mSessionUri, getActivity(), SessionFeedbackActivity.class) // )); for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) { final String linkUrl = cursor.getString(SessionsQuery.LINKS_INDICES[i]); if (TextUtils.isEmpty(linkUrl)) { continue; } links.add(new Pair<Integer, Intent>(SessionsQuery.LINKS_TITLES[i], new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl)) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET))); } // Render links if (links.size() > 0) { LayoutInflater inflater = LayoutInflater.from(context); int columns = context.getResources().getInteger(R.integer.links_columns); LinearLayout currentLinkRowView = null; for (int i = 0; i < links.size(); i++) { final Pair<Integer, Intent> link = links.get(i); // Create link view TextView linkView = (TextView) inflater.inflate(R.layout.list_item_session_link, linkContainer, false); linkView.setText(getString(link.first)); linkView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { fireLinkEvent(link.first); try { startActivity(link.second); } catch (ActivityNotFoundException ignored) { } } }); // Place it inside a container if (columns == 1) { linkContainer.addView(linkView); } else { // create a new link row if (i % columns == 0) { currentLinkRowView = (LinearLayout) inflater.inflate(R.layout.include_link_row, linkContainer, false); currentLinkRowView.setWeightSum(columns); linkContainer.addView(currentLinkRowView); } ((LinearLayout.LayoutParams) linkView.getLayoutParams()).width = 0; ((LinearLayout.LayoutParams) linkView.getLayoutParams()).weight = 1; currentLinkRowView.addView(linkView); } } mRootView.findViewById(R.id.session_links_header).setVisibility(View.VISIBLE); mRootView.findViewById(R.id.links_container).setVisibility(View.VISIBLE); } else { mRootView.findViewById(R.id.session_links_header).setVisibility(View.GONE); mRootView.findViewById(R.id.links_container).setVisibility(View.GONE); } // Show past/present/future and livestream status for this block. UIUtils.updateTimeAndLivestreamBlockUI(context, mSessionBlockStart, mSessionBlockEnd, hasLivestream, null, mSubtitle, subtitle); EasyTracker.getTracker().sendView("Session: " + mTitleString); LOGD("Tracker", "Session: " + mTitleString); }
From source file:lewa.support.v7.app.ActionBarActivityDelegateBase.java
@Override public void setContentView(View v) { ensureSubDecor();/*from ww w .j av a 2 s . c om*/ if (mHasActionBar) { ViewGroup contentParent = (ViewGroup) mActivity.findViewById(android.R.id.content); contentParent.removeAllViews(); contentParent.addView(v); } else { mActivity.superSetContentView(v); } mActivity.onSupportContentChanged(); }
From source file:lewa.support.v7.app.ActionBarActivityDelegateBase.java
@Override public void setContentView(int resId) { ensureSubDecor();/*from www . ja va2 s . c om*/ if (mHasActionBar) { ViewGroup contentParent = (ViewGroup) mActivity.findViewById(android.R.id.content); contentParent.removeAllViews(); mActivity.getLayoutInflater().inflate(resId, contentParent); } else { mActivity.superSetContentView(resId); } mActivity.onSupportContentChanged(); }