Commit 4ceab2ff by zhengnw@sobot.com

picture 1.2.4

parent 18f0610a
...@@ -41,6 +41,7 @@ dependencies { ...@@ -41,6 +41,7 @@ dependencies {
// api 'com.sobot.library:sobotcommon_x:1.0' // api 'com.sobot.library:sobotcommon_x:1.0'
implementation 'com.github.bumptech.glide:glide:4.9.0' implementation 'com.github.bumptech.glide:glide:4.9.0'
// api 'com.sobot.chat:sobotsupport-glidev4:3.8'
// implementation 'com.facebook.fresco:fresco:1.13.0' // implementation 'com.facebook.fresco:fresco:1.13.0'
//android x 可以用这个 ,普通版不能用这个 //android x 可以用这个 ,普通版不能用这个
// implementation 'com.facebook.fresco:fresco:2.6.0' // implementation 'com.facebook.fresco:fresco:2.6.0'
......
...@@ -22,6 +22,7 @@ import com.sobot.album.Action; ...@@ -22,6 +22,7 @@ import com.sobot.album.Action;
import com.sobot.album.AlbumFile; import com.sobot.album.AlbumFile;
import com.sobot.album.SobotAlbum; import com.sobot.album.SobotAlbum;
import com.sobot.album.api.widget.Widget; import com.sobot.album.api.widget.Widget;
import com.sobot.chat.imageloader.SobotImageLoader;
import com.sobot.common.login.SobotLoginTools; import com.sobot.common.login.SobotLoginTools;
import com.sobot.common.login.callback.SobotResultBlock; import com.sobot.common.login.callback.SobotResultBlock;
import com.sobot.common.login.callback.SobotResultCode; import com.sobot.common.login.callback.SobotResultCode;
...@@ -67,9 +68,19 @@ public class MainActivity extends SobotBaseActivity { ...@@ -67,9 +68,19 @@ public class MainActivity extends SobotBaseActivity {
SobotToastUtil.showCustomToast(getSobotBaseActivity(), "sdafdsafsadfasdfsdaf"); SobotToastUtil.showCustomToast(getSobotBaseActivity(), "sdafdsafsadfasdfsdaf");
SobotWidgetApi.setSwitchMarkStatus(SobotMarkConfig.SHOW_PERMISSION_TIPS_POP, true); SobotWidgetApi.setSwitchMarkStatus(SobotMarkConfig.SHOW_PERMISSION_TIPS_POP, true);
setTitle("ddddd"); setTitle("ddddd");
SobotBitmapUtil.display(getSobotBaseActivity(), "https://img.sobot.com/console/common/face/admin.png", getAvatarImageView(true)); SobotBitmapUtil.display(getSobotBaseActivity(), "https://img.sobot.com/console/common/face/admin.png", getAvatarImageView(true), 0, 0);
img = findViewById(R.id.img); img = findViewById(R.id.img);
SobotBitmapUtil.display(this, "https://img.sobot.com/console/common/face/admin.png", img, R.mipmap.ic_launcher, R.mipmap.ic_launcher); SobotBitmapUtil.display(this, "https://img.sobot.com/console/common/face/admin.png", img, R.mipmap.ic_launcher, R.mipmap.ic_launcher,img.getWidth(),img.getHeight(), new SobotImageLoader.SobotDisplayImageListener() {
@Override
public void onSuccess(View view, String path) {
// SobotToastUtil.showToast(getSobotBaseActivity(),"成功");
}
@Override
public void onFail(View view, String path) {
// SobotToastUtil.showToast(getSobotBaseActivity(),"失败");
}
});
img2 = findViewById(R.id.img2); img2 = findViewById(R.id.img2);
// img2.setScaleType(ImageView.ScaleType.FIT_XY); // img2.setScaleType(ImageView.ScaleType.FIT_XY);
// SobotBitmapUtil.display(this, "https://img.sobot.com/chatres/75574e5fa29a48458d1f57ab5489a4c5/msg/20220421/34a466420d78fa1172bc0acd85166745/9410b53be86b4d589c61c60f6aee2461.jpeg", img2); // SobotBitmapUtil.display(this, "https://img.sobot.com/chatres/75574e5fa29a48458d1f57ab5489a4c5/msg/20220421/34a466420d78fa1172bc0acd85166745/9410b53be86b4d589c61c60f6aee2461.jpeg", img2);
...@@ -299,7 +310,7 @@ public class MainActivity extends SobotBaseActivity { ...@@ -299,7 +310,7 @@ public class MainActivity extends SobotBaseActivity {
if (!checkStoragePermission(4)) { if (!checkStoragePermission(4)) {
return; return;
} }
openAlbum(); // openAlbum();
// selectPicFromLocal(); // selectPicFromLocal();
// preview(); // preview();
......
...@@ -21,8 +21,10 @@ dependencies { ...@@ -21,8 +21,10 @@ dependencies {
compileOnly 'androidx.appcompat:appcompat:1.1.0' compileOnly 'androidx.appcompat:appcompat:1.1.0'
compileOnly 'androidx.recyclerview:recyclerview:1.0.0' compileOnly 'androidx.recyclerview:recyclerview:1.0.0'
compileOnly 'com.google.android.material:material:1.4.0' compileOnly 'com.google.android.material:material:1.4.0'
api 'com.sobot.library:widget_x:1.3.1' api 'com.sobot.library:widget_x:1.3.2'
api 'com.sobot.library:sobotcommon_x:2.2.1' api 'com.sobot.library:sobotcommon_x:2.2.2'
// implementation project(':sobot_common')
// implementation project(':sobot_widget')
} }
......
...@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) { ...@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
ext { ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名 PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
PUBLISH_ARTIFACT_ID = 'album' //项目名 PUBLISH_ARTIFACT_ID = 'album' //项目名
PUBLISH_VERSION = '1.1.1' //版本号 PUBLISH_VERSION = '1.1.2' //版本号
} }
......
...@@ -7,6 +7,8 @@ android { ...@@ -7,6 +7,8 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 14 minSdkVersion 14
//添加此行
multiDexEnabled true
} }
//这里就是打jar包 //这里就是打jar包
task makeJar(type: Copy) { task makeJar(type: Copy) {
...@@ -34,7 +36,7 @@ dependencies { ...@@ -34,7 +36,7 @@ dependencies {
api 'com.sobot.library:utils:1.1.3' api 'com.sobot.library:utils:1.1.3'
api 'com.sobot.library:picture_x:1.2.1' api 'com.sobot.library:picture_x:1.2.4'
api 'com.sobot.library:net:1.2.8' api 'com.sobot.library:net:1.2.8'
api 'com.sobot.library:gson:1.1.1' api 'com.sobot.library:gson:1.1.1'
} }
......
...@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) { ...@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
ext { ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名 PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
PUBLISH_ARTIFACT_ID = 'sobotcommon_x' //项目名 PUBLISH_ARTIFACT_ID = 'sobotcommon_x' //项目名
PUBLISH_VERSION = '2.2.1' //版本号 PUBLISH_VERSION = '2.2.2' //版本号
} }
......
...@@ -80,7 +80,7 @@ Gradle窗口 --> sobot_pictureframe --> Tasks --> build --> publishing --> 点 ...@@ -80,7 +80,7 @@ Gradle窗口 --> sobot_pictureframe --> Tasks --> build --> publishing --> 点
3、 在使用4.9.0(包含4.9.0)以上版本的glide时,需额外添加依赖,之前的版本不需要 3、 在使用4.9.0(包含4.9.0)以上版本的glide时,需额外添加依赖,之前的版本不需要
``` ```
implementation 'com.sobot.chat:sobotsupport-glidev4:3.2' implementation 'com.sobot.chat:sobotsupport-glidev4:3.7'
``` ```
4、picasso不支持显示本地图片 4、picasso不支持显示本地图片
......
...@@ -7,11 +7,13 @@ android { ...@@ -7,11 +7,13 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 14 minSdkVersion 14
//添加此行
multiDexEnabled true
} }
//这里就是打jar包 //这里就是打jar包
task makeJar(type: Copy) { task makeJar(type: Copy) {
//删除旧的jar包 //删除旧的jar包
delete 'build/libs/sobot_picture_1.2.1.jar' delete 'build/libs/sobot_picture_1.2.3.jar'
//原地址 //原地址
from('build/intermediates/packaged-classes/release/') from('build/intermediates/packaged-classes/release/')
//导出jar包的地址 //导出jar包的地址
...@@ -19,7 +21,7 @@ android { ...@@ -19,7 +21,7 @@ android {
//包含的jar包 //包含的jar包
include('classes.jar') include('classes.jar')
//重命名jar包为mysdk //重命名jar包为mysdk
rename ('classes.jar', 'sobot_picture_1.2.1.jar') rename ('classes.jar', 'sobot_picture_1.2.3.jar')
} }
makeJar.dependsOn(build) makeJar.dependsOn(build)
...@@ -32,7 +34,7 @@ dependencies { ...@@ -32,7 +34,7 @@ dependencies {
compileOnly 'com.github.bumptech.glide:glide:3.8.0' compileOnly 'com.github.bumptech.glide:glide:3.8.0'
compileOnly 'com.squareup.picasso:picasso:2.8' compileOnly 'com.squareup.picasso:picasso:2.8'
compileOnly 'com.facebook.fresco:fresco:2.6.0' compileOnly 'com.facebook.fresco:fresco:2.6.0'
api 'com.sobot.chat:sobotsupport-glidev4:3.3' api 'com.sobot.chat:sobotsupport-glidev4:3.9'
} }
//添加发布到mavenCentral脚本 //添加发布到mavenCentral脚本
......
...@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) { ...@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
ext { ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名 PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
PUBLISH_ARTIFACT_ID = 'picture_x' //项目名 PUBLISH_ARTIFACT_ID = 'picture_x' //项目名
PUBLISH_VERSION = '1.2.1' //版本号 PUBLISH_VERSION = '1.2.4' //版本号
} }
......
...@@ -16,7 +16,7 @@ public class SobotBitmapUtil { ...@@ -16,7 +16,7 @@ public class SobotBitmapUtil {
private static SobotImageLoader sImageLoader; private static SobotImageLoader sImageLoader;
private static final SobotImageLoader getImageLoader() { private static SobotImageLoader getImageLoader() {
if (sImageLoader == null) { if (sImageLoader == null) {
synchronized (SobotBitmapUtil.class) { synchronized (SobotBitmapUtil.class) {
if (sImageLoader == null) { if (sImageLoader == null) {
...@@ -39,7 +39,8 @@ public class SobotBitmapUtil { ...@@ -39,7 +39,8 @@ public class SobotBitmapUtil {
return sImageLoader; return sImageLoader;
} }
private static final boolean isClassExists(String classFullName) { //判断是否存在该类
private static boolean isClassExists(String classFullName) {
try { try {
Class.forName(classFullName); Class.forName(classFullName);
return true; return true;
...@@ -48,39 +49,87 @@ public class SobotBitmapUtil { ...@@ -48,39 +49,87 @@ public class SobotBitmapUtil {
} }
} }
//使用客户指定的图片加载器
public static void setImageLoader(SobotImageLoader imageLoader) { public static void setImageLoader(SobotImageLoader imageLoader) {
sImageLoader = imageLoader; sImageLoader = imageLoader;
} }
/**
* 加载网络图片
*
* @param context 上下文
* @param url 网络图片地址
* @param imageView 图片控件
* @param defaultPic 预加载图片
* @param error 加载失败图片
*/
public static void display(Context context, String url, public static void display(Context context, String url,
ImageView imageView, int defaultPic, int error) { ImageView imageView, int defaultPic, int error) {
if (context != null && imageView != null) { if (context != null && imageView != null) {
getImageLoader().displayImage(context, imageView, url, defaultPic, error, imageView.getWidth(), imageView.getHeight(), null); getImageLoader().displayImage(context, imageView, url, defaultPic, error, imageView.getWidth(), imageView.getHeight(), null);
} }
} }
/**
* 加载网络图片
*
* @param context 上下文
* @param url 网络图片地址
* @param imageView 图片控件
* @param defaultPic 预加载图片
* @param error 加载失败图片
* @param imageWidth 图片控件宽高
* @param imageHeight 图片控件宽高
* @param listener 加载结果回调
*/
public static void display(Context context, String url, public static void display(Context context, String url,
ImageView imageView) { ImageView imageView, int defaultPic, int error, int imageWidth, int imageHeight, SobotImageLoader.SobotDisplayImageListener listener) {
if (context != null && imageView != null) {
getImageLoader().displayImage(context, imageView, url, defaultPic, error, imageWidth, imageHeight, listener);
}
}
/**
* 加载网络图片
*
* @param context 上下文
* @param url 网络图片地址
* @param imageView 图片控件
*/
public static void display(Context context, String url,
ImageView imageView) {
if (context != null && imageView != null) { if (context != null && imageView != null) {
getImageLoader().displayImage(context, imageView, url, 0, 0, imageView.getWidth(), imageView.getHeight(), null); getImageLoader().displayImage(context, imageView, url, 0, 0, imageView.getWidth(), imageView.getHeight(), null);
} }
} }
/**
* 本地图片加载图片
*
* @param context 上下文
* @param resourceId 本地图片地址
* @param imageView 图片控件
*/
public static void display(Context context, int resourceId, ImageView imageView) { public static void display(Context context, int resourceId, ImageView imageView) {
if (context != null && imageView != null) { if (context != null && imageView != null) {
getImageLoader().displayImage(context, imageView, resourceId, 0, 0, imageView.getWidth(), imageView.getHeight(), null); getImageLoader().displayImage(context, imageView, resourceId, 0, 0, imageView.getWidth(), imageView.getHeight(), null);
} }
} }
/**
* uri 方式加载图片
*
* @param context 上下文
* @param uri 图片Uri
* @param imageView 图片控件
*/
public static void display(Context context, Uri uri, ImageView imageView) { public static void display(Context context, Uri uri, ImageView imageView) {
if (context != null && imageView != null) { if (context != null && imageView != null) {
getImageLoader().displayImage(context, imageView, uri, 0, 0, imageView.getWidth(), imageView.getHeight(), null); getImageLoader().displayImage(context, imageView, uri, 0, 0, imageView.getWidth(), imageView.getHeight(), null);
} }
} }
@SuppressWarnings("deprecation")
public static Bitmap compress(String filePath, Context context, boolean isCamera) { 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(); BitmapFactory.Options options = new BitmapFactory.Options();
......
...@@ -4,8 +4,10 @@ import android.content.Context; ...@@ -4,8 +4,10 @@ import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import androidx.annotation.DrawableRes; import androidx.annotation.DrawableRes;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import android.text.TextUtils; import android.text.TextUtils;
import android.widget.ImageView; import android.widget.ImageView;
...@@ -39,7 +41,7 @@ public class SobotFrescoImageLoader extends SobotImageLoader { ...@@ -39,7 +41,7 @@ public class SobotFrescoImageLoader extends SobotImageLoader {
File file = new File(path); File file = new File(path);
if (file != null) { if (file != null) {
builder = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(file)); builder = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(file));
}else{ } else {
builder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(path)); builder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(path));
} }
} }
...@@ -67,9 +69,11 @@ public class SobotFrescoImageLoader extends SobotImageLoader { ...@@ -67,9 +69,11 @@ public class SobotFrescoImageLoader extends SobotImageLoader {
@Override @Override
protected void onPostExecute(Bitmap bitmap) { protected void onPostExecute(Bitmap bitmap) {
if (listener != null) {
listener.onSuccess(imageView, path);
}
if (bitmap != null) { if (bitmap != null) {
imageView.setImageBitmap(bitmap); imageView.setImageBitmap(bitmap);
} else {
} }
} }
}.execute(bitmap); }.execute(bitmap);
...@@ -78,11 +82,15 @@ public class SobotFrescoImageLoader extends SobotImageLoader { ...@@ -78,11 +82,15 @@ public class SobotFrescoImageLoader extends SobotImageLoader {
@Override @Override
public void onFailureImpl(DataSource dataSource) { public void onFailureImpl(DataSource dataSource) {
if (listener != null) {
listener.onFail(imageView, path);
}
} }
}; };
dataSource.subscribe(subscriber, UiThreadImmediateExecutorService.getInstance()); dataSource.subscribe(subscriber, UiThreadImmediateExecutorService.getInstance());
} }
@Override @Override
public void displayImage(Context context, final ImageView imageView, final Uri imgUri, @DrawableRes int loadingResId, @DrawableRes int failResId, int width, int height, final SobotDisplayImageListener listener) { public void displayImage(Context context, final ImageView imageView, final Uri imgUri, @DrawableRes int loadingResId, @DrawableRes int failResId, int width, int height, final SobotDisplayImageListener listener) {
if (null == imgUri) { if (null == imgUri) {
...@@ -116,9 +124,11 @@ public class SobotFrescoImageLoader extends SobotImageLoader { ...@@ -116,9 +124,11 @@ public class SobotFrescoImageLoader extends SobotImageLoader {
@Override @Override
protected void onPostExecute(Bitmap bitmap) { protected void onPostExecute(Bitmap bitmap) {
if (listener != null) {
listener.onSuccess(imageView, imgUri == null ? "" : imgUri.getPath());
}
if (bitmap != null) { if (bitmap != null) {
imageView.setImageBitmap(bitmap); imageView.setImageBitmap(bitmap);
} else {
} }
} }
}.execute(bitmap); }.execute(bitmap);
...@@ -127,6 +137,9 @@ public class SobotFrescoImageLoader extends SobotImageLoader { ...@@ -127,6 +137,9 @@ public class SobotFrescoImageLoader extends SobotImageLoader {
@Override @Override
public void onFailureImpl(DataSource dataSource) { public void onFailureImpl(DataSource dataSource) {
if (listener != null) {
listener.onFail(imageView, imgUri == null ? "" : imgUri.getPath());
}
} }
}; };
......
...@@ -2,6 +2,7 @@ package com.sobot.pictureframe; ...@@ -2,6 +2,7 @@ package com.sobot.pictureframe;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import androidx.annotation.DrawableRes; import androidx.annotation.DrawableRes;
import android.net.Uri; import android.net.Uri;
...@@ -34,6 +35,9 @@ public class SobotGlideImageLoader extends SobotImageLoader { ...@@ -34,6 +35,9 @@ public class SobotGlideImageLoader extends SobotImageLoader {
builder.listener(new RequestListener<String, Bitmap>() { builder.listener(new RequestListener<String, Bitmap>() {
@Override @Override
public boolean onException(Exception e, String model, Target<Bitmap> target, boolean isFirstResource) { public boolean onException(Exception e, String model, Target<Bitmap> target, boolean isFirstResource) {
if (listener != null) {
listener.onFail(imageView, path);
}
return false; return false;
} }
...@@ -46,6 +50,7 @@ public class SobotGlideImageLoader extends SobotImageLoader { ...@@ -46,6 +50,7 @@ public class SobotGlideImageLoader extends SobotImageLoader {
} }
}).into(imageView); }).into(imageView);
} }
@Override @Override
public void displayImage(Context context, final ImageView imageView, final Uri imgUri, @DrawableRes int loadingResId, @DrawableRes int failResId, int width, int height, final SobotDisplayImageListener listener) { public void displayImage(Context context, final ImageView imageView, final Uri imgUri, @DrawableRes int loadingResId, @DrawableRes int failResId, int width, int height, final SobotDisplayImageListener listener) {
if (null == imgUri) { if (null == imgUri) {
...@@ -61,13 +66,16 @@ public class SobotGlideImageLoader extends SobotImageLoader { ...@@ -61,13 +66,16 @@ public class SobotGlideImageLoader extends SobotImageLoader {
builder.listener(new RequestListener<Object, Bitmap>() { builder.listener(new RequestListener<Object, Bitmap>() {
@Override @Override
public boolean onException(Exception e, Object model, Target<Bitmap> target, boolean isFirstResource) { public boolean onException(Exception e, Object model, Target<Bitmap> target, boolean isFirstResource) {
if (listener != null) {
listener.onFail(imageView, imgUri == null ? "" : imgUri.getPath());
}
return false; return false;
} }
@Override @Override
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, boolean isFromMemoryCache, boolean isFirstResource) { public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, boolean isFromMemoryCache, boolean isFirstResource) {
if (listener != null) { if (listener != null) {
listener.onSuccess(imageView, imgUri.getPath()); listener.onSuccess(imageView, imgUri == null ? "" : imgUri.getPath());
} }
return false; return false;
} }
...@@ -84,6 +92,9 @@ public class SobotGlideImageLoader extends SobotImageLoader { ...@@ -84,6 +92,9 @@ public class SobotGlideImageLoader extends SobotImageLoader {
builder.listener(new RequestListener<Integer, Bitmap>() { builder.listener(new RequestListener<Integer, Bitmap>() {
@Override @Override
public boolean onException(Exception e, Integer model, Target<Bitmap> target, boolean isFirstResource) { public boolean onException(Exception e, Integer model, Target<Bitmap> target, boolean isFirstResource) {
if (listener != null) {
listener.onFail(imageView, "");
}
return false; return false;
} }
......
...@@ -24,7 +24,7 @@ public class SobotPicassoImageLoader extends SobotImageLoader { ...@@ -24,7 +24,7 @@ public class SobotPicassoImageLoader extends SobotImageLoader {
if (TextUtils.isEmpty(path)) { if (TextUtils.isEmpty(path)) {
pathStr = "error"; pathStr = "error";
} }
RequestCreator creator ; RequestCreator creator;
if (pathStr.startsWith("http")) { if (pathStr.startsWith("http")) {
creator = Picasso.get().load(pathStr); creator = Picasso.get().load(pathStr);
} else { } else {
...@@ -32,7 +32,7 @@ public class SobotPicassoImageLoader extends SobotImageLoader { ...@@ -32,7 +32,7 @@ public class SobotPicassoImageLoader extends SobotImageLoader {
if (file != null) { if (file != null) {
creator = Picasso.get().load(file); creator = Picasso.get().load(file);
} else { } else {
creator = Picasso.get().load(pathStr);; creator = Picasso.get().load(pathStr);
} }
} }
if (loadingResId != 0) { if (loadingResId != 0) {
...@@ -54,8 +54,16 @@ public class SobotPicassoImageLoader extends SobotImageLoader { ...@@ -54,8 +54,16 @@ public class SobotPicassoImageLoader extends SobotImageLoader {
listener.onSuccess(imageView, path); listener.onSuccess(imageView, path);
} }
} }
@Override
public void onError(Exception e) {
if (listener != null) {
listener.onFail(imageView, path);
}
}
}); });
} }
@Override @Override
public void displayImage(Context context, final ImageView imageView, final Uri imgUri, int loadingResId, int failResId, int width, int height, final SobotDisplayImageListener listener) { public void displayImage(Context context, final ImageView imageView, final Uri imgUri, int loadingResId, int failResId, int width, int height, final SobotDisplayImageListener listener) {
if (null == imgUri) { if (null == imgUri) {
...@@ -78,7 +86,14 @@ public class SobotPicassoImageLoader extends SobotImageLoader { ...@@ -78,7 +86,14 @@ public class SobotPicassoImageLoader extends SobotImageLoader {
@Override @Override
public void onSuccess() { public void onSuccess() {
if (listener != null) { if (listener != null) {
listener.onSuccess(imageView, imgUri.getPath()); listener.onSuccess(imageView, imgUri == null ? "" : imgUri.getPath());
}
}
@Override
public void onError(Exception e) {
if (listener != null) {
listener.onFail(imageView, imgUri == null ? "" : imgUri.getPath());
} }
} }
}); });
...@@ -86,7 +101,7 @@ public class SobotPicassoImageLoader extends SobotImageLoader { ...@@ -86,7 +101,7 @@ public class SobotPicassoImageLoader extends SobotImageLoader {
@Override @Override
public void displayImage(Context context, final ImageView imageView, int targetResId, int loadingResId, int failResId, int width, int height, final SobotDisplayImageListener listener) { public void displayImage(Context context, final ImageView imageView, int targetResId, int loadingResId, int failResId, int width, int height, final SobotDisplayImageListener listener) {
RequestCreator creator = Picasso.get().load(targetResId).config(Bitmap.Config.RGB_565); RequestCreator creator = Picasso.get().load(targetResId).config(Bitmap.Config.RGB_565);
if (loadingResId != 0) { if (loadingResId != 0) {
creator.placeholder(loadingResId); creator.placeholder(loadingResId);
} }
...@@ -105,6 +120,13 @@ public class SobotPicassoImageLoader extends SobotImageLoader { ...@@ -105,6 +120,13 @@ public class SobotPicassoImageLoader extends SobotImageLoader {
listener.onSuccess(imageView, ""); listener.onSuccess(imageView, "");
} }
} }
@Override
public void onError(Exception e) {
if (listener != null) {
listener.onFail(imageView, "");
}
}
}); });
} }
} }
\ No newline at end of file
...@@ -13,6 +13,7 @@ import android.widget.ImageView; ...@@ -13,6 +13,7 @@ import android.widget.ImageView;
import com.nostra13.universalimageloader.core.DisplayImageOptions; import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.assist.ImageSize; import com.nostra13.universalimageloader.core.assist.ImageSize;
import com.nostra13.universalimageloader.core.imageaware.ImageViewAware; import com.nostra13.universalimageloader.core.imageaware.ImageViewAware;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener; import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
...@@ -32,7 +33,7 @@ public class SobotUILImageLoader extends SobotImageLoader { ...@@ -32,7 +33,7 @@ public class SobotUILImageLoader extends SobotImageLoader {
} }
@Override @Override
public void displayImage(Context context, ImageView imageView, String path, @DrawableRes int loadingResId, @DrawableRes int failResId, int width, int height, final SobotDisplayImageListener listener) { public void displayImage(Context context, ImageView imageView, final String path, @DrawableRes int loadingResId, @DrawableRes int failResId, int width, int height, final SobotDisplayImageListener listener) {
initImageLoader(context); initImageLoader(context);
DisplayImageOptions options = new DisplayImageOptions.Builder() DisplayImageOptions options = new DisplayImageOptions.Builder()
...@@ -49,7 +50,14 @@ public class SobotUILImageLoader extends SobotImageLoader { ...@@ -49,7 +50,14 @@ public class SobotUILImageLoader extends SobotImageLoader {
@Override @Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
if (listener != null) { if (listener != null) {
listener.onSuccess(view, imageUri); listener.onSuccess(view, path);
}
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
if (listener != null) {
listener.onFail(view, path);
} }
} }
}, null); }, null);
...@@ -78,6 +86,13 @@ public class SobotUILImageLoader extends SobotImageLoader { ...@@ -78,6 +86,13 @@ public class SobotUILImageLoader extends SobotImageLoader {
listener.onSuccess(view, imageUri); listener.onSuccess(view, imageUri);
} }
} }
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
if (listener != null) {
listener.onFail(view, imageUri);
}
}
}, null); }, null);
} }
} catch (Exception e) { } catch (Exception e) {
...@@ -104,6 +119,13 @@ public class SobotUILImageLoader extends SobotImageLoader { ...@@ -104,6 +119,13 @@ public class SobotUILImageLoader extends SobotImageLoader {
listener.onSuccess(view, imageUri); listener.onSuccess(view, imageUri);
} }
} }
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
if (listener != null) {
listener.onFail(view, imageUri);
}
}
}, null); }, null);
} }
......
...@@ -5,6 +5,8 @@ android { ...@@ -5,6 +5,8 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 17 minSdkVersion 17
//添加此行
multiDexEnabled true
} }
buildTypes { buildTypes {
...@@ -26,7 +28,9 @@ dependencies { ...@@ -26,7 +28,9 @@ dependencies {
compileOnly 'androidx.appcompat:appcompat:1.0.0' compileOnly 'androidx.appcompat:appcompat:1.0.0'
compileOnly 'androidx.recyclerview:recyclerview:1.0.0' compileOnly 'androidx.recyclerview:recyclerview:1.0.0'
api 'com.sobot.library:utils:1.1.3' api 'com.sobot.library:utils:1.1.3'
api 'com.sobot.library:picture_x:1.2.1' api 'com.sobot.library:picture_x:1.2.4'
// api project(':sobot_pictureframe')
// api project(':sobot_utils')
} }
......
...@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) { ...@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
ext { ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名 PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
PUBLISH_ARTIFACT_ID = 'widget_x' //项目名 PUBLISH_ARTIFACT_ID = 'widget_x' //项目名
PUBLISH_VERSION = '1.3.1' //版本号 PUBLISH_VERSION = '1.3.2' //版本号
} }
......
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