Search in sources :

Example 16 with Event

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

the class UpdateEventFragment method setupPlacesAutocomplete.

private void setupPlacesAutocomplete() {
    ApplicationInfo ai = null;
    try {
        ai = getContext().getPackageManager().getApplicationInfo(getContext().getPackageName(), PackageManager.GET_META_DATA);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    Bundle bundle = ai.metaData;
    String placesApiKey = bundle.getString("com.google.android.geo.API_KEY");
    Places.initialize(getActivity().getApplicationContext(), placesApiKey);
    AutocompleteSupportFragment autocompleteFragment = (AutocompleteSupportFragment) getChildFragmentManager().findFragmentById(R.id.autocomplete_fragment);
    autocompleteFragment.setPlaceFields(Arrays.asList(Place.Field.ID, Place.Field.NAME, Place.Field.LAT_LNG, Place.Field.ADDRESS));
    autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {

        @Override
        public void onPlaceSelected(Place place) {
            Timber.d(place.getAddress());
            Event event = binding.getEvent();
            event.latitude = place.getLatLng().latitude;
            event.longitude = place.getLatLng().longitude;
            event.locationName = place.getAddress();
            event.searchableLocationName = place.getName();
        }

        @Override
        public void onError(Status status) {
            ViewUtils.showSnackbar(binding.getRoot(), status.getStatusMessage());
        }
    });
}
Also used : Status(com.google.android.gms.common.api.Status) PackageManager(android.content.pm.PackageManager) Bundle(android.os.Bundle) ApplicationInfo(android.content.pm.ApplicationInfo) AutocompleteSupportFragment(com.google.android.libraries.places.widget.AutocompleteSupportFragment) Event(com.eventyay.organizer.data.event.Event) PlaceSelectionListener(com.google.android.libraries.places.widget.listener.PlaceSelectionListener) Place(com.google.android.libraries.places.api.model.Place)

Example 17 with Event

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

the class CreateTrackViewModel method createTrack.

public void createTrack() {
    nullifyEmptyFields(track);
    long eventId = ContextManager.getSelectedEvent().getId();
    Event event = new Event();
    event.setId(eventId);
    track.setEvent(event);
    compositeDisposable.add(trackRepository.createTrack(track).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(createdTrack -> {
        success.setValue("Track 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) ViewModel(androidx.lifecycle.ViewModel) ContextManager(com.eventyay.organizer.common.ContextManager) Random(java.util.Random) Color(android.graphics.Color) Inject(javax.inject.Inject) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) TrackRepository(com.eventyay.organizer.data.tracks.TrackRepository) ErrorUtils(com.eventyay.organizer.utils.ErrorUtils) StringUtils(com.eventyay.organizer.utils.StringUtils) Track(com.eventyay.organizer.data.tracks.Track) Event(com.eventyay.organizer.data.event.Event)

Example 18 with Event

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

the class CreateSpeakersCallViewModel method updateSpeakersCall.

public void updateSpeakersCall(long eventId) {
    if (!verify())
        return;
    Event event = new Event();
    event.setId(eventId);
    speakersCallLive.getValue().setEvent(event);
    compositeDisposable.add(speakersCallRepository.updateSpeakersCall(speakersCallLive.getValue()).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(var -> success.setValue("Speakers Call Updated Successfully"), throwable -> error.setValue(ErrorUtils.getMessage(throwable).toString())));
}
Also used : MutableLiveData(androidx.lifecycle.MutableLiveData) DateUtils(com.eventyay.organizer.utils.DateUtils) LiveData(androidx.lifecycle.LiveData) Event(com.eventyay.organizer.data.event.Event) ViewModel(androidx.lifecycle.ViewModel) SpeakersCall(com.eventyay.organizer.data.speakerscall.SpeakersCall) ZonedDateTime(org.threeten.bp.ZonedDateTime) Inject(javax.inject.Inject) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) LocalDateTime(org.threeten.bp.LocalDateTime) ErrorUtils(com.eventyay.organizer.utils.ErrorUtils) VisibleForTesting(androidx.annotation.VisibleForTesting) DateTimeParseException(org.threeten.bp.format.DateTimeParseException) SpeakersCallRepository(com.eventyay.organizer.data.speakerscall.SpeakersCallRepository) Event(com.eventyay.organizer.data.event.Event)

Example 19 with Event

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

the class CreateSpeakersCallViewModel method createSpeakersCall.

public void createSpeakersCall(long eventId) {
    if (!verify())
        return;
    Event event = new Event();
    event.setId(eventId);
    speakersCallLive.getValue().setEvent(event);
    compositeDisposable.add(speakersCallRepository.createSpeakersCall(speakersCallLive.getValue()).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(var -> success.setValue("Speakers Call Created Successfully"), throwable -> error.setValue(ErrorUtils.getMessage(throwable).toString())));
}
Also used : MutableLiveData(androidx.lifecycle.MutableLiveData) DateUtils(com.eventyay.organizer.utils.DateUtils) LiveData(androidx.lifecycle.LiveData) Event(com.eventyay.organizer.data.event.Event) ViewModel(androidx.lifecycle.ViewModel) SpeakersCall(com.eventyay.organizer.data.speakerscall.SpeakersCall) ZonedDateTime(org.threeten.bp.ZonedDateTime) Inject(javax.inject.Inject) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) LocalDateTime(org.threeten.bp.LocalDateTime) ErrorUtils(com.eventyay.organizer.utils.ErrorUtils) VisibleForTesting(androidx.annotation.VisibleForTesting) DateTimeParseException(org.threeten.bp.format.DateTimeParseException) SpeakersCallRepository(com.eventyay.organizer.data.speakerscall.SpeakersCallRepository) Event(com.eventyay.organizer.data.event.Event)

Example 20 with Event

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

the class CreateSponsorViewModel method updateSponsor.

public void updateSponsor() {
    nullifyEmptyFields(sponsor);
    long eventId = ContextManager.getSelectedEvent().getId();
    Event event = new Event();
    event.setId(eventId);
    sponsor.setEvent(event);
    compositeDisposable.add(sponsorRepository.updateSponsor(sponsor).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(updatedSponsor -> {
        success.setValue("Sponsor Updated");
        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