GithubHelp home page GithubHelp logo

pineapple's Introduction

Pineapple

中文

Glide version :Release

Fresco version: Release

Build Status: BuildStatus

Pineapple is an imageLoader manger library.

  • Base on kotlin.
  • Glide and Fresco implements same interfaces.
  • Switch Fresco or Glide is easy,just switch gradle dependencies,android change some code.
  • Base on androidx

Downloads

Glide version and fresco version can be installed one, both installations will have an error switch

Glide

dependencies {
    //glide version
    implementation 'io.github.keep2iron:pineapple-glide:$latest_version'
    
    //Since pineapple does not integrate glide versions internally, it needs to integrate itself.
    implementation 'com.github.bumptech.glide:glide:$glide_latest_version'
    //kotlin should use kapt
    annotationProcessor 'com.github.bumptech.glide:compiler:$glide_latest_version'
}

One thing to note is that due to the features of Glide v4, you need to use GlideAppModule to set some global features or properties, so I implemented a class myself io.github.keep2iron.pineapple.GlideInitModule

If you use the properties such as setting the cache, you must inherit the class when you get the width and height of the image. Remember to call the parent class method when overriding the method.

@GlideModule
class GlideModule : GlideInitModule()

Fresco

dependencies {
    //fresco version
    implementation 'io.github.keep2iron:pineapple-fresco:$latest_version'
   
    //Since pineapple does not integrate fresco versions internally, it needs to integrate itself.
    implementation 'com.facebook.fresco:fresco:2.0.0'
}

Use

Initialize the ImageLoaderManager as early as possible, the internal will automatically load fresco or glide, no external parameters are required.

ImageLoaderManager.init(
    application,
    ImageLoaderConfig(
        applicationContext,
        maxCacheCount = 300,
        maxCacheSize = 400 * Util.MB
    ),
    defaultImageLoaderOptions = {
        isCircleImage = false 
        scaleType = ImageLoaderOptions.ScaleType.FIT_CENTER
        placeHolderRes = R.mipmap.ic_launcher
        placeHolder = ResourcesCompat.getDrawable(resources, R.mipmap.ic_launcher, null)
    }
)

If you are using a loaded image scene, use MiddlewareView to replace IimageView in xml, because this class has different implementations in the two versions of the library.

<io.github.keep2iron.pineapple.MiddlewareView
	android:id="@+id/middleImageView"
	android:layout_width="match_parent"
	android:layout_height="match_parent" /> 

Load Image by default options

ImageLoaderManager.getInstance().showImageView(middleImageView, url)

Loading the image through option, be careful, internally I will merge the defaultImageLoaderOptions object passed in the previous init method with the currently loaded options. The defaultImageLoaderOptions property will be passed to the new options object, and the properties of both will take precedence. The level will be higher in the current options.

ImageLoaderManager.getInstance().showImageView(
    holder.binding.imageView, data[position]
) {
    isCircleImage = true
    scaleType = ImageLoaderOptions.ScaleType.FIT_XY
    placeHolder = null
    isLoadGif = true
}

In the init method above we passed the isCircleImage to load the prototype image, but the current options have higher priority, so the final isCircleImage = true

ProGuard

No need......

License

Copyright 2019 Keep2iron.

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.

pineapple's People

Contributors

keep2iron avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pineapple's Issues

support svg

fresco和glide中需要测试针对svg的支持

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.