-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.修改ImageLoaderManager的创建方式,通过传入一个ImageLoader的实现类的方式传入进去
2.删除Fresco getConfig()
- Loading branch information
Showing
3 changed files
with
51 additions
and
49 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
55 changes: 43 additions & 12 deletions
55
lib-pineapple/src/main/java/io/github/keep2iron/pineapple/ImageLoaderManager.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 |
---|---|---|
@@ -1,22 +1,53 @@ | ||
package io.github.keep2iron.pineapple | ||
|
||
import android.app.Application | ||
import android.content.Context | ||
import android.graphics.Bitmap | ||
import android.net.Uri | ||
|
||
/** | ||
* | ||
* @author keep2iron <a href="http://keep2iron.github.io">Contract me.</a> | ||
* @version 1.0 | ||
* @since 2018/06/25 19:42 | ||
* | ||
* 相当于ImageLoader的代理 | ||
*/ | ||
class ImageLoaderManager private constructor() { | ||
|
||
companion object { | ||
@JvmStatic | ||
private val instance: ImageLoader by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { | ||
FrescoImageLoader() | ||
} | ||
|
||
@JvmStatic | ||
fun getImageLoader(): ImageLoader { | ||
return instance | ||
} | ||
class ImageLoaderManager(private val imageLoader: ImageLoader, application: Application) : ImageLoader { | ||
|
||
init { | ||
this.init(application) | ||
} | ||
|
||
override fun init(context: Application) { | ||
imageLoader.init(context) | ||
} | ||
|
||
override fun showImageView(imageView: MiddlewareView, url: String, options: ImageLoaderOptions) { | ||
imageLoader.showImageView(imageView, url, options) | ||
} | ||
|
||
override fun showImageView(imageView: MiddlewareView, uri: Uri, options: ImageLoaderOptions) { | ||
imageLoader.showImageView(imageView, uri, options) | ||
} | ||
|
||
override fun getBitmap(context: Context, url: String, options: ImageLoaderOptions, onGetBitmap: (Bitmap?) -> Unit) { | ||
imageLoader.getBitmap(context, url, options, onGetBitmap) | ||
} | ||
|
||
override fun cleanMemory(context: Context) { | ||
imageLoader.cleanMemory(context) | ||
} | ||
|
||
override fun pause(context: Context) { | ||
imageLoader.pause(context) | ||
} | ||
|
||
override fun resume(context: Context) { | ||
imageLoader.pause(context) | ||
} | ||
|
||
override fun clearAllCache() { | ||
imageLoader.clearAllCache() | ||
} | ||
} |