Skip to content
Html.ImageGetter which uses Coil to load images
Kotlin
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app Update for both sync and async Feb 3, 2020
coilimagegetter Update for both sync and async Feb 3, 2020
gradle/wrapper 📷 Feb 2, 2020
.gitignore 📷 Feb 2, 2020
.travis.yml Update for both sync and async Feb 3, 2020
README.md Update for both sync and async Feb 3, 2020
build.gradle Couple of updates Feb 2, 2020
gradle.properties 📷 Feb 2, 2020
gradlew 📷 Feb 2, 2020
gradlew.bat 📷 Feb 2, 2020
settings.gradle 📷 Feb 2, 2020

README.md

coil-imagegetter

Loads images for Html rendering in Android using Coil

Build Status

Dependency

Add this in your root build.gradle file (not your module build.gradle file):

allprojects {
	repositories {
		...
		maven { url "https://jitpack.io" }
	}
}

Then, add the library to your project build.gradle

dependencies {
    implementation("com.github.Commit451:CoilImageGetter:latest.version.here")
}

Usage

When rendering HTML, you will need to provide an Html.ImageGetter, which you can use CoilImageGetter or a subclass in order to load image references:

val imageGetter = CoilImageGetter(textView)
val html = ...
val spanned = Html.fromHtml(this, Html.FROM_HTML_MODE_LEGACY, imageGetter)
textView.text = spanned

When running the above on the Main thread, you will see the text appear first, then the images. Otherwise, if run on a background thread, the text and images will appear at the same time. You can see this in the sample app. For advanced usage, you can also specify your own ImageLoader and source modifier. See the class docs for more.

License

Copyright 2020 Commit 451

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You can’t perform that action at this time.