Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
Sobot_module_Dev
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sobot_android
Sobot_module_Dev
Commits
27207957
Commit
27207957
authored
Sep 19, 2022
by
郑娜伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
picture 支持fresco
parent
ebacb6f2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
2 deletions
+83
-2
build.gradle
sobot_pictureframe/build.gradle
+1
-0
SobotBitmapUtil.java
...src/main/java/com/sobot/pictureframe/SobotBitmapUtil.java
+4
-2
SobotFrescoImageLoader.java
...n/java/com/sobot/pictureframe/SobotFrescoImageLoader.java
+78
-0
No files found.
sobot_pictureframe/build.gradle
View file @
27207957
...
...
@@ -31,6 +31,7 @@ dependencies {
compileOnly
'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compileOnly
'com.github.bumptech.glide:glide:3.8.0'
compileOnly
'com.squareup.picasso:picasso:2.5.2'
compileOnly
'com.facebook.fresco:fresco:2.6.0'
api
'com.sobot.chat:sobotsupport-glidev4:2.0'
}
...
...
sobot_pictureframe/src/main/java/com/sobot/pictureframe/SobotBitmapUtil.java
View file @
27207957
...
...
@@ -27,8 +27,10 @@ public class SobotBitmapUtil {
sImageLoader
=
new
SobotPicassoImageLoader
();
}
else
if
(
isClassExists
(
"com.nostra13.universalimageloader.core.ImageLoader"
))
{
sImageLoader
=
new
SobotUILImageLoader
();
}
else
if
(
isClassExists
(
"com.facebook.drawee.backends.pipeline.Fresco"
))
{
sImageLoader
=
new
SobotFrescoImageLoader
();
}
else
{
throw
new
RuntimeException
(
"必须在(Glide、Picasso、universal-image-loader)中选择一个图片加载库添加依赖,或者检查是否添加了相应的混淆配置"
);
throw
new
RuntimeException
(
"必须在(Glide、Picasso、universal-image-loader
、Fresco
)中选择一个图片加载库添加依赖,或者检查是否添加了相应的混淆配置"
);
}
}
}
...
...
@@ -74,7 +76,7 @@ public class SobotBitmapUtil {
@SuppressWarnings
(
"deprecation"
)
public
static
Bitmap
compress
(
String
filePath
,
Context
context
,
boolean
isCamera
)
{
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
Q
||
isCamera
)
{
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
Q
||
isCamera
)
{
BitmapFactory
.
Options
options
=
new
BitmapFactory
.
Options
();
options
.
inJustDecodeBounds
=
true
;
// 设置后decode图片不会返回一个bitmap对象,但是会将图片的信息封装到Options中
BitmapFactory
.
decodeFile
(
filePath
,
options
);
...
...
sobot_pictureframe/src/main/java/com/sobot/pictureframe/SobotFrescoImageLoader.java
0 → 100644
View file @
27207957
package
com
.
sobot
.
pictureframe
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.net.Uri
;
import
android.os.AsyncTask
;
import
android.support.annotation.DrawableRes
;
import
android.support.annotation.Nullable
;
import
android.widget.ImageView
;
import
com.facebook.common.executors.UiThreadImmediateExecutorService
;
import
com.facebook.common.references.CloseableReference
;
import
com.facebook.datasource.DataSource
;
import
com.facebook.drawee.backends.pipeline.Fresco
;
import
com.facebook.imagepipeline.common.ResizeOptions
;
import
com.facebook.imagepipeline.core.ImagePipeline
;
import
com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber
;
import
com.facebook.imagepipeline.image.CloseableImage
;
import
com.facebook.imagepipeline.request.ImageRequest
;
import
com.facebook.imagepipeline.request.ImageRequestBuilder
;
import
com.sobot.chat.imageloader.SobotImageLoader
;
public
class
SobotFrescoImageLoader
extends
SobotImageLoader
{
@Override
public
void
displayImage
(
Context
context
,
final
ImageView
imageView
,
final
String
path
,
@DrawableRes
int
loadingResId
,
@DrawableRes
int
failResId
,
int
width
,
int
height
,
final
SobotDisplayImageListener
listener
)
{
ImageRequestBuilder
builder
=
ImageRequestBuilder
.
newBuilderWithSource
(
Uri
.
parse
(
path
));
if
(
width
>
0
&&
height
>
0
)
{
builder
.
setResizeOptions
(
new
ResizeOptions
(
width
,
height
));
}
ImageRequest
imageRequest
=
builder
.
build
();
ImagePipeline
imagePipeline
=
Fresco
.
getImagePipeline
();
DataSource
<
CloseableReference
<
CloseableImage
>>
dataSource
=
imagePipeline
.
fetchDecodedImage
(
imageRequest
,
context
);
BaseBitmapDataSubscriber
subscriber
=
new
BaseBitmapDataSubscriber
()
{
@Override
public
void
onNewResultImpl
(
@Nullable
Bitmap
bitmap
)
{
// if (listener != null) {
new
AsyncTask
<
Bitmap
,
Void
,
Bitmap
>()
{
@Override
protected
Bitmap
doInBackground
(
Bitmap
...
params
)
{
Bitmap
bitmap
=
params
[
0
];
Bitmap
result
=
null
;
if
(
bitmap
!=
null
&&
!
bitmap
.
isRecycled
())
{
result
=
bitmap
.
copy
(
Bitmap
.
Config
.
RGB_565
,
false
);
}
return
result
;
}
@Override
protected
void
onPostExecute
(
Bitmap
bitmap
)
{
if
(
bitmap
!=
null
)
{
// listener.onLoadComplete(bitmap);
imageView
.
setImageBitmap
(
bitmap
);
}
else
{
// listener.onLoadFailed(null);
}
}
}.
execute
(
bitmap
);
}
@Override
public
void
onFailureImpl
(
DataSource
dataSource
)
{
// if (listener != null) {
// listener.onLoadFailed(dataSource.getFailureCause());
// }
}
};
dataSource
.
subscribe
(
subscriber
,
UiThreadImmediateExecutorService
.
getInstance
());
}
@Override
public
void
displayImage
(
Context
context
,
final
ImageView
imageView
,
@DrawableRes
int
targetResId
,
@DrawableRes
int
loadingResId
,
@DrawableRes
int
failResId
,
int
width
,
int
height
,
final
SobotDisplayImageListener
listener
)
{
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment