Skip to content

Commit

Permalink
Merge branch 'development' into sort
Browse files Browse the repository at this point in the history
  • Loading branch information
iamareebjamal authored Mar 19, 2018
2 parents 977ceb0 + 2a527d0 commit 41e50f5
Show file tree
Hide file tree
Showing 49 changed files with 1,570 additions and 245 deletions.
103 changes: 48 additions & 55 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apply plugin: 'com.android.application'
apply plugin: 'io.sentry.android.gradle'
apply plugin: 'com.noveogroup.android.check'
apply from: './jacoco.gradle'
def versions = {}
apply from: project(':app').file('config.gradle'), to: versions

def app_name = System.getenv('app_name') ?: "eventyay organizer"

Expand All @@ -15,12 +17,12 @@ android {
exclude 'META-INF/LICENSE'
}

compileSdkVersion 27
buildToolsVersion "27.0.1"
compileSdkVersion versions.compileSdkVersion
buildToolsVersion versions.buildToolsVersion
defaultConfig {
applicationId "org.fossasia.eventyay"
minSdkVersion 16
targetSdkVersion 27
minSdkVersion versions.minSdkVersion
targetSdkVersion versions.targetSdkVersion
versionCode 4
versionName "1.0.3alpha"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -96,59 +98,50 @@ check {
}
}

def dbflow_version = "4.1.2"
def glide_version = "4.4.0"
def retrofit_version = "2.3.0"
def butterknife_version = "8.8.1"
def dagger_version = "2.13"
def stetho_version = "1.5.0"
def leak_canary_version = "1.5.4"
def support_lib_version = "27.0.2"

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

// Support Lib
implementation 'com.android.support:multidex:1.0.2'
implementation "com.android.support:appcompat-v7:${support_lib_version}"
implementation "com.android.support:cardview-v7:${support_lib_version}"
implementation "com.android.support:recyclerview-v7:${support_lib_version}"
implementation "com.android.support:design:${support_lib_version}"
implementation "com.android.support:palette-v7:${support_lib_version}"
implementation "com.takisoft.fix:preference-v7:${support_lib_version}.0"
implementation 'com.google.android.gms:play-services-vision:11.8.0'
implementation "com.android.support:appcompat-v7:${versions.support_lib_version}"
implementation "com.android.support:cardview-v7:${versions.support_lib_version}"
implementation "com.android.support:recyclerview-v7:${versions.support_lib_version}"
implementation "com.android.support:design:${versions.support_lib_version}"
implementation "com.android.support:palette-v7:${versions.support_lib_version}"
implementation "com.takisoft.fix:preference-v7:${versions.support_lib_version}.0"
implementation "com.google.android.gms:play-services-vision:${versions.play_services_vision}"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'

// Misc
implementation 'com.jakewharton.timber:timber:4.6.0'
implementation 'com.evernote:android-job:1.2.1'
implementation "com.jakewharton.timber:timber:${versions.timber_version}"
implementation "com.evernote:android-job:${versions.android_job_version}"
implementation 'com.mikhaellopez:circularprogressbar:1.1.1'
implementation 'com.github.Ilhasoft:data-binding-validator:1.0.0'
implementation 'io.sentry:sentry-android:1.3.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation "io.sentry:sentry-android:${versions.sentry_android_version}"
implementation "com.github.PhilJay:MPAndroidChart:${versions.mpAndroidChartVersion}"
compileOnly 'com.google.code.findbugs:findbugs-annotations:3.0.1'

// DbFlow
implementation "com.github.raizlabs.dbflow:dbflow-core:${dbflow_version}"
implementation "com.github.raizlabs.dbflow:dbflow:${dbflow_version}"
implementation "com.github.raizlabs.dbflow:dbflow-rx2:${dbflow_version}"
annotationProcessor "com.github.raizlabs.dbflow:dbflow-processor:${dbflow_version}"
implementation "com.github.raizlabs.dbflow:dbflow-core:${versions.dbflow_version}"
implementation "com.github.raizlabs.dbflow:dbflow:${versions.dbflow_version}"
implementation "com.github.raizlabs.dbflow:dbflow-rx2:${versions.dbflow_version}"
annotationProcessor "com.github.raizlabs.dbflow:dbflow-processor:${versions.dbflow_version}"

// Dagger
implementation "com.google.dagger:dagger:${dagger_version}"
annotationProcessor "com.google.dagger:dagger-compiler:${dagger_version}"
implementation "com.google.dagger:dagger:${versions.dagger_version}"
annotationProcessor "com.google.dagger:dagger-compiler:${versions.dagger_version}"

// Retrofit
implementation "com.squareup.okhttp3:okhttp:3.10.0"
implementation "com.squareup.retrofit2:retrofit:${retrofit_version}"
implementation "com.squareup.retrofit2:converter-jackson:${retrofit_version}"
implementation "com.squareup.retrofit2:adapter-rxjava2:${retrofit_version}"
implementation "com.squareup.okhttp3:okhttp:${versions.okhttp_version}"
implementation "com.squareup.retrofit2:retrofit:${versions.retrofit_version}"
implementation "com.squareup.retrofit2:converter-jackson:${versions.retrofit_version}"
implementation "com.squareup.retrofit2:adapter-rxjava2:${versions.retrofit_version}"
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.1'
implementation 'com.github.jasminb:jsonapi-converter:0.8'

// RxJava
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.1.10'
implementation "io.reactivex.rxjava2:rxandroid:${versions.rxandroid_version}"
implementation "io.reactivex.rxjava2:rxjava:${versions.rxjava_version}"
implementation 'com.f2prateek.rx.preferences2:rx-preferences:2.0.0-RC3'

// Fast Adapter
Expand All @@ -163,33 +156,33 @@ dependencies {
implementation ("com.github.florent37:glidepalette:2.1.0") {
transitive = false
}
implementation "com.github.bumptech.glide:glide:${glide_version}"
implementation "com.github.bumptech.glide:okhttp3-integration:${glide_version}"
annotationProcessor "com.github.bumptech.glide:compiler:${glide_version}"
implementation "com.github.bumptech.glide:glide:${versions.glide_version}"
implementation "com.github.bumptech.glide:okhttp3-integration:${versions.glide_version}"
annotationProcessor "com.github.bumptech.glide:compiler:${versions.glide_version}"

// ThreeTen
implementation 'com.jakewharton.threetenabp:threetenabp:1.0.5'
implementation "com.jakewharton.threetenabp:threetenabp:${versions.threetenbp_version}"
testImplementation 'org.threeten:threetenbp:1.3.6'

// Leak Canary
debugImplementation "com.squareup.leakcanary:leakcanary-android:${leak_canary_version}"
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:${leak_canary_version}"
debugImplementation "com.squareup.leakcanary:leakcanary-android:${versions.leak_canary_version}"
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:${versions.leak_canary_version}"

// Stetho
debugImplementation "com.facebook.stetho:stetho:${stetho_version}"
debugImplementation "com.facebook.stetho:stetho-okhttp3:${stetho_version}"
releaseImplementation 'net.igenius:stetho-no-op:1.1'
testImplementation 'net.igenius:stetho-no-op:1.1'
debugImplementation "com.facebook.stetho:stetho:${versions.stetho_version}"
debugImplementation "com.facebook.stetho:stetho-okhttp3:${versions.stetho_version}"
releaseImplementation "net.igenius:stetho-no-op:${versions.stetho_no_op_version}"
testImplementation "net.igenius:stetho-no-op:${versions.stetho_no_op_version}"

// Butterknife
implementation "com.jakewharton:butterknife:${butterknife_version}"
annotationProcessor "com.jakewharton:butterknife-compiler:${butterknife_version}"
implementation "com.jakewharton:butterknife:${versions.butterknife_version}"
annotationProcessor "com.jakewharton:butterknife-compiler:${versions.butterknife_version}"

// Lombok
compileOnly 'org.projectlombok:lombok:1.16.18'
testCompileOnly 'org.projectlombok:lombok:1.16.18'
annotationProcessor 'org.projectlombok:lombok:1.16.18'
testAnnotationProcessor 'org.projectlombok:lombok:1.16.18'
compileOnly "org.projectlombok:lombok:${versions.lombokVersion}"
testCompileOnly "org.projectlombok:lombok:${versions.lombokVersion}"
annotationProcessor "org.projectlombok:lombok:${versions.lombokVersion}"
testAnnotationProcessor "org.projectlombok:lombok:${versions.lombokVersion}"

//Testing
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
Expand All @@ -198,7 +191,7 @@ dependencies {
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-inline:2.8.9'
testImplementation 'org.json:json:20140107'
testImplementation 'org.robolectric:robolectric:3.6.1'
testImplementation "org.robolectric:shadows-multidex:3.6.1"
testImplementation "org.robolectric:shadows-supportv4:3.6.1"
testImplementation "org.robolectric:robolectric:${versions.roboelectric_version}"
testImplementation "org.robolectric:shadows-multidex:${versions.roboelectric_version}"
testImplementation "org.robolectric:shadows-supportv4:${versions.roboelectric_version}"
}
28 changes: 28 additions & 0 deletions app/config.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ext {
compileSdkVersion = 27
buildToolsVersion = '27.0.1'
minSdkVersion = 16
targetSdkVersion = 27

//Libraries
dbflow_version = '4.1.2'
glide_version = '4.4.0'
retrofit_version = '2.3.0'
okhttp_version = '3.10.0'
butterknife_version = '8.8.1'
dagger_version = '2.13'
android_job_version = '1.2.1'
sentry_android_version = '1.3.0'
rxandroid_version = '2.0.2'
rxjava_version = '2.1.10'
stetho_version = '1.5.0'
stetho_no_op_version = '1.1'
roboelectric_version = '3.6.1'
threetenbp_version = '1.0.5'
mpAndroidChartVersion = 'v3.0.3'
lombokVersion = '1.16.18'
timber_version = '4.6.0'
leak_canary_version = '1.5.4'
support_lib_version = '27.0.2'
play_services_vision='11.8.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public static String doubleToStr(Double value) {
return value == null ? "" : String.valueOf(value);
}

@BindingConversion
@InverseMethod("strToInteger")
public static String integerToStr(Integer value) {
return value == null ? "" : String.valueOf(value);
}

@SuppressWarnings("PMD")
public static Long strToLong(String value) {
return Utils.isEmpty(value) ? null : Long.parseLong(value);
Expand All @@ -62,6 +68,11 @@ public static Double strToDouble(String value) {
return Utils.isEmpty(value) ? null : Double.parseDouble(value);
}

@SuppressWarnings("PMD.NullAssignment")
public static Integer strToInteger(String value) {
return Utils.isEmpty(value) ? null : Integer.parseInt(value);
}

@InverseMethod("getType")
public static int toId(String ticketType) {
if (ticketType == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.fossasia.openevent.app.module.event.create.CreateEventFragment;
import org.fossasia.openevent.app.module.event.dashboard.EventDashboardFragment;
import org.fossasia.openevent.app.module.event.list.EventListFragment;
import org.fossasia.openevent.app.module.faq.create.CreateFaqFragment;
import org.fossasia.openevent.app.module.faq.list.FaqListFragment;
import org.fossasia.openevent.app.module.main.MainActivity;
import org.fossasia.openevent.app.module.organizer.detail.OrganizerDetailFragment;
Expand Down Expand Up @@ -82,4 +83,6 @@ public interface AppComponent {
void inject(FaqListFragment faqListFragment);

void inject(CreateCopyrightFragment createCopyrightFragment);

void inject(CreateFaqFragment createFaqFragment);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.fossasia.openevent.app.common.data.db.DatabaseChangeListener;
import org.fossasia.openevent.app.common.data.db.contract.IDatabaseChangeListener;
import org.fossasia.openevent.app.common.data.models.Attendee;
import org.fossasia.openevent.app.common.data.models.Faq;
import org.fossasia.openevent.app.common.data.models.Ticket;

import dagger.Module;
Expand All @@ -21,4 +22,8 @@ IDatabaseChangeListener<Ticket> providesTicketChangeListener() {
return new DatabaseChangeListener<>(Ticket.class);
}

@Provides
IDatabaseChangeListener<Faq> providesFaqChangeListener() {
return new DatabaseChangeListener<>(Faq.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.fossasia.openevent.app.common.data.repository.contract.IAttendeeRepository;
import org.fossasia.openevent.app.common.data.repository.contract.ICopyrightRepository;
import org.fossasia.openevent.app.common.data.repository.contract.IEventRepository;
import org.fossasia.openevent.app.common.data.repository.contract.IFAQRepository;
import org.fossasia.openevent.app.common.data.repository.contract.IFaqRepository;
import org.fossasia.openevent.app.common.data.repository.contract.ITicketRepository;

import javax.inject.Singleton;
Expand Down Expand Up @@ -57,7 +57,7 @@ public abstract class DataModule {

@Binds
@Singleton
abstract IFAQRepository bindsFAQRepository(FaqRepository faqRepository);
abstract IFaqRepository bindsFAQRepository(FaqRepository faqRepository);

@Binds
@Singleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.fossasia.openevent.app.module.event.create.contract.ICreateEventPresenter;
import org.fossasia.openevent.app.module.event.dashboard.EventDashboardPresenter;
import org.fossasia.openevent.app.module.event.dashboard.contract.IEventDashboardPresenter;
import org.fossasia.openevent.app.module.faq.create.CreateFaqPresenter;
import org.fossasia.openevent.app.module.faq.create.contract.ICreateFaqPresenter;
import org.fossasia.openevent.app.module.faq.list.FaqListPresenter;
import org.fossasia.openevent.app.module.faq.list.contract.IFaqListPresenter;
import org.fossasia.openevent.app.module.event.list.EventsPresenter;
Expand Down Expand Up @@ -107,4 +109,7 @@ public abstract class PresenterModule {

@Binds
abstract ICreateCopyrightPresenter bindsCreateCopyrightPresenter(CreateCopyrightPresenter createCopyrightPresenter);

@Binds
abstract ICreateFaqPresenter bindsCreateFaqPresenter(CreateFaqPresenter createFaqPresenter);
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ public interface EventService {
@POST("event-copyrights")
Observable<Copyright> postCopyright(@Body Copyright copyright);

@GET("events/{eventId}/event-copyright")
@GET("events/{eventId}/event-copyright?include=event&fields[event]=id&page[size]=0")
Observable<Copyright> getCopyright(@Path("eventId") long eventId);

@POST("faqs")
Observable<Faq> postFaq(@Body Faq faq);

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.fossasia.openevent.app.common.data.contract.IUtilModel;
import org.fossasia.openevent.app.common.data.db.contract.IDatabaseRepository;
import org.fossasia.openevent.app.common.data.models.Copyright;
import org.fossasia.openevent.app.common.data.models.Copyright_Table;
import org.fossasia.openevent.app.common.data.network.EventService;
import org.fossasia.openevent.app.common.data.repository.contract.ICopyrightRepository;

Expand Down Expand Up @@ -42,13 +43,20 @@ public Observable<Copyright> createCopyright(Copyright copyright) {
@NonNull
@Override
public Observable<Copyright> getCopyright(long eventId, boolean reload) {
if (!utilModel.isConnected()) {
return Observable.error(new Throwable(Constants.NO_NETWORK));
}

return eventService
.getCopyright(eventId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
Observable<Copyright> diskObservable = Observable.defer(() ->
databaseRepository.getItems(Copyright.class, Copyright_Table.event_id.eq(eventId)).take(1)
);

Observable<Copyright> networkObservable = Observable.defer(() ->
eventService.getCopyright(eventId)
.doOnNext(copyright -> databaseRepository
.save(Copyright.class, copyright)
.subscribe()));

return new AbstractObservableBuilder<Copyright>(utilModel)
.reload(reload)
.withDiskObservable(diskObservable)
.withNetworkObservable(networkObservable)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
package org.fossasia.openevent.app.common.data.repository;

import android.support.annotation.NonNull;

import org.fossasia.openevent.app.common.Constants;
import org.fossasia.openevent.app.common.data.contract.IUtilModel;
import org.fossasia.openevent.app.common.data.db.contract.IDatabaseRepository;
import org.fossasia.openevent.app.common.data.models.Faq;
import org.fossasia.openevent.app.common.data.models.Faq_Table;
import org.fossasia.openevent.app.common.data.network.EventService;
import org.fossasia.openevent.app.common.data.repository.contract.IFAQRepository;
import org.fossasia.openevent.app.common.data.repository.contract.IFaqRepository;

import javax.inject.Inject;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import timber.log.Timber;

public class FaqRepository extends Repository implements IFAQRepository {
public class FaqRepository extends Repository implements IFaqRepository {

@Inject
public FaqRepository(IUtilModel utilModel, IDatabaseRepository databaseRepository, EventService eventService) {
Expand Down Expand Up @@ -41,4 +46,22 @@ public Observable<Faq> getFaqs(long eventId, boolean reload) {
.withNetworkObservable(networkObservable)
.build();
}

@NonNull
@Override
public Observable<Faq> createFaq(Faq faq) {
if (!utilModel.isConnected()) {
return Observable.error(new Throwable(Constants.NO_NETWORK));
}

return eventService
.postFaq(faq)
.doOnNext(created -> {
created.setEvent(faq.getEvent());
databaseRepository.save(Faq.class, created)
.subscribe();
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
}
Loading

0 comments on commit 41e50f5

Please sign in to comment.