forked from ffgiraldez/reactive-mvvm-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: :refactor: update project with the latest technologies (ffgiral…
…dez#10) closes ffgiraldez#7
- Loading branch information
1 parent
c701640
commit f265edd
Showing
81 changed files
with
676 additions
and
2,136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
.DS_Store | ||
/build | ||
/captures | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
||
|
@@ -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 | ||
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
app/src/main/java/es/ffgiraldez/comicsearch/ComicApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
app/src/main/java/es/ffgiraldez/comicsearch/comics/ComicRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
|
19 changes: 19 additions & 0 deletions
19
app/src/main/java/es/ffgiraldez/comicsearch/comics/data/ComicVineApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/es/ffgiraldez/comicsearch/comics/data/ComicVineResponses.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
29 changes: 0 additions & 29 deletions
29
app/src/main/java/es/ffgiraldez/comicsearch/data/ComicDataSource.java
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
app/src/main/java/es/ffgiraldez/comicsearch/data/ComicStorage.java
This file was deleted.
Oops, something went wrong.
52 changes: 0 additions & 52 deletions
52
app/src/main/java/es/ffgiraldez/comicsearch/data/MockDataSource.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.