Search in sources :

Example 6 with ImageLoader

use of com.google.samples.apps.iosched.util.ImageLoader in project iosched by google.

the class VideoLibraryFilteredFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mImageLoader = new ImageLoader(getActivity(), android.R.color.transparent);
    mYearsFilterRadioGroup = (RadioGroup) getActivity().findViewById(R.id.years_radio_group);
    mTopicsFilterRadioGroup = (RadioGroup) getActivity().findViewById(R.id.topics_radio_group);
    mDrawerLayout = (DrawerLayout) getActivity().findViewById(R.id.drawer_layout);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_flipped, GravityCompat.END);
    initPresenter();
}
Also used : ImageLoader(com.google.samples.apps.iosched.util.ImageLoader)

Example 7 with ImageLoader

use of com.google.samples.apps.iosched.util.ImageLoader in project iosched by google.

the class VideoLibraryFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mImageLoader = new ImageLoader(getActivity(), android.R.color.transparent);
    initPresenter();
}
Also used : ImageLoader(com.google.samples.apps.iosched.util.ImageLoader)

Example 8 with ImageLoader

use of com.google.samples.apps.iosched.util.ImageLoader in project iosched by google.

the class MyScheduleDayAdapter method getView.

@Override
public View getView(int position, View view, ViewGroup parent) {
    if (mImageLoader == null) {
        mImageLoader = new ImageLoader(mContext);
    }
    ViewHolder holder;
    // Create a new view if it is not ready yet.
    if (view == null) {
        view = LayoutInflater.from(mContext).inflate(R.layout.my_schedule_item, parent, false);
        holder = new ViewHolder();
        holder.startTime = (TextView) view.findViewById(R.id.start_time);
        holder.more = (TextView) view.findViewById(R.id.more);
        holder.icon = (ImageView) view.findViewById(R.id.icon);
        holder.title = (TextView) view.findViewById(R.id.slot_title);
        holder.description = (TextView) view.findViewById(R.id.slot_description);
        holder.browse = (TextView) view.findViewById(R.id.browse_sessions);
        holder.feedback = (Button) view.findViewById(R.id.give_feedback_button);
        holder.separator = view.findViewById(R.id.separator);
        holder.touchArea = view.findViewById(R.id.touch_area);
        holder.live = view.findViewById(R.id.live_now_badge);
        view.setTag(holder);
        // Typeface
        mLUtils.setMediumTypeface(holder.startTime);
        mLUtils.setMediumTypeface(holder.browse);
        mLUtils.setMediumTypeface(holder.title);
        adjustForRtl(holder);
    } else {
        holder = (ViewHolder) view.getTag();
        // Clear event listeners
        clearClickable(view);
        clearClickable(holder.startTime);
        clearClickable(holder.touchArea);
        //Make sure it doesn't retain conflict coloring
        holder.description.setTextColor(mHourColorDefault);
    }
    if (position < 0 || position >= mItems.size()) {
        LOGE(TAG, "Invalid view position passed to MyScheduleDayAdapter: " + position);
        return view;
    }
    final ScheduleItem item = mItems.get(position);
    ScheduleItem nextItem = position < mItems.size() - 1 ? mItems.get(position + 1) : null;
    long now = TimeUtils.getCurrentTime(view.getContext());
    boolean isNowPlaying = item.startTime <= now && now <= item.endTime && item.type == ScheduleItem.SESSION;
    boolean isPastDuringConference = item.endTime <= now && now < Config.CONFERENCE_END_MILLIS;
    if (isPastDuringConference) {
        view.setBackgroundColor(mColorBackgroundPast);
        holder.startTime.setTextColor(mHourColorPast);
        holder.title.setTextColor(mTitleColorPast);
        holder.description.setVisibility(View.GONE);
        holder.icon.setColorFilter(mIconColorPast);
    } else {
        view.setBackgroundColor(mColorBackgroundDefault);
        holder.startTime.setTextColor(mHourColorDefault);
        holder.title.setTextColor(mTitleColorDefault);
        holder.description.setVisibility(View.VISIBLE);
        holder.icon.setColorFilter(mIconColorDefault);
    }
    holder.startTime.setText(TimeUtils.formatShortTime(mContext, new Date(item.startTime)));
    // show or hide the "LIVE NOW" badge
    holder.live.setVisibility(0 != (item.flags & ScheduleItem.FLAG_HAS_LIVESTREAM) && isNowPlaying ? View.VISIBLE : View.GONE);
    holder.touchArea.setTag(R.id.myschedule_uri_tagkey, null);
    if (item.type == ScheduleItem.FREE) {
        holder.startTime.setVisibility(View.VISIBLE);
        holder.more.setVisibility(View.GONE);
        holder.icon.setImageResource(R.drawable.ic_browse);
        holder.feedback.setVisibility(View.GONE);
        holder.title.setVisibility(View.GONE);
        holder.browse.setVisibility(View.VISIBLE);
        setUriClickable(view, ScheduleContract.Sessions.buildUnscheduledSessionsInInterval(item.startTime, item.endTime));
        holder.description.setVisibility(View.GONE);
    } else if (item.type == ScheduleItem.BREAK) {
        holder.startTime.setVisibility(View.VISIBLE);
        holder.more.setVisibility(View.GONE);
        holder.feedback.setVisibility(View.GONE);
        holder.title.setVisibility(View.VISIBLE);
        holder.title.setText(item.title);
        holder.icon.setImageResource(UIUtils.getBreakIcon(item.title));
        holder.browse.setVisibility(View.GONE);
        holder.description.setText(formatDescription(item));
    } else if (item.type == ScheduleItem.SESSION) {
        if (holder.feedback != null) {
            boolean showFeedbackButton = !item.hasGivenFeedback;
            // conference too.
            if (showFeedbackButton) {
                if (item.endTime > now) {
                    // Session hasn't finished yet, don't show button.
                    showFeedbackButton = false;
                }
            }
            holder.feedback.setVisibility(showFeedbackButton ? View.VISIBLE : View.GONE);
            holder.feedback.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    Bundle bundle = new Bundle();
                    bundle.putString(MyScheduleModel.SESSION_ID_KEY, item.sessionId);
                    bundle.putString(MyScheduleModel.SESSION_TITLE_KEY, item.title);
                    mListener.onUserAction(MyScheduleUserActionEnum.FEEDBACK, bundle);
                    Intent feedbackIntent = new Intent(Intent.ACTION_VIEW, ScheduleContract.Sessions.buildSessionUri(item.sessionId), mContext, SessionFeedbackActivity.class);
                    mContext.startActivity(feedbackIntent);
                }
            });
        }
        holder.title.setVisibility(View.VISIBLE);
        holder.title.setText(item.title);
        holder.more.setVisibility(item.isKeynote() ? View.GONE : View.VISIBLE);
        holder.browse.setVisibility(View.GONE);
        holder.icon.setImageResource(UIUtils.getSessionIcon(item.sessionType));
        final Uri sessionUri = ScheduleContract.Sessions.buildSessionUri(item.sessionId);
        if (0 != (item.flags & ScheduleItem.FLAG_CONFLICTS_WITH_PREVIOUS)) {
            holder.startTime.setVisibility(View.GONE);
            holder.description.setTextColor(mColorConflict);
            setUriClickable(holder.touchArea, sessionUri);
        } else {
            holder.startTime.setVisibility(View.VISIBLE);
            setUriClickable(holder.startTime, ScheduleContract.Sessions.buildUnscheduledSessionsInInterval(item.startTime, item.endTime));
            // Padding fix needed for KitKat (padding gets removed by setting the background)
            holder.startTime.setPadding((int) mContext.getResources().getDimension(R.dimen.keyline_2), 0, (int) mContext.getResources().getDimension(R.dimen.keyline_2), 0);
            setUriClickable(holder.touchArea, sessionUri);
            if (0 != (item.flags & ScheduleItem.FLAG_CONFLICTS_WITH_NEXT)) {
                holder.description.setTextColor(mColorConflict);
            }
        }
        holder.description.setText(formatDescription(item));
    } else {
        LOGE(TAG, "Invalid item type in MyScheduleDayAdapter: " + item.type);
    }
    holder.separator.setVisibility(nextItem == null || 0 != (item.flags & ScheduleItem.FLAG_CONFLICTS_WITH_NEXT) ? View.GONE : View.VISIBLE);
    if (position == 0) {
        // First item
        view.setPadding(0, mListSpacing, 0, 0);
    } else if (nextItem == null) {
        // Last item
        view.setPadding(0, 0, 0, mListSpacing);
    } else {
        view.setPadding(0, 0, 0, 0);
    }
    return view;
}
Also used : ScheduleItem(com.google.samples.apps.iosched.model.ScheduleItem) Bundle(android.os.Bundle) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) Uri(android.net.Uri) Date(java.util.Date) ImageLoader(com.google.samples.apps.iosched.util.ImageLoader) SessionFeedbackActivity(com.google.samples.apps.iosched.feedback.SessionFeedbackActivity)

Aggregations

ImageLoader (com.google.samples.apps.iosched.util.ImageLoader)8 View (android.view.View)4 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)2 Intent (android.content.Intent)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 RecyclerView (android.support.v7.widget.RecyclerView)1 ViewGroup (android.view.ViewGroup)1 AbsListView (android.widget.AbsListView)1 ImageButton (android.widget.ImageButton)1 SessionFeedbackActivity (com.google.samples.apps.iosched.feedback.SessionFeedbackActivity)1 ScheduleItem (com.google.samples.apps.iosched.model.ScheduleItem)1 AppNavigationViewAsDrawerImpl (com.google.samples.apps.iosched.navigation.AppNavigationViewAsDrawerImpl)1 Date (java.util.Date)1