Example usage for android.widget LinearLayout addView

List of usage examples for android.widget LinearLayout addView

Introduction

In this page you can find the example usage for android.widget LinearLayout addView.

Prototype

public void addView(View child) 

Source Link

Document

Adds a child view.

Usage

From source file:com.keylesspalace.tusky.ComposeActivity.java

private void makeCaptionDialog(QueuedMedia item) {
    LinearLayout dialogLayout = new LinearLayout(this);
    int padding = Utils.dpToPx(this, 8);
    dialogLayout.setPadding(padding, padding, padding, padding);

    dialogLayout.setOrientation(LinearLayout.VERTICAL);
    ImageView imageView = new ImageView(this);

    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

    Picasso.with(this).load(item.uri).resize(displayMetrics.widthPixels, displayMetrics.heightPixels)
            .onlyScaleDown().into(imageView);

    int margin = Utils.dpToPx(this, 4);
    dialogLayout.addView(imageView);
    ((LinearLayout.LayoutParams) imageView.getLayoutParams()).weight = 1;
    imageView.getLayoutParams().height = 0;
    ((LinearLayout.LayoutParams) imageView.getLayoutParams()).setMargins(0, margin, 0, 0);

    EditText input = new EditText(this);
    input.setHint(R.string.hint_describe_for_visually_impaired);
    dialogLayout.addView(input);/*from w  ww.  ja va 2 s  .  com*/
    ((LinearLayout.LayoutParams) input.getLayoutParams()).setMargins(margin, margin, margin, margin);
    input.setLines(1);
    input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
    input.setText(item.description);

    DialogInterface.OnClickListener okListener = (dialog, which) -> {
        mastodonApi.updateMedia(item.id, input.getText().toString()).enqueue(new Callback<Attachment>() {
            @Override
            public void onResponse(@NonNull Call<Attachment> call, @NonNull Response<Attachment> response) {
                Attachment attachment = response.body();
                if (response.isSuccessful() && attachment != null) {
                    item.description = attachment.getDescription();
                    item.preview.setChecked(item.description != null && !item.description.isEmpty());
                    dialog.dismiss();
                } else {
                    showFailedCaptionMessage();
                }
            }

            @Override
            public void onFailure(@NonNull Call<Attachment> call, @NonNull Throwable t) {
                showFailedCaptionMessage();
            }
        });
    };

    AlertDialog dialog = new AlertDialog.Builder(this).setView(dialogLayout)
            .setPositiveButton(android.R.string.ok, okListener).setNegativeButton(android.R.string.cancel, null)
            .create();

    Window window = dialog.getWindow();
    if (window != null) {
        window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    }

    dialog.show();
}

From source file:com.googlecode.networklog.AppFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Context context = getActivity().getApplicationContext();

    MyLog.d("[AppFragment] onCreateView");

    if (NetworkLog.settings == null) {
        NetworkLog activity = (NetworkLog) getActivity();

        if (activity != null) {
            activity.loadSettings();/*from w w  w . j a v a  2 s .c  o m*/
        }
    }

    LinearLayout layout = new LinearLayout(context);
    layout.setOrientation(LinearLayout.VERTICAL);

    TextView tv = new TextView(context);
    tv.setText(getString(R.string.app_instructions));
    layout.addView(tv);

    listView = new ExpandableListView(context);
    listView.setAdapter(adapter);
    listView.setTextFilterEnabled(true);
    listView.setFastScrollEnabled(true);
    listView.setSmoothScrollbarEnabled(false);
    listView.setGroupIndicator(null);
    listView.setChildIndicator(null);
    listView.setDividerHeight(0);
    listView.setChildDivider(getResources().getDrawable(R.color.transparent));
    layout.addView(listView);

    listView.setOnGroupExpandListener(new OnGroupExpandListener() {
        @Override
        public void onGroupExpand(int groupPosition) {
            ((GroupItem) adapter.getGroup(groupPosition)).isExpanded = true;
        }
    });

    listView.setOnGroupCollapseListener(new OnGroupCollapseListener() {
        @Override
        public void onGroupCollapse(int groupPosition) {
            ((GroupItem) adapter.getGroup(groupPosition)).isExpanded = false;
        }
    });

    listView.setOnChildClickListener(new OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
                long id) {
            GroupItem group = (GroupItem) adapter.getGroup(groupPosition);
            ChildItem child = (ChildItem) adapter.getChild(groupPosition, childPosition);

            getActivity()
                    .startActivity(new Intent(getActivity().getApplicationContext(), AppTimelineGraph.class)
                            .putExtra("app_uid", group.app.uid).putExtra("src_addr", child.receivedAddress)
                            .putExtra("src_port", child.receivedPort).putExtra("dst_addr", child.sentAddress)
                            .putExtra("dst_port", child.sentPort));

            return true;
        }
    });

    registerForContextMenu(listView);

    if (gotInstalledApps == false) {
        getInstalledApps(true);
        gotInstalledApps = true;
    }

    startUpdater();

    return layout;
}

From source file:com.gome.haoyuangong.views.MyViewPageIndicator.java

private void addTab(int index, CharSequence text, int iconResId) {
    final TabView tabView = new TabView(getContext());
    tabView.mIndex = index;/*from   w w w . j  a v a 2s  .c  o  m*/
    tabView.setTag("tavView");
    tabView.setId(index);
    //      tabView.setFocusable(true);
    //      tabView.setOnClickListener(mTabClickListener);
    tabView.setText(text);
    //tabView.setPadding(pointSize, 0, pointSize, 0);
    tabView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    tabView.setMaxLines(1);
    tabView.setGravity(Gravity.CENTER);
    XmlPullParser xrp = getResources().getXml(R.drawable.tab_button);
    try {
        ColorStateList csl = ColorStateList.createFromXml(getResources(), xrp);
        tabView.setTextColor(csl);
    } catch (Exception e) {

    }

    if (iconResId != 0) {
        //tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0);
    }

    FrameLayout.LayoutParams tabTvL = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    tabView.setLayoutParams(tabTvL);

    //measureView(tabView);

    LinearLayout layoutWraper1 = new LinearLayout(getContext());
    LinearLayout.LayoutParams lp1 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, 1);
    layoutWraper1.setLayoutParams(lp1);
    layoutWraper1.setGravity(Gravity.CENTER);
    layoutWraper1.setFocusable(true);
    layoutWraper1.setOnClickListener(mTabClickListener);
    layoutWraper1.setPadding(0, 0, 0, 0);
    layoutWraper1.setBackgroundResource(R.drawable.tab_btn_red);

    FrameLayout frameLayout = new FrameLayout(getContext());
    frameLayout.setTag("framelayout");
    //      FrameLayout.LayoutParams fl2 = new FrameLayout.LayoutParams(tabView.getMeasuredWidth() + padding, tabView.getMeasuredHeight()+ (int)(padding * 1.5));
    FrameLayout.LayoutParams fl2 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    //      frameLayout.setPadding(padding, padding, padding, padding);
    frameLayout.setLayoutParams(fl2);
    //      frameLayout.addView(tabView);

    View hasNew = new View(getContext());
    FrameLayout.LayoutParams hasNewL = new FrameLayout.LayoutParams(pointSize, pointSize);
    hasNew.setLayoutParams(hasNewL);
    hasNewL.gravity = Gravity.TOP | Gravity.RIGHT;
    hasNew.setBackgroundResource(R.drawable.shape_circle);

    FrameLayout tabTvframe = new FrameLayout(getContext());
    FrameLayout.LayoutParams tabTvframeL = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    tabTvframeL.gravity = Gravity.CENTER;
    tabTvframe.setLayoutParams(tabTvframeL);
    tabTvframe.addView(tabView);
    tabTvframe.addView(hasNew);
    hasNew.setVisibility(View.GONE);

    frameLayout.addView(tabTvframe);

    layoutWraper1.addView(frameLayout);

    tabView.setTagView(hasNew);

    mTabLayout.addView(layoutWraper1, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1));
}

From source file:com.krayzk9s.imgurholo.ui.SingleImageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    final ImgurHoloActivity activity = (ImgurHoloActivity) getActivity();
    final SharedPreferences settings = activity.getApiCall().settings;
    sort = settings.getString("CommentSort", "Best");
    boolean newData = true;
    if (commentData != null) {
        newData = false;/*from w  w  w  .jav a 2 s . co  m*/
    }

    mainView = inflater.inflate(R.layout.single_image_layout, container, false);
    String[] mMenuList = getResources().getStringArray(R.array.emptyList);
    if (commentAdapter == null)
        commentAdapter = new CommentAdapter(mainView.getContext());
    commentLayout = (ListView) mainView.findViewById(R.id.comment_thread);
    commentLayout.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    if (settings.getString("theme", MainActivity.HOLO_LIGHT).equals(MainActivity.HOLO_LIGHT))
        imageLayoutView = (LinearLayout) View.inflate(getActivity(), R.layout.image_view, null);
    else
        imageLayoutView = (LinearLayout) View.inflate(getActivity(), R.layout.dark_image_view, null);

    mPullToRefreshLayout = (PullToRefreshLayout) mainView.findViewById(R.id.ptr_layout);
    ActionBarPullToRefresh.from(getActivity())
            // Mark All Children as pullable
            .allChildrenArePullable()
            // Set the OnRefreshListener
            .listener(this)
            // Finally commit the setup to our PullToRefreshLayout
            .setup(mPullToRefreshLayout);
    if (savedInstanceState != null && newData) {
        imageData = savedInstanceState.getParcelable("imageData");
        inGallery = savedInstanceState.getBoolean("inGallery");
    }
    LinearLayout layout = (LinearLayout) imageLayoutView.findViewById(R.id.image_buttons);
    TextView imageDetails = (TextView) imageLayoutView.findViewById(R.id.single_image_details);
    layout.setVisibility(View.VISIBLE);
    ImageButton imageFullscreen = (ImageButton) imageLayoutView.findViewById(R.id.fullscreen);
    imageUpvote = (ImageButton) imageLayoutView.findViewById(R.id.rating_good);
    imageDownvote = (ImageButton) imageLayoutView.findViewById(R.id.rating_bad);
    ImageButton imageFavorite = (ImageButton) imageLayoutView.findViewById(R.id.rating_favorite);
    imageComment = (ImageButton) imageLayoutView.findViewById(R.id.comment);
    ImageButton imageUser = (ImageButton) imageLayoutView.findViewById(R.id.user);
    imageScore = (TextView) imageLayoutView.findViewById(R.id.single_image_score);
    TextView imageInfo = (TextView) imageLayoutView.findViewById(R.id.single_image_info);
    Log.d("imageData", imageData.getJSONObject().toString());
    if (imageData.getJSONObject().has("ups")) {
        imageUpvote.setVisibility(View.VISIBLE);
        imageDownvote.setVisibility(View.VISIBLE);
        imageScore.setVisibility(View.VISIBLE);
        imageComment.setVisibility(View.VISIBLE);
        ImageUtils.updateImageFont(imageData, imageScore);
    }
    imageInfo.setVisibility(View.VISIBLE);
    ImageUtils.updateInfoFont(imageData, imageInfo);
    imageUser.setVisibility(View.VISIBLE);
    imageFavorite.setVisibility(View.VISIBLE);
    try {
        if (!imageData.getJSONObject().has("account_url")
                || imageData.getJSONObject().getString("account_url").equals("null")
                || imageData.getJSONObject().getString("account_url").equals("[deleted]"))
            imageUser.setVisibility(View.GONE);
        if (!imageData.getJSONObject().has("vote")) {
            imageUpvote.setVisibility(View.GONE);
            imageDownvote.setVisibility(View.GONE);
        } else {
            if (imageData.getJSONObject().getString("vote") != null
                    && imageData.getJSONObject().getString("vote").equals("up"))
                imageUpvote.setImageResource(R.drawable.green_rating_good);
            else if (imageData.getJSONObject().getString("vote") != null
                    && imageData.getJSONObject().getString("vote").equals("down"))
                imageDownvote.setImageResource(R.drawable.red_rating_bad);
        }
        if (imageData.getJSONObject().getString("favorite") != null
                && imageData.getJSONObject().getBoolean("favorite"))
            imageFavorite.setImageResource(R.drawable.green_rating_favorite);
    } catch (JSONException e) {
        Log.e("Error!", e.toString());
    }
    imageFavorite.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ImageUtils.favoriteImage(singleImageFragment, imageData, (ImageButton) view, activity.getApiCall());
        }
    });
    imageUser.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ImageUtils.gotoUser(singleImageFragment, imageData);
        }
    });
    imageComment.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Activity activity = getActivity();
            final EditText newBody = new EditText(activity);
            newBody.setHint(R.string.body_hint_body);
            newBody.setLines(3);
            final TextView characterCount = new TextView(activity);
            characterCount.setText("140");
            LinearLayout commentReplyLayout = new LinearLayout(activity);
            newBody.addTextChangedListener(new TextWatcher() {
                @Override
                public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                    //
                }

                @Override
                public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                    characterCount.setText(String.valueOf(140 - charSequence.length()));
                }

                @Override
                public void afterTextChanged(Editable editable) {
                    for (int i = editable.length(); i > 0; i--) {
                        if (editable.subSequence(i - 1, i).toString().equals("\n"))
                            editable.replace(i - 1, i, "");
                    }
                }
            });
            commentReplyLayout.setOrientation(LinearLayout.VERTICAL);
            commentReplyLayout.addView(newBody);
            commentReplyLayout.addView(characterCount);
            new AlertDialog.Builder(activity).setTitle(R.string.dialog_comment_on_image_title)
                    .setView(commentReplyLayout)
                    .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            if (newBody.getText() != null && newBody.getText().toString().length() < 141) {
                                HashMap<String, Object> commentMap = new HashMap<String, Object>();
                                try {
                                    commentMap.put("comment", newBody.getText().toString());
                                    commentMap.put("image_id", imageData.getJSONObject().getString("id"));
                                    Fetcher fetcher = new Fetcher(singleImageFragment, "3/comment/",
                                            ApiCall.POST, commentMap,
                                            ((ImgurHoloActivity) getActivity()).getApiCall(), POSTCOMMENT);
                                    fetcher.execute();
                                } catch (JSONException e) {
                                    Log.e("Error!", e.toString());
                                }
                            }
                        }
                    }).setNegativeButton(R.string.dialog_answer_cancel, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            // Do nothing.
                        }
                    }).show();
        }
    });
    imageUpvote.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ImageUtils.upVote(singleImageFragment, imageData, imageUpvote, imageDownvote,
                    activity.getApiCall());
            ImageUtils.updateImageFont(imageData, imageScore);
        }
    });
    imageDownvote.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ImageUtils.downVote(singleImageFragment, imageData, imageUpvote, imageDownvote,
                    activity.getApiCall());
            ImageUtils.updateImageFont(imageData, imageScore);
        }
    });
    if (popupWindow != null) {
        popupWindow.dismiss();
    }
    popupWindow = new PopupWindow();
    imageFullscreen.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ImageUtils.fullscreen(singleImageFragment, imageData, popupWindow, mainView);
        }
    });
    ArrayAdapter<String> tempAdapter = new ArrayAdapter<String>(mainView.getContext(),
            R.layout.drawer_list_item, mMenuList);
    Log.d("URI", "YO I'M IN YOUR SINGLE FRAGMENT gallery:" + inGallery);
    imageView = (ImageView) imageLayoutView.findViewById(R.id.single_image_view);
    loadImage();
    TextView imageTitle = (TextView) imageLayoutView.findViewById(R.id.single_image_title);
    TextView imageDescription = (TextView) imageLayoutView.findViewById(R.id.single_image_description);

    try {
        String size = String
                .valueOf(NumberFormat.getIntegerInstance()
                        .format(imageData.getJSONObject().getInt(ImgurHoloActivity.IMAGE_DATA_WIDTH)))
                + "x"
                + NumberFormat.getIntegerInstance()
                        .format(imageData.getJSONObject().getInt(ImgurHoloActivity.IMAGE_DATA_HEIGHT))
                + " (" + NumberFormat.getIntegerInstance()
                        .format(imageData.getJSONObject().getInt(ImgurHoloActivity.IMAGE_DATA_SIZE))
                + "B)";
        String initial = imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_TYPE) + " "
                + Html.fromHtml("&#8226;") + " " + size + " " + Html.fromHtml("&#8226;") + " " + "Views: "
                + NumberFormat.getIntegerInstance()
                        .format(imageData.getJSONObject().getInt(ImgurHoloActivity.IMAGE_DATA_VIEWS));
        imageDetails.setText(initial);
        Log.d("imagedata", imageData.getJSONObject().toString());
        if (!imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_TITLE).equals("null"))
            imageTitle.setText(imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_TITLE));
        else
            imageTitle.setVisibility(View.GONE);
        if (!imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_DESCRIPTION).equals("null")) {
            imageDescription
                    .setText(imageData.getJSONObject().getString(ImgurHoloActivity.IMAGE_DATA_DESCRIPTION));
            imageDescription.setVisibility(View.VISIBLE);
        } else
            imageDescription.setVisibility(View.GONE);
        commentLayout.addHeaderView(imageLayoutView);
        commentLayout.setAdapter(tempAdapter);
    } catch (JSONException e) {
        Log.e("Text Error!", e.toString());
    }
    if ((savedInstanceState == null || commentData == null) && newData) {
        commentData = new JSONParcelable();
        getComments();
        commentLayout.setAdapter(commentAdapter);
    } else if (newData) {
        commentArray = savedInstanceState.getParcelableArrayList("commentData");
        commentAdapter.addAll(commentArray);
        commentLayout.setAdapter(commentAdapter);
        commentAdapter.notifyDataSetChanged();
    } else if (commentArray != null) {
        commentAdapter.addAll(commentArray);
        commentLayout.setAdapter(commentAdapter);
        commentAdapter.notifyDataSetChanged();
    }
    return mainView;
}

From source file:com.conferenceengineer.android.iosched.ui.SessionDetailFragment.java

/**
 * Handle {@link SessionsQuery} {@link Cursor}.
 *///w w  w . ja  v  a  2  s .  co  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
    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:org.sirimangalo.meditationplus.ActivityMain.java

private void populateLog(JSONArray jsonLogged) {
    Calendar utc = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
    int hour = utc.get(Calendar.HOUR_OF_DAY);

    int max_hour = 0;
    int max_height = 100;

    LinearLayout hll = (LinearLayout) findViewById(R.id.time_log);

    if (hll == null)
        return;/*from  ww w .  java 2 s.  c o m*/

    hll.removeAllViews();

    try {
        max_hour = jsonLogged.getInt(0);
        for (int i = 1; i < jsonLogged.length(); i++) {
            max_hour = Math.max(max_hour, jsonLogged.getInt(i));
        }
        for (int i = 0; i < jsonLogged.length(); i++) {
            int height = (int) Math.ceil(max_height * jsonLogged.getInt(i) / max_hour);
            LinearLayout ll = (LinearLayout) context.getLayoutInflater().inflate(R.layout.list_item_log, null);

            ImageView iv = (ImageView) ll.findViewById(R.id.min_cell);
            iv.getLayoutParams().height = height;
            iv.getLayoutParams().width = hll.getWidth() / 24;
            TextView tv = (TextView) ll.findViewById(R.id.hour_no);
            tv.setText(i + "");
            if (hour == i)
                tv.setBackgroundColor(0xFFFFFF33);
            ImageView sv = (ImageView) ll.findViewById(R.id.space_cell);
            sv.getLayoutParams().height = 100 - height;
            hll.addView(ll);
        }

    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:com.fizz.StickyFragment.java

@Override
public void onStart() {
    super.onStart();
    LinearLayout ll = (LinearLayout) getActivity().findViewById(R.id.ll);
    for (int i = 0; i < drinks.length; i++) {
        TextView tt = new TextView(getActivity());
        tt.setText(drinks[i].toUpperCase(Locale.US) + "\n" + ingredients[i]);
        tt.setPadding(15, 15, 15, 15);//from w w  w.j  a  va  2 s . c om
        tt.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                drink = ((TextView) v).getText().toString();
                try {
                    Intent venmoIntent = VenmoLibrary.openVenmoPayment("1684", "Fizz", "8123744601", "0.01",
                            drink, "pay");
                    startActivityForResult(venmoIntent, 1);
                    // 1 is the requestCode we are using for Venmo. Feel
                    // free to change this to another number.

                    // Venmo native app not install on device, so let's
                    // instead open a mobile web version of Venmo in a
                    // WebView
                } catch (android.content.ActivityNotFoundException e) {
                    Log.e("Fizz", "onClicked");
                    {
                        Intent venmoIntent = new Intent(getActivity(), VenmoWebViewActivity.class);
                        String venmo_uri = VenmoLibrary.openVenmoPaymentInWebView("1684", "Fizz", "8123744601",
                                "0.01", "Drink", "pay");
                        venmoIntent.putExtra("url", venmo_uri);
                        startActivityForResult(venmoIntent, 1);
                    }
                    //} catch (android.content.ActivityNotFoundException e) {
                    //e.printStackTrace() ;
                }
            }
        });
        tt.setTextSize(22);
        if (textnum % 2 == 0) {
            tt.setBackgroundColor(Color.argb(0, 51, 181, 229));
            tt.setTextColor(Color.argb(255, 51, 181, 229));
        } else {
            tt.setBackgroundColor(Color.argb(240, 51, 181, 229));
            tt.setTextColor(Color.argb(255, 255, 255, 255));
        }
        tt.setTypeface(SplashActivity.tp);
        ll.addView(tt);
        textnum++;
    }
}

From source file:com.mdlive.sav.MDLiveProviderDetails.java

private void clickForVideoOrPhoneTapReqFutureAction() {
    findViewById(R.id.dateTxtLayout).setVisibility(View.VISIBLE);
    tapSeetheDoctorTxtLayout.setVisibility(View.GONE);
    reqfutureapptBtnLayout.setVisibility(View.GONE);
    videophoneparentLl.setVisibility(View.VISIBLE);
    horizontalscrollview.setVisibility(View.GONE);
    //This condition is only for PHS Users

    final UserBasicInfo userBasicInfo = UserBasicInfo.readFromSharedPreference(getBaseContext());
    //PHS user/*from  w  w w  .  ja  v  a  2  s  .co m*/
    if (userBasicInfo.getPersonalInfo().getConsultMethod().equalsIgnoreCase("video")) {
        byphoneBtnLayout.setVisibility(View.INVISIBLE);
        byphoneBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
        byphoneBtn.setTextColor(getResources().getColor(R.color.disableBtn));
        ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon_gray);
        byphoneBtnLayout.setClickable(false);

        saveAppmtType("video");
        byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_white_rounded_corner);
        byvideoBtn.setTextColor(Color.GRAY);
        byvideoBtn.setTextColor(Color.GRAY);
        byvideoBtnLayout.setVisibility(View.VISIBLE);
        byvideoBtnLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                    byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_blue_rounded_corner);
                    byvideoBtn.setTextColor(Color.WHITE);
                    ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_white);
                    ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon_gray);
                    byphoneBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
                    byphoneBtn.setTextColor(getResources().getColor(R.color.disableBtn));
                    byphoneBtnLayout.setVisibility(View.INVISIBLE);
                    byphoneBtnLayout.setClickable(false);

                    horizontalscrollview.setVisibility(View.VISIBLE);
                    final LinearLayout layout = (LinearLayout) findViewById(R.id.panelMessageFiles);
                    if (layout.getChildCount() > 0) {
                        layout.removeAllViews();
                    }

                    for (TextView tv : videoList) {
                        layout.addView(tv);
                    }
                    saveConsultationType("Video", MDLiveProviderDetails.this);
                    //Enable Request Appointment Button
                    enableReqAppmtBtn();
                    ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_white);
                    //horizontalscrollview.smoothScrollTo(0,0);

                    horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                    horizontalscrollview.postDelayed(new Runnable() {
                        public void run() {
                            horizontalscrollview.fullScroll(HorizontalScrollView.FOCUS_LEFT);
                        }
                    }, 100L);
                    //horizontalscrollview.fullScroll(HorizontalScrollView.FOCUS_LEFT);
                    selectedTimeslot = false;
                    enableReqAppmtBtn();
                    clearTimeSlotViews();
                    horizontalscrollview.startAnimation(AnimationUtils.loadAnimation(MDLiveProviderDetails.this,
                            R.anim.mdlive_trans_left_in));

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

    } else if (userBasicInfo.getPersonalInfo().getConsultMethod().equalsIgnoreCase("phone")) {
        phsOnlyForPhone();
    }
    //Only For idaho
    else if (longLocation.equalsIgnoreCase("idaho")) {
        onlyForIdaho();
    }
    //Only For Texas
    else if (longLocation.equalsIgnoreCase("texas")) {
        phsOnlyForPhone();
    }
    //Vido or Phone Button on Click listener for Blue color
    else {
        //Disabling the Video or Phone Based on the Phone list and video list
        //if the phone list is empty we should not shown the Phone Layout
        //if the video list is empty then we should not show the Video Layout.
        byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_white_rounded_corner);
        ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon);
        ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon);
        byvideoBtn.setTextColor(Color.GRAY);
        byphoneBtnLayout.setBackgroundResource(R.drawable.searchpvr_white_rounded_corner);
        byphoneBtn.setTextColor(Color.GRAY);

        if (videoList.size() == 0) {
            saveAppmtType("phone");
            byvideoBtnLayout.setVisibility(View.VISIBLE);
            byvideoBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
            byvideoBtn.setTextColor(getResources().getColor(R.color.disableBtn));
            ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_gray);
            byvideoBtnLayout.setClickable(false);
        } else {
            byvideoBtnLayout.setVisibility(View.VISIBLE);
            byvideoBtnLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    try {
                        horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                        byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_blue_rounded_corner);
                        byvideoBtn.setTextColor(Color.WHITE);
                        ((ImageView) findViewById(R.id.videoicon))
                                .setImageResource(R.drawable.video_icon_white);
                        byphoneBtnLayout.setVisibility(View.VISIBLE);
                        byphoneBtnLayout.setBackgroundResource(R.drawable.searchpvr_white_rounded_corner);
                        byphoneBtn.setTextColor(Color.GRAY);
                        ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon);

                        horizontalscrollview.setVisibility(View.VISIBLE);
                        LinearLayout layout = (LinearLayout) findViewById(R.id.panelMessageFiles);
                        if (layout.getChildCount() > 0) {
                            layout.removeAllViews();
                        }

                        for (TextView tv : videoList) {
                            layout.addView(tv);
                        }
                        saveConsultationType("Video", MDLiveProviderDetails.this);
                        //Enable Request Appointment Button

                        horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                        ((ImageView) findViewById(R.id.videoicon))
                                .setImageResource(R.drawable.video_icon_white);
                        ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon);
                        selectedTimeslot = false;
                        enableReqAppmtBtn();
                        clearTimeSlotViews();
                        horizontalscrollview.startAnimation(AnimationUtils
                                .loadAnimation(MDLiveProviderDetails.this, R.anim.mdlive_trans_left_in));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }
        if (phoneList.size() == 0) {
            saveAppmtType("video");
            byphoneBtnLayout.setVisibility(View.VISIBLE);
            byphoneBtnLayout.setBackgroundResource(R.drawable.disable_round_rect_grey_border);
            byphoneBtn.setTextColor(getResources().getColor(R.color.disableBtn));
            ((ImageView) findViewById(R.id.phoneicon)).setImageResource(R.drawable.phone_icon_gray);
            byphoneBtnLayout.setClickable(false);
        } else {
            byphoneBtnLayout.setVisibility(View.VISIBLE);
            byphoneBtnLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    try {
                        horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                        byphoneBtnLayout.setBackgroundResource(R.drawable.searchpvr_blue_rounded_corner);
                        byphoneBtn.setTextColor(Color.WHITE);
                        ((ImageView) findViewById(R.id.phoneicon))
                                .setImageResource(R.drawable.phone_icon_white);

                        byvideoBtnLayout.setVisibility(View.VISIBLE);
                        byvideoBtnLayout.setBackgroundResource(R.drawable.searchpvr_white_rounded_corner);
                        byvideoBtn.setTextColor(Color.GRAY);
                        ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon_gray);
                        horizontalscrollview.setVisibility(View.VISIBLE);
                        LinearLayout layout = (LinearLayout) findViewById(R.id.panelMessageFiles);
                        if (layout.getChildCount() > 0) {
                            layout.removeAllViews();
                        }
                        for (TextView tv : phoneList) {
                            layout.addView(tv);
                        }
                        saveConsultationType("Phone", MDLiveProviderDetails.this);
                        //Enable Request Appointment Button

                        horizontalscrollview.smoothScrollTo(layout.getChildAt(0).getLeft(), 0);
                        ((ImageView) findViewById(R.id.phoneicon))
                                .setImageResource(R.drawable.phone_icon_white);
                        ((ImageView) findViewById(R.id.videoicon)).setImageResource(R.drawable.video_icon);
                        selectedTimeslot = false;
                        enableReqAppmtBtn();
                        clearTimeSlotViews();
                        horizontalscrollview.startAnimation(AnimationUtils
                                .loadAnimation(MDLiveProviderDetails.this, R.anim.mdlive_trans_left_in));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }

    }

}

From source file:com.android.nsboc.ComposeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (mItem != null) {
        switch (mItem.id + "") {
        case "1":
            mRootView = inflater.inflate(R.layout.form_unlicensed, container, false);
            break;
        case "2":
            mRootView = inflater.inflate(R.layout.form_salon, container, false);
            break;
        }//from  w ww .ja  v a  2 s.  c om
    }

    showCurrentDateInEditText();

    ToggleButton complianceToggle = (ToggleButton) mRootView.findViewById(R.id.compliance_toggle);
    if (complianceToggle != null) {
        final LinearLayout complianceContainer = (LinearLayout) mRootView
                .findViewById(R.id.compliance_container);

        complianceToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (!isChecked) {
                    complianceContainer.setVisibility(View.VISIBLE);

                    final LinearLayout complianceLayout = (LinearLayout) View.inflate(getActivity(),
                            R.layout.compliance_layout, null);

                    Spinner violationTypeSpinner = (Spinner) complianceLayout
                            .findViewById(R.id.violation_type_spinner);
                    violationTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                        @Override
                        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                            switch (position) {
                            case 0:
                                complianceLayout.findViewById(R.id.type_citation_container)
                                        .setVisibility(View.VISIBLE);
                                break;
                            case 1:
                                complianceLayout.findViewById(R.id.type_citation_container)
                                        .setVisibility(View.GONE);
                                break;
                            }
                        }

                        @Override
                        public void onNothingSelected(AdapterView<?> parent) {
                        }
                    });

                    ToggleButton anotherToggle = (ToggleButton) complianceLayout
                            .findViewById(R.id.compliance_toggle);
                    anotherToggle.setOnCheckedChangeListener(getNextToggleListener(complianceLayout));

                    complianceContainer.addView(complianceLayout);
                } else {
                    complianceContainer.setVisibility(View.GONE);
                }
            }
        });
    }

    ToggleButton emailToggle = (ToggleButton) mRootView.findViewById(R.id.emailTo_toggle);
    if (emailToggle != null) {
        final LinearLayout emailLayout = (LinearLayout) mRootView.findViewById(R.id.emailTo_layout);

        emailToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    emailLayout.setVisibility(View.VISIBLE);
                } else {
                    emailLayout.setVisibility(View.GONE);
                }
            }
        });
    }

    final TextView noticeTextView = (TextView) mRootView.findViewById(R.id.notice_textview);
    if (noticeTextView != null) {
        noticeTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (noticeTextView.getCurrentTextColor() == Color.BLACK) {
                    noticeTextView.setText(R.string.civil_citation_header);
                    noticeTextView.setTextColor(Color.parseColor("#17405e"));
                    noticeTextView.setText(Html.fromHtml("<u>" + noticeTextView.getText() + "</u>"));
                    mRootView.findViewById(R.id.civil_citation).requestFocus();
                } else {
                    noticeTextView.setText(R.string.civil_citation_notice);
                    noticeTextView.setMaxLines(Integer.MAX_VALUE);
                    noticeTextView.setTextColor(Color.BLACK);
                    noticeTextView.setText(
                            noticeTextView.getText().toString().replace("<u>", "").replace("</u>", ""));
                }
            }
        });
    }

    Spinner stateSpinner = (Spinner) mRootView.findViewById(R.id.state);
    if (stateSpinner != null) {
        stateSpinner.setSelection(27);
    }

    return mRootView;
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.SessionDetailFragment.java

/**
 * Handle {@link SessionsQuery} {@link Cursor}.
 *///from   w  w  w.  ja v a2 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);
    }

    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);
}