Example usage for android.view ViewGroup setOnClickListener

List of usage examples for android.view ViewGroup setOnClickListener

Introduction

In this page you can find the example usage for android.view ViewGroup setOnClickListener.

Prototype

public void setOnClickListener(@Nullable OnClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked.

Usage

From source file:net.bible.android.view.activity.base.actionbar.Title.java

public void addToBar(ActionBar actionBar, final Activity activity) {
    this.actionBar = actionBar;
    this.activity = activity;

    actionBar.setCustomView(R.layout.title);

    documentTitle = (TextView) actionBar.getCustomView().findViewById(R.id.documentTitle);
    documentSubtitle = (TextView) actionBar.getCustomView().findViewById(R.id.documentSubtitle);
    pageTitle = (TextView) actionBar.getCustomView().findViewById(R.id.pageTitle);
    pageSubtitle = (TextView) actionBar.getCustomView().findViewById(R.id.pageSubtitle);

    // clicking document title shows document selector
    ViewGroup documentTitleContainer = (ViewGroup) actionBar.getCustomView()
            .findViewById(R.id.documentTitleContainer);
    documentTitleContainer.setOnClickListener(new OnClickListener() {
        @Override//from  www  .j a  v a 2  s.co  m
        public void onClick(View v) {
            onDocumentTitleClick();
        }
    });

    // clicking page title shows appropriate key selector
    ViewGroup pageTitleContainer = (ViewGroup) actionBar.getCustomView().findViewById(R.id.pageTitleContainer);
    pageTitleContainer.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            onPageTitleClick();
        }
    });

    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);

    update(true);

    // do not display the app icon in the actionbar
    actionBar.setDisplayShowHomeEnabled(false);
}

From source file:com.bellman.bible.android.view.activity.base.actionbar.Title.java

public void addToBar(ActionBar actionBar, final Activity activity) {
    this.actionBar = actionBar;
    this.activity = activity;

    actionBar.setCustomView(R.layout.title);

    documentTitle = (TextView) actionBar.getCustomView().findViewById(R.id.documentTitle);
    documentSubtitle = (TextView) actionBar.getCustomView().findViewById(R.id.documentSubtitle);
    pageTitle = (TextView) actionBar.getCustomView().findViewById(R.id.pageTitle);
    pageSubtitle = (TextView) actionBar.getCustomView().findViewById(R.id.pageSubtitle);

    // clicking document title shows document selector
    ViewGroup documentTitleContainer = (ViewGroup) actionBar.getCustomView()
            .findViewById(R.id.documentTitleContainer);
    documentTitleContainer.setOnClickListener(new OnClickListener() {
        @Override/*  ww  w.  j  a  v  a2  s . c o m*/
        public void onClick(View v) {
            onDocumentTitleClick();
        }
    });

    // clicking page title shows appropriate key selector
    ViewGroup pageTitleContainer = (ViewGroup) actionBar.getCustomView().findViewById(R.id.pageTitleContainer);
    pageTitleContainer.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            onPageTitleClick();
        }
    });

    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME);

    update(true);

    // do not display the app icon in the actionbar
    actionBar.setDisplayShowHomeEnabled(false);

    // remove a small amount of extra padding at the left of the actionbar see: http://stackoverflow.com/questions/27354812/android-remove-left-margin-from-actionbars-custom-layout
    ViewParent toolbar = actionBar.getCustomView().getParent();
    if (toolbar != null && toolbar instanceof Toolbar) {
        ((Toolbar) toolbar).setContentInsetsAbsolute(0, 0);
    }
}

From source file:org.addhen.smssync.presentation.view.ui.activity.MainActivity.java

private void initViews() {
    setSupportActionBar(mToolbar);//from  w  w  w. j  av  a2s .c om
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.app_name,
            R.string.app_name);
    mDrawerToggle.setDrawerIndicatorEnabled(true);
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    if (mNavigationView != null) {
        View headerLayout = getLayoutInflater().inflate(R.layout.navdrawer_header, null);
        mNavigationView.addHeaderView(headerLayout);
        mAppCompatTextView = (AppCompatTextView) headerLayout.findViewById(R.id.header_app_version);
        ViewGroup headerContainer = (ViewGroup) headerLayout.findViewById(R.id.nav_header_container);
        headerContainer.setOnClickListener(v -> {
            if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
                mDrawerLayout.closeDrawer(GravityCompat.START);
            }
        });
        mAppCompatTextView.setText(getAppVersionName());
        setupDrawerContent();
    }
    setupFragment(mNavigationView.getMenu().findItem(mCurrentMenu));
    handleSearchIntent(getIntent());
}

From source file:uk.org.ngo.squeezer.itemlist.AlarmView.java

private View getAdapterView(View convertView, final ViewGroup parent) {
    AlarmViewHolder currentViewHolder = (convertView != null && convertView.getTag() instanceof AlarmViewHolder)
            ? (AlarmViewHolder) convertView.getTag()
            : null;/* w  w  w  .j av  a  2  s  . c o  m*/

    if (currentViewHolder == null) {
        convertView = getLayoutInflater().inflate(R.layout.list_item_alarm, parent, false);
        final View alarmView = convertView;
        final AlarmViewHolder viewHolder = new AlarmViewHolder();
        viewHolder.is24HourFormat = DateFormat.is24HourFormat(getActivity());
        viewHolder.timeFormat = viewHolder.is24HourFormat ? "%02d:%02d" : "%d:%02d";
        String[] amPmStrings = new DateFormatSymbols().getAmPmStrings();
        viewHolder.am = amPmStrings[0];
        viewHolder.pm = amPmStrings[1];
        viewHolder.time = (TextView) convertView.findViewById(R.id.time);
        viewHolder.amPm = (TextView) convertView.findViewById(R.id.am_pm);
        viewHolder.amPm.setVisibility(viewHolder.is24HourFormat ? View.GONE : View.VISIBLE);
        viewHolder.enabled = new CompoundButtonWrapper((CompoundButton) convertView.findViewById(R.id.enabled));
        viewHolder.enabled.setOncheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if (getActivity().getService() != null) {
                    viewHolder.alarm.setEnabled(b);
                    getActivity().getService().alarmEnable(viewHolder.alarm.getId(), b);
                }
            }
        });
        viewHolder.repeat = new CompoundButtonWrapper((CompoundButton) convertView.findViewById(R.id.repeat));
        viewHolder.repeat.setOncheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if (getActivity().getService() != null) {
                    viewHolder.alarm.setRepeat(b);
                    getActivity().getService().alarmRepeat(viewHolder.alarm.getId(), b);
                    viewHolder.dowHolder.setVisibility(b ? View.VISIBLE : View.GONE);
                }
            }
        });
        viewHolder.repeat.getButton().setText(ServerString.ALARM_ALARM_REPEAT.getLocalizedString());
        viewHolder.delete = (ImageView) convertView.findViewById(R.id.delete);
        viewHolder.playlist = (Spinner) convertView.findViewById(R.id.playlist);
        viewHolder.dowHolder = (LinearLayout) convertView.findViewById(R.id.dow);
        for (int day = 0; day < 7; day++) {
            ViewGroup dowButton = (ViewGroup) viewHolder.dowHolder.getChildAt(day);
            final int finalDay = day;
            dowButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (getActivity().getService() != null) {
                        final Alarm alarm = viewHolder.alarm;
                        boolean wasChecked = alarm.isDayActive(finalDay);
                        if (wasChecked) {
                            alarm.clearDay(finalDay);
                            getActivity().getService().alarmRemoveDay(alarm.getId(), finalDay);
                        } else {
                            alarm.setDay(finalDay);
                            getActivity().getService().alarmAddDay(alarm.getId(), finalDay);
                        }
                        setDowText(viewHolder, finalDay);
                    }
                }
            });
            viewHolder.dowTexts[day] = (TextView) dowButton.getChildAt(0);
        }
        viewHolder.delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View view) {
                final AnimationSet animationSet = new AnimationSet(true);
                animationSet.addAnimation(new ScaleAnimation(1F, 1F, 1F, 0.5F));
                animationSet.addAnimation(new AlphaAnimation(1F, 0F));
                animationSet.setDuration(ANIMATION_DURATION);
                animationSet.setAnimationListener(new AnimationEndListener() {
                    @Override
                    public void onAnimationEnd(Animation animation) {
                        mActivity.getItemAdapter().removeItem(viewHolder.position);
                        UndoBarController.show(getActivity(), ServerString.ALARM_DELETING.getLocalizedString(),
                                new UndoListener(viewHolder.position, viewHolder.alarm));
                    }
                });

                alarmView.startAnimation(animationSet);
            }
        });
        viewHolder.playlist.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                final AlarmPlaylist selectedAlarmPlaylist = mAlarmPlaylists.get(position);
                final Alarm alarm = viewHolder.alarm;
                if (getActivity().getService() != null && selectedAlarmPlaylist.getId() != null
                        && !selectedAlarmPlaylist.getId().equals(alarm.getUrl())) {
                    alarm.setUrl(selectedAlarmPlaylist.getId());
                    getActivity().getService().alarmSetPlaylist(alarm.getId(), selectedAlarmPlaylist);
                }
            }

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

        convertView.setTag(viewHolder);
    }

    return convertView;
}

From source file:com.ez.gallery.ucrop.UCropActivity.java

private void setupAspectRatioWidget() {

    // Set the colors before the default item is selected
    ((AspectRatioTextView) ((ViewGroup) findViewById(R.id.crop_aspect_ratio_1_1)).getChildAt(0))
            .setActiveColor(mActiveWidgetColor);
    ((AspectRatioTextView) ((ViewGroup) findViewById(R.id.crop_aspect_ratio_3_4)).getChildAt(0))
            .setActiveColor(mActiveWidgetColor);
    ((AspectRatioTextView) ((ViewGroup) findViewById(R.id.crop_aspect_ratio_original)).getChildAt(0))
            .setActiveColor(mActiveWidgetColor);
    ((AspectRatioTextView) ((ViewGroup) findViewById(R.id.crop_aspect_ratio_3_2)).getChildAt(0))
            .setActiveColor(mActiveWidgetColor);
    ((AspectRatioTextView) ((ViewGroup) findViewById(R.id.crop_aspect_ratio_16_9)).getChildAt(0))
            .setActiveColor(mActiveWidgetColor);

    mCropAspectRatioViews.add((ViewGroup) findViewById(R.id.crop_aspect_ratio_1_1));
    mCropAspectRatioViews.add((ViewGroup) findViewById(R.id.crop_aspect_ratio_3_4));
    mCropAspectRatioViews.add((ViewGroup) findViewById(R.id.crop_aspect_ratio_original));
    mCropAspectRatioViews.add((ViewGroup) findViewById(R.id.crop_aspect_ratio_3_2));
    mCropAspectRatioViews.add((ViewGroup) findViewById(R.id.crop_aspect_ratio_16_9));
    mCropAspectRatioViews.get(2).setSelected(true);

    for (ViewGroup cropAspectRatioView : mCropAspectRatioViews) {
        cropAspectRatioView.setOnClickListener(new View.OnClickListener() {
            @Override//from   w  ww . j av a2  s  .c  o  m
            public void onClick(View v) {
                mGestureCropImageView.setTargetAspectRatio(
                        ((AspectRatioTextView) ((ViewGroup) v).getChildAt(0)).getAspectRatio(v.isSelected()));
                mGestureCropImageView.setImageToWrapCropBounds();
                if (!v.isSelected()) {
                    for (ViewGroup cropAspectRatioView : mCropAspectRatioViews) {
                        cropAspectRatioView.setSelected(cropAspectRatioView == v);
                    }
                }
            }
        });
    }
}

From source file:com.dgsd.android.ShiftTracker.Fragment.EditShiftFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_edit_shift, container, false);

    mName = (StatefulAutoCompleteTextView) v.findViewById(R.id.name);
    mNotes = (StatefulEditText) v.findViewById(R.id.notes);
    mPayRate = (StatefulEditText) v.findViewById(R.id.pay_rate);
    mUnpaidBreak = (StatefulEditText) v.findViewById(R.id.unpaid_break);
    mStartDate = (TextView) v.findViewById(R.id.start_date);
    mEndDate = (TextView) v.findViewById(R.id.end_date);
    mStartTime = (TextView) v.findViewById(R.id.start_time);
    mEndTime = (TextView) v.findViewById(R.id.end_time);
    mSaveAsTemplate = (CheckBox) v.findViewById(R.id.is_template);
    mReminders = v.findViewById(R.id.reminders);

    ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getActivity(),
            R.layout.reminders_spinner_item, mRemindersLabels);
    adapter.setDropDownViewResource(R.layout.reminders_spinner_dropdown_item);
    setAdapter(mReminders, adapter);// ww w .j  a v a 2 s . co  m

    if (StApp.isFreeApp(getActivity())) {
        mReminders.setEnabled(false);
        mReminders.setClickable(false);
        ViewGroup parent = ((ViewGroup) mReminders.getParent());
        parent.setClickable(true);
        parent.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mLinkToPaidAppFragment != null && mLinkToPaidAppFragment.isResumed())
                    return; //Already showing

                mLinkToPaidAppFragment = LinkToPaidAppFragment
                        .newInstance(getString(R.string.reminders_unavailable_message));
                mLinkToPaidAppFragment.show(getSherlockActivity().getSupportFragmentManager(), null);
            }
        });
    }

    mStartDate.setOnClickListener(this);
    mEndDate.setOnClickListener(this);
    mStartTime.setOnClickListener(this);
    mEndTime.setOnClickListener(this);

    mNameAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_1, null,
            new String[] { DbField.NAME.name }, new int[] { android.R.id.text1 }, 0);
    mNameAdapter.setStringConversionColumn(0);//Index of 'Name' column
    mName.setAdapter(mNameAdapter);

    mName.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            mName.setError(null);

            mLastNameFilter = mName.getText() == null ? null : mName.getText().toString();
            getLoaderManager().restartLoader(LOADER_ID_NAMES, null, EditShiftFragment.this);
        }
    });

    mUnpaidBreak.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            mUnpaidBreak.setError(null);
        }
    });

    return v;
}

From source file:net.archenemy.archenemyapp.view.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = viewPager.getAdapter();
    final View.OnClickListener tabClickListener = new TabClickListener();
    if (adapter.getCount() > 0) {
        int width = getResources().getDisplayMetrics().widthPixels;
        int tabWidth = width / adapter.getCount();
        for (int i = 0; i < adapter.getCount(); i++) {
            ViewGroup tabView = null;
            ImageView tabIcon = null;

            if (tabViewLayoutId != 0) {
                // If there is a custom tab view layout id set, try and inflate it
                tabView = (ViewGroup) LayoutInflater.from(getContext()).inflate(tabViewLayoutId, tabStrip,
                        false);//from   www.  j a  v a 2  s .c  o m
                tabIcon = (ImageView) tabView.findViewById(tabViewImageViewId);
            }

            tabIcon.setImageResource(((BaseFragmentPagerAdapter) adapter).getIconResId(i));
            tabView.setOnClickListener(tabClickListener);
            tabStrip.addView(tabView, tabWidth, android.view.ViewGroup.LayoutParams.MATCH_PARENT);
        }
    }
}

From source file:com.limitfan.gojuuon.utils.ScreenSlidePageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout containing a title and body text.
    ViewGroup rootView = (ViewGroup) inflater.inflate(com.limitfan.gojuuon.R.layout.detail_slide_page,
            container, false);//  w  w  w  .j ava 2 s .c  om

    ImageView stroke = (ImageView) (rootView.findViewById(com.limitfan.gojuuon.R.id.stroke));
    String romaji = Common.roma[getPageNumber()];

    try {
        String img = "";
        if (ActKana.isHira)
            img = "kanagraph/hiragana_" + romaji + ".jpg";
        else
            img = "kanagraph/katakana_" + romaji + ".jpg";
        InputStream is = getContext().getAssets().open(img, AssetManager.ACCESS_STREAMING);

        Bitmap bm = BitmapFactory.decodeStream(is);
        stroke.setImageBitmap(bm);
    } catch (Exception e) {

    }

    ViewGroup listView = (ViewGroup) rootView.findViewById(com.limitfan.gojuuon.R.id.list);
    ViewGroup demo_speak = (ViewGroup) inflater.inflate(com.limitfan.gojuuon.R.layout.demo_list_item, null);
    ((TextView) demo_speak.findViewById(com.limitfan.gojuuon.R.id.text))
            .setText(com.limitfan.gojuuon.R.string.demo);
    ((ImageView) demo_speak.findViewById(com.limitfan.gojuuon.R.id.icon))
            .setImageResource(com.limitfan.gojuuon.R.drawable.speak_off);

    listView.addView(demo_speak);

    TextView sample = (TextView) (rootView.findViewById(com.limitfan.gojuuon.R.id.sample));
    setSample(sample);
    demo_speak.setOnClickListener(new SpeakListener());

    //stroke.setImageResource();

    // Set the title view to show the page number.
    //EditText main = ((EditText) rootView.findViewById(R.id.Description));
    // main.setText(getString(R.string.title_template_step, mPageNumber + 1));
    //main.setEnabled(false);
    // main.setBackgroundColor(Color.TRANSPARENT);
    // main.setText(getFromAssets("details/"+(mPageNumber+1)+".txt"));

    return rootView;
}

From source file:com.pranavpandey.smallapp.sample.SmallAppSample.java

private void showSettings() {
    LayoutInflater inflater = LayoutInflater.from(getContext());
    View view = inflater.inflate(R.layout.settings, new LinearLayout(this), false);

    ViewGroup clearDefaults;

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder.setTitle(R.string.sas_settings).setView(view).setPositiveButton(android.R.string.ok,
            null);/*from w  w  w .jav a  2  s  .  c  o m*/
    final AlertDialog alertDialog = alertDialogBuilder.create();

    // Create dialog using SmallUtils as we have to show it from a service
    SmallUtils.createDialog(alertDialog, getRootView().getWindowToken()).show();

    clearDefaults = (ViewGroup) alertDialog.findViewById(R.id.view_clear_defaults);

    clearDefaults.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // Clear all the associated apps
            (new Associations(getContext())).getHelper().clearAll(true);
        }
    });
}

From source file:net.abcdroid.devfest12.ui.SessionDetailFragment.java

/**
 * Handle {@link SessionsQuery} {@link Cursor}.
 *//*w w  w.  j a v  a  2 s  . c om*/
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);
}