-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an experimental integration with Flows
Currently the only Flow will emit the status of the load along with the current placeholder or resource, clearing the request when the Flow ends. In future versions we might consider making clearing the target optional so that resources could be used after the flow is over. We could also expose some additional helper functions to make it easier to work with the first run of a flow, or to exclude placeholders. For now this seems like a reasonable starting point.
- Loading branch information
Showing
11 changed files
with
883 additions
and
5 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
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,54 @@ | ||
plugins { | ||
id 'com.android.library' | ||
id 'org.jetbrains.kotlin.android' | ||
} | ||
|
||
android { | ||
compileSdk COMPILE_SDK_VERSION as int | ||
|
||
defaultConfig { | ||
minSdk MIN_SDK_VERSION as int | ||
targetSdk TARGET_SDK_VERSION as int | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles "consumer-rules.pro" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_7 | ||
targetCompatibility JavaVersion.VERSION_1_7 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
} | ||
|
||
// Enable strict mode, but exclude tests. | ||
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { | ||
if (!it.name.contains("Test")) { | ||
kotlinOptions.freeCompilerArgs += "-Xexplicit-api=strict" | ||
} | ||
} | ||
|
||
dependencies { | ||
api project(":library") | ||
implementation "androidx.core:core-ktx:$ANDROID_X_CORE_KTX_VERSION" | ||
implementation "androidx.test:core-ktx:$ANDROID_X_TEST_CORE_KTX_VERSION" | ||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$JETBRAINS_KOTLINX_COROUTINES_VERSION" | ||
testImplementation "androidx.test.ext:junit-ktx:$ANDROID_X_TEST_JUNIT_KTX_VERSION" | ||
testImplementation "androidx.test.ext:junit:$ANDROID_X_TEST_JUNIT_VERSION" | ||
testImplementation "org.robolectric:robolectric:$ROBOLECTRIC_VERSION" | ||
testImplementation "androidx.test:runner:$ANDROID_X_TEST_RUNNER_VERSION" | ||
testImplementation "junit:junit:$JUNIT_VERSION" | ||
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$JETBRAINS_KOTLINX_COROUTINES_TEST_VERSION" | ||
testImplementation "com.google.truth:truth:$TRUTH_VERSION" | ||
androidTestImplementation "androidx.test.ext:junit:$ANDROID_X_TEST_JUNIT_VERSION" | ||
} | ||
|
||
apply from: "${rootProject.projectDir}/scripts/upload.gradle" |
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,9 @@ | ||
POM_NAME=Glide Kotlin Extensions | ||
POM_ARTIFACT_ID=ktx | ||
POM_PACKAGING=aar | ||
POM_DESCRIPTION=An integration library to improve Kotlin interop with Glide | ||
|
||
VERSION_MAJOR=1 | ||
VERSION_MINOR=0 | ||
VERSION_PATCH=0 | ||
VERSION_NAME=1.0.0-alpha.0-SNAPSHOT |
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,2 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="com.bumptech.glide.integration.ktx" /> |
19 changes: 19 additions & 0 deletions
19
integration/ktx/src/main/java/com/bumptech/glide/GlideIntegration.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 @@ | ||
/** | ||
* Functions that give us access to some of Glide's non-public internals to make the flows API a bit | ||
* better. | ||
*/ | ||
package com.bumptech.glide | ||
|
||
import com.bumptech.glide.request.RequestListener | ||
import com.bumptech.glide.request.target.Target | ||
|
||
internal fun RequestBuilder<*>.requestManager() = this.requestManager | ||
|
||
internal fun <ResourceT, TargetAndRequestListenerT> RequestBuilder<ResourceT>.intoDirect( | ||
targetAndRequestListener: TargetAndRequestListenerT, | ||
) where TargetAndRequestListenerT : Target<ResourceT>, | ||
TargetAndRequestListenerT : RequestListener<ResourceT> { | ||
this.into(targetAndRequestListener, targetAndRequestListener) { | ||
it.run() | ||
} | ||
} |
Oops, something went wrong.