Skip to content

Commit f265edd

Browse files
authored
feat: :refactor: update project with the latest technologies (#10)
closes #7
1 parent c701640 commit f265edd

File tree

81 files changed

+676
-2136
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+676
-2136
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
.DS_Store
66
/build
77
/captures
8+
*.iml

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,25 @@
33
My way to MVVM using RxJava with new Android databinding
44

55
## Summary
6-
* Use [MVVM][1] to separate Android Framework with a [clean architecture][2] to my domain logic.
6+
* Use [MVVM][1] using [architecture components][6] with to separate Android Framework with a [clean architecture][2] to my domain logic.
77
* Use [Android Databinding][3] to glue view model and Android
88
* Asynchronous communications implemented with [Rx][4].
99
* Rest API from [ComicVine][5]
10-
* Use [Frodo][6] to debug Rx
10+
11+
## Dependencies
12+
* architecture components
13+
* rx-java
14+
* floating search
15+
* okhttp
16+
* retrofit
17+
* koin
18+
* picasso
1119

1220
TODO LIST
1321
---------
1422

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

2127

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

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

3440
License
@@ -52,4 +58,4 @@ License
5258
[3]: https://developer.android.com/topic/libraries/data-binding/index.html
5359
[4]: http://reactivex.io/
5460
[5]: http://www.comicvine.com/api/
55-
[6]: https://github.com/android10/frodo
61+
[6]: https://developer.android.com/topic/libraries/architecture/index.html

app/build.gradle

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
apply plugin: 'com.android.application'
2-
apply plugin: 'com.fernandocejas.frodo'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
4+
apply plugin: 'kotlin-kapt'
35

46
android {
5-
compileSdkVersion 23
6-
buildToolsVersion "23.0.2"
7+
compileSdkVersion compile_sdk
78

89
packagingOptions {
910
exclude 'LICENSE.txt'
@@ -17,33 +18,57 @@ android {
1718

1819
defaultConfig {
1920
applicationId "es.ffgiraldez.comicsearch"
20-
minSdkVersion 19
21-
targetSdkVersion 23
21+
minSdkVersion min_sdk
2222
versionCode 1
2323
versionName "1.0"
2424
}
25+
2526
buildTypes {
2627
release {
2728
minifyEnabled false
2829
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2930
}
3031
}
32+
3133
dataBinding {
3234
enabled = true
3335
}
36+
37+
compileOptions {
38+
sourceCompatibility JavaVersion.VERSION_1_8
39+
targetCompatibility JavaVersion.VERSION_1_8
40+
}
41+
42+
androidExtensions {
43+
experimental = true
44+
}
3445
}
3546

3647
dependencies {
37-
compile 'com.android.support:appcompat-v7:23.1.1'
38-
compile 'com.android.support:design:23.1.1'
39-
compile 'io.reactivex:rxandroid:1.0.1'
40-
compile 'com.jakewharton.rxbinding:rxbinding:0.2.0'
41-
compile 'com.miguelcatalan:materialsearchview:1.2.0'
42-
compile 'com.jakewharton:butterknife:6.1.0'
43-
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
44-
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
45-
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
46-
compile 'com.squareup.okhttp:logging-interceptor:2.6.0'
47-
compile 'com.squareup.picasso:picasso:2.5.2'
48-
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
48+
kapt libs.databinding_compiler
49+
50+
implementation libs.arch_comp_livedata
51+
implementation libs.arch_comp_viewmodel
52+
implementation libs.constraint
53+
implementation libs.design
54+
implementation libs.floating_search
55+
implementation libs.okhttp
56+
implementation libs.okhttp_logging
57+
implementation libs.koin
58+
implementation libs.koin_android
59+
implementation libs.koin_architecture
60+
implementation libs.kotlin_stdlib
61+
implementation libs.picasso
62+
implementation libs.retrofit
63+
implementation libs.retrofit_gson
64+
implementation libs.retrofit_rx_java
65+
implementation libs.rx_java
66+
implementation libs.rx_android
67+
68+
testImplementation libs.junit
69+
testImplementation libs.koin_test
70+
testImplementation libs.mockito_kotlin
71+
}
72+
repositories {
73+
mavenCentral()
4974
}

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<uses-permission android:name="android.permission.INTERNET" />
66

77
<application
8+
android:name=".ComicApplication"
89
android:allowBackup="true"
910
android:icon="@mipmap/ic_launcher"
1011
android:label="@string/app_name"
11-
android:supportsRtl="true"
12-
android:theme="@style/AppTheme">
12+
android:theme="@style/Theme.ComicSearch">
1313
<activity android:name=".search.ui.SearchActivity">
1414
<intent-filter>
1515
<action android:name="android.intent.action.MAIN" />
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package es.ffgiraldez.comicsearch
2+
3+
import android.app.Application
4+
import es.ffgiraldez.comicsearch.di.comicContext
5+
import org.koin.android.ext.android.startKoin
6+
7+
class ComicApplication : Application() {
8+
override fun onCreate() {
9+
super.onCreate()
10+
startKoin(this, listOf(comicContext));
11+
}
12+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package es.ffgiraldez.comicsearch.comics
2+
3+
import es.ffgiraldez.comicsearch.comics.data.ComicVineApi
4+
import io.reactivex.Single
5+
import io.reactivex.schedulers.Schedulers
6+
7+
class ComicRepository(
8+
private val api: ComicVineApi
9+
) {
10+
fun searchSuggestion(query: String): Single<List<String>> = api.fetchSuggestedVolumes(query)
11+
.subscribeOn(Schedulers.io())
12+
.map { response ->
13+
response.results
14+
.distinctBy { it.name }
15+
.map { it.name }
16+
}
17+
.subscribeOn(Schedulers.computation())
18+
19+
fun searchVolume(query: String): Single<List<Volume>> = api.fetchVolumes(query)
20+
.subscribeOn(Schedulers.io())
21+
.map { response ->
22+
response.results
23+
.filter { it.apiPublisher != null && it.apiImage != null }
24+
.map {
25+
Volume(it.name, it.apiPublisher!!.name, it.apiImage!!.url)
26+
}
27+
}
28+
.subscribeOn(Schedulers.computation())
29+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package es.ffgiraldez.comicsearch.comics
2+
3+
data class Volume(
4+
val title: String,
5+
val author: String,
6+
val cover: String
7+
)
8+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package es.ffgiraldez.comicsearch.comics.data
2+
3+
import io.reactivex.Single
4+
import retrofit2.http.GET
5+
import retrofit2.http.Query
6+
7+
interface ComicVineApi {
8+
9+
companion object {
10+
const val KEY = "75d580a0593b7320727309feb6309f62def786cd"
11+
const val BASE_URL = "http://www.comicvine.com"
12+
}
13+
14+
@GET("/api/search?format=json&field_list=name&limit=20&page=1&resources=volume&api_key=$KEY")
15+
fun fetchSuggestedVolumes(@Query("query") query: String): Single<SuggestionResponse>
16+
17+
@GET("/api/search?format=json&field_list=name,image,publisher&limit=20&page=1&resources=volume&api_key=$KEY")
18+
fun fetchVolumes(@Query("query") query: String): Single<VolumeResponse>
19+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package es.ffgiraldez.comicsearch.comics.data
2+
3+
import com.google.gson.annotations.SerializedName
4+
5+
6+
data class VolumeResponse(
7+
@SerializedName("status_code") var statusCode: Int = 0,
8+
@SerializedName("error") var error: String?,
9+
@SerializedName("results") var results: List<ApiVolume>
10+
)
11+
12+
data class SuggestionResponse(
13+
@SerializedName("status_code") var statusCode: Int = 0,
14+
@SerializedName("error") var error: String?,
15+
@SerializedName("results") var results: List<SuggestionVolume>
16+
)
17+
18+
data class SuggestionVolume(
19+
@SerializedName("name") var name: String
20+
)
21+
22+
data class ApiVolume(
23+
@SerializedName("name") var name: String,
24+
@SerializedName("publisher") var apiPublisher: ApiPublisher?,
25+
@SerializedName("image") var apiImage: ApiImage?
26+
)
27+
28+
data class ApiImage(
29+
@SerializedName("thumb_url") val url: String
30+
)
31+
32+
data class ApiPublisher(
33+
@SerializedName("name") val name: String
34+
)

app/src/main/java/es/ffgiraldez/comicsearch/data/ComicDataSource.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)