Skip to content

Commit

Permalink
Merge branch 'release/0.0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiago Silva authored and Tiago Silva committed Feb 17, 2019
2 parents 29c21ec + 51160b4 commit 83acf2b
Show file tree
Hide file tree
Showing 20 changed files with 452 additions and 409 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
8 changes: 8 additions & 0 deletions .idea/markdown-exported-files.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ android {
applicationId "com.tiagohs.hqr"
minSdkVersion 17
targetSdkVersion 28
versionCode 12
versionCode 13
versionName "0.0.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -102,6 +102,7 @@ dependencies {

// Network client
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'
implementation 'com.squareup.okio:okio:1.14.0'

// REST
Expand All @@ -110,6 +111,7 @@ dependencies {
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"


// JSON
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.github.salomonbrys.kotson:kotson:2.5.0'
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
android:name="com.tiagohs.hqr.App"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:usesCleartextTraffic="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
Expand Down
26 changes: 9 additions & 17 deletions app/src/main/java/com/tiagohs/hqr/database/HQInitialData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import io.realm.RealmList

object HQRInitialData {

fun initialData(realm: Realm?): List<CatalogueSource> {
fun initialData(realm: Realm): List<CatalogueSource> {
return arrayListOf(
/*CatalogueSource().apply {
CatalogueSource().apply {
this.id = 1L
this.language = "pt-BR"
this.sourceDBS = getPortugueseCatalogue(realm)
},*/
},
CatalogueSource().apply {
this.id = 2L
this.language = "en"
Expand All @@ -27,26 +27,18 @@ object HQRInitialData {
)
}

private fun getPortugueseCatalogue(realm: Realm?): RealmList<SourceDB> {
private fun getPortugueseCatalogue(realm: Realm): RealmList<SourceDB> {
val list = RealmList<SourceDB>()

list.add(realm!!.createObject(SourceDB::class.java, 1L).apply {
this.name = "HQBR - Leitor Online de Quadrinhos"
this.hasThumbnailSupport = false
this.baseUrl = "https://hqbr.com.br/"
this.language = "BR"
this.hasInAllPageSupport = false
this.hasInGenresPageSupport = false
this.hasInPublisherPageSupport = false
})
/*
list.add(realm.createObject(SourceDB::class.java, 2L).apply {
this.name = "HQ Ultimate"
this.hasPageSupport= true
this.hasThumbnailSupport = true
this.hasInAllPageSupport = true
this.hasInGenresPageSupport = true
this.hasInPublisherPageSupport = true
this.baseUrl = "http://hqultimate.site/"
this.language = "pt-BR"
})*/
this.language = "BR"
})

return list
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import dagger.Module
import dagger.Provides
import okhttp3.Cache
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import java.util.concurrent.TimeUnit

Expand All @@ -22,9 +23,12 @@ class NetModule {

@Provides
internal fun provideOkHttpClient(cache: Cache): OkHttpClient {
val logging = HttpLoggingInterceptor()
logging.setLevel(HttpLoggingInterceptor.Level.BODY)

return OkHttpClient.Builder()
.addInterceptor(CallInterceptor())
.addInterceptor(logging)
.connectTimeout(60, TimeUnit.SECONDS)
.writeTimeout(60, TimeUnit.SECONDS)
.readTimeout(60, TimeUnit.SECONDS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.tiagohs.hqr.dragger.modules

import com.tiagohs.hqr.download.cache.ChapterCache
import com.tiagohs.hqr.sources.SourceManager
import com.tiagohs.hqr.sources.portuguese.HQBRSource
import dagger.Module
import dagger.Provides
import okhttp3.OkHttpClient
Expand All @@ -15,8 +14,4 @@ class SourcesModule {
return SourceManager(client, chapterCache)
}

@Provides
fun providesHQBRSource(client: OkHttpClient, chapterCache: ChapterCache): HQBRSource {
return HQBRSource(client, chapterCache)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@ class ScreenUtils {
fun getStatusConstant(status: String?): String? {

if (status != null) {
if (status.toLowerCase().contains("concluído") or status.contains("completed") or status.contains(COMPLETED)) {
if (status.toLowerCase().contains("concluído") or
status.toLowerCase().contains("completo") or
status.contains("completed") or status.contains(COMPLETED)) {
return COMPLETED
} else if (status.toLowerCase().contains("em andamento") or status.contains("ongoing") or status.contains(ONGOING)) {
} else if (
status.toLowerCase().contains("em andamento") or
status.toLowerCase().contains("ativo") or
status.contains("ongoing") or status.contains(ONGOING)) {
return ONGOING
} else if (status.toLowerCase().contains("cancelado") or status.contains("canceled") or status.contains(CANCELED)) {
return CANCELED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ListComicsInterceptor(

type = FETCH_ALL

return onGetAllByFlag(sourceHttp?.fetchAllComicsByLetter(letter)!!, sourceHttp, sourceId)
return onGetAllByFlag(sourceHttp?.fetchAllComicsByLetter(letter, page++)!!, sourceHttp, sourceId)
}

override fun onGetAllByScanlator(scanlator: String): Observable<List<ComicViewModel>> {
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/com/tiagohs/hqr/sources/HttpSourceBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@ abstract class HttpSourceBase(

abstract protected fun parseComicDetailsResponse(response: Response, comicPath: String) : ComicViewModel?

override fun fetchAllComicsByLetter(letter: String): Observable<List<ComicViewModel>> {
return fetch(GET(getAllComicsByLetterEndpoint(letter), headersBuilder().build()))
override fun fetchAllComicsByLetter(letter: String, page: Int): Observable<List<ComicViewModel>> {
val s = getAllComicsByLetterEndpoint(letter, page)
return fetch(GET(s, headersBuilder().build()))
.map({ response: Response -> parseAllComicsByLetterResponse(response) })
}

abstract protected fun getAllComicsByLetterEndpoint(letter: String): String
abstract protected fun getAllComicsByLetterEndpoint(letter: String, page: Int): String

abstract protected fun parseAllComicsByLetterResponse(response: Response) : List<ComicViewModel>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/tiagohs/hqr/sources/IHttpSource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface IHttpSource {
fun fetchReaderComics(hqReaderPath: String): Observable<ChapterViewModel>
fun fetchComicDetails(comicPath: String): Observable<ComicViewModel?>

fun fetchAllComicsByLetter(letter: String): Observable<List<ComicViewModel>>
fun fetchAllComicsByLetter(letter: String, page: Int): Observable<List<ComicViewModel>>
fun fetchAllComicsByPublisher(publisherPath: String, page: Int): Observable<List<ComicViewModel>>
fun fetchAllComicsByScanlator(scanlatorPath: String): Observable<List<ComicViewModel>>
fun fetchAllComicsByGenre(genre: String, page: Int): Observable<List<ComicViewModel>>
Expand Down
18 changes: 1 addition & 17 deletions app/src/main/java/com/tiagohs/hqr/sources/ParserHttpSource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,7 @@ abstract class ParserHttpSource(


override fun parsePublishersResponse(response: Response): List<DefaultModelView> {
val publishers: ArrayList<DefaultModelView> = ArrayList()

try {
val document = response.asJsoup()

document.select(homeCategoriesListSelector).map { element ->
val publisher = parseHomeCategoriesByElement(element)

if (publisher != null)
publishers.add(publisher)
}

} catch (ex: Exception) {
Timber.e(ex)
}

return publishers
return emptyList()
}

abstract fun parseHomeCategoriesByElement(element: Element): DefaultModelView?
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/tiagohs/hqr/sources/SourceManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.tiagohs.hqr.sources

import com.tiagohs.hqr.download.cache.ChapterCache
import com.tiagohs.hqr.sources.english.ReadComics
import com.tiagohs.hqr.sources.portuguese.HQBRSource
import com.tiagohs.hqr.sources.portuguese.HQUltimate
import okhttp3.OkHttpClient

class SourceManager(
Expand Down Expand Up @@ -32,6 +32,7 @@ class SourceManager(
}

private fun createSources(): List<IHttpSource> = listOf(
ReadComics(client, chapterCache)
ReadComics(client, chapterCache),
HQUltimate(client, chapterCache)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ReadComics(
return scanlatorPath
}

override fun getAllComicsByLetterEndpoint(letter: String): String {
override fun getAllComicsByLetterEndpoint(letter: String, page: Int): String {
return "$baseUrl/comics-list"
}

Expand Down
Loading

0 comments on commit 83acf2b

Please sign in to comment.