This file contains hidden or 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
public class Needs { | |
public Food mFood; | |
public Clothes mClothes; | |
public Shelter mShelter; | |
@Inject | |
public Needs(Food food, Clothes clothes, Shelter shelter) { | |
this.mFood = food; | |
this.mClothes = clothes; |
This file contains hidden or 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
public class Clothes { | |
public Money mMoney; | |
@Inject | |
public Clothes(Money money) { | |
this.mMoney = money; | |
if (mMoney != null) { | |
System.out.println("I've Clothes to wear!"); |
This file contains hidden or 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
@Singleton | |
public class Money { | |
public Job mJob; | |
@Inject | |
public Money(Job job) { | |
this.mJob = job; | |
if (mJob != null) { |
This file contains hidden or 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
public class Job { | |
public Education mEducation; | |
@Inject | |
public Job(Education education) { | |
this.mEducation = education; | |
if (mEducation != null) { | |
System.out.println("I've Job!"); |
This file contains hidden or 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
package life; | |
import javax.inject.Inject; | |
public class Education { | |
@Inject | |
public Education() { | |
System.out.println("I'm Well Educated!"); | |
} |
This file contains hidden or 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
package life; | |
import javax.inject.Inject; | |
public class Life { | |
public Needs mNeeds; | |
@Inject | |
public Life(Needs needs) { |
This file contains hidden or 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
public class WithoutDI { | |
public static void main(String[] args) { | |
Education education = new Education(); | |
Job job = new Job(education); | |
Money money = new Money(job); | |
Food food = new Food(money); | |
Clothes clothes = new Clothes(money); |
This file contains hidden or 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
dependencies { | |
// Firebase SDKs | |
implementation 'com.google.firebase:firebase-firestore:21.4.1' | |
implementation 'com.google.firebase:firebase-database:19.2.1' | |
// FirebaseUI for Real-time database | |
implementation 'com.firebaseui:firebase-ui-database:6.2.0' | |
// FirebaseUI for Cloud Firestore | |
implementation 'com.firebaseui:firebase-ui-firestore:6.2.0' |
This file contains hidden or 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
fun changeQuery() { | |
val newQuery = mCollectionReference | |
.orderBy("timestamp") | |
.whereEqualTo("seen", false) | |
.limitToLast(100) | |
// Make new options | |
val newOptions = FirestoreRecyclerOptions.Builder<Post>() | |
.setQuery(newQuery, Post::class.java) |
This file contains hidden or 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
fun changeQuery() { | |
val newQuery = mBaseQuery | |
.orderByChild("timestamp") | |
.limitToLast(100) | |
// Make new options | |
val newOptions = FirebaseRecyclerOptions.Builder<Post>() | |
.setQuery(newQuery, Post::class.java) | |
.build() |