List of usage examples for android.widget ImageView getParent
public final ViewParent getParent()
From source file:com.geniusgithub.contact.common.ContactPhotoManager.java
/** * Cancels pending requests to load photos asynchronously for views inside * {@param fragmentRootView}. If {@param fragmentRootView} is null, cancels all requests. *//*from ww w . j a v a 2 s . c o m*/ @Override public void cancelPendingRequests(View fragmentRootView) { if (fragmentRootView == null) { mPendingRequests.clear(); return; } ImageView[] requestSetCopy = mPendingRequests.keySet().toArray(new ImageView[mPendingRequests.size()]); for (ImageView imageView : requestSetCopy) { // If an ImageView is orphaned (currently scrap) or a child of fragmentRootView, then // we can safely remove its request. if (imageView.getParent() == null || isChildView(fragmentRootView, imageView)) { mPendingRequests.remove(imageView); } } }
From source file:it.configure.imageloader.zoom.PhotoViewAttacher.java
public final void onDrag(float dx, float dy) { if (DEBUG) {/*from ww w . ja v a 2s . c om*/ Log.d(LOG_TAG, String.format("onDrag: dx: %.2f. dy: %.2f", dx, dy)); } ImageView imageView = getImageView(); if (null != imageView && hasDrawable(imageView)) { mSuppMatrix.postTranslate(dx, dy); checkAndDisplayMatrix(); /** * Here we decide whether to let the ImageView's parent to start * taking over the touch event. * * First we check whether this function is enabled. We never want the * parent to take over if we're scaling. We then check the edge we're * on, and the direction of the scroll (i.e. if we're pulling against * the edge, aka 'overscrolling', let the parent take over). */ if (mAllowParentInterceptOnEdge && !mScaleDragDetector.isScaling()) { if (mScrollEdge == EDGE_BOTH || (mScrollEdge == EDGE_LEFT && dx >= 1f) || (mScrollEdge == EDGE_RIGHT && dx <= -1f)) { imageView.getParent().requestDisallowInterceptTouchEvent(false); } } } }
From source file:io.intue.kamu.BestNearbyFragment.java
@Override public void bindCollectionItemView(Context context, View view, int groupId, int indexInGroup, int dataIndex, Object tag) {/*from w w w . ja v a 2 s . co m*/ // if (mCursor == null || !mCursor.moveToPosition(dataIndex)) { // LOGW(TAG, "Can't bind collection view item, dataIndex=" + dataIndex + // (mCursor == null ? ": cursor is null" : ": bad data index.")); // return; // } if (mresult == null) { return; } Venue result = mresult.get(dataIndex); final String sessionId = result.getId(); if (sessionId == null) { return; } // first, read session info from cursor and put it in convenience variables final String sessionTitle = result.getName(); //final String speakerNames = "SessionsQuery.SPEAKER_NAMES"; //final String sessionAbstract = "SessionsQuery.ABSTRACT"; //final long sessionStart = 44454544; //final long sessionEnd = 334343433; //final String roomName = "SessionsQuery.ROOM_NAME"; int sessionColor = 0; sessionColor = sessionColor == 0 ? getResources().getColor(R.color.transparent) : sessionColor; //final String snippet = "SessionsQuery.SNIPPET"; final Spannable styledSnippet = null; final boolean starred = false; //final String[] tags = "A,B,C".split(","); // now let's compute a few pieces of information from the data, which we will use // later to decide what to render where final boolean hasLivestream = false; final long now = UIUtils.getCurrentTime(context); final boolean happeningNow = false; // text that says "LIVE" if session is live, or empty if session is not live //final String liveNowText = ""; // get reference to all the views in the layout we will need final TextView titleView = (TextView) view.findViewById(R.id.session_title); final TextView subtitleView = (TextView) view.findViewById(R.id.session_subtitle); final TextView shortSubtitleView = (TextView) view.findViewById(R.id.session_subtitle_short); final TextView snippetView = (TextView) view.findViewById(R.id.session_snippet); //final TextView abstractView = (TextView) view.findViewById(R.id.session_abstract); //final TextView categoryView = (TextView) view.findViewById(R.id.session_category); final View boxView = view.findViewById(R.id.info_box); final View sessionTargetView = view.findViewById(R.id.session_target); if (sessionColor == 0) { // use default sessionColor = getResources().getColor(R.color.transparent); } sessionColor = UIUtils.scaleSessionColorToDefaultBG(sessionColor); ImageView photoView = (ImageView) view.findViewById(R.id.session_photo_colored); if (photoView != null) { if (!mPreloader.isDimensSet()) { final ImageView finalPhotoView = photoView; photoView.post(new Runnable() { @Override public void run() { mPreloader.setDimens(finalPhotoView.getWidth(), finalPhotoView.getHeight()); } }); } // colored photoView.setColorFilter(UIUtils.setColorAlpha(sessionColor, UIUtils.SESSION_PHOTO_SCRIM_ALPHA)); } else { photoView = (ImageView) view.findViewById(R.id.session_photo); } ((BaseActivity) getActivity()).getLPreviewUtils().setViewName(photoView, "photo_" + sessionId); // when we load a photo, it will fade in from transparent so the // background of the container must be the session color to avoid a white flash ViewParent parent = photoView.getParent(); if (parent != null && parent instanceof View) { ((View) parent).setBackgroundColor(sessionColor); } else { photoView.setBackgroundColor(sessionColor); } String photo = result.getPhotoUrl(); if (!TextUtils.isEmpty(photo)) { mImageLoader.loadImage(photo, photoView, true /*crop*/); } else { // cleaning the (potentially) recycled photoView, in case this session has no photo: photoView.setImageDrawable(null); } // render title titleView.setText(sessionTitle == null ? "?" : sessionTitle); // render subtitle into either the subtitle view, or the short subtitle view, as available if (subtitleView != null) { subtitleView.setText(result.getAddress()); } else if (shortSubtitleView != null) { shortSubtitleView.setText(result.getAddress()); } // render category // if (categoryView != null) { // TagMetadata.Tag groupTag = mTagMetadata.getSessionGroupTag(tags); // if (groupTag != null && !Config.Tags.SESSIONS.equals(groupTag.getId())) { // categoryView.setText(groupTag.getName()); // categoryView.setVisibility(View.VISIBLE); // } else { // categoryView.setVisibility(View.GONE); // } // } // if a snippet view is available, render the session snippet there. if (snippetView != null) { //if (mIsSearchCursor) { // render the search snippet into the snippet view snippetView.setText(styledSnippet); // } else { // // render speaker names and abstracts into the snippet view // mBuffer.setLength(0); // if (!TextUtils.isEmpty(speakerNames)) { // mBuffer.append(speakerNames).append(". "); // } // if (!TextUtils.isEmpty(sessionAbstract)) { // mBuffer.append(sessionAbstract); // } // snippetView.setText(mBuffer.toString()); // } } // if (abstractView != null && !mIsSearchCursor) { // // render speaker names and abstracts into the abstract view // mBuffer.setLength(0); // if (!TextUtils.isEmpty(speakerNames)) { // mBuffer.append(speakerNames).append("\n\n"); // } // if (!TextUtils.isEmpty(sessionAbstract)) { // mBuffer.append(sessionAbstract); // } // abstractView.setText(mBuffer.toString()); // } // in expanded mode, the box background color follows the session color //if (useExpandedMode()) { boxView.setBackgroundColor(sessionColor); //} // show or hide the "in my schedule" indicator view.findViewById(R.id.indicator_in_schedule).setVisibility(starred ? View.VISIBLE : View.INVISIBLE); // if we are in condensed mode and this card is the hero card (big card at the top // of the screen), set up the message card if necessary. if (groupId == HERO_GROUP_ID) { // this is the hero view, so we might want to show a message card final boolean cardShown = setupMessageCard(view); // if this is the wide hero layout, show or hide the card or the session abstract // view, as appropriate (they are mutually exclusive). final View cardContainer = view.findViewById(R.id.message_card_container_wide); final View abstractContainer = view.findViewById(R.id.session_abstract); if (cardContainer != null && abstractContainer != null) { cardContainer.setVisibility(cardShown ? View.VISIBLE : View.GONE); abstractContainer.setVisibility(cardShown ? View.GONE : View.VISIBLE); abstractContainer.setBackgroundColor(sessionColor); } } // if this session is live right now, display the "LIVE NOW" icon on top of it View liveNowBadge = view.findViewById(R.id.live_now_badge); if (liveNowBadge != null) { liveNowBadge.setVisibility(happeningNow && hasLivestream ? View.VISIBLE : View.GONE); } // if this view is clicked, open the session details view final View finalPhotoView = photoView; sessionTargetView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mCallbacks.onSessionSelected(sessionId, finalPhotoView); } }); // animate this card // if (dataIndex > mMaxDataIndexAnimated) { // mMaxDataIndexAnimated = dataIndex; // } }
From source file:com.android.contacts.common.ContactPhotoManager.java
/** * Cancels pending requests to load photos asynchronously for views inside * {@param fragmentRootView}. If {@param fragmentRootView} is null, cancels all requests. *//*w w w. j a va 2 s . co m*/ @Override public void cancelPendingRequests(View fragmentRootView) { if (fragmentRootView == null) { mPendingRequests.clear(); return; } final Iterator<Entry<ImageView, Request>> iterator = mPendingRequests.entrySet().iterator(); while (iterator.hasNext()) { final ImageView imageView = iterator.next().getKey(); // If an ImageView is orphaned (currently scrap) or a child of fragmentRootView, then // we can safely remove its request. if (imageView.getParent() == null || isChildView(fragmentRootView, imageView)) { iterator.remove(); } } }
From source file:fr.paug.droidcon.ui.SessionsFragment.java
@Override public void bindCollectionItemView(Context context, View view, int groupId, int indexInGroup, int dataIndex, Object tag) {/*from w w w .j a v a2s . co m*/ if (mCursor == null || !mCursor.moveToPosition(dataIndex)) { LOGW(TAG, "Can't bind collection view item, dataIndex=" + dataIndex + (mCursor == null ? ": cursor is null" : ": bad data index.")); return; } final String sessionId = mCursor.getString(SessionsQuery.SESSION_ID); if (sessionId == null) { return; } // first, read session info from cursor and put it in convenience variables final String sessionTitle = mCursor.getString(SessionsQuery.TITLE); final String speakerNames = mCursor.getString(SessionsQuery.SPEAKER_NAMES); final String sessionAbstract = mCursor.getString(SessionsQuery.ABSTRACT); final long sessionStart = mCursor.getLong(SessionsQuery.SESSION_START); final long sessionEnd = mCursor.getLong(SessionsQuery.SESSION_END); final String roomName = mCursor.getString(SessionsQuery.ROOM_NAME); final String mainTag = mCursor.getString(SessionsQuery.MAIN_TAG); int sessionColor = mCursor.getInt(SessionsQuery.COLOR); sessionColor = sessionColor == 0 ? getResources().getColor(R.color.default_session_color) : sessionColor; final String snippet = mIsSearchCursor ? mCursor.getString(SessionsQuery.SNIPPET) : null; final Spannable styledSnippet = mIsSearchCursor ? buildStyledSnippet(snippet) : null; final boolean starred = mCursor.getInt(SessionsQuery.IN_MY_SCHEDULE) != 0; final String[] tags = mCursor.getString(SessionsQuery.TAGS).split(","); // now let's compute a few pieces of information from the data, which we will use // later to decide what to render where final boolean hasLivestream = !TextUtils.isEmpty(mCursor.getString(SessionsQuery.LIVESTREAM_URL)); final long now = UIUtils.getCurrentTime(context); final boolean happeningNow = now >= sessionStart && now <= sessionEnd; // text that says "LIVE" if session is live, or empty if session is not live final String liveNowText = hasLivestream ? " " + UIUtils.getLiveBadgeText(context, sessionStart, sessionEnd) : ""; // get reference to all the views in the layout we will need final TextView titleView = (TextView) view.findViewById(R.id.session_title); final TextView subtitleView = (TextView) view.findViewById(R.id.session_subtitle); final TextView shortSubtitleView = (TextView) view.findViewById(R.id.session_subtitle_short); final TextView snippetView = (TextView) view.findViewById(R.id.session_snippet); final TextView abstractView = (TextView) view.findViewById(R.id.session_abstract); final TextView categoryView = (TextView) view.findViewById(R.id.session_category); final View boxView = view.findViewById(R.id.info_box); final View sessionTargetView = view.findViewById(R.id.session_target); if (sessionColor == 0) { // use default sessionColor = mDefaultSessionColor; } sessionColor = UIUtils.scaleSessionColorToDefaultBG(sessionColor); ImageView photoView = (ImageView) view.findViewById(R.id.session_photo_colored); if (photoView != null) { if (!mPreloader.isDimensSet()) { final ImageView finalPhotoView = photoView; photoView.post(new Runnable() { @Override public void run() { mPreloader.setDimens(finalPhotoView.getWidth(), finalPhotoView.getHeight()); } }); } // colored photoView.setColorFilter(UIUtils.setColorAlpha(sessionColor, UIUtils.SESSION_PHOTO_SCRIM_ALPHA)); } else { photoView = (ImageView) view.findViewById(R.id.session_photo); } ((BaseActivity) getActivity()).getLPreviewUtils().setViewName(photoView, "photo_" + sessionId); // when we load a photo, it will fade in from transparent so the // background of the container must be the session color to avoid a white flash ViewParent parent = photoView.getParent(); if (parent != null && parent instanceof View) { ((View) parent).setBackgroundColor(sessionColor); } else { photoView.setBackgroundColor(sessionColor); } String photo = mCursor.getString(SessionsQuery.PHOTO_URL); if (!TextUtils.isEmpty(photo)) { mImageLoader.loadImage(photo, photoView, true /*crop*/); } else { // cleaning the (potentially) recycled photoView, in case this session has no photo: // photoView.setImageDrawable(null); photoView.setImageResource(R.drawable.default_session_img); } // render title titleView.setText(sessionTitle == null ? "?" : sessionTitle); // render subtitle into either the subtitle view, or the short subtitle view, as available if (subtitleView != null) { subtitleView.setText(UIUtils.formatSessionSubtitle(sessionStart, sessionEnd, roomName, mBuffer, context) + liveNowText); } else if (shortSubtitleView != null) { shortSubtitleView.setText( UIUtils.formatSessionSubtitle(sessionStart, sessionEnd, roomName, mBuffer, context, true) + liveNowText); } // render category if (categoryView != null) { TagMetadata.Tag groupTag = mTagMetadata.getSessionGroupTag(tags); if (groupTag != null && !Config.Tags.SESSIONS.equals(groupTag.getId())) { categoryView.setText(groupTag.getName()); categoryView.setVisibility(View.VISIBLE); } else { categoryView.setVisibility(View.GONE); } } // if a snippet view is available, render the session snippet there. if (snippetView != null) { if (mIsSearchCursor) { // render the search snippet into the snippet view snippetView.setText(styledSnippet); } else { // render speaker names and abstracts into the snippet view mBuffer.setLength(0); if (!TextUtils.isEmpty(speakerNames)) { mBuffer.append(speakerNames).append(". "); } if (!TextUtils.isEmpty(sessionAbstract)) { mBuffer.append(sessionAbstract); } snippetView.setText(mBuffer.toString()); } } if (abstractView != null && !mIsSearchCursor) { // render speaker names and abstracts into the abstract view mBuffer.setLength(0); if (!TextUtils.isEmpty(speakerNames)) { mBuffer.append(speakerNames).append("\n\n"); } if (!TextUtils.isEmpty(sessionAbstract)) { mBuffer.append(sessionAbstract); } abstractView.setText(mBuffer.toString()); } // in expanded mode, the box background color follows the session color if (useExpandedMode()) { boxView.setBackgroundColor(sessionColor); } // show or hide the "in my schedule" indicator ImageView indicatorInSchedule = (ImageView) view.findViewById(R.id.indicator_in_schedule); indicatorInSchedule.setVisibility(starred ? View.VISIBLE : View.INVISIBLE); if (starred) { int resId = R.drawable.indicator_in_schedule; if (mainTag.equals(SessionDetailFragment.TOPIC_EVERYWHERE)) resId = R.drawable.indicator_in_schedule_red; else if (mainTag.equals(SessionDetailFragment.TOPIC_DEVELOPMENT)) resId = R.drawable.indicator_in_schedule_blue; else if (mainTag.equals(SessionDetailFragment.TOPIC_UI_UX)) resId = R.drawable.indicator_in_schedule_amber; else if (mainTag.equals(SessionDetailFragment.TOPIC_OTHER)) resId = R.drawable.indicator_in_schedule_indigo; indicatorInSchedule.setImageResource(resId); } // if we are in condensed mode and this card is the hero card (big card at the top // of the screen), set up the message card if necessary. if (!useExpandedMode() && groupId == HERO_GROUP_ID) { // this is the hero view, so we might want to show a message card final boolean cardShown = setupMessageCard(view); // if this is the wide hero layout, show or hide the card or the session abstract // view, as appropriate (they are mutually exclusive). final View cardContainer = view.findViewById(R.id.message_card_container_wide); final View abstractContainer = view.findViewById(R.id.session_abstract); if (cardContainer != null && abstractContainer != null) { cardContainer.setVisibility(cardShown ? View.VISIBLE : View.GONE); abstractContainer.setVisibility(cardShown ? View.GONE : View.VISIBLE); abstractContainer.setBackgroundColor(sessionColor); } } // if this session is live right now, display the "LIVE NOW" icon on top of it View liveNowBadge = view.findViewById(R.id.live_now_badge); if (liveNowBadge != null) { liveNowBadge.setVisibility(happeningNow && hasLivestream ? View.VISIBLE : View.GONE); } // if this view is clicked, open the session details view final View finalPhotoView = photoView; sessionTargetView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mCallbacks.onSessionSelected(sessionId, finalPhotoView); } }); // animate this card if (dataIndex > mMaxDataIndexAnimated) { mMaxDataIndexAnimated = dataIndex; } }
From source file:koma.movieapp.ui.MoviesFragment.java
@Override public void bindCollectionItemView(Context context, View view, int groupId, int indexInGroup, int dataIndex, Object tag) {//from www. ja v a 2 s.c o m if (mMovieList.isEmpty() || mMovieList.get(dataIndex) == null) { return; } Movie movie = mMovieList.get(dataIndex); final String movieId = movie.id.toString(); if (movieId == null) return; final String movieTitle = movie.title; final String movieRating = movie.vote_average.toString(); final String movieBackdrop = movie.backdrop_path; System.out.println("Movie title in BindCollectionItemView: " + movieTitle); int movieColor = getResources().getColor(R.color.default_movie_color); int darkMovieColor = 0; final TextView titleView = (TextView) view.findViewById(R.id.movie_title); final View movieTargetView = view.findViewById(R.id.movie_target); if (movieColor == 0) { movieColor = mDefaultMovieColor; } darkMovieColor = UIUtils.scaleMovieColorToDefaultBG(movieColor); ImageView photoView = (ImageView) view.findViewById(R.id.session_photo_colored); if (photoView != null) { if (!mPreloader.isDimensSet()) { final ImageView finalPhotoView = photoView; photoView.post(new Runnable() { @Override public void run() { mPreloader.setDimens(finalPhotoView.getWidth(), finalPhotoView.getHeight()); } }); } // // colored filter on the images // photoView.setColorFilter(mNoTrackBranding // ? new PorterDuffColorFilter( // getResources().getColor(R.color.no_track_branding_session_tile_overlay), // PorterDuff.Mode.SRC_ATOP) // : UIUtils.makeSessionImageScrimColorFilter(darkMovieColor)); } else { photoView = (ImageView) view.findViewById(R.id.session_photo_colored); } ViewCompat.setTransitionName(photoView, "photo_" + movieId); // when we load a photo, it will fade in from transparent so the // background of the container must be the session color to avoid a white flash ViewParent parent = photoView.getParent(); if (parent != null && parent instanceof View) { ((View) parent).setBackgroundColor(darkMovieColor); } else { photoView.setBackgroundColor(darkMovieColor); } // render title //titleView.setTextColor(getResources().getColor(R.color.body_text_1_inverse)); //titleView.setTextColor(getResources().getColor(R.color.body_text_1_inverse)); //titleView.setBackgroundColor(getResources().getColor(R.color.material_blue_grey_800)); //titleView.setBackgroundColor(getResources().getColor(R.color.theme_primary)); titleView.setText(movieTitle == null ? "?" : movieTitle); //photoView.setColorFilter(new PorterDuffColorFilter(getResources().getColor(R.color.data_item_background_with_alpha),PorterDuff.Mode.SCREEN)); // set the images if (movieBackdrop != null) { mImageLoader.loadImage(Config.TMDB_IMAGE_BASE_URL + "w780" + movieBackdrop, photoView); } final View finalPhotoView = photoView; movieTargetView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mCallbacks.onMovieSelected(movieId, finalPhotoView); } }); // animate this card if (dataIndex > mMaxDataIndexAnimated) { mMaxDataIndexAnimated = dataIndex; } }
From source file:com.ptapp.activity.SessionsFragment.java
@Override public void bindCollectionItemView(Context context, View view, final int groupId, int indexInGroup, int dataIndex, Object tag) { if (mCursor == null || !mCursor.moveToPosition(dataIndex)) { LOGW(TAG, "Can't bind collection view item, dataIndex=" + dataIndex + (mCursor == null ? ": cursor is null" : ": bad data index.")); return;// w w w . jav a 2 s . co m } Log.v(TAG, "test collection view cursor data: " + mCursor.getString(0) + ", " + mCursor.getString(1) + ", " + mCursor.getString(2) + ", " + mCursor.getString(3) + ", "); final String groupJid = mCursor.getString(SessionsQuery.GROUP_JID); final String classSubjectId = mCursor.getString(SessionsQuery.CLASS_SUBJECT_ID); if (classSubjectId == null) { return; } // first, read session info from cursor and put it in convenience variables final String courseTitle = mCursor.getString(SessionsQuery.GROUP_NAME); /*final String courseTitle = mCursor.getString(SessionsQuery.SUBJECT_TITLE); final String className = mCursor.getString(SessionsQuery.CLASS_TITLE) + "-" + mCursor.getString(SessionsQuery.SECTION_TITLE);*/ /*final String educatorId = mCursor.getString(SessionsQuery.EDUCATOR_ID); final String classId = mCursor.getString(SessionsQuery.CLASS_ID); final String studentId = mCursor.getString(SessionsQuery.STUDENT_ID);*/ /*final String sessionAbstract = mCursor.getString(SessionsQuery.ABSTRACT); final long sessionStart = mCursor.getLong(SessionsQuery.SESSION_START); final long sessionEnd = mCursor.getLong(SessionsQuery.SESSION_END); final String roomName = mCursor.getString(SessionsQuery.ROOM_NAME); int sessionColor = mCursor.getInt(SessionsQuery.COLOR);*/ int sessionColor = 0; sessionColor = sessionColor == 0 ? getResources().getColor(R.color.default_session_color) : sessionColor; /*final String snippet = mIsSearchCursor ? mCursor.getString(SessionsQuery.SNIPPET) : null; final Spannable styledSnippet = mIsSearchCursor ? buildStyledSnippet(snippet) : null; final boolean starred = mCursor.getInt(SessionsQuery.IN_MY_SCHEDULE) != 0; final String[] tags = mCursor.getString(SessionsQuery.TAGS).split(",");*/ // now let's compute a few pieces of information from the data, which we will use // later to decide what to render where /*final boolean hasLivestream = !TextUtils.isEmpty(mCursor.getString( SessionsQuery.LIVESTREAM_URL));*/ final long now = UIUtils.getCurrentTime(context); /*final boolean happeningNow = now >= sessionStart && now <= sessionEnd;*/ // text that says "LIVE" if session is live, or empty if session is not live /*final String liveNowText = hasLivestream ? " " + UIUtils.getLiveBadgeText(context, sessionStart, sessionEnd) : "";*/ final String liveNowText = ""; // get reference to all the views in the layout we will need final TextView titleView = (TextView) view.findViewById(R.id.session_title); final TextView subtitleView = (TextView) view.findViewById(R.id.session_subtitle); final TextView shortSubtitleView = (TextView) view.findViewById(R.id.session_subtitle_short); /*final TextView snippetView = (TextView) view.findViewById(R.id.session_snippet);*/ final TextView abstractView = (TextView) view.findViewById(R.id.session_abstract); final TextView categoryView = (TextView) view.findViewById(R.id.session_category); final View boxView = view.findViewById(R.id.info_box); final View sessionTargetView = view.findViewById(R.id.session_target); final View grpmsgView = (ImageView) view.findViewById(R.id.session_grp_msg); if (sessionColor == 0) { // use default sessionColor = mDefaultSessionColor; } sessionColor = UIUtils.scaleSessionColorToDefaultBG(sessionColor); ImageView photoView = (ImageView) view.findViewById(R.id.session_photo_colored); if (photoView != null) { if (!mPreloader.isDimensSet()) { final ImageView finalPhotoView = photoView; photoView.post(new Runnable() { @Override public void run() { mPreloader.setDimens(finalPhotoView.getWidth(), finalPhotoView.getHeight()); } }); } // colored photoView.setColorFilter(UIUtils.setColorAlpha(sessionColor, UIUtils.SESSION_PHOTO_SCRIM_ALPHA)); } else { photoView = (ImageView) view.findViewById(R.id.session_photo); } ((BaseActivity) getActivity()).getLPreviewUtils().setViewName(photoView, "photo_" + classSubjectId); // when we load a photo, it will fade in from transparent so the // background of the container must be the session color to avoid a white flash ViewParent parent = photoView.getParent(); if (parent != null && parent instanceof View) { ((View) parent).setBackgroundColor(sessionColor); } else { photoView.setBackgroundColor(sessionColor); } //String photo = mCursor.getString(SessionsQuery.PHOTO_URL); int subjPath = R.drawable.nophotoavailable; //TODO:Temporary task to generate screenshots if (courseTitle != null) { if (courseTitle.contains("English")) { subjPath = R.drawable.logo_english; } else if (courseTitle.contains("Math")) { subjPath = R.drawable.logo_math; } else if (courseTitle.contains("Punjabi")) { subjPath = R.drawable.course_punjabi; } else if (courseTitle.contains("Hindi")) { subjPath = R.drawable.course_hindi; } else if (courseTitle.contains("German")) { subjPath = R.drawable.course_german; } else if (courseTitle.contains("Dutch")) { subjPath = R.drawable.course_dutch; } else if (courseTitle.contains("Science")) { subjPath = R.drawable.course_science; } else if (courseTitle.contains("French")) { subjPath = R.drawable.course_french; } } /*if (!TextUtils.isEmpty(photo)) {*/ //mImageLoader.loadImage(photo, photoView, true /*crop*/); Picasso.with(context) // .load(subjPath) // .placeholder(CommonConstants.LOADING) // .error(CommonConstants.ERROR_IMAGE) // .fit() // .into(photoView); /*} else { // cleaning the (potentially) recycled photoView, in case this session has no photo: photoView.setImageDrawable(null); }*/ // render title /*titleView.setText(courseTitle == null ? "?" : courseTitle);*/ titleView.setText(courseTitle == null ? "?" : courseTitle); // render subtitle into either the subtitle view, or the short subtitle view, as available if (subtitleView != null) { /*subtitleView.setText(UIUtils.formatSessionSubtitle( sessionStart, sessionEnd, roomName, mBuffer, context) + liveNowText);*/ //subtitleView.setText(className == null ? "?" : className); } else if (shortSubtitleView != null) { //Dummy data /*shortSubtitleView.setText("25");*/ shortSubtitleView.setText(mCursor.getString(SessionsQuery.MEMBER_COUNT)); shortSubtitleView.setGravity(Gravity.RIGHT); /*shortSubtitleView.setText(UIUtils.formatSessionSubtitle( sessionStart, sessionEnd, roomName, mBuffer, context, true) + liveNowText);*/ //shortSubtitleView.setText(className == null ? "?" : className); } // render category if (categoryView != null) { /*categoryView.setText(className == null ? "?" : className);*/ } // if a snippet view is available, render the session snippet there. /*if (snippetView != null) { *//*if (mIsSearchCursor) { // render the search snippet into the snippet view snippetView.setText(styledSnippet); } else { // render speaker names and abstracts into the snippet view mBuffer.setLength(0); if (!TextUtils.isEmpty(speakerNames)) { mBuffer.append(speakerNames).append(". "); } if (!TextUtils.isEmpty(sessionAbstract)) { mBuffer.append(sessionAbstract); } snippetView.setText(mBuffer.toString()); }*//* }*/ if (abstractView != null && !mIsSearchCursor) { // render speaker names and abstracts into the abstract view mBuffer.setLength(0); /*if (!TextUtils.isEmpty(speakerNames)) { mBuffer.append(speakerNames).append("\n\n"); } if (!TextUtils.isEmpty(sessionAbstract)) { mBuffer.append(sessionAbstract); }*/ abstractView.setText(mBuffer.toString()); } // in expanded mode, the box background color follows the session color if (useExpandedMode()) { boxView.setBackgroundColor(sessionColor); } /*// show or hide the "in my schedule" indicator view.findViewById(R.id.indicator_in_schedule).setVisibility(starred ? View.VISIBLE : View.INVISIBLE);*/ // if we are in condensed mode and this card is the hero card (big card at the top // of the screen), set up the message card if necessary. if (!useExpandedMode() && groupId == HERO_GROUP_ID) { // this is the hero view, so we might want to show a message card final boolean cardShown = setupMessageCard(view); // if this is the wide hero layout, show or hide the card or the session abstract // view, as appropriate (they are mutually exclusive). final View cardContainer = view.findViewById(R.id.message_card_container_wide); final View abstractContainer = view.findViewById(R.id.session_abstract); if (cardContainer != null && abstractContainer != null) { cardContainer.setVisibility(cardShown ? View.VISIBLE : View.GONE); abstractContainer.setVisibility(cardShown ? View.GONE : View.VISIBLE); abstractContainer.setBackgroundColor(sessionColor); } } // if this session is live right now, display the "LIVE NOW" icon on top of it View liveNowBadge = view.findViewById(R.id.live_now_badge); if (liveNowBadge != null) { liveNowBadge.setVisibility(View.INVISIBLE); //liveNowBadge.setVisibility(happeningNow && hasLivestream ? View.VISIBLE : View.GONE); } // if this view is clicked, open the session details view final View finalPhotoView = photoView; final int studentGroupId = mCursor.getInt(SessionsQuery.GROUP_ID); sessionTargetView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mCallbacks.onSessionSelected(classSubjectId, courseTitle, groupJid, studentGroupId, finalPhotoView); } }); // animate this card if (dataIndex > mMaxDataIndexAnimated) { mMaxDataIndexAnimated = dataIndex; } //if this view is clicked, open group messages chatting screen if (grpmsgView != null) { grpmsgView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Log.i(TAG, "grp msg image clicked, opening group messages screen"); Intent intent = new Intent(getActivity(), EducatorGroupMsgActivity.class); startActivity(intent); } }); } }
From source file:com.ncode.android.apps.schedo.ui.EventsFragment.java
@Override public void bindCollectionItemView(Context context, View view, int groupId, int indexInGroup, int dataIndex, Object tag) {//from www. ja v a 2s . c o m if (mCursor == null || !mCursor.moveToPosition(dataIndex)) { LOGW(TAG, "Can't bind collection view item, dataIndex=" + dataIndex + (mCursor == null ? ": cursor is null" : ": bad data index.")); return; } final String eventId = mCursor.getString(EventsQuery.EVENT_ID); if (eventId == null) { return; } // first, read event info from cursor and put it in convenience variables final String eventTitle = mCursor.getString(EventsQuery.TITLE); final String speakerNames = mCursor.getString(EventsQuery.SPEAKER_NAMES); final String eventAbstract = mCursor.getString(EventsQuery.ABSTRACT); final String[] eventDays = mCursor.getString(EventsQuery.EVENT_DAYS).split(","); final long eventStart = Long.valueOf(eventDays[0]).longValue(); final long eventEnd = Long.valueOf(eventDays[eventDays.length / 2]).longValue(); //final String roomName = mCursor.getString(EventsQuery.ROOM_NAME); int eventColor = mCursor.getInt(EventsQuery.COLOR); eventColor = eventColor == 0 ? getResources().getColor(R.color.default_event_color) : eventColor; int darkEventColor = 0; final String snippet = mIsSearchCursor ? mCursor.getString(EventsQuery.SNIPPET) : null; final Spannable styledSnippet = mIsSearchCursor ? buildStyledSnippet(snippet) : null; final boolean starred = mCursor.getInt(EventsQuery.IN_MY_SCHEDULE) != 0; final String[] tags = mCursor.getString(EventsQuery.TAGS).split(","); // now let's compute a few pieces of information from the data, which we will use // later to decide what to render where final boolean hasLivestream = !TextUtils.isEmpty(mCursor.getString(EventsQuery.LIVESTREAM_URL)); final long now = UIUtils.getCurrentTime(context); final boolean happeningNow = now >= eventStart && now <= eventEnd; // text that says "LIVE" if event is live, or empty if event is not live final String liveNowText = hasLivestream ? " " + UIUtils.getLiveBadgeText(context, eventStart, eventEnd) : ""; // get reference to all the views in the layout we will need final TextView titleView = (TextView) view.findViewById(R.id.session_title); final TextView subtitleView = (TextView) view.findViewById(R.id.session_subtitle); final TextView shortSubtitleView = (TextView) view.findViewById(R.id.session_subtitle_short); final TextView snippetView = (TextView) view.findViewById(R.id.session_snippet); final TextView abstractView = (TextView) view.findViewById(R.id.session_abstract); final TextView categoryView = (TextView) view.findViewById(R.id.session_category); final View eventTargetView = view.findViewById(R.id.session_target); if (eventColor == 0) { // use default eventColor = mDefaultEventColor; } if (mNoTrackBranding) { eventColor = getResources().getColor(R.color.no_track_branding_session_color); } darkEventColor = UIUtils.scaleSessionColorToDefaultBG(eventColor); ImageView photoView = (ImageView) view.findViewById(R.id.session_photo_colored); if (photoView != null) { if (!mPreloader.isDimensSet()) { final ImageView finalPhotoView = photoView; photoView.post(new Runnable() { @Override public void run() { mPreloader.setDimens(finalPhotoView.getWidth(), finalPhotoView.getHeight()); } }); } // colored photoView .setColorFilter(mNoTrackBranding ? new PorterDuffColorFilter( getResources().getColor(R.color.no_track_branding_session_tile_overlay), PorterDuff.Mode.SRC_ATOP) : UIUtils.makeSessionImageScrimColorFilter(darkEventColor)); } else { photoView = (ImageView) view.findViewById(R.id.session_photo); } ViewCompat.setTransitionName(photoView, "photo_" + eventId); // when we load a photo, it will fade in from transparent so the // background of the container must be the event color to avoid a white flash ViewParent parent = photoView.getParent(); if (parent != null && parent instanceof View) { ((View) parent).setBackgroundColor(darkEventColor); } else { photoView.setBackgroundColor(darkEventColor); } String photo = mCursor.getString(EventsQuery.PHOTO_URL); if (!TextUtils.isEmpty(photo)) { mImageLoader.loadImage(photo, photoView, true /*crop*/); } else { // cleaning the (potentially) recycled photoView, in case this event has no photo: photoView.setImageDrawable(null); } // render title titleView.setText(eventTitle == null ? "?" : eventTitle); // render subtitle into either the subtitle view, or the short subtitle view, as available if (subtitleView != null) { subtitleView.setText(UIUtils.formatEventSubtitle(eventStart, eventEnd, mBuffer, context) + liveNowText); } else if (shortSubtitleView != null) { shortSubtitleView.setText( UIUtils.formatEventSubtitle(eventStart, eventEnd, mBuffer, context, true) + liveNowText); } // render category if (categoryView != null) { TagMetadata.Tag groupTag = mTagMetadata.getGroupTag(tags, Config.Tags.EVENT_GROUPING_TAG_CATEGORY); if (groupTag != null && !Config.Tags.EVENTS.equals(groupTag.getId())) { categoryView.setText(groupTag.getName()); categoryView.setVisibility(View.VISIBLE); } else { categoryView.setVisibility(View.GONE); } } // if a snippet view is available, render the event snippet there. if (snippetView != null) { if (mIsSearchCursor) { // render the search snippet into the snippet view snippetView.setText(styledSnippet); } else { // render speaker names and abstracts into the snippet view mBuffer.setLength(0); if (!TextUtils.isEmpty(speakerNames)) { mBuffer.append(speakerNames).append(". "); } if (!TextUtils.isEmpty(eventAbstract)) { mBuffer.append(eventAbstract); } snippetView.setText(mBuffer.toString()); } } if (abstractView != null && !mIsSearchCursor) { // render speaker names and abstracts into the abstract view mBuffer.setLength(0); if (!TextUtils.isEmpty(speakerNames)) { mBuffer.append(speakerNames).append("\n\n"); } if (!TextUtils.isEmpty(eventAbstract)) { mBuffer.append(eventAbstract); } abstractView.setText(mBuffer.toString()); } // show or hide the "in my schedule" indicator view.findViewById(R.id.indicator_in_schedule).setVisibility(starred ? View.VISIBLE : View.INVISIBLE); // if we are in condensed mode and this card is the hero card (big card at the top // of the screen), set up the message card if necessary. if (!useExpandedMode() && groupId == HERO_GROUP_ID) { // this is the hero view, so we might want to show a message card final boolean cardShown = setupMessageCard(view); // if this is the wide hero layout, show or hide the card or the event abstract // view, as appropriate (they are mutually exclusive). final View cardContainer = view.findViewById(R.id.message_card_container_wide); final View abstractContainer = view.findViewById(R.id.session_abstract); if (cardContainer != null && abstractContainer != null) { cardContainer.setVisibility(cardShown ? View.VISIBLE : View.GONE); abstractContainer.setVisibility(cardShown ? View.GONE : View.VISIBLE); abstractContainer.setBackgroundColor(darkEventColor); } } // if this event is live right now, display the "LIVE NOW" icon on top of it View liveNowBadge = view.findViewById(R.id.live_now_badge); if (liveNowBadge != null) { liveNowBadge.setVisibility(happeningNow && hasLivestream ? View.VISIBLE : View.GONE); } // if this view is clicked, open the event details view final View finalPhotoView = photoView; eventTargetView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mCallbacks.onEventSelected(eventId, finalPhotoView); } }); // animate this card if (dataIndex > mMaxDataIndexAnimated) { mMaxDataIndexAnimated = dataIndex; } }
From source file:com.google.samples.apps.iosched.ui.SessionsFragment.java
@Override public void bindCollectionItemView(Context context, View view, int groupId, int indexInGroup, int dataIndex, Object tag) {/* w w w . j a va 2s .c o m*/ if (mCursor == null || !mCursor.moveToPosition(dataIndex)) { LOGW(TAG, "Can't bind collection view item, dataIndex=" + dataIndex + (mCursor == null ? ": cursor is null" : ": bad data index.")); return; } final String sessionId = mCursor.getString(SessionsQuery.SESSION_ID); if (sessionId == null) { return; } // first, read session info from cursor and put it in convenience variables final String sessionTitle = mCursor.getString(SessionsQuery.TITLE); final String speakerNames = mCursor.getString(SessionsQuery.SPEAKER_NAMES); final String sessionAbstract = mCursor.getString(SessionsQuery.ABSTRACT); final long sessionStart = mCursor.getLong(SessionsQuery.SESSION_START); final long sessionEnd = mCursor.getLong(SessionsQuery.SESSION_END); final String roomName = mCursor.getString(SessionsQuery.ROOM_NAME); int sessionColor = mCursor.getInt(SessionsQuery.COLOR); sessionColor = sessionColor == 0 ? getResources().getColor(R.color.default_session_color) : sessionColor; int darkSessionColor = 0; final String snippet = mIsSearchCursor ? mCursor.getString(SessionsQuery.SNIPPET) : null; final Spannable styledSnippet = mIsSearchCursor ? buildStyledSnippet(snippet) : null; final boolean starred = mCursor.getInt(SessionsQuery.IN_MY_SCHEDULE) != 0; final String[] tags = mCursor.getString(SessionsQuery.TAGS).split(","); // now let's compute a few pieces of information from the data, which we will use // later to decide what to render where final boolean hasLivestream = !TextUtils.isEmpty(mCursor.getString(SessionsQuery.LIVESTREAM_URL)); final long now = UIUtils.getCurrentTime(context); final boolean happeningNow = now >= sessionStart && now <= sessionEnd; // text that says "LIVE" if session is live, or empty if session is not live final String liveNowText = hasLivestream ? " " + UIUtils.getLiveBadgeText(context, sessionStart, sessionEnd) : ""; // get reference to all the views in the layout we will need final TextView titleView = (TextView) view.findViewById(R.id.session_title); final TextView subtitleView = (TextView) view.findViewById(R.id.session_subtitle); final TextView shortSubtitleView = (TextView) view.findViewById(R.id.session_subtitle_short); final TextView snippetView = (TextView) view.findViewById(R.id.session_snippet); final TextView abstractView = (TextView) view.findViewById(R.id.session_abstract); final TextView categoryView = (TextView) view.findViewById(R.id.session_category); final View sessionTargetView = view.findViewById(R.id.session_target); if (sessionColor == 0) { // use default sessionColor = mDefaultSessionColor; } if (mNoTrackBranding) { sessionColor = getResources().getColor(R.color.no_track_branding_session_color); } darkSessionColor = UIUtils.scaleSessionColorToDefaultBG(sessionColor); ImageView photoView = (ImageView) view.findViewById(R.id.session_photo_colored); if (photoView != null) { if (!mPreloader.isDimensSet()) { final ImageView finalPhotoView = photoView; photoView.post(new Runnable() { @Override public void run() { mPreloader.setDimens(finalPhotoView.getWidth(), finalPhotoView.getHeight()); } }); } // colored photoView .setColorFilter(mNoTrackBranding ? new PorterDuffColorFilter( getResources().getColor(R.color.no_track_branding_session_tile_overlay), PorterDuff.Mode.SRC_ATOP) : UIUtils.makeSessionImageScrimColorFilter(darkSessionColor)); } else { photoView = (ImageView) view.findViewById(R.id.session_photo); } ViewCompat.setTransitionName(photoView, "photo_" + sessionId); // when we load a photo, it will fade in from transparent so the // background of the container must be the session color to avoid a white flash ViewParent parent = photoView.getParent(); if (parent != null && parent instanceof View) { ((View) parent).setBackgroundColor(darkSessionColor); } else { photoView.setBackgroundColor(darkSessionColor); } String photo = mCursor.getString(SessionsQuery.PHOTO_URL); if (!TextUtils.isEmpty(photo)) { mImageLoader.loadImage(photo, photoView, true /*crop*/); } else { // cleaning the (potentially) recycled photoView, in case this session has no photo: photoView.setImageDrawable(null); } // render title titleView.setText(sessionTitle == null ? "?" : sessionTitle); // render subtitle into either the subtitle view, or the short subtitle view, as available if (subtitleView != null) { subtitleView.setText(UIUtils.formatSessionSubtitle(sessionStart, sessionEnd, roomName, mBuffer, context) + liveNowText); } else if (shortSubtitleView != null) { shortSubtitleView.setText( UIUtils.formatSessionSubtitle(sessionStart, sessionEnd, roomName, mBuffer, context, true) + liveNowText); } // render category if (categoryView != null) { TagMetadata.Tag groupTag = mTagMetadata.getSessionGroupTag(tags); if (groupTag != null && !Config.Tags.SESSIONS.equals(groupTag.getId())) { categoryView.setText(groupTag.getName()); categoryView.setVisibility(View.VISIBLE); } else { categoryView.setVisibility(View.GONE); } } // if a snippet view is available, render the session snippet there. if (snippetView != null) { if (mIsSearchCursor) { // render the search snippet into the snippet view snippetView.setText(styledSnippet); } else { // render speaker names and abstracts into the snippet view mBuffer.setLength(0); if (!TextUtils.isEmpty(speakerNames)) { mBuffer.append(speakerNames).append(". "); } if (!TextUtils.isEmpty(sessionAbstract)) { mBuffer.append(sessionAbstract); } snippetView.setText(mBuffer.toString()); } } if (abstractView != null && !mIsSearchCursor) { // render speaker names and abstracts into the abstract view mBuffer.setLength(0); if (!TextUtils.isEmpty(speakerNames)) { mBuffer.append(speakerNames).append("\n\n"); } if (!TextUtils.isEmpty(sessionAbstract)) { mBuffer.append(sessionAbstract); } abstractView.setText(mBuffer.toString()); } // show or hide the "in my schedule" indicator view.findViewById(R.id.indicator_in_schedule).setVisibility(starred ? View.VISIBLE : View.INVISIBLE); // if we are in condensed mode and this card is the hero card (big card at the top // of the screen), set up the message card if necessary. if (!useExpandedMode() && groupId == HERO_GROUP_ID) { // this is the hero view, so we might want to show a message card final boolean cardShown = setupMessageCard(view); // if this is the wide hero layout, show or hide the card or the session abstract // view, as appropriate (they are mutually exclusive). final View cardContainer = view.findViewById(R.id.message_card_container_wide); final View abstractContainer = view.findViewById(R.id.session_abstract); if (cardContainer != null && abstractContainer != null) { cardContainer.setVisibility(cardShown ? View.VISIBLE : View.GONE); abstractContainer.setVisibility(cardShown ? View.GONE : View.VISIBLE); abstractContainer.setBackgroundColor(darkSessionColor); } } // if this session is live right now, display the "LIVE NOW" icon on top of it View liveNowBadge = view.findViewById(R.id.live_now_badge); if (liveNowBadge != null) { liveNowBadge.setVisibility(happeningNow && hasLivestream ? View.VISIBLE : View.GONE); } // if this view is clicked, open the session details view final View finalPhotoView = photoView; sessionTargetView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mCallbacks.onSessionSelected(sessionId, finalPhotoView); } }); // animate this card if (dataIndex > mMaxDataIndexAnimated) { mMaxDataIndexAnimated = dataIndex; } }
From source file:com.ncode.android.apps.schedo.ui.SessionsFragment.java
@Override public void bindCollectionItemView(Context context, View view, int groupId, int indexInGroup, int dataIndex, Object tag) {//from ww w. j a v a 2 s . c o m if (mCursor == null || !mCursor.moveToPosition(dataIndex)) { LOGW(TAG, "Can't bind collection view item, dataIndex=" + dataIndex + (mCursor == null ? ": cursor is null" : ": bad data index.")); return; } final String sessionId = mCursor.getString(SessionsQuery.SESSION_ID); if (sessionId == null) { return; } // first, read session info from cursor and put it in convenience variables final String sessionTitle = mCursor.getString(SessionsQuery.TITLE); final String speakerNames = mCursor.getString(SessionsQuery.SPEAKER_NAMES); final String sessionAbstract = mCursor.getString(SessionsQuery.ABSTRACT); final long sessionStart = mCursor.getLong(SessionsQuery.SESSION_START); final long sessionEnd = mCursor.getLong(SessionsQuery.SESSION_END); final String roomName = mCursor.getString(SessionsQuery.ROOM_NAME); int sessionColor = mCursor.getInt(SessionsQuery.COLOR); sessionColor = sessionColor == 0 ? getResources().getColor(R.color.default_session_color) : sessionColor; int darkSessionColor = 0; final String snippet = mIsSearchCursor ? mCursor.getString(SessionsQuery.SNIPPET) : null; final Spannable styledSnippet = mIsSearchCursor ? buildStyledSnippet(snippet) : null; final boolean starred = mCursor.getInt(SessionsQuery.IN_MY_SCHEDULE) != 0; final String[] tags = mCursor.getString(SessionsQuery.TAGS).split(","); // now let's compute a few pieces of information from the data, which we will use // later to decide what to render where final boolean hasLivestream = !TextUtils.isEmpty(mCursor.getString(SessionsQuery.LIVESTREAM_URL)); final long now = UIUtils.getCurrentTime(context); final boolean happeningNow = now >= sessionStart && now <= sessionEnd; // text that says "LIVE" if session is live, or empty if session is not live final String liveNowText = hasLivestream ? " " + UIUtils.getLiveBadgeText(context, sessionStart, sessionEnd) : ""; // get reference to all the views in the layout we will need final TextView titleView = (TextView) view.findViewById(R.id.session_title); final TextView subtitleView = (TextView) view.findViewById(R.id.session_subtitle); final TextView shortSubtitleView = (TextView) view.findViewById(R.id.session_subtitle_short); final TextView snippetView = (TextView) view.findViewById(R.id.session_snippet); final TextView abstractView = (TextView) view.findViewById(R.id.session_abstract); final TextView categoryView = (TextView) view.findViewById(R.id.session_category); final View sessionTargetView = view.findViewById(R.id.session_target); if (sessionColor == 0) { // use default sessionColor = mDefaultSessionColor; } if (mNoTrackBranding) { sessionColor = getResources().getColor(R.color.no_track_branding_session_color); } darkSessionColor = UIUtils.scaleSessionColorToDefaultBG(sessionColor); ImageView photoView = (ImageView) view.findViewById(R.id.session_photo_colored); if (photoView != null) { if (!mPreloader.isDimensSet()) { final ImageView finalPhotoView = photoView; photoView.post(new Runnable() { @Override public void run() { mPreloader.setDimens(finalPhotoView.getWidth(), finalPhotoView.getHeight()); } }); } // colored photoView .setColorFilter(mNoTrackBranding ? new PorterDuffColorFilter( getResources().getColor(R.color.no_track_branding_session_tile_overlay), PorterDuff.Mode.SRC_ATOP) : UIUtils.makeSessionImageScrimColorFilter(darkSessionColor)); } else { photoView = (ImageView) view.findViewById(R.id.session_photo); } ViewCompat.setTransitionName(photoView, "photo_" + sessionId); // when we load a photo, it will fade in from transparent so the // background of the container must be the session color to avoid a white flash ViewParent parent = photoView.getParent(); if (parent != null && parent instanceof View) { ((View) parent).setBackgroundColor(darkSessionColor); } else { photoView.setBackgroundColor(darkSessionColor); } String photo = mCursor.getString(SessionsQuery.PHOTO_URL); if (!TextUtils.isEmpty(photo)) { mImageLoader.loadImage(photo, photoView, true /*crop*/); } else { // cleaning the (potentially) recycled photoView, in case this session has no photo: photoView.setImageDrawable(null); } // render title titleView.setText(sessionTitle == null ? "?" : sessionTitle); // render subtitle into either the subtitle view, or the short subtitle view, as available if (subtitleView != null) { subtitleView.setText(UIUtils.formatSessionSubtitle(sessionStart, sessionEnd, roomName, mBuffer, context) + liveNowText); } else if (shortSubtitleView != null) { shortSubtitleView.setText( UIUtils.formatSessionSubtitle(sessionStart, sessionEnd, roomName, mBuffer, context, true) + liveNowText); } // render category if (categoryView != null) { TagMetadata.Tag groupTag = mTagMetadata.getGroupTag(tags, Config.Tags.SESSION_GROUPING_TAG_CATEGORY); if (groupTag != null && !Config.Tags.SESSIONS.equals(groupTag.getId())) { categoryView.setText(groupTag.getName()); categoryView.setVisibility(View.VISIBLE); } else { categoryView.setVisibility(View.GONE); } } // if a snippet view is available, render the session snippet there. if (snippetView != null) { if (mIsSearchCursor) { // render the search snippet into the snippet view snippetView.setText(styledSnippet); } else { // render speaker names and abstracts into the snippet view mBuffer.setLength(0); if (!TextUtils.isEmpty(speakerNames)) { mBuffer.append(speakerNames).append(". "); } if (!TextUtils.isEmpty(sessionAbstract)) { mBuffer.append(sessionAbstract); } snippetView.setText(mBuffer.toString()); } } if (abstractView != null && !mIsSearchCursor) { // render speaker names and abstracts into the abstract view mBuffer.setLength(0); if (!TextUtils.isEmpty(speakerNames)) { mBuffer.append(speakerNames).append("\n\n"); } if (!TextUtils.isEmpty(sessionAbstract)) { mBuffer.append(sessionAbstract); } abstractView.setText(mBuffer.toString()); } // show or hide the "in my schedule" indicator view.findViewById(R.id.indicator_in_schedule).setVisibility(starred ? View.VISIBLE : View.INVISIBLE); // if we are in condensed mode and this card is the hero card (big card at the top // of the screen), set up the message card if necessary. if (!useExpandedMode() && groupId == HERO_GROUP_ID) { // this is the hero view, so we might want to show a message card final boolean cardShown = setupMessageCard(view); // if this is the wide hero layout, show or hide the card or the session abstract // view, as appropriate (they are mutually exclusive). final View cardContainer = view.findViewById(R.id.message_card_container_wide); final View abstractContainer = view.findViewById(R.id.session_abstract); if (cardContainer != null && abstractContainer != null) { cardContainer.setVisibility(cardShown ? View.VISIBLE : View.GONE); abstractContainer.setVisibility(cardShown ? View.GONE : View.VISIBLE); abstractContainer.setBackgroundColor(darkSessionColor); } } // if this session is live right now, display the "LIVE NOW" icon on top of it View liveNowBadge = view.findViewById(R.id.live_now_badge); if (liveNowBadge != null) { liveNowBadge.setVisibility(happeningNow && hasLivestream ? View.VISIBLE : View.GONE); } // if this view is clicked, open the session details view final View finalPhotoView = photoView; sessionTargetView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mCallbacks.onSessionSelected(sessionId, finalPhotoView); } }); // animate this card if (dataIndex > mMaxDataIndexAnimated) { mMaxDataIndexAnimated = dataIndex; } }