Commit bd1a76e1 by zhengnw@sobot.com

widget 1.1.7 Fresco 加载本地图片

parent fceb9d4d
...@@ -12,8 +12,7 @@ task androidSourcesJar(type: Jar) { ...@@ -12,8 +12,7 @@ task androidSourcesJar(type: Jar) {
ext { ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名 PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
PUBLISH_ARTIFACT_ID = 'picture' //项目名 PUBLISH_ARTIFACT_ID = 'picture' //项目名
//PUBLISH_ARTIFACT_ID = 'picture_x' //项目名 PUBLISH_VERSION = '1.1.7' //版本号
PUBLISH_VERSION = '1.1.6' //版本号
} }
......
...@@ -21,6 +21,8 @@ import com.facebook.imagepipeline.request.ImageRequest; ...@@ -21,6 +21,8 @@ import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequestBuilder; import com.facebook.imagepipeline.request.ImageRequestBuilder;
import com.sobot.chat.imageloader.SobotImageLoader; import com.sobot.chat.imageloader.SobotImageLoader;
import java.io.File;
public class SobotFrescoImageLoader extends SobotImageLoader { public class SobotFrescoImageLoader extends SobotImageLoader {
@Override @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) { public void displayImage(Context context, final ImageView imageView, final String path, @DrawableRes int loadingResId, @DrawableRes int failResId, int width, int height, final SobotDisplayImageListener listener) {
...@@ -30,7 +32,17 @@ public class SobotFrescoImageLoader extends SobotImageLoader { ...@@ -30,7 +32,17 @@ public class SobotFrescoImageLoader extends SobotImageLoader {
if (imageView == null) { if (imageView == null) {
return; return;
} }
ImageRequestBuilder builder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(path)); ImageRequestBuilder builder;
if (path.startsWith("http")) {
builder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(path));
} else {
File file = new File(path);
if (file != null) {
builder = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(file));
}else{
builder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(path));
}
}
if (width > 0 && height > 0) { if (width > 0 && height > 0) {
builder.setResizeOptions(new ResizeOptions(width, height)); builder.setResizeOptions(new ResizeOptions(width, height));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment