You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
--- +++ @@ -134,6 +134,57 @@
requestBuilder.load(url).into(view);
}
```
++#### Thumbnail requests+Glide's [``thumbnail()``][9] API allows you to specify a [``RequestBuilder``][8] to start in parallel with your main request. The [``thumbnail()``][9] will be displayed while the primary request is loading. If the primary request completes before the thumbnail request, the image from the thumbnail request will not be shown. The [``thumbnail()``][9] API allows you easily and quickly load low resolution versions of your images while your full quality equivalents load, reducing the amount of time users spend staring at loading indicators.++The [``thumbnail()``][9] API is useful for both local and remote images, especially once the lower resolution thumbnails are in Glide's disk cache where they can be loaded very quickly. ++The [``thumbnail()``][9] API is relatively simple to use:++```java+Glide.with(fragment)+ .load(url)+ .thumbnail(Glide.with(fragment)+ .load(thumbnailUrl))+ .into(imageView);+```++This will work well if your ``thumbnailUrl`` points to a lower resolution image than your primary ``url``. A number of image loading APIs offer ways for you to specify the size of the image you want in your URL, which works particularly well with the [``thumbnail()``][9] API. ++If you're just loading a local image, or you only have a single remote URL, you can still benefit from the thumbnail API by using Glide's [``override()``][17] or [``sizeMultiplier()``][18] APIs to force Glide to load a lower resolution image in the thumbnail request:++```java+int thumbnailSize = ...;+Glide.with(fragment)+ .load(localUri)+ .thumbnail(Glide.with(fragment)+ .load(localUri)+ .override(thumbnailSize))+ .into(view);+```++There's a [``thumbnail()``][19] convenience method that just takes a ``sizeMultiplier`` if you just want to load the same model at some percentage of your ``View`` or ``Target``'s size:++```java+Glide.with(fragment)+ .load(localUri)+ .thumbnail(/*sizeMultiplier=*/ 0.25f)+ .into(imageView);+```++#### Starting a new request on failure.+Starting in Glide 4.3.0, you can now easily specify a [``RequestBuilder``][8] to use to start a new load if your main request fails using the [``error()``][20] API. For example, to load ``fallbackUrl`` if your request for ``primaryUrl`` fails:++```java+Glide.with(fragment)+ .load(primaryUrl)+ .error(Glide.with(fragment)+ .load(fallbackUrl))+ .into(imageView);+```++The [error][20] [``RequestBuilder``][8] will not be started if the main request completes successfully. If you specify both a [``thumbnail()``][9] and an [``error()``][20] [``RequestBuilder``][8], the error [``RequestBuilder``][8] will be started if the primary request fails, even if the thumbnail request succeeds.
### Component Options
@@ -187,3 +238,7 @@
[14]: {{ site.baseurl }}/javadocs/400/com/bumptech/glide/load/ResourceEncoder.html
[15]: {{ site.baseurl }}/javadocs/400/com/bumptech/glide/load/Encoder.html
[16]: {{ site.baseurl }}/doc/generatedapi.html
+[17]: {{ site.baseurl }}/javadocs/430/com/bumptech/glide/request/RequestOptions.html#override-int-int-+[18]: {{ site.baseurl }}/javadocs/420/com/bumptech/glide/request/RequestOptions.html#sizeMultiplier-float-+[19]: {{ site.baseurl }}/javadocs/430/com/bumptech/glide/RequestBuilder.html#thumbnail-float-+[20]: {{ site.baseurl }}/javadocs/430/com/bumptech/glide/RequestBuilder.html#error-com.bumptech.glide.RequestBuilder-
--- +++ @@ -38,8 +38,8 @@
```gradle
dependencies {
- compile 'com.github.bumptech.glide:glide:4.2.0-SNAPSHOT'- compile 'com.github.bumptech.glide:okhttp-integration:4.2.0-SNAPSHOT'+ compile 'com.github.bumptech.glide:glide:4.3.0-SNAPSHOT'+ compile 'com.github.bumptech.glide:okhttp-integration:4.3.0-SNAPSHOT'
}
```
@@ -71,14 +71,49 @@
<dependency>
<groupId>com.github.bumptech.glide</groupId>
<artifactId>glide</artifactId>
- <version>4.2.0-SNAPSHOT</version>+ <version>4.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.github.bumptech.glide</groupId>
<artifactId>okhttp-integration</artifactId>
- <version>4.2.0-SNAPSHOT</version>+ <version>4.3.0-SNAPSHOT</version>
</dependency>
```
++### Fixing your snapshot dependency+Depending on a ``-SNAPSHOT`` version of Glide can be risky in production applications because the code Gradle will fetch for that ``-SNAPSHOT`` version will vary depending on when you first build your project. If you add a snapshot dependency, test on your local machine, and then push that build configuration to a build server, the build server may end up building with a different version of Glide. Snapshot versions are updated after every successful push to GitHub and may change at any time.++To fix your dependency, you can pick a specific version from sonatype and use that instead of depending on ``-SNAPSHOT``. For example, in Gradle:++```gradle+dependencies {+ compile 'com.github.bumptech.glide:glide:4.3.0-20171024.022226-26'+ compile 'com.github.bumptech.glide:okhttp-integration:4.3.0-20171024.022226-26'+}+```++Or in Maven (untested):+```xml+<dependency>+ <groupId>com.github.bumptech.glide</groupId>+ <artifactId>glide</artifactId>+ <version>4.3.0-20171024.022226-26</version>+</dependency>+<dependency>+ <groupId>com.github.bumptech.glide</groupId>+ <artifactId>okhttp-integration</artifactId>+ <version>4.3.0-20171024.022226-26</version>+</dependency>+```++The version, ``4.3.0-20171024.022226-26``, comes from the Sonatype repo. You can pick a specific version by:++1. [Open Sonatype][3]+2. Click on the package you want. Typically you can just use [glide][5].+3. Click on the version of Glide that you want the snapshot of. For example, [4.3.0-SNAPSHOT][6].+4. Copy and paste the version number from any of the listed artifacts. For example if you see ``glide-4.3.0-20171024.022211-26-javadoc.jar``, the version number is just ``4.3.0-20171024.022211-26``. Usually you will want the most recent artifact available. Check the date modified column to be sure, but typically more recent artifacts are shown at the bottom of the page.++Although picking a specific snapshot version is a bit more work, it's typically a safer option if you're going to depend on the snapshot version of Glide in a prod version of your application or library.
### Building snapshots locally
If you want to get the same files that would be released execute this command:
@@ -102,3 +137,5 @@
[2]: https://oss.sonatype.org/content/repositories/snapshots/
[3]: https://oss.sonatype.org/content/repositories/snapshots/com/github/bumptech/glide/
[4]: http://stackoverflow.com/questions/7715321/how-to-download-snapshot-version-from-maven-snapshot-repository
+[5]: https://oss.sonatype.org/content/repositories/snapshots/com/github/bumptech/glide/glide/+[6]: https://oss.sonatype.org/content/repositories/snapshots/com/github/bumptech/glide/glide/4.3.0-SNAPSHOT/
--- +++ @@ -99,6 +99,48 @@
To fix memory leaks, remove references to the destroyed ``Fragment`` or ``Activity`` at the appropriate point in the lifecycle to avoid retaining excessive objects. Use the heap dump to help find other ways your application retains memory and remove unnecessary references as you find them. It's often helpful to start by listing the shortest paths excluding weak references to all Bitmap objects (using [MAT][12] or another memory analyzer) and then looking for reference chains that seem suspicious. You can also check to make sure that you have no more than once instance of each ``Activity`` and only the expected number of instances of each ``Fragment`` by searching for them in your memory analyzer.
+### Other common issues++#### "You can't start or clear loads in RequestListener or Target callbacks"+If you attempt to start a new load in ``onResourceReady`` or ``onLoadFailed`` in a ``Target`` or ``RequestListener``, Glide will throw an exception. We throw this exception because it's challenging for us to handle the load being recycled while it's in the middle of notifying. ++Fortunately this is easy to fix. Starting in Glide 4.3.0, you can simply use the [``.error()``][14] method. [``error()``][14] takes an arbitrary [``RequestBuilder``][15] that will start a new request only if the primary request fails:++```java+Glide.with(fragment)+ .load(url)+ .error(Glide.with(fragment)+ .load(fallbackUrl))+ .into(imageView);+```++Prior to Glide 4.3.0, you can also use an Android [``Handler``][16] to post a Runnable with your request:++```java+private final Handler handler = new Handler();+...++Glide.with(fragment)+ .load(url)+ .listener(new RequestListener<Drawable>() {+ ...++ @Override+ public boolean onLoadFailed(@Nullable GlideException e, Object model, + Target<Drawable> target, boolean isFirstResource) {+ handler.post(new Runnable() {+ @Override+ public void run() {+ Glide.with(fragment)+ .load(fallbackUrl)+ .into(imageView);+ }+ });+ }+ )+ .into(imageView);+```+
[1]: {{ site.baseurl }}/javadocs/400/com/bumptech/glide/GlideBuilder.html#setLogLevel-int-
[2]: {{ site.baseurl }}/javadocs/400/com/bumptech/glide/RequestBuilder.html#into-android.widget.ImageView-
[3]: {{ site.baseurl }}/javadocs/400/com/bumptech/glide/RequestBuilder.html#submit-int-int-
@@ -112,3 +154,6 @@
[11]: https://developer.android.com/studio/profile/investigate-ram.html#HeapDump
[12]: http://www.eclipse.org/mat/
[13]: {{ site.baseurl }}/doc/caching.html
+[14]: http://bumptech.github.io/glide/javadocs/430/com/bumptech/glide/RequestBuilder.html#error-com.bumptech.glide.RequestBuilder-+[15]: http://bumptech.github.io/glide/javadocs/430/com/bumptech/glide/RequestBuilder.html+[16]: https://developer.android.com/reference/android/os/Handler.html
--- +++ @@ -80,6 +80,13 @@
```
To use ``kapt``, see the [official documentation][14].
++#### Android Studio++For the most part Android Studio just works with annotation processors and the generated API. However, you may need to rebuild the project the first time you add your ``AppGlideModule`` or after some types of changes. If the API won't import or seems out of date, you can re-build by:++1. Open the Build menu+2. Click Rebuild Project.
### Using the generated API
The text was updated successfully, but these errors were encountered:
概述
此 Issue 由 Sync Robot 自动创建,详情请参见 #6 。
本次扫描结果: 新增:0 , 修改: 4, 删除: 0。
文件变化列表
文件具体变更信息如下(仅展示UPDATED):
The text was updated successfully, but these errors were encountered: