Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Commit

Permalink
feat: Move lombok to another module
Browse files Browse the repository at this point in the history
- Add kotlin support in main app
- Move JSONAPI models to another module data
- Convert preleminary classes to data classes
- Balance classes of lombok and Kotlin within modules
- Fix kotlin properties and tests
- Add mockito extension inline for kotlin classes
  • Loading branch information
sriramr98 authored and iamareebjamal committed Mar 21, 2018
1 parent 9bb3f4c commit bf90474
Show file tree
Hide file tree
Showing 75 changed files with 472 additions and 543 deletions.
23 changes: 16 additions & 7 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'realm-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'

def gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
def buildTime = new Date().format("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC"))
Expand All @@ -8,8 +11,8 @@ def isTravis = "true" == System.getenv("TRAVIS")
def preDexEnabled = "true" == System.getProperty("pre-dex", "true")

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
compileSdkVersion rootProject.sdkVersion
buildToolsVersion rootProject.buildTools

dexOptions {
// Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
Expand All @@ -22,8 +25,8 @@ android {

defaultConfig {
applicationId "org.fossasia.openevent"
minSdkVersion 16
targetSdkVersion 27
targetSdkVersion rootProject.sdkVersion
minSdkVersion rootProject.minSdkVersion
versionCode 101
versionName "1.0.1"

Expand Down Expand Up @@ -67,6 +70,10 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}

androidExtensions {
experimental = true
}

sourceSets.test.resources.srcDirs += ["src/main/assets"]
}

Expand All @@ -88,6 +95,10 @@ dependencies {
implementation "com.android.support:customtabs:${SUPPORT_LIB_VERSION}"
implementation "com.android.support:palette-v7:${SUPPORT_LIB_VERSION}"
implementation 'com.android.support:multidex:1.0.2'

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation project(':data')

implementation 'com.github.jasminb:jsonapi-converter:0.7'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-jackson:2.3.0'
Expand All @@ -107,9 +118,7 @@ dependencies {
implementation 'com.github.yalantis:ucrop:2.2.1'
implementation 'io.reactivex.rxjava2:rxjava:2.1.3'
implementation "android.arch.lifecycle:reactivestreams:1.0.0"
compileOnly "org.projectlombok:lombok:1.16.18"
annotationProcessor "org.projectlombok:lombok:1.16.18"
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
kapt 'com.jakewharton:butterknife-compiler:8.6.0'

// Googleplay Variant
googleplayImplementation 'com.google.android.gms:play-services-maps:11.8.0'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package org.fossasia.openevent.config

import org.fossasia.openevent.config.strategies.*

/**
* Project level configuration strategies holder singleton
*
* Holds all strategies and provides an interface to get singleton strategies or
* override the default strategy holder. Also sets the order and strategies in default
* holder which is then utilised by [AppConfigurer] to configure the application
*/
class StrategyRegistry private constructor() {
private val defaultHolder: ConfigStrategyHolder = ConfigStrategyHolder()

var strategyHolder: ConfigStrategyHolder? = null

private fun <T> lazyInit(field: T?, initializer: () -> T): T {
return field ?: initializer()
}

var httpStrategy: HttpStrategy? = null
get() {
field = lazyInit(field) { HttpStrategy() }
return field
}
var languageStrategy: LanguageStrategy? = null
get() {
field = lazyInit(field) { LanguageStrategy() }
return field
}
var leakCanaryStrategy: LeakCanaryStrategy? = null
get() {
field = lazyInit(field) { LeakCanaryStrategy() }
return field
}
var eventBusStrategy: EventBusStrategy? = null
get() {
field = lazyInit(field) { EventBusStrategy() }
return field
}
var mapModuleStrategy: MapModuleStrategy? = null
get() {
field = lazyInit(field) { MapModuleStrategy() }
return field
}
var appConfigStrategy: AppConfigStrategy? = null
get() {
field = lazyInit(field) { AppConfigStrategy() }
return field
}


fun getDefaultHolder(): ConfigStrategyHolder {
if (strategyHolder != null)
return strategyHolder as ConfigStrategyHolder
defaultHolder.register(leakCanaryStrategy)
defaultHolder.register(httpStrategy)
defaultHolder.register(eventBusStrategy)
defaultHolder.register(mapModuleStrategy)
defaultHolder.register(appConfigStrategy)
defaultHolder.register(languageStrategy)
defaultHolder.register(TimberStrategy())
defaultHolder.register(TimeConfigStrategy())
defaultHolder.register(RealmStrategy())
return defaultHolder
}

companion object {
@JvmStatic
val instance by lazy { StrategyRegistry() }
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.fossasia.openevent.config.strategies

import android.content.Context
import com.facebook.stetho.Stetho
import com.facebook.stetho.okhttp3.StethoInterceptor
import com.jakewharton.picasso.OkHttp3Downloader
import com.squareup.picasso.Picasso
import com.uphyca.stetho_realm.RealmInspectorModulesProvider
import okhttp3.Cache
import okhttp3.OkHttpClient
import org.fossasia.openevent.BuildConfig
import org.fossasia.openevent.config.ConfigStrategy
import java.io.File

/**
* Configures Http Cache and stetho plugin and sets picasso to use the configured client
*
* Also provides an interface for application to use Picasso with cache
* To be used via [org.fossasia.openevent.config.StrategyRegistry]
*/
class HttpStrategy : ConfigStrategy {

lateinit var picassoWithCache: Picasso
private set

override fun configure(context: Context): Boolean {
//Initialize Cache
val httpCacheDirectory = File(context.cacheDir, "picasso-cache")
val cache = Cache(httpCacheDirectory, (15 * 1024 * 1024).toLong())

val okHttpClientBuilder: OkHttpClient.Builder = OkHttpClient.Builder().cache(cache)

if (BuildConfig.DEBUG) {
// Create an InitializerBuilder
Stetho.initialize(
Stetho.newInitializerBuilder(context)
.enableDumpapp(Stetho.defaultDumperPluginsProvider(context))
.enableWebKitInspector(RealmInspectorModulesProvider.builder(context).build())
.build())

//Initialize Stetho Interceptor into OkHttp client
val httpClient = OkHttpClient.Builder().addNetworkInterceptor(StethoInterceptor()).build()
okHttpClientBuilder.addNetworkInterceptor(StethoInterceptor())

//Initialize Picasso
val picasso = Picasso.Builder(context).downloader(OkHttp3Downloader(httpClient)).build()
Picasso.setSingletonInstance(picasso)
}

//Initialize Picasso with cache
picassoWithCache = Picasso.Builder(context).downloader(OkHttp3Downloader(okHttpClientBuilder.build())).build()

return false
}

}

This file was deleted.

Loading

0 comments on commit bf90474

Please sign in to comment.