Skip to content

Instantly share code, notes, and snippets.

View PatilShreyas's full-sized avatar
👨‍💻
Might be writing code at the moment

Shreyas Patil PatilShreyas

👨‍💻
Might be writing code at the moment
View GitHub Profile
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;
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!");
@Singleton
public class Money {
public Job mJob;
@Inject
public Money(Job job) {
this.mJob = job;
if (mJob != null) {
public class Job {
public Education mEducation;
@Inject
public Job(Education education) {
this.mEducation = education;
if (mEducation != null) {
System.out.println("I've Job!");
package life;
import javax.inject.Inject;
public class Education {
@Inject
public Education() {
System.out.println("I'm Well Educated!");
}
package life;
import javax.inject.Inject;
public class Life {
public Needs mNeeds;
@Inject
public Life(Needs needs) {
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);
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'
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)
fun changeQuery() {
val newQuery = mBaseQuery
.orderByChild("timestamp")
.limitToLast(100)
// Make new options
val newOptions = FirebaseRecyclerOptions.Builder<Post>()
.setQuery(newQuery, Post::class.java)
.build()