diff --git a/android/app/src/main/java/org/fossasia/openevent/core/about/AboutFragmentViewModel.java b/android/app/src/main/java/org/fossasia/openevent/core/about/AboutFragmentViewModel.java index 0710ea727d..fe7aa89bb2 100644 --- a/android/app/src/main/java/org/fossasia/openevent/core/about/AboutFragmentViewModel.java +++ b/android/app/src/main/java/org/fossasia/openevent/core/about/AboutFragmentViewModel.java @@ -34,7 +34,7 @@ public class AboutFragmentViewModel extends ViewModel { private FilterableRealmLiveData filterableRealmLiveData; private List dateList; private LiveData eventLiveData; - private LiveData> featuredSpeakers; + private LiveRealmData featuredSpeakersLiveData; private MutableLiveData eventLogo; public AboutFragmentViewModel() { @@ -91,12 +91,11 @@ private List getSessionsList(List bookmarked) { return sessionsList; } - public LiveData> getFeaturedSpeakers() { - if (featuredSpeakers == null) { - LiveRealmData featuredSpeakersLiveData = RealmDataRepository.asLiveData(realmRepo.getFeaturedSpeakers()); - featuredSpeakers = Transformations.map(featuredSpeakersLiveData, input -> input); + public LiveRealmData getFeaturedSpeakers() { + if (featuredSpeakersLiveData == null) { + featuredSpeakersLiveData = RealmDataRepository.asLiveData(realmRepo.getFeaturedSpeakers()); } - return featuredSpeakers; + return featuredSpeakersLiveData; } public LiveData getEventLogo(String url) { diff --git a/android/app/src/main/java/org/fossasia/openevent/core/discount/DiscountFragmentViewModel.java b/android/app/src/main/java/org/fossasia/openevent/core/discount/DiscountFragmentViewModel.java index a9c1e6a300..3f8c079f9a 100644 --- a/android/app/src/main/java/org/fossasia/openevent/core/discount/DiscountFragmentViewModel.java +++ b/android/app/src/main/java/org/fossasia/openevent/core/discount/DiscountFragmentViewModel.java @@ -2,7 +2,6 @@ import android.arch.lifecycle.LiveData; import android.arch.lifecycle.MutableLiveData; -import android.arch.lifecycle.Transformations; import android.arch.lifecycle.ViewModel; import org.fossasia.openevent.common.api.APIClient; @@ -10,8 +9,6 @@ import org.fossasia.openevent.data.DiscountCode; import org.fossasia.openevent.data.repository.RealmDataRepository; -import java.util.List; - import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; import io.reactivex.schedulers.Schedulers; @@ -19,7 +16,7 @@ public class DiscountFragmentViewModel extends ViewModel { - private LiveData> discountCodes; + private LiveRealmData discountCodeLiveRealmData; private RealmDataRepository realmRepo; private MutableLiveData discountCodesDownloadResponse; private CompositeDisposable compositeDisposable; @@ -30,12 +27,11 @@ public DiscountFragmentViewModel() { } - public LiveData> getDiscountCodes() { - if (discountCodes == null) { - LiveRealmData discountCodeLiveRealmData = RealmDataRepository.asLiveData(realmRepo.getDiscountCodes()); - discountCodes = Transformations.map(discountCodeLiveRealmData, input -> input); + public LiveRealmData getDiscountCodes() { + if (discountCodeLiveRealmData == null) { + discountCodeLiveRealmData = RealmDataRepository.asLiveData(realmRepo.getDiscountCodes()); } - return discountCodes; + return discountCodeLiveRealmData; } public LiveData downloadDiscountCodes() { diff --git a/android/app/src/main/java/org/fossasia/openevent/core/faqs/FAQViewModel.java b/android/app/src/main/java/org/fossasia/openevent/core/faqs/FAQViewModel.java index dbe6d73966..c66a813aa5 100644 --- a/android/app/src/main/java/org/fossasia/openevent/core/faqs/FAQViewModel.java +++ b/android/app/src/main/java/org/fossasia/openevent/core/faqs/FAQViewModel.java @@ -2,7 +2,6 @@ import android.arch.lifecycle.LiveData; import android.arch.lifecycle.MutableLiveData; -import android.arch.lifecycle.Transformations; import android.arch.lifecycle.ViewModel; import org.fossasia.openevent.common.api.APIClient; @@ -10,8 +9,6 @@ import org.fossasia.openevent.data.FAQ; import org.fossasia.openevent.data.repository.RealmDataRepository; -import java.util.List; - import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; import io.reactivex.schedulers.Schedulers; @@ -20,7 +17,7 @@ public class FAQViewModel extends ViewModel { private RealmDataRepository realmRepo; - private LiveData> faqData; + private LiveRealmData faqLiveRealmData; private MutableLiveData faqOnDownloadResponse; private final CompositeDisposable compositeDisposable; @@ -29,12 +26,11 @@ public FAQViewModel() { compositeDisposable = new CompositeDisposable(); } - public LiveData> getFaqData() { - if (faqData == null) { - LiveRealmData faqLiveRealmData = RealmDataRepository.asLiveData(realmRepo.getEventFAQs()); - faqData = Transformations.map(faqLiveRealmData, input -> input); + public LiveRealmData getFaqData() { + if (faqLiveRealmData == null) { + faqLiveRealmData = RealmDataRepository.asLiveData(realmRepo.getEventFAQs()); } - return faqData; + return faqLiveRealmData; } public LiveData downloadFAQ() { diff --git a/android/app/src/main/java/org/fossasia/openevent/core/notifications/NotificationsFragmentViewModel.java b/android/app/src/main/java/org/fossasia/openevent/core/notifications/NotificationsFragmentViewModel.java index 65cc1d4850..f326005f87 100644 --- a/android/app/src/main/java/org/fossasia/openevent/core/notifications/NotificationsFragmentViewModel.java +++ b/android/app/src/main/java/org/fossasia/openevent/core/notifications/NotificationsFragmentViewModel.java @@ -2,7 +2,6 @@ import android.arch.lifecycle.LiveData; import android.arch.lifecycle.MutableLiveData; -import android.arch.lifecycle.Transformations; import android.arch.lifecycle.ViewModel; import org.fossasia.openevent.common.arch.LiveRealmData; @@ -19,7 +18,7 @@ public class NotificationsFragmentViewModel extends ViewModel { private RealmDataRepository realmRepo; - private LiveData> notificationsData; + private LiveRealmData liveNotificationsRealmData; private MutableLiveData notificationDownloadResponse; private final CompositeDisposable compositeDisposable; private final NotificationsRepository notificationsRepository; @@ -30,12 +29,11 @@ public NotificationsFragmentViewModel() { notificationsRepository = new NotificationsRepository(); } - public LiveData> getNotificationsData() { - if (notificationsData == null) { - LiveRealmData liveRealmData = RealmDataRepository.asLiveData(realmRepo.getNotifications()); - notificationsData = Transformations.map(liveRealmData, input -> input); + public LiveRealmData getNotificationsData() { + if (liveNotificationsRealmData == null) { + liveNotificationsRealmData = RealmDataRepository.asLiveData(realmRepo.getNotifications()); } - return notificationsData; + return liveNotificationsRealmData; } public LiveData downloadNotifications() { diff --git a/android/app/src/main/java/org/fossasia/openevent/core/sponsor/SponsorsFragmentViewModel.java b/android/app/src/main/java/org/fossasia/openevent/core/sponsor/SponsorsFragmentViewModel.java index f1c5d2a934..b94c14852a 100644 --- a/android/app/src/main/java/org/fossasia/openevent/core/sponsor/SponsorsFragmentViewModel.java +++ b/android/app/src/main/java/org/fossasia/openevent/core/sponsor/SponsorsFragmentViewModel.java @@ -1,30 +1,25 @@ package org.fossasia.openevent.core.sponsor; -import android.arch.lifecycle.LiveData; -import android.arch.lifecycle.Transformations; import android.arch.lifecycle.ViewModel; -import org.fossasia.openevent.data.Sponsor; import org.fossasia.openevent.common.arch.LiveRealmData; +import org.fossasia.openevent.data.Sponsor; import org.fossasia.openevent.data.repository.RealmDataRepository; -import java.util.List; - public class SponsorsFragmentViewModel extends ViewModel { - private LiveData> sponsorsList; + private LiveRealmData sponsorLiveRealmData; private RealmDataRepository realmRepo; public SponsorsFragmentViewModel() { realmRepo = RealmDataRepository.getDefaultInstance(); } - public LiveData> getSponsors() { - if (sponsorsList == null) { - LiveRealmData sponsorLiveRealmData = RealmDataRepository.asLiveData(realmRepo.getSponsors()); - sponsorsList = Transformations.map(sponsorLiveRealmData, input -> input); + public LiveRealmData getSponsors() { + if (sponsorLiveRealmData == null) { + sponsorLiveRealmData = RealmDataRepository.asLiveData(realmRepo.getSponsors()); } - return sponsorsList; + return sponsorLiveRealmData; } } \ No newline at end of file