Commit 4ceab2ff by zhengnw@sobot.com

picture 1.2.4

parent 18f0610a
......@@ -41,6 +41,7 @@ dependencies {
// api 'com.sobot.library:sobotcommon_x:1.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'
//android x 可以用这个 ,普通版不能用这个
// implementation 'com.facebook.fresco:fresco:2.6.0'
......
......@@ -22,6 +22,7 @@ import com.sobot.album.Action;
import com.sobot.album.AlbumFile;
import com.sobot.album.SobotAlbum;
import com.sobot.album.api.widget.Widget;
import com.sobot.chat.imageloader.SobotImageLoader;
import com.sobot.common.login.SobotLoginTools;
import com.sobot.common.login.callback.SobotResultBlock;
import com.sobot.common.login.callback.SobotResultCode;
......@@ -67,9 +68,19 @@ public class MainActivity extends SobotBaseActivity {
SobotToastUtil.showCustomToast(getSobotBaseActivity(), "sdafdsafsadfasdfsdaf");
SobotWidgetApi.setSwitchMarkStatus(SobotMarkConfig.SHOW_PERMISSION_TIPS_POP, true);
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);
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.setScaleType(ImageView.ScaleType.FIT_XY);
// SobotBitmapUtil.display(this, "https://img.sobot.com/chatres/75574e5fa29a48458d1f57ab5489a4c5/msg/20220421/34a466420d78fa1172bc0acd85166745/9410b53be86b4d589c61c60f6aee2461.jpeg", img2);
......@@ -299,7 +310,7 @@ public class MainActivity extends SobotBaseActivity {
if (!checkStoragePermission(4)) {
return;
}
openAlbum();
// openAlbum();
// selectPicFromLocal();
// preview();
......
......@@ -21,8 +21,10 @@ dependencies {
compileOnly 'androidx.appcompat:appcompat:1.1.0'
compileOnly 'androidx.recyclerview:recyclerview:1.0.0'
compileOnly 'com.google.android.material:material:1.4.0'
api 'com.sobot.library:widget_x:1.3.1'
api 'com.sobot.library:sobotcommon_x:2.2.1'
api 'com.sobot.library:widget_x:1.3.2'
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) {
ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
PUBLISH_ARTIFACT_ID = 'album' //项目名
PUBLISH_VERSION = '1.1.1' //版本号
PUBLISH_VERSION = '1.1.2' //版本号
}
......
......@@ -7,6 +7,8 @@ android {
defaultConfig {
minSdkVersion 14
//添加此行
multiDexEnabled true
}
//这里就是打jar包
task makeJar(type: Copy) {
......@@ -34,7 +36,7 @@ dependencies {
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:gson:1.1.1'
}
......
......@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
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 --> 点
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不支持显示本地图片
......
......@@ -7,11 +7,13 @@ android {
defaultConfig {
minSdkVersion 14
//添加此行
multiDexEnabled true
}
//这里就是打jar包
task makeJar(type: Copy) {
//删除旧的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/')
//导出jar包的地址
......@@ -19,7 +21,7 @@ android {
//包含的jar包
include('classes.jar')
//重命名jar包为mysdk
rename ('classes.jar', 'sobot_picture_1.2.1.jar')
rename ('classes.jar', 'sobot_picture_1.2.3.jar')
}
makeJar.dependsOn(build)
......@@ -32,7 +34,7 @@ dependencies {
compileOnly 'com.github.bumptech.glide:glide:3.8.0'
compileOnly 'com.squareup.picasso:picasso:2.8'
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脚本
......
......@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
PUBLISH_ARTIFACT_ID = 'picture_x' //项目名
PUBLISH_VERSION = '1.2.1' //版本号
PUBLISH_VERSION = '1.2.4' //版本号
}
......
......@@ -16,7 +16,7 @@ public class SobotBitmapUtil {
private static SobotImageLoader sImageLoader;
private static final SobotImageLoader getImageLoader() {
private static SobotImageLoader getImageLoader() {
if (sImageLoader == null) {
synchronized (SobotBitmapUtil.class) {
if (sImageLoader == null) {
......@@ -39,7 +39,8 @@ public class SobotBitmapUtil {
return sImageLoader;
}
private static final boolean isClassExists(String classFullName) {
//判断是否存在该类
private static boolean isClassExists(String classFullName) {
try {
Class.forName(classFullName);
return true;
......@@ -48,39 +49,87 @@ public class SobotBitmapUtil {
}
}
//使用客户指定的图片加载器
public static void setImageLoader(SobotImageLoader imageLoader) {
sImageLoader = imageLoader;
}
/**
* 加载网络图片
*
* @param context 上下文
* @param url 网络图片地址
* @param imageView 图片控件
* @param defaultPic 预加载图片
* @param error 加载失败图片
*/
public static void display(Context context, String url,
ImageView imageView, int defaultPic, int error) {
if (context != null && imageView != 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,
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) {
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) {
if (context != null && imageView != 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) {
if (context != null && imageView != 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) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || isCamera) {
BitmapFactory.Options options = new BitmapFactory.Options();
......
......@@ -4,8 +4,10 @@ import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.AsyncTask;
import androidx.annotation.DrawableRes;
import androidx.annotation.Nullable;
import android.text.TextUtils;
import android.widget.ImageView;
......@@ -39,7 +41,7 @@ public class SobotFrescoImageLoader extends SobotImageLoader {
File file = new File(path);
if (file != null) {
builder = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(file));
}else{
} else {
builder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(path));
}
}
......@@ -67,9 +69,11 @@ public class SobotFrescoImageLoader extends SobotImageLoader {
@Override
protected void onPostExecute(Bitmap bitmap) {
if (listener != null) {
listener.onSuccess(imageView, path);
}
if (bitmap != null) {
imageView.setImageBitmap(bitmap);
} else {
}
}
}.execute(bitmap);
......@@ -78,11 +82,15 @@ public class SobotFrescoImageLoader extends SobotImageLoader {
@Override
public void onFailureImpl(DataSource dataSource) {
if (listener != null) {
listener.onFail(imageView, path);
}
}
};
dataSource.subscribe(subscriber, UiThreadImmediateExecutorService.getInstance());
}
@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) {
if (null == imgUri) {
......@@ -116,9 +124,11 @@ public class SobotFrescoImageLoader extends SobotImageLoader {
@Override
protected void onPostExecute(Bitmap bitmap) {
if (listener != null) {
listener.onSuccess(imageView, imgUri == null ? "" : imgUri.getPath());
}
if (bitmap != null) {
imageView.setImageBitmap(bitmap);
} else {
}
}
}.execute(bitmap);
......@@ -127,6 +137,9 @@ public class SobotFrescoImageLoader extends SobotImageLoader {
@Override
public void onFailureImpl(DataSource dataSource) {
if (listener != null) {
listener.onFail(imageView, imgUri == null ? "" : imgUri.getPath());
}
}
};
......
......@@ -2,6 +2,7 @@ package com.sobot.pictureframe;
import android.content.Context;
import android.graphics.Bitmap;
import androidx.annotation.DrawableRes;
import android.net.Uri;
......@@ -34,6 +35,9 @@ public class SobotGlideImageLoader extends SobotImageLoader {
builder.listener(new RequestListener<String, Bitmap>() {
@Override
public boolean onException(Exception e, String model, Target<Bitmap> target, boolean isFirstResource) {
if (listener != null) {
listener.onFail(imageView, path);
}
return false;
}
......@@ -46,6 +50,7 @@ public class SobotGlideImageLoader extends SobotImageLoader {
}
}).into(imageView);
}
@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) {
if (null == imgUri) {
......@@ -61,13 +66,16 @@ public class SobotGlideImageLoader extends SobotImageLoader {
builder.listener(new RequestListener<Object, Bitmap>() {
@Override
public boolean onException(Exception e, Object model, Target<Bitmap> target, boolean isFirstResource) {
if (listener != null) {
listener.onFail(imageView, imgUri == null ? "" : imgUri.getPath());
}
return false;
}
@Override
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, boolean isFromMemoryCache, boolean isFirstResource) {
if (listener != null) {
listener.onSuccess(imageView, imgUri.getPath());
listener.onSuccess(imageView, imgUri == null ? "" : imgUri.getPath());
}
return false;
}
......@@ -84,6 +92,9 @@ public class SobotGlideImageLoader extends SobotImageLoader {
builder.listener(new RequestListener<Integer, Bitmap>() {
@Override
public boolean onException(Exception e, Integer model, Target<Bitmap> target, boolean isFirstResource) {
if (listener != null) {
listener.onFail(imageView, "");
}
return false;
}
......
......@@ -24,7 +24,7 @@ public class SobotPicassoImageLoader extends SobotImageLoader {
if (TextUtils.isEmpty(path)) {
pathStr = "error";
}
RequestCreator creator ;
RequestCreator creator;
if (pathStr.startsWith("http")) {
creator = Picasso.get().load(pathStr);
} else {
......@@ -32,7 +32,7 @@ public class SobotPicassoImageLoader extends SobotImageLoader {
if (file != null) {
creator = Picasso.get().load(file);
} else {
creator = Picasso.get().load(pathStr);;
creator = Picasso.get().load(pathStr);
}
}
if (loadingResId != 0) {
......@@ -54,8 +54,16 @@ public class SobotPicassoImageLoader extends SobotImageLoader {
listener.onSuccess(imageView, path);
}
}
@Override
public void onError(Exception e) {
if (listener != null) {
listener.onFail(imageView, path);
}
}
});
}
@Override
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) {
......@@ -78,7 +86,14 @@ public class SobotPicassoImageLoader extends SobotImageLoader {
@Override
public void onSuccess() {
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 {
@Override
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) {
creator.placeholder(loadingResId);
}
......@@ -105,6 +120,13 @@ public class SobotPicassoImageLoader extends SobotImageLoader {
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;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
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.imageaware.ImageViewAware;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
......@@ -32,7 +33,7 @@ public class SobotUILImageLoader extends SobotImageLoader {
}
@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);
DisplayImageOptions options = new DisplayImageOptions.Builder()
......@@ -49,7 +50,14 @@ public class SobotUILImageLoader extends SobotImageLoader {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
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);
......@@ -78,6 +86,13 @@ public class SobotUILImageLoader extends SobotImageLoader {
listener.onSuccess(view, imageUri);
}
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
if (listener != null) {
listener.onFail(view, imageUri);
}
}
}, null);
}
} catch (Exception e) {
......@@ -104,6 +119,13 @@ public class SobotUILImageLoader extends SobotImageLoader {
listener.onSuccess(view, imageUri);
}
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
if (listener != null) {
listener.onFail(view, imageUri);
}
}
}, null);
}
......
......@@ -5,6 +5,8 @@ android {
defaultConfig {
minSdkVersion 17
//添加此行
multiDexEnabled true
}
buildTypes {
......@@ -26,7 +28,9 @@ dependencies {
compileOnly 'androidx.appcompat:appcompat:1.0.0'
compileOnly 'androidx.recyclerview:recyclerview:1.0.0'
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) {
ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
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