-
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.
## Description Add `androidx.paging` [v3 library](https://developer.android.com/topic/libraries/architecture/paging/v3-overview) helper to handle integration layer content with pagination. There is two use cases 1. Requesting a amount of content with a list of urns that exceed the integration layer page limit (50) 2. Requesting a result with a nextUrl Both are supported with 1. `UrnsPagingSource` 2. `NexturlPagingSource` ### Recommended We recommend to use `DataProviderPaging` that simplify the usage and retrieve directly the content needed with `PagingDataAdapter`. ## Usage ```kotlin val dataProvider = DataProviderPaging(...) val pagingAdapter = PagingDataAdapter(...) dataProvider.getMediaRecommendedByUrn(urn, pageSize = 15).collectLatest { pagingData -> pagingAdapter.submitData(pagingData) } ```
- Loading branch information
Showing
20 changed files
with
619 additions
and
9 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 |
---|---|---|
@@ -1,9 +1,10 @@ | ||
object Versions { | ||
const val coreKtx = "1.8.0" | ||
const val lifecycle_version = "2.5.1" | ||
const val lifecycle = "2.5.1" | ||
const val dagger = "2.44.2" | ||
const val retrofit_version = "2.9.0" | ||
const val okHttp_version = "4.9.1" | ||
const val gsonVersion = "2.10.1" | ||
const val retrofit = "2.9.0" | ||
const val okHttp = "4.9.1" | ||
const val gson = "2.10.1" | ||
const val detekt = "1.22.0" | ||
const val paging = "3.1.1" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
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,79 @@ | ||
plugins { | ||
id("com.android.library") | ||
id("org.jetbrains.kotlin.android") | ||
id("org.jetbrains.kotlin.kapt") | ||
`maven-publish` | ||
} | ||
|
||
android { | ||
namespace = "ch.srgssr.dataprovider.paging" | ||
compileSdk = Config.compileSdk | ||
|
||
defaultConfig { | ||
minSdk = Config.minSdk | ||
targetSdk = Config.targetSdk | ||
group = Config.maven_group | ||
version = Config.versionName | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles("consumer-rules.pro") | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
lint { | ||
// https://developer.android.com/reference/tools/gradle-api/4.1/com/android/build/api/dsl/LintOptions | ||
abortOnError = false | ||
} | ||
} | ||
|
||
dependencies { | ||
api(project(mapOf("path" to ":dataprovider-retrofit"))) | ||
implementation("androidx.core:core-ktx:${Versions.coreKtx}") | ||
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:${Versions.lifecycle}") | ||
api("androidx.paging:paging-runtime-ktx:${Versions.paging}") | ||
|
||
implementation("com.google.dagger:dagger:${Versions.dagger}") | ||
kapt("com.google.dagger:dagger-compiler:${Versions.dagger}") | ||
|
||
testImplementation("junit:junit:4.13.2") | ||
androidTestImplementation("androidx.test.ext:junit:1.1.5") | ||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") | ||
} | ||
|
||
publishing { | ||
publications { | ||
register<MavenPublication>("gpr") { | ||
afterEvaluate { | ||
from(components["release"]) | ||
} | ||
} | ||
} | ||
repositories { | ||
maven { | ||
name = "GitHubPackages" | ||
url = uri("https://maven.pkg.github.com/SRGSSR/srgdataprovider-android") | ||
credentials { | ||
username = project.findProperty("gpr.user") as String? ?: System.getenv("USERNAME") | ||
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN") | ||
} | ||
} | ||
maven { | ||
url = uri("https://maven.ecetest.rts.ch/content/repositories/srg-letterbox-releases/") | ||
credentials { | ||
username = project.findProperty("sonatypeUsername") as String? ?: System.getenv("SONATYPE_USERNAME") | ||
password = project.findProperty("sonatypePassword") as String? ?: System.getenv("SONATYPE_PASSWORD") | ||
} | ||
} | ||
} | ||
} |
Empty file.
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
...ider-paging/src/androidTest/java/ch/srgssr/dataprovider/paging/ExampleInstrumentedTest.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,24 @@ | ||
package ch.srgssr.dataprovider.paging | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("ch.srgssr.dataprovider.paging.test", appContext.packageName) | ||
} | ||
} |
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
Oops, something went wrong.