Search in sources :

Example 1 with LocationViewHolder

use of org.fossasia.openevent.core.location.LocationViewHolder in project open-event-android by fossasia.

the class GlobalSearchAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch(holder.getItemViewType()) {
        case TRACK:
            TrackViewHolder trackSearchHolder = (TrackViewHolder) holder;
            Track currentTrack = (Track) getItem(position);
            trackSearchHolder.bindTrack(currentTrack);
            break;
        case SPEAKER:
            SpeakerViewHolder speakerSearchHolder = (SpeakerViewHolder) holder;
            Speaker speaker = (Speaker) getItem(position);
            speakerSearchHolder.bindSpeaker(speaker);
            break;
        case LOCATION:
            LocationViewHolder locationSearchHolder = (LocationViewHolder) holder;
            Microlocation location = (Microlocation) getItem(position);
            locationSearchHolder.bindLocation(location);
            break;
        case DIVIDER:
            DividerViewHolder resultTypeViewHolder = (DividerViewHolder) holder;
            String headerItem = (String) getItem(position);
            resultTypeViewHolder.bindHeader(headerItem);
            break;
        case SESSION:
            DayScheduleViewHolder bookmarkTypeViewHolder = (DayScheduleViewHolder) holder;
            Session bookmarkItem = (Session) getItem(position);
            bookmarkTypeViewHolder.setSession(bookmarkItem);
            bookmarkTypeViewHolder.bindSession(realmRepo);
            break;
        default:
            // If viewType is none of the above then nothing is done
            break;
    }
}
Also used : SpeakerViewHolder(org.fossasia.openevent.core.speaker.SpeakerViewHolder) DividerViewHolder(org.fossasia.openevent.common.ui.recyclerview.DividerViewHolder) LocationViewHolder(org.fossasia.openevent.core.location.LocationViewHolder) DayScheduleViewHolder(org.fossasia.openevent.core.schedule.DayScheduleViewHolder) TrackViewHolder(org.fossasia.openevent.core.track.TrackViewHolder) Track(org.fossasia.openevent.data.Track) Microlocation(org.fossasia.openevent.data.Microlocation) Speaker(org.fossasia.openevent.data.Speaker) Session(org.fossasia.openevent.data.Session)

Example 2 with LocationViewHolder

use of org.fossasia.openevent.core.location.LocationViewHolder in project open-event-android by fossasia.

the class GlobalSearchAdapter method onCreateViewHolder.

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    RecyclerView.ViewHolder resultHolder = null;
    LayoutInflater inflater = LayoutInflater.from(parent.getContext());
    switch(viewType) {
        case TRACK:
            View track = inflater.inflate(R.layout.item_track, parent, false);
            resultHolder = new TrackViewHolder(track, context);
            break;
        case SPEAKER:
            View speaker = inflater.inflate(R.layout.search_item_speaker, parent, false);
            resultHolder = new SpeakerViewHolder(speaker, context);
            ((SpeakerViewHolder) resultHolder).setIsImageCircle(true);
            break;
        case LOCATION:
            View location = inflater.inflate(R.layout.item_location, parent, false);
            resultHolder = new LocationViewHolder(location, context);
            break;
        case DIVIDER:
            View header;
            if (context instanceof SearchActivity) {
                header = inflater.inflate(R.layout.search_result_type_header_format, parent, false);
            } else {
                header = inflater.inflate(R.layout.recycler_view_header, parent, false);
            }
            resultHolder = new DividerViewHolder(header);
            break;
        case SESSION:
            View bookmark = inflater.inflate(R.layout.item_schedule, parent, false);
            resultHolder = new DayScheduleViewHolder(bookmark, context, onBookmarkSelectedListener);
            break;
        default:
            // If viewType doesn't match any of the above objects no view is created
            break;
    }
    return resultHolder;
}
Also used : SpeakerViewHolder(org.fossasia.openevent.core.speaker.SpeakerViewHolder) DividerViewHolder(org.fossasia.openevent.common.ui.recyclerview.DividerViewHolder) LocationViewHolder(org.fossasia.openevent.core.location.LocationViewHolder) DayScheduleViewHolder(org.fossasia.openevent.core.schedule.DayScheduleViewHolder) LayoutInflater(android.view.LayoutInflater) RecyclerView(android.support.v7.widget.RecyclerView) TrackViewHolder(org.fossasia.openevent.core.track.TrackViewHolder) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

DividerViewHolder (org.fossasia.openevent.common.ui.recyclerview.DividerViewHolder)2 LocationViewHolder (org.fossasia.openevent.core.location.LocationViewHolder)2 DayScheduleViewHolder (org.fossasia.openevent.core.schedule.DayScheduleViewHolder)2 SpeakerViewHolder (org.fossasia.openevent.core.speaker.SpeakerViewHolder)2 TrackViewHolder (org.fossasia.openevent.core.track.TrackViewHolder)2 RecyclerView (android.support.v7.widget.RecyclerView)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 Microlocation (org.fossasia.openevent.data.Microlocation)1 Session (org.fossasia.openevent.data.Session)1 Speaker (org.fossasia.openevent.data.Speaker)1 Track (org.fossasia.openevent.data.Track)1