Skip to content

Commit

Permalink
lots of move refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
misto committed Aug 8, 2018
1 parent 752a2f5 commit 113df11
Show file tree
Hide file tree
Showing 97 changed files with 2,004 additions and 937 deletions.
16 changes: 16 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 16 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 28
dataBinding {
enabled = true
}
defaultConfig {
applicationId "ch.beerpro"
minSdkVersion 21
targetSdkVersion 28
versionCode 7
versionName "Alpha 7"
versionCode 8
versionName "Alpha 8"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
Expand All @@ -26,12 +29,12 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.appcompat:appcompat:1.0.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha1'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.android.material:material:1.0.0-beta01'
implementation 'com.google.android.material:material:1.0.0-rc01'
implementation 'com.google.firebase:firebase-firestore:17.0.4'
implementation 'com.firebaseui:firebase-ui-firestore:4.0.0'

Expand All @@ -40,24 +43,29 @@ dependencies {
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'

implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01'
implementation 'androidx.recyclerview:recyclerview:1.0.0-rc01'
implementation 'com.github.yalantis:ucrop:2.2.2-native'
implementation 'com.github.tajchert:nammu:1.2.0'
implementation 'com.github.jkwiecien:EasyImage:2.1.0'

// lombok
//compileOnly "org.projectlombok:lombok:1.18.2"
//annotationProcessor "org.projectlombok:lombok:1.18.2"
// before upgrading, check if this has been resolved:
// https://github.com/mplushnikov/lombok-intellij-plugin/issues/496
compileOnly "org.projectlombok:lombok:1.16.20"
annotationProcessor "org.projectlombok:lombok:1.16.20"

// ButterKnife
implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT'

implementation 'net.danlew:android.joda:2.9.9.4'

implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
implementation 'com.android.support:design:28.0.0-beta01'
implementation 'com.android.support:design:28.0.0-rc01'
}

apply plugin: 'com.google.gms.google-services'
Binary file added app/release/app.aab
Binary file not shown.
35 changes: 27 additions & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".SplashScreenActivity"
android:name=".presentation.splash.SplashScreenActivity"
android:theme="@style/LoginScreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -24,30 +24,49 @@
</intent-filter>
</activity>
<activity
android:name=".home.HomeScreenActivity"
android:name=".presentation.home.HomeScreenActivity"
android:label="@string/title_activity_home_screen"
android:theme="@style/AppTheme" />
<activity android:name=".search.SearchActivity" />
<activity android:name=".presentation.search.SearchActivity" />
<activity
android:name=".single.SingleBeerActivity"
android:name=".presentation.details.DetailsActivity"
android:label="@string/title_activity_single_beer"
android:parentActivityName=".search.SearchActivity"
android:parentActivityName=".presentation.search.SearchActivity"
android:theme="@style/DetailsPageTheme">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="ch.beerpro.search.SearchActivity" />
android:value=".presentation.search.SearchActivity" />
</activity>
<activity
android:name=".rating.RatingActivity"
android:name=".presentation.createrating.CreateRatingActivity"
android:parentActivityName=".presentation.details.DetailsActivity"
android:windowSoftInputMode="adjustResize">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".single.SingleBeerActivity" />
android:value=".presentation.details.DetailsActivity" />
</activity>
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
<activity
android:name=".presentation.wishlist.WishlistActivity"
android:label="@string/title_activity_wishlist"
android:parentActivityName=".presentation.home.HomeScreenActivity"
android:theme="@style/AppTheme">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".presentation.home.HomeScreenActivity" />
</activity>
<activity
android:name=".presentation.myratings.MyRatingsActivity"
android:label="@string/title_activity_myratings"
android:parentActivityName=".presentation.home.HomeScreenActivity"
android:theme="@style/AppTheme">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".presentation.home.HomeScreenActivity" />
</activity>
</application>

</manifest>
4 changes: 4 additions & 0 deletions app/src/main/java/ch/beerpro/MyApplication.java
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);
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
package ch.beerpro.helpers;
package ch.beerpro.domain.helpers;

import android.os.Handler;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
import ch.beerpro.models.Beer;
import ch.beerpro.models.Entity;
import com.firebase.ui.common.ChangeEventType;
import com.firebase.ui.firestore.ChangeEventListener;
import com.firebase.ui.firestore.FirestoreArray;
import com.firebase.ui.firestore.ObservableSnapshotArray;
import ch.beerpro.domain.models.Entity;
import ch.beerpro.presentation.helpers.EntityClassSnapshotParser;
import com.google.firebase.firestore.*;

import javax.annotation.Nullable;
import java.util.List;

public class FirestoreQueryLiveData<T extends Entity> extends LiveData<T> implements EventListener<DocumentSnapshot> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package ch.beerpro.helpers;
package ch.beerpro.domain.helpers;

import android.os.Handler;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
import ch.beerpro.models.Entity;
import ch.beerpro.domain.models.Entity;
import ch.beerpro.presentation.helpers.EntityClassSnapshotParser;
import com.firebase.ui.common.ChangeEventType;
import com.firebase.ui.firestore.ChangeEventListener;
import com.firebase.ui.firestore.FirestoreArray;
Expand Down
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));
}
}
};
}
}
27 changes: 27 additions & 0 deletions app/src/main/java/ch/beerpro/domain/models/Beer.java
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;

}
19 changes: 19 additions & 0 deletions app/src/main/java/ch/beerpro/domain/models/Entity.java
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;
}
}
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;

Expand Down
Loading

0 comments on commit 113df11

Please sign in to comment.