Skip to content

Commit

Permalink
feat: :refactor: update project with the latest technologies (ffgiral…
Browse files Browse the repository at this point in the history
  • Loading branch information
ffgiraldez authored Apr 9, 2018
1 parent c701640 commit f265edd
Show file tree
Hide file tree
Showing 81 changed files with 676 additions and 2,136 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.DS_Store
/build
/captures
*.iml
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@
My way to MVVM using RxJava with new Android databinding

## Summary
* Use [MVVM][1] to separate Android Framework with a [clean architecture][2] to my domain logic.
* Use [MVVM][1] using [architecture components][6] with to separate Android Framework with a [clean architecture][2] to my domain logic.
* Use [Android Databinding][3] to glue view model and Android
* Asynchronous communications implemented with [Rx][4].
* Rest API from [ComicVine][5]
* Use [Frodo][6] to debug Rx

## Dependencies
* architecture components
* rx-java
* floating search
* okhttp
* retrofit
* koin
* picasso

TODO LIST
---------

* Better UI, with Material Design concepts and so on
* Add unit tests, allways fail on that :(
* Add Dependency Injection
* [WIP] Implement an Annotation processor to remove most of the View Model boilerplate code
* Add unit tests, allways fail on that :(
* Implement a local datasource with Realm to test it


Expand All @@ -25,10 +31,10 @@ Developed By
Fernando Franco Giráldez - <[email protected]>

<a href="https://twitter.com/thanerian">
<img alt="Follow me on Twitter" src="http://imageshack.us/a/img812/3923/smallth.png" />
<img alt="Follow me on Twitter" src="/images/twitter_icon.png" height="128"/>
</a>
<a href="http://es.linkedin.com/pub/fernando-franco-giraldez/22/803/b44/es">
<img alt="Add me to Linkedin" src="http://imageshack.us/a/img41/7877/smallld.png" />
<img alt="Add me to Linkedin" src="/images/linkedin_icon.png" height="128"/>
</a>

License
Expand All @@ -52,4 +58,4 @@ License
[3]: https://developer.android.com/topic/libraries/data-binding/index.html
[4]: http://reactivex.io/
[5]: http://www.comicvine.com/api/
[6]: https://github.com/android10/frodo
[6]: https://developer.android.com/topic/libraries/architecture/index.html
59 changes: 42 additions & 17 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
apply plugin: 'com.android.application'
apply plugin: 'com.fernandocejas.frodo'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
compileSdkVersion compile_sdk

packagingOptions {
exclude 'LICENSE.txt'
Expand All @@ -17,33 +18,57 @@ android {

defaultConfig {
applicationId "es.ffgiraldez.comicsearch"
minSdkVersion 19
targetSdkVersion 23
minSdkVersion min_sdk
versionCode 1
versionName "1.0"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

dataBinding {
enabled = true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

androidExtensions {
experimental = true
}
}

dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'io.reactivex:rxandroid:1.0.1'
compile 'com.jakewharton.rxbinding:rxbinding:0.2.0'
compile 'com.miguelcatalan:materialsearchview:1.2.0'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
compile 'com.squareup.okhttp:logging-interceptor:2.6.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
kapt libs.databinding_compiler

implementation libs.arch_comp_livedata
implementation libs.arch_comp_viewmodel
implementation libs.constraint
implementation libs.design
implementation libs.floating_search
implementation libs.okhttp
implementation libs.okhttp_logging
implementation libs.koin
implementation libs.koin_android
implementation libs.koin_architecture
implementation libs.kotlin_stdlib
implementation libs.picasso
implementation libs.retrofit
implementation libs.retrofit_gson
implementation libs.retrofit_rx_java
implementation libs.rx_java
implementation libs.rx_android

testImplementation libs.junit
testImplementation libs.koin_test
testImplementation libs.mockito_kotlin
}
repositories {
mavenCentral()
}
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".ComicApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/Theme.ComicSearch">
<activity android:name=".search.ui.SearchActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/es/ffgiraldez/comicsearch/ComicApplication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package es.ffgiraldez.comicsearch

import android.app.Application
import es.ffgiraldez.comicsearch.di.comicContext
import org.koin.android.ext.android.startKoin

class ComicApplication : Application() {
override fun onCreate() {
super.onCreate()
startKoin(this, listOf(comicContext));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package es.ffgiraldez.comicsearch.comics

import es.ffgiraldez.comicsearch.comics.data.ComicVineApi
import io.reactivex.Single
import io.reactivex.schedulers.Schedulers

class ComicRepository(
private val api: ComicVineApi
) {
fun searchSuggestion(query: String): Single<List<String>> = api.fetchSuggestedVolumes(query)
.subscribeOn(Schedulers.io())
.map { response ->
response.results
.distinctBy { it.name }
.map { it.name }
}
.subscribeOn(Schedulers.computation())

fun searchVolume(query: String): Single<List<Volume>> = api.fetchVolumes(query)
.subscribeOn(Schedulers.io())
.map { response ->
response.results
.filter { it.apiPublisher != null && it.apiImage != null }
.map {
Volume(it.name, it.apiPublisher!!.name, it.apiImage!!.url)
}
}
.subscribeOn(Schedulers.computation())
}
8 changes: 8 additions & 0 deletions app/src/main/java/es/ffgiraldez/comicsearch/comics/Volume.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package es.ffgiraldez.comicsearch.comics

data class Volume(
val title: String,
val author: String,
val cover: String
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package es.ffgiraldez.comicsearch.comics.data

import io.reactivex.Single
import retrofit2.http.GET
import retrofit2.http.Query

interface ComicVineApi {

companion object {
const val KEY = "75d580a0593b7320727309feb6309f62def786cd"
const val BASE_URL = "http://www.comicvine.com"
}

@GET("/api/search?format=json&field_list=name&limit=20&page=1&resources=volume&api_key=$KEY")
fun fetchSuggestedVolumes(@Query("query") query: String): Single<SuggestionResponse>

@GET("/api/search?format=json&field_list=name,image,publisher&limit=20&page=1&resources=volume&api_key=$KEY")
fun fetchVolumes(@Query("query") query: String): Single<VolumeResponse>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package es.ffgiraldez.comicsearch.comics.data

import com.google.gson.annotations.SerializedName


data class VolumeResponse(
@SerializedName("status_code") var statusCode: Int = 0,
@SerializedName("error") var error: String?,
@SerializedName("results") var results: List<ApiVolume>
)

data class SuggestionResponse(
@SerializedName("status_code") var statusCode: Int = 0,
@SerializedName("error") var error: String?,
@SerializedName("results") var results: List<SuggestionVolume>
)

data class SuggestionVolume(
@SerializedName("name") var name: String
)

data class ApiVolume(
@SerializedName("name") var name: String,
@SerializedName("publisher") var apiPublisher: ApiPublisher?,
@SerializedName("image") var apiImage: ApiImage?
)

data class ApiImage(
@SerializedName("thumb_url") val url: String
)

data class ApiPublisher(
@SerializedName("name") val name: String
)

This file was deleted.

48 changes: 0 additions & 48 deletions app/src/main/java/es/ffgiraldez/comicsearch/data/ComicStorage.java

This file was deleted.

This file was deleted.

Loading

0 comments on commit f265edd

Please sign in to comment.