Skip to content

Commit

Permalink
Release 2.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aallam committed Mar 18, 2021
2 parents 3c35f48 + ed77fc2 commit 8855be6
Show file tree
Hide file tree
Showing 80 changed files with 2,915 additions and 67 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.iml
local.properties
*.hprof
.bundle/

# fastlane
**/fastlane/report.xml
Expand All @@ -14,3 +15,4 @@ local.properties

# bitrise
.bitrise.yml
bitrise.yml
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 2.10.0

### Added
- Integration of `InstantSearch Insights` library
- Add `retry` to paging data sources

# 2.9.0

### Added
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,4 @@ DEPENDENCIES
fastlane

BUNDLED WITH
1.17.2
1.17.3
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@ subprojects {
tasks.withType<Test> {
maxParallelForks = Runtime.getRuntime().availableProcessors().minus(1).coerceAtLeast(1)
}

tasks.register<Delete>("clean") {
delete(rootProject.buildDir)
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Library.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ object Library: Dependency {

override val group = "com.algolia"
override val artifact = "instantsearch-android"
override val version = "2.9.0"
override val version = "2.10.0"
}
10 changes: 10 additions & 0 deletions buildSrc/src/main/kotlin/dependency/lib/Work.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dependency.lib

import dependency.Dependency

object Work : Dependency {

override val group = "androidx.work"
override val artifact = "work"
override val version = "2.5.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package dependency.network

import dependency.Dependency


object AlgoliaClient : Dependency {

override val group = "com.algolia"
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/dependency/plugin/AndroidTools.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ object AndroidTools : Dependency {

override val group = "com.android.tools.build"
override val artifact = "gradle"
override val version = "4.0.1"
override val version = "4.0.2"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ object GradleMavenPublish : Dependency {

override val group = "com.vanniktech"
override val artifact = "gradle-maven-publish-plugin"
override val version = "0.13.0"
override val version = "0.14.2"
}
1 change: 0 additions & 1 deletion buildSrc/src/main/kotlin/dependency/test/AndroidTestExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package dependency.test

import dependency.Dependency


object AndroidTestExt : Dependency {

override val group = "androidx.test.ext"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ object AndroidTestRunner: Dependency {
override val group = "androidx.test"
override val artifact = "runner"
override val version = "1.2.0"
}
}
10 changes: 10 additions & 0 deletions buildSrc/src/main/kotlin/dependency/test/Mockk.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dependency.test

import dependency.Dependency

object Mockk : Dependency {

override val group = "io.mockk"
override val artifact = "mockk"
override val version = "1.10.6"
}
5 changes: 2 additions & 3 deletions buildSrc/src/main/kotlin/dependency/test/Robolectric.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package dependency.test

import dependency.Dependency


object Robolectric : Dependency {

override val group = "org.robolectric"
override val artifact = "robolectric"
override val version = "4.3.1"
}
override val version = "4.5.1"
}
1 change: 0 additions & 1 deletion buildSrc/src/main/kotlin/dependency/util/AtomicFu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package dependency.util

import dependency.Dependency


object AtomicFu: Dependency {

override val group = "org.jetbrains.kotlinx"
Expand Down
3 changes: 0 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
kotlin.code.style=official

android.enableJetifier=true
android.useAndroidX=true
org.gradle.parallel=true

Expand All @@ -19,5 +18,3 @@ POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=algolia
POM_DEVELOPER_NAME=The Algolia Team
POM_DEVELOPER_EMAIL=[email protected]

RELEASE_SIGNING_ENABLED=false
25 changes: 0 additions & 25 deletions gradle/gradle-maven-publish.gradle

This file was deleted.

6 changes: 1 addition & 5 deletions instantsearch-android-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm")
id("java-library")
id ("com.vanniktech.maven.publish")
}

apply(from = "../gradle/gradle-maven-publish.gradle")

group = Library.group
version = Library.version

sourceSets {
main {
java.srcDirs("$buildDir/generated/sources/templates/kotlin/main")
Expand Down
29 changes: 12 additions & 17 deletions instantsearch-android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
import dependency.network.AlgoliaClient
import dependency.network.Coroutines
import dependency.network.Ktor
import dependency.test.AndroidTestExt
import dependency.test.AndroidTestRunner
import dependency.test.Robolectric
import dependency.ui.AndroidCore
import dependency.ui.AppCompat
import dependency.ui.MaterialDesign
import dependency.ui.Paging
import dependency.ui.RecyclerView
import dependency.ui.SwipeRefreshLayout
import dependency.network.*
import dependency.test.*
import dependency.ui.*

plugins {
id("com.android.library")
id("kotlin-android")
id("kotlinx-serialization")
id("com.vanniktech.maven.publish")
}

apply(from = "../gradle/gradle-maven-publish.gradle")

android {
compileSdkVersion(30)

Expand All @@ -42,7 +32,6 @@ android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
freeCompilerArgs += listOf(
"-Xexplicit-api=warning",
"-Xopt-in=kotlin.RequiresOptIn",
"-Xopt-in=com.algolia.search.ExperimentalAlgoliaClientAPI"
)
Expand All @@ -56,11 +45,15 @@ android {
}
}

group = Library.group
version = Library.version
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
if ("UnitTest" !in name) {
kotlinOptions.freeCompilerArgs += "-Xexplicit-api=strict"
}
}

dependencies {
api(project(":instantsearch-android-core"))
api(project(":instantsearch-insights"))
api(AlgoliaClient())
api(Ktor("client-okhttp"))
api(AndroidCore("ktx"))
Expand All @@ -77,4 +70,6 @@ dependencies {
testImplementation(AndroidTestRunner())
testImplementation(AndroidTestExt())
testImplementation(Robolectric())
testImplementation(Coroutines("test"))
testImplementation(Mockk())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.algolia.instantsearch.helper.android.list

import androidx.paging.PageKeyedDataSource
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.asExecutor
import kotlinx.coroutines.withContext

/**
* A [PageKeyedDataSource] with retry capability.
*/
public abstract class RetryablePageKeyedDataSource<Key, Value>(private val retryDispatcher: CoroutineDispatcher) :
PageKeyedDataSource<Key, Value>() {

internal var retry: (() -> Any)? = null

public suspend fun retry() {
retry?.let { prevRetry ->
retry = null
withContext(retryDispatcher) {
prevRetry()
}
}
}

/**
* Retries the latest call.
*/
public fun retryAsync() {
retry?.let { prevRetry ->
retry = null
retryDispatcher.asExecutor().execute {
prevRetry()
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
package com.algolia.instantsearch.helper.android.list

import androidx.paging.DataSource
import androidx.paging.PageKeyedDataSource
import com.algolia.instantsearch.helper.searcher.SearcherMultipleIndex
import com.algolia.search.model.multipleindex.IndexQuery
import com.algolia.search.model.response.ResponseSearch
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext

public class SearcherMultipleIndexDataSource<T>(
private val searcher: SearcherMultipleIndex,
private val indexQuery: IndexQuery,
private val triggerSearchForQueries: ((List<IndexQuery>) -> Boolean) = { true },
retryDispatcher: CoroutineDispatcher = Dispatchers.IO,
private val transformer: (ResponseSearch.Hit) -> T,
) : PageKeyedDataSource<Int, T>() {
) : RetryablePageKeyedDataSource<Int, T>(retryDispatcher) {

public class Factory<T>(
private val searcher: SearcherMultipleIndex,
private val indexQuery: IndexQuery,
private val triggerSearchForQueries: ((List<IndexQuery>) -> Boolean) = { true },
private val retryDispatcher: CoroutineDispatcher = Dispatchers.IO,
private val transformer: (ResponseSearch.Hit) -> T,
) : DataSource.Factory<Int, T>() {

override fun create(): DataSource<Int, T> {
return SearcherMultipleIndexDataSource(searcher, indexQuery, triggerSearchForQueries, transformer)
return SearcherMultipleIndexDataSource(
searcher = searcher,
indexQuery = indexQuery,
triggerSearchForQueries = triggerSearchForQueries,
transformer = transformer,
retryDispatcher = retryDispatcher
)
}
}

Expand Down Expand Up @@ -52,8 +61,10 @@ public class SearcherMultipleIndexDataSource<T>(
searcher.response.value = response
searcher.isLoading.value = false
}
retry = null
callback.onResult(result.hits.map(transformer), 0, result.nbHits, null, nextKey)
} catch (throwable: Throwable) {
retry = { loadInitial(params, callback) }
resultError(throwable)
}
}
Expand All @@ -76,8 +87,10 @@ public class SearcherMultipleIndexDataSource<T>(
searcher.response.value = response
searcher.isLoading.value = false
}
retry = null
callback.onResult(result.hits.map(transformer), nextKey)
} catch (throwable: Throwable) {
retry = { loadAfter(params, callback) }
resultError(throwable)
}
}
Expand Down
Loading

0 comments on commit 8855be6

Please sign in to comment.