Search in sources :

Example 26 with Event

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

the class UpdateCopyrightViewModel method updateCopyright.

public void updateCopyright() {
    nullifyEmptyFields(copyright);
    if (!verifyYear(copyright))
        return;
    long eventId = ContextManager.getSelectedEvent().getId();
    Event event = new Event();
    event.setId(eventId);
    copyright.setEvent(event);
    compositeDisposable.add(copyrightRepository.updateCopyright(copyright).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(updatedTicket -> {
        success.setValue("Copyright Updated");
        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 27 with Event

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

the class CreateFaqViewModel method createFaq.

public void createFaq() {
    long eventId = ContextManager.getSelectedEvent().getId();
    Event event = new Event();
    event.setId(eventId);
    faq.setEvent(event);
    compositeDisposable.add(faqRepository.createFaq(faq).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(createdFaq -> {
        success.setValue("Faq 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) Faq(com.eventyay.organizer.data.faq.Faq) ViewModel(androidx.lifecycle.ViewModel) ContextManager(com.eventyay.organizer.common.ContextManager) ErrorUtils(com.eventyay.organizer.utils.ErrorUtils) FaqRepository(com.eventyay.organizer.data.faq.FaqRepository) Event(com.eventyay.organizer.data.event.Event)

Example 28 with Event

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

the class ListPageAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final EventRecyclerViewHolder holder, int position) {
    final Event thisEvent = events.get(position);
    holder.bind(thisEvent);
}
Also used : Event(com.eventyay.organizer.data.event.Event) MotionEvent(android.view.MotionEvent)

Example 29 with Event

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

the class EventDashboardPresenterTest method shouldHideProgressbarOnToggleError.

@Test
public void shouldHideProgressbarOnToggleError() {
    when(eventRepository.updateEvent(any(Event.class))).thenReturn(Observable.error(Logger.TEST_ERROR));
    eventDashboardPresenter.setEvent(EVENT);
    eventDashboardPresenter.toggleState();
    InOrder inOrder = Mockito.inOrder(eventDetailView, eventRepository);
    inOrder.verify(eventRepository).updateEvent(any(Event.class));
    inOrder.verify(eventDetailView).showProgress(true);
    inOrder.verify(eventDetailView).showResult(any(Event.class));
    inOrder.verify(eventDetailView).showProgress(false);
}
Also used : InOrder(org.mockito.InOrder) Event(com.eventyay.organizer.data.event.Event) Test(org.junit.Test)

Example 30 with Event

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

the class TicketTest method setUp.

@Override
public void setUp() {
    RxJavaPlugins.setIoSchedulerHandler(scheduler -> Schedulers.trampoline());
    RxAndroidPlugins.setInitMainThreadSchedulerHandler(schedulerCallable -> Schedulers.trampoline());
    Event event = new Event();
    event.setId(12L);
    Ticket ticket1 = Ticket.builder().id(1L).quantity(120L).type(FREE).event(event).build();
    Ticket ticket2 = Ticket.builder().id(2L).quantity(20L).type(PAID).price(25.99f).event(event).build();
    Ticket ticket3 = Ticket.builder().id(3L).quantity(30L).type(DONATION).event(event).build();
    Ticket ticket4 = Ticket.builder().id(4L).quantity(10L).type(DONATION).event(event).build();
    Ticket ticket5 = Ticket.builder().id(5L).quantity(50L).type(PAID).price(99.99f).event(event).build();
    Attendee attendee = Attendee.builder().id(1L).ticket(ticket1).event(event).build();
    Attendee attendee2 = Attendee.builder().id(2L).ticket(ticket1).event(event).build();
    Attendee attendee3 = Attendee.builder().id(3L).ticket(ticket1).event(event).build();
    Attendee attendee4 = Attendee.builder().id(4L).ticket(ticket2).event(event).build();
    Attendee attendee5 = Attendee.builder().id(5L).ticket(ticket2).event(event).build();
    Attendee attendee6 = Attendee.builder().id(6L).ticket(ticket4).event(event).build();
    Attendee attendee7 = Attendee.builder().id(7L).ticket(ticket5).event(event).build();
    event.setTickets(Arrays.asList(ticket1, ticket2, ticket3, ticket4, ticket5));
    DbFlowDatabaseRepository databaseRepository = new DbFlowDatabaseRepository();
    databaseRepository.save(Event.class, event).subscribe();
    databaseRepository.saveList(Ticket.class, Arrays.asList(ticket1, ticket2, ticket3, ticket4, ticket5)).subscribe();
    databaseRepository.saveList(Attendee.class, Arrays.asList(attendee, attendee2, attendee3, attendee4, attendee5, attendee6, attendee7)).subscribe();
    Repository repository = new Repository(null, null, null, databaseRepository);
    ticketRepository = new TicketRepositoryImpl(null, repository);
}
Also used : Ticket(com.eventyay.organizer.data.ticket.Ticket) Repository(com.eventyay.organizer.data.Repository) DbFlowDatabaseRepository(com.eventyay.organizer.data.db.DbFlowDatabaseRepository) DbFlowDatabaseRepository(com.eventyay.organizer.data.db.DbFlowDatabaseRepository) Event(com.eventyay.organizer.data.event.Event) TicketRepositoryImpl(com.eventyay.organizer.data.ticket.TicketRepositoryImpl) Attendee(com.eventyay.organizer.data.attendee.Attendee)

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