-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
97 changed files
with
2,004 additions
and
937 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
package ch.beerpro; | ||
|
||
import android.app.Application; | ||
import com.google.firebase.firestore.FirebaseFirestore; | ||
import net.danlew.android.joda.JodaTimeAndroid; | ||
|
||
public class MyApplication extends Application { | ||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
|
||
FirebaseFirestore.setLoggingEnabled(true); | ||
|
||
JodaTimeAndroid.init(this); | ||
} | ||
} |
13 changes: 3 additions & 10 deletions
13
...erpro/helpers/FirestoreQueryLiveData.java → ...omain/helpers/FirestoreQueryLiveData.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
5 changes: 3 additions & 2 deletions
5
.../helpers/FirestoreQueryLiveDataArray.java → .../helpers/FirestoreQueryLiveDataArray.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
93 changes: 93 additions & 0 deletions
93
app/src/main/java/ch/beerpro/domain/helpers/LiveDataExtensions.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 |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package ch.beerpro.domain.helpers; | ||
|
||
import android.util.Pair; | ||
import androidx.lifecycle.LiveData; | ||
import androidx.lifecycle.MediatorLiveData; | ||
import org.apache.commons.lang3.tuple.Triple; | ||
|
||
public class LiveDataExtensions { | ||
|
||
public static <A, B> LiveData<Pair<A, B>> zip(LiveData<A> as, LiveData<B> bs) { | ||
return new MediatorLiveData<Pair<A, B>>() { | ||
|
||
A lastA = null; | ||
B lastB = null; | ||
|
||
{ | ||
{ | ||
addSource(as, (A a) -> { | ||
lastA = a; | ||
update(); | ||
}); | ||
addSource(bs, (B b) -> { | ||
lastB = b; | ||
update(); | ||
}); | ||
} | ||
} | ||
|
||
private void update() { | ||
this.setValue(new Pair<>(lastA, lastB)); | ||
} | ||
}; | ||
} | ||
|
||
public static <A, B> LiveData<Pair<A, B>> combineLatest(LiveData<A> as, LiveData<B> bs) { | ||
return new MediatorLiveData<Pair<A, B>>() { | ||
|
||
A lastA = null; | ||
B lastB = null; | ||
|
||
{ | ||
{ | ||
addSource(as, (A a) -> { | ||
lastA = a; | ||
update(); | ||
}); | ||
addSource(bs, (B b) -> { | ||
lastB = b; | ||
update(); | ||
}); | ||
} | ||
} | ||
|
||
private void update() { | ||
if (lastA != null && lastB != null) { | ||
this.setValue(new Pair<>(lastA, lastB)); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
public static <A, B, C> LiveData<Triple<A, B, C>> combineLatest(LiveData<A> as, LiveData<B> bs, LiveData<C> cs) { | ||
return new MediatorLiveData<Triple<A, B, C>>() { | ||
|
||
A lastA = null; | ||
B lastB = null; | ||
C lastC = null; | ||
|
||
{ | ||
{ | ||
addSource(as, (A a) -> { | ||
lastA = a; | ||
update(); | ||
}); | ||
addSource(bs, (B b) -> { | ||
lastB = b; | ||
update(); | ||
}); | ||
addSource(cs, (C c) -> { | ||
lastC = c; | ||
update(); | ||
}); | ||
} | ||
} | ||
|
||
private void update() { | ||
if (lastA != null && lastB != null && lastC != null) { | ||
this.setValue(Triple.of(lastA, lastB, lastC)); | ||
} | ||
} | ||
}; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package ch.beerpro.domain.models; | ||
|
||
import com.google.firebase.firestore.Exclude; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.Serializable; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class Beer implements Entity, Serializable { | ||
|
||
public static final String COLLECTION = "beers"; | ||
public static final String FIELD_NAME = "name"; | ||
|
||
@Exclude | ||
private String id; | ||
private String manufacturer; | ||
private String name; | ||
private String category; | ||
private String photo; | ||
private float avgRating; | ||
private int numRatings; | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package ch.beerpro.domain.models; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
public interface Entity { | ||
|
||
String getId(); | ||
|
||
void setId(String id); | ||
|
||
static <T extends Entity> HashMap<String, T> entitiesById(List<T> entries) { | ||
HashMap<String, T> byId = new HashMap<>(); | ||
for (T entry : entries) { | ||
byId.put(entry.getId(), entry); | ||
} | ||
return byId; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...src/main/java/ch/beerpro/models/Like.java → ...n/java/ch/beerpro/domain/models/Like.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,4 +1,4 @@ | ||
package ch.beerpro.models; | ||
package ch.beerpro.domain.models; | ||
|
||
import com.google.firebase.firestore.Exclude; | ||
|
||
|
Oops, something went wrong.