Search in sources :

Example 11 with Session

use of org.fossasia.openevent.data.Session in project open-event-android by fossasia.

the class OSMapFragment method showEvent.

private void showEvent() {
    if (!event.isValid())
        return;
    try {
        int id = SharedPreferencesUtil.getInt(ConstantStrings.SESSION_MAP_ID, -1);
        if (id != -1) {
            Session session = realmRepo.getSessionSync(id);
            Microlocation microlocation = session.getMicrolocation();
            if (microlocation.getLatitude() == 0 && microlocation.getLongitude() == 0) {
                setDestinationLatitude(event.getLatitude());
                setDestinationLongitude(event.getLongitude());
                setDestinationName(event.getLocationName());
            } else {
                setDestinationLatitude(microlocation.getLatitude());
                setDestinationLongitude(microlocation.getLongitude());
                setDestinationName(microlocation.getName());
            }
        } else {
            setDestinationLatitude(event.getLatitude());
            setDestinationLongitude(event.getLongitude());
            setDestinationName(event.getLocationName());
        }
    } catch (Exception e) {
        setDestinationLatitude(event.getLatitude());
        setDestinationLongitude(event.getLongitude());
        setDestinationName(event.getLocationName());
    }
}
Also used : GeoPoint(org.osmdroid.util.GeoPoint) Microlocation(org.fossasia.openevent.data.Microlocation) Session(org.fossasia.openevent.data.Session)

Example 12 with Session

use of org.fossasia.openevent.data.Session 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 13 with Session

use of org.fossasia.openevent.data.Session in project open-event-android by fossasia.

the class TrackSessionsActivityViewModel method calculateUpcomingOngoingPosition.

private void calculateUpcomingOngoingPosition(List<Session> sessions) {
    int countUpcoming = 0;
    int countOngoing = 0;
    for (Session trackSession : sessions) {
        flag = 0;
        ZonedDateTime start = DateConverter.getDate(trackSession.getStartsAt());
        ZonedDateTime end = DateConverter.getDate((trackSession.getEndsAt()));
        ZonedDateTime current = ZonedDateTime.now();
        if (DateService.isOngoingSession(start, end, current)) {
            ongoingPosition = countOngoing;
            break;
        } else if (DateService.isUpcomingSession(start, end, current)) {
            upcomingPosition = countUpcoming;
            break;
        } else
            flag += 1;
        countUpcoming += 1;
        countOngoing += 1;
    }
}
Also used : ZonedDateTime(org.threeten.bp.ZonedDateTime) Session(org.fossasia.openevent.data.Session)

Aggregations

Session (org.fossasia.openevent.data.Session)13 Intent (android.content.Intent)5 Track (org.fossasia.openevent.data.Track)4 Build (android.os.Build)3 Bundle (android.os.Bundle)3 View (android.view.View)3 BindView (butterknife.BindView)3 R (org.fossasia.openevent.R)3 ConstantStrings (org.fossasia.openevent.common.ConstantStrings)3 DateConverter (org.fossasia.openevent.common.date.DateConverter)3 Utils (org.fossasia.openevent.common.utils.Utils)3 RealmDataRepository (org.fossasia.openevent.data.repository.RealmDataRepository)3 ZonedDateTime (org.threeten.bp.ZonedDateTime)3 Timber (timber.log.Timber)3 Context (android.content.Context)2 Color (android.graphics.Color)2 PorterDuff (android.graphics.PorterDuff)2 AppBarLayout (android.support.design.widget.AppBarLayout)2 Snackbar (android.support.design.widget.Snackbar)2 Fragment (android.support.v4.app.Fragment)2