Skip to content

Commit

Permalink
Make 'calls' module kotlin-only
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbanes committed May 29, 2018
1 parent 810af77 commit 91ed9fd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 52 deletions.
27 changes: 4 additions & 23 deletions calls/build.gradle
Expand Up @@ -15,38 +15,19 @@
*
*/

apply plugin: 'com.android.library'

apply plugin: 'kotlin-android'
apply plugin: 'kotlin'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion buildConfig.compileSdk

defaultConfig {
minSdkVersion buildConfig.minSdk
}

lintOptions {
disable 'GradleCompatible'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation project(":base")
implementation project(":base-android")
implementation project(":show-fetcher")
implementation project(':seasons-fetcher')
implementation project(":trakt")
implementation project(":tmdb")
implementation project(":data")
implementation project(":data-android")

api "io.reactivex.rxjava2:rxjava:${versions.rx}"
compile "android.arch.paging:common:${versions.androidx.paging}"

implementation "io.reactivex.rxjava2:rxjava:${versions.rx}"
implementation "io.reactivex.rxjava2:rxkotlin:${versions.rxkotlin}"
}
20 changes: 0 additions & 20 deletions calls/src/main/AndroidManifest.xml

This file was deleted.

Expand Up @@ -17,7 +17,6 @@
package me.banes.chris.tivi.calls

import android.arch.paging.DataSource
import android.database.sqlite.SQLiteConstraintException
import io.reactivex.Flowable
import kotlinx.coroutines.experimental.withContext
import me.banes.chris.tivi.ShowFetcher
Expand All @@ -29,7 +28,7 @@ import me.banes.chris.tivi.data.entities.ListItem
import me.banes.chris.tivi.extensions.parallelForEach
import me.banes.chris.tivi.util.AppCoroutineDispatchers
import me.banes.chris.tivi.util.AppRxSchedulers
import timber.log.Timber
import me.banes.chris.tivi.util.Logger

abstract class PaginatedEntryCallImpl<TT, ET : PaginatedEntry, LI : ListItem<ET>, out ED : PaginatedEntryDao<ET, LI>>(
private val databaseTransactionRunner: DatabaseTransactionRunner,
Expand All @@ -38,6 +37,7 @@ abstract class PaginatedEntryCallImpl<TT, ET : PaginatedEntry, LI : ListItem<ET>
private val showFetcher: ShowFetcher,
protected val schedulers: AppRxSchedulers,
private val dispatchers: AppCoroutineDispatchers,
private val logger: Logger,
override val pageSize: Int = 21
) : PaginatedCall<Unit, LI> {

Expand Down Expand Up @@ -89,11 +89,11 @@ abstract class PaginatedEntryCallImpl<TT, ET : PaginatedEntry, LI : ListItem<ET>
else -> entryDao.deletePage(page)
}
items.forEach { entry ->
Timber.d("Saving entry: %s", entry)
logger.d("Saving entry: %s", entry)
try {
entryDao.insert(entry)
} catch (e: SQLiteConstraintException) {
Timber.d(e, "Ignoring SQLiteConstraintException while inserting %s", entry)
} catch (e: RuntimeException) {
logger.d(e, "Ignoring exception while inserting %s", entry)
}
}
}
Expand Down
Expand Up @@ -30,6 +30,7 @@ import me.banes.chris.tivi.data.entities.PopularListItem
import me.banes.chris.tivi.extensions.fetchBodyWithRetry
import me.banes.chris.tivi.util.AppCoroutineDispatchers
import me.banes.chris.tivi.util.AppRxSchedulers
import me.banes.chris.tivi.util.Logger
import javax.inject.Inject
import javax.inject.Provider

Expand All @@ -40,14 +41,16 @@ class PopularCall @Inject constructor(
private val showFetcher: ShowFetcher,
private val showsService: Provider<Shows>,
schedulers: AppRxSchedulers,
dispatchers: AppCoroutineDispatchers
dispatchers: AppCoroutineDispatchers,
logger: Logger
) : PaginatedEntryCallImpl<ItemWithIndex<Show>, PopularEntry, PopularListItem, PopularDao>(
databaseTransactionRunner,
showDao,
popularDao,
showFetcher,
schedulers,
dispatchers
dispatchers,
logger
) {

override suspend fun networkCall(page: Int): List<ItemWithIndex<Show>> {
Expand Down
Expand Up @@ -29,6 +29,7 @@ import me.banes.chris.tivi.data.entities.TrendingListItem
import me.banes.chris.tivi.extensions.fetchBodyWithRetry
import me.banes.chris.tivi.util.AppCoroutineDispatchers
import me.banes.chris.tivi.util.AppRxSchedulers
import me.banes.chris.tivi.util.Logger
import javax.inject.Inject
import javax.inject.Provider

Expand All @@ -39,14 +40,16 @@ class TrendingCall @Inject constructor(
private val showFetcher: ShowFetcher,
private val showsService: Provider<Shows>,
schedulers: AppRxSchedulers,
dispatchers: AppCoroutineDispatchers
dispatchers: AppCoroutineDispatchers,
logger: Logger
) : PaginatedEntryCallImpl<TrendingShow, TrendingEntry, TrendingListItem, TrendingDao>(
databaseTransactionRunner,
showDao,
trendingDao,
showFetcher,
schedulers,
dispatchers
dispatchers,
logger
) {
override suspend fun networkCall(page: Int): List<TrendingShow> {
// We add one to the page since Trakt uses a 1-based index whereas we use 0-based
Expand Down

0 comments on commit 91ed9fd

Please sign in to comment.