This repository has been archived by the owner on Oct 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Remove unnecessary transformations (#2444)
- Loading branch information
1 parent
1e9e0dd
commit 1f2ca18
Showing
5 changed files
with
26 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 6 additions & 11 deletions
17
android/app/src/main/java/org/fossasia/openevent/core/sponsor/SponsorsFragmentViewModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<List<Sponsor>> sponsorsList; | ||
private LiveRealmData<Sponsor> sponsorLiveRealmData; | ||
private RealmDataRepository realmRepo; | ||
|
||
public SponsorsFragmentViewModel() { | ||
realmRepo = RealmDataRepository.getDefaultInstance(); | ||
} | ||
|
||
public LiveData<List<Sponsor>> getSponsors() { | ||
if (sponsorsList == null) { | ||
LiveRealmData<Sponsor> sponsorLiveRealmData = RealmDataRepository.asLiveData(realmRepo.getSponsors()); | ||
sponsorsList = Transformations.map(sponsorLiveRealmData, input -> input); | ||
public LiveRealmData<Sponsor> getSponsors() { | ||
if (sponsorLiveRealmData == null) { | ||
sponsorLiveRealmData = RealmDataRepository.asLiveData(realmRepo.getSponsors()); | ||
} | ||
return sponsorsList; | ||
return sponsorLiveRealmData; | ||
} | ||
|
||
} |