Glide


Source link: https://github.com/bumptech/glide

Glide

| View Glide's documentation | ?????? | Report an issue with Glide

Glide is a fast and efficient open source media management and image loading framework for Android that wraps media decoding, memory and disk caching, and resource pooling into a simple and easy to use interface.

Glide supports fetching, decoding, and displaying video stills, images, and animated GIFs. Glide includes a flexible API that allows developers to plug in to almost any network stack. By default Glide uses a custom HttpUrlConnection based stack, but also includes utility libraries plug in to Google's Volley project or Square's OkHttp library instead.

Glide's primary focus is on making scrolling any kind of a list of images as smooth and fast as possible, but Glide is also effective for almost any case where you need to fetch, resize, and display a remote image.

Download

You can download a jar from GitHub's releases page.

Or use Gradle:

repositories {

mavenCentral()
maven {
 url 'https://maven.google.com' 
}
 
}
  dependencies {

compile 'com.github.bumptech.glide:glide:4.3.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1' 
}

Or Maven:

<dependency>
<groupId>com.github.bumptech.glide</groupId>
<artifactId>glide</artifactId>
<version>4.3.1</version> </dependency> <dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r7</version> </dependency> <dependency>
<groupId>com.github.bumptech.glide</groupId>
<artifactId>compiler</artifactId>
<version>4.3.1</version>
<optional>true</optional> </dependency>

For info on using the bleeding edge, see the Snapshots wiki page.

ProGuard

Depending on your ProGuard (DexGuard) config and usage, you may need to include the following lines in your proguard.cfg (see Configuration wiki for more details):

-keep public class * implements com.bumptech.glide.module.GlideModule -keep public class * extends com.bumptech.glide.module.AppGlideModule -keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {

**[] $VALUES;
public *; 
}
  # for DexGuard only -keepresourcexmlelements manifest/application/meta-data@value=GlideModule

How do I use Glide?

Check out the documentation for pages on a variety of topics, and see the javadocs.

For Glide v3, see the wiki.

Simple use cases with Glide's generated API will look something like this:

// For a simple view: @Override public void onCreate(Bundle savedInstanceState) {

...
ImageView imageView = (ImageView) findViewById(R.id.my_image_view);

 GlideApp.with(this).load("http://goo.gl/gEgYUd").into(imageView);
 
}
  // For a simple image list: @Override public View getView(int position, View recycled, ViewGroup container) {

final ImageView myImageView;
if (recycled == null) {

  myImageView = (ImageView) inflater.inflate(R.layout.my_image_view, container, false);

}
 else {

  myImageView = (ImageView) recycled;

}

 String url = myUrls.get(position);

 GlideApp
  .with(myFragment)
  .load(url)
  .centerCrop()
  .placeholder(R.drawable.loading_spinner)
  .into(myImageView);

 return myImageView; 
}

Status

Version 4 is now released and stable. Updates are currently released at least monthly with new features and bug fixes.

Comments/bugs/questions/pull requests are always welcome! Please read CONTRIBUTING.md on how to report issues.

Compatibility

  • Minimum Android SDK: Glide requires a minimum API level of 14.
  • Compile Android SDK: Glide requires you to compile against API 26.

If you need to support older versions, consider staying on Glide v3, which works on API 10, but not actively maintained.

  • OkHttp 2.x: there are optional dependencies available called okhttp-integration, see Integration Libraries wiki page.
  • OkHttp 3.x: there are optional dependencies available called okhttp3-integration, see Integration Libraries wiki page.
  • Volley: there are optional dependencies available called volley-integration, see Integration Libraries wiki page.
  • Round Pictures: CircleImageView/ CircularImageView/ RoundedImageView are known to have issues with TransitionDrawable ( .crossFade() with .thumbnail() or .placeholder()) and animated GIFs, use a BitmapTransformation ( .circleCrop() will be available in v4) or .dontAnimate() to fix the issue.
  • Huge Images (maps, comic strips): Glide can load huge images by downsampling them, but does not support zooming and panning ImageViews as they require special resource optimizations (such as tiling) to work without OutOfMemoryErrors.

Build

Building Glide with gradle is fairly straight forward:

git clone [email protected]:bumptech/glide.git # use https://github.com/bumptech/glide.git if "Permission Denied" cd glide git submodule init && git submodule update ./gradlew jar

Note: Make sure your Android SDK has the Android Support Repository installed, and that your $ANDROID_HOME environment variable is pointing at the SDK or add a local.properties file in the root project with a sdk.dir=... line.

Samples

Follow the steps in the Build section to set up the project and then:

./gradlew :samples:flickr:run ./gradlew :samples:giphy:run ./gradlew :samples:svg:run ./gradlew :samples:contacturi:run

You may also find precompiled APKs on the releases page.

Development

Follow the steps in the Build section to setup the project and then edit the files however you wish. Intellij IDEA 14 cleanly imports both Glide's source and tests and is the recommended way to work with Glide.

To open the project in IntelliJ IDEA:

  1. Go to File menu or the Welcome Screen
  2. Click on Open...
  3. Navigate to Glide's root directory.
  4. Select build.gradle

Getting Help

To report a specific problem or feature request, open a new issue on Github. For questions, suggestions, or anything else, email Glide's discussion group, or join our IRC channel: irc.freenode.net#glide-library.

Contributing

Before submitting pull requests, contributors must sign Google's individual contributor license agreement.

Thanks

Author

Sam Judd - @sjudd on GitHub, @samajudd on Twitter

License

BSD, part MIT and Apache 2.0. See the LICENSE file for details.

Disclaimer

This is not an official Google product.

Resources

OkHttpParamsGet helps you to get Okhttp request params.

Support

  1. Map<String, String>
  2. Map<String, RequestBody>
  3. List<MultipartBody.Part>
  4. MultipartBody.Builder

How to use 1. Choose a class. 2. Press Alt + P or click the Generate menu choose GetParams. 3. Choose a type. 4. click ok.

A simple ImageView which scales the width or height aspect with the given ratio.

Live-models backed up by SharedPreferences and observable with Rx, LiveData or old-fashioned listeners.

Kotlin Json DSL.

Android's regular spinner can be really annoying sometimes. Unwanted calls during initialization, doesn't let user to select same item etc. Respinner is a simple spinner which supports item click events. You can set item click listener.

Tinder like swipeable card view for Android.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes