Search in sources :

Example 6 with Event

use of com.eventyay.organizer.data.event.Event in project open-event-orga-app by fossasia.

the class CreateCopyrightViewModel method createCopyright.

public void createCopyright() {
    nullifyEmptyFields(copyright);
    if (!verifyYear(copyright))
        return;
    long eventId = ContextManager.getSelectedEvent().getId();
    Event event = new Event();
    event.setId(eventId);
    copyright.setEvent(event);
    compositeDisposable.add(copyrightRepository.createCopyright(copyright).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(createdTicket -> {
        success.setValue("Copyright Created");
        dismiss.call();
    }, throwable -> error.setValue(ErrorUtils.getMessage(throwable).toString())));
}
Also used : Inject(javax.inject.Inject) LiveData(androidx.lifecycle.LiveData) SingleEventLiveData(com.eventyay.organizer.common.livedata.SingleEventLiveData) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Event(com.eventyay.organizer.data.event.Event) Copyright(com.eventyay.organizer.data.copyright.Copyright) ViewModel(androidx.lifecycle.ViewModel) CopyrightRepository(com.eventyay.organizer.data.copyright.CopyrightRepository) ContextManager(com.eventyay.organizer.common.ContextManager) ErrorUtils(com.eventyay.organizer.utils.ErrorUtils) StringUtils(com.eventyay.organizer.utils.StringUtils) Event(com.eventyay.organizer.data.event.Event)

Example 7 with Event

use of com.eventyay.organizer.data.event.Event in project open-event-orga-app by fossasia.

the class EventDashboardFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    Event event = ContextManager.getSelectedEvent();
    String startsAt = DateUtils.formatDateWithDefault(DateUtils.FORMAT_DATE_TIME, event.getStartsAt());
    String endsAt = DateUtils.formatDateWithDefault(DateUtils.FORMAT_DATE_TIME, event.getEndsAt());
    ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(event.getName());
    ((AppCompatActivity) getActivity()).getSupportActionBar().setSubtitle(startsAt + " - " + endsAt);
}
Also used : Event(com.eventyay.organizer.data.event.Event)

Example 8 with Event

use of com.eventyay.organizer.data.event.Event in project open-event-orga-app by fossasia.

the class EventsViewModel method filter.

public void filter() {
    List<Event> live = new ArrayList<>();
    List<Event> past = new ArrayList<>();
    List<Event> draft = new ArrayList<>();
    for (Event event : events.getValue()) {
        try {
            if (event.getState().equals("draft"))
                draft.add(event);
            else if ("past".equalsIgnoreCase(DateService.getEventStatus(event)))
                past.add(event);
            else
                live.add(event);
        } catch (ParseException e) {
            Timber.e(e);
        }
    }
    liveEvents.setValue(live);
    pastEvents.setValue(past);
    draftEvents.setValue(draft);
}
Also used : ArrayList(java.util.ArrayList) Event(com.eventyay.organizer.data.event.Event) ParseException(java.text.ParseException)

Example 9 with Event

use of com.eventyay.organizer.data.event.Event in project open-event-orga-app by fossasia.

the class EventViewModel method showLoadedEvent.

private void showLoadedEvent(long storedEventId) {
    eventId.setValue(storedEventId);
    Event staticEvent = ContextManager.getSelectedEvent();
    if (staticEvent != null) {
        selectedEvent.setValue(staticEvent);
        showEventDashboard();
        return;
    }
    compositeDisposable.add(eventRepository.getEvent(storedEventId, false).subscribe(bus::pushSelectedEvent, throwable -> {
        Logger.logError(throwable);
        error.setValue(throwable.getMessage());
    }));
}
Also used : MutableLiveData(androidx.lifecycle.MutableLiveData) LiveData(androidx.lifecycle.LiveData) SingleEventLiveData(com.eventyay.organizer.common.livedata.SingleEventLiveData) Event(com.eventyay.organizer.data.event.Event) ViewModel(androidx.lifecycle.ViewModel) ContextManager(com.eventyay.organizer.common.ContextManager) CurrencyUtils(com.eventyay.organizer.utils.CurrencyUtils) Logger(com.eventyay.organizer.common.rx.Logger) Inject(javax.inject.Inject) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Bus(com.eventyay.organizer.data.Bus) EventRepository(com.eventyay.organizer.data.event.EventRepository) EVENT_KEY(com.eventyay.organizer.core.main.MainActivity.EVENT_KEY) Preferences(com.eventyay.organizer.data.Preferences) Event(com.eventyay.organizer.data.event.Event)

Example 10 with Event

use of com.eventyay.organizer.data.event.Event in project open-event-orga-app by fossasia.

the class CreateSponsorViewModel method createSponsor.

public void createSponsor() {
    long eventId = ContextManager.getSelectedEvent().getId();
    Event event = new Event();
    event.setId(eventId);
    sponsor.setEvent(event);
    nullifyEmptyFields(sponsor);
    compositeDisposable.add(sponsorRepository.createSponsor(sponsor).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(createdSponsor -> {
        success.setValue("Sponsor Created");
        dismiss.call();
    }, throwable -> error.setValue(ErrorUtils.getMessage(throwable).toString())));
}
Also used : LiveData(androidx.lifecycle.LiveData) SingleEventLiveData(com.eventyay.organizer.common.livedata.SingleEventLiveData) Event(com.eventyay.organizer.data.event.Event) Sponsor(com.eventyay.organizer.data.sponsor.Sponsor) ViewModel(androidx.lifecycle.ViewModel) ContextManager(com.eventyay.organizer.common.ContextManager) SponsorRepository(com.eventyay.organizer.data.sponsor.SponsorRepository) Logger(com.eventyay.organizer.common.rx.Logger) Inject(javax.inject.Inject) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) ErrorUtils(com.eventyay.organizer.utils.ErrorUtils) StringUtils(com.eventyay.organizer.utils.StringUtils) VisibleForTesting(androidx.annotation.VisibleForTesting) Event(com.eventyay.organizer.data.event.Event)

Aggregations

Event (com.eventyay.organizer.data.event.Event)36 LiveData (androidx.lifecycle.LiveData)15 ViewModel (androidx.lifecycle.ViewModel)15 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)15 Inject (javax.inject.Inject)15 ErrorUtils (com.eventyay.organizer.utils.ErrorUtils)14 Test (org.junit.Test)14 SingleEventLiveData (com.eventyay.organizer.common.livedata.SingleEventLiveData)13 ContextManager (com.eventyay.organizer.common.ContextManager)10 StringUtils (com.eventyay.organizer.utils.StringUtils)8 DateUtils (com.eventyay.organizer.utils.DateUtils)5 LocalDateTime (org.threeten.bp.LocalDateTime)5 ZonedDateTime (org.threeten.bp.ZonedDateTime)5 DateTimeParseException (org.threeten.bp.format.DateTimeParseException)5 VisibleForTesting (androidx.annotation.VisibleForTesting)4 MutableLiveData (androidx.lifecycle.MutableLiveData)4 Track (com.eventyay.organizer.data.tracks.Track)4 InOrder (org.mockito.InOrder)4 Logger (com.eventyay.organizer.common.rx.Logger)3 Ticket (com.eventyay.organizer.data.ticket.Ticket)3