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
14ee710a
Commit
14ee710a
authored
Mar 19, 2024
by
郭倩芳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.1 相册选择 可以根据Uri加载
parent
6d225728
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
156 additions
and
22 deletions
+156
-22
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+6
-0
build.gradle
sobot_album/build.gradle
+1
-16
SobotMediaLoader.java
...album/src/main/java/com/sobot/album/SobotMediaLoader.java
+10
-5
build.gradle
sobot_pictureframe/build.gradle
+1
-1
SobotBitmapUtil.java
...src/main/java/com/sobot/pictureframe/SobotBitmapUtil.java
+6
-0
SobotFrescoImageLoader.java
...n/java/com/sobot/pictureframe/SobotFrescoImageLoader.java
+49
-0
SobotGlideImageLoader.java
...in/java/com/sobot/pictureframe/SobotGlideImageLoader.java
+30
-0
SobotPicassoImageLoader.java
.../java/com/sobot/pictureframe/SobotPicassoImageLoader.java
+28
-0
SobotUILImageLoader.java
...main/java/com/sobot/pictureframe/SobotUILImageLoader.java
+25
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
14ee710a
...
@@ -3,6 +3,12 @@
...
@@ -3,6 +3,12 @@
package=
"com.sobot.moduletest"
>
package=
"com.sobot.moduletest"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.CAMERA"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.RECORD_AUDIO"
/>
<!-- To handle the reselection within the app on Android 14 (API level 34) -->
<uses-permission
android:name=
"android.permission.READ_MEDIA_VISUAL_USER_SELECTED"
/>
<application
<application
android:name=
".MyApp"
android:name=
".MyApp"
...
...
sobot_album/build.gradle
View file @
14ee710a
...
@@ -14,22 +14,7 @@ android {
...
@@ -14,22 +14,7 @@ android {
sourceCompatibility
JavaVersion
.
VERSION_1_8
sourceCompatibility
JavaVersion
.
VERSION_1_8
targetCompatibility
JavaVersion
.
VERSION_1_8
targetCompatibility
JavaVersion
.
VERSION_1_8
}
}
buildTypes
{
debug
{
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
}
release
{
minifyEnabled
true
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
),
'proguard-rules.pro'
consumerProguardFiles
'proguard-rules.pro'
}
qa_test
{
}
qa_api
{
}
}
}
}
dependencies
{
dependencies
{
...
...
sobot_album/src/main/java/com/sobot/album/SobotMediaLoader.java
View file @
14ee710a
...
@@ -10,8 +10,12 @@ public class SobotMediaLoader implements AlbumLoader {
...
@@ -10,8 +10,12 @@ public class SobotMediaLoader implements AlbumLoader {
@Override
@Override
public
void
load
(
ImageView
imageView
,
AlbumFile
albumFile
)
{
public
void
load
(
ImageView
imageView
,
AlbumFile
albumFile
)
{
if
(
albumFile
!=
null
&&
SobotStringUtils
.
isNoEmpty
(
albumFile
.
getPath
()))
{
if
(
albumFile
!=
null
)
{
load
(
imageView
,
albumFile
.
getPath
());
if
(
albumFile
.
getUri
()
!=
null
)
{
load
(
imageView
,
albumFile
.
getUri
());
}
else
{
load
(
imageView
,
albumFile
.
getPath
());
}
}
}
}
}
...
@@ -23,9 +27,9 @@ public class SobotMediaLoader implements AlbumLoader {
...
@@ -23,9 +27,9 @@ public class SobotMediaLoader implements AlbumLoader {
}
}
public
void
load
(
ImageView
imageView
,
Uri
uri
)
{
public
void
load
(
ImageView
imageView
,
Uri
uri
)
{
//
if (uri != null && imageView != null) {
if
(
uri
!=
null
&&
imageView
!=
null
)
{
// imageView.setImageURI(uri
);
SobotBitmapUtil
.
display
(
imageView
.
getContext
(),
uri
,
imageView
);
//
}
}
}
}
}
}
\ No newline at end of file
sobot_pictureframe/build.gradle
View file @
14ee710a
...
@@ -32,7 +32,7 @@ dependencies {
...
@@ -32,7 +32,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:
1
.0'
api
'com.sobot.chat:sobotsupport-glidev4:
3
.0'
}
}
//添加发布到mavenCentral脚本
//添加发布到mavenCentral脚本
...
...
sobot_pictureframe/src/main/java/com/sobot/pictureframe/SobotBitmapUtil.java
View file @
14ee710a
...
@@ -3,6 +3,7 @@ package com.sobot.pictureframe;
...
@@ -3,6 +3,7 @@ package com.sobot.pictureframe;
import
android.content.Context
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.BitmapFactory
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Build
;
import
android.view.WindowManager
;
import
android.view.WindowManager
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
...
@@ -73,6 +74,11 @@ public class SobotBitmapUtil {
...
@@ -73,6 +74,11 @@ public class SobotBitmapUtil {
getImageLoader
().
displayImage
(
context
,
imageView
,
resourceId
,
0
,
0
,
imageView
.
getWidth
(),
imageView
.
getHeight
(),
null
);
getImageLoader
().
displayImage
(
context
,
imageView
,
resourceId
,
0
,
0
,
imageView
.
getWidth
(),
imageView
.
getHeight
(),
null
);
}
}
}
}
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"
)
@SuppressWarnings
(
"deprecation"
)
public
static
Bitmap
compress
(
String
filePath
,
Context
context
,
boolean
isCamera
)
{
public
static
Bitmap
compress
(
String
filePath
,
Context
context
,
boolean
isCamera
)
{
...
...
sobot_pictureframe/src/main/java/com/sobot/pictureframe/SobotFrescoImageLoader.java
View file @
14ee710a
...
@@ -83,6 +83,55 @@ public class SobotFrescoImageLoader extends SobotImageLoader {
...
@@ -83,6 +83,55 @@ public class SobotFrescoImageLoader extends SobotImageLoader {
dataSource
.
subscribe
(
subscriber
,
UiThreadImmediateExecutorService
.
getInstance
());
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
)
{
return
;
}
if
(
imageView
==
null
)
{
return
;
}
ImageRequestBuilder
builder
=
ImageRequestBuilder
.
newBuilderWithSource
(
imgUri
);
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
)
{
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
)
{
imageView
.
setImageBitmap
(
bitmap
);
}
else
{
}
}
}.
execute
(
bitmap
);
}
@Override
public
void
onFailureImpl
(
DataSource
dataSource
)
{
}
};
dataSource
.
subscribe
(
subscriber
,
UiThreadImmediateExecutorService
.
getInstance
());
}
@Override
@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
)
{
public
void
displayImage
(
Context
context
,
final
ImageView
imageView
,
@DrawableRes
int
targetResId
,
@DrawableRes
int
loadingResId
,
@DrawableRes
int
failResId
,
int
width
,
int
height
,
final
SobotDisplayImageListener
listener
)
{
...
...
sobot_pictureframe/src/main/java/com/sobot/pictureframe/SobotGlideImageLoader.java
View file @
14ee710a
...
@@ -3,6 +3,8 @@ package com.sobot.pictureframe;
...
@@ -3,6 +3,8 @@ 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.text.TextUtils
;
import
android.text.TextUtils
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
...
@@ -44,6 +46,34 @@ public class SobotGlideImageLoader extends SobotImageLoader {
...
@@ -44,6 +46,34 @@ public class SobotGlideImageLoader extends SobotImageLoader {
}
}
}).
into
(
imageView
);
}).
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
)
{
return
;
}
if
(
imageView
==
null
)
{
return
;
}
BitmapRequestBuilder
<
Uri
,
Bitmap
>
builder
=
Glide
.
with
(
context
).
load
(
imgUri
).
asBitmap
().
placeholder
(
loadingResId
).
error
(
failResId
);
if
(
width
!=
0
||
height
!=
0
)
{
builder
.
override
(
width
,
height
);
}
builder
.
listener
(
new
RequestListener
<
Object
,
Bitmap
>()
{
@Override
public
boolean
onException
(
Exception
e
,
Object
model
,
Target
<
Bitmap
>
target
,
boolean
isFirstResource
)
{
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
());
}
return
false
;
}
}).
into
(
imageView
);
}
@Override
@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
)
{
public
void
displayImage
(
Context
context
,
final
ImageView
imageView
,
@DrawableRes
int
targetResId
,
@DrawableRes
int
loadingResId
,
@DrawableRes
int
failResId
,
int
width
,
int
height
,
final
SobotDisplayImageListener
listener
)
{
...
...
sobot_pictureframe/src/main/java/com/sobot/pictureframe/SobotPicassoImageLoader.java
View file @
14ee710a
...
@@ -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
android.net.Uri
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
...
@@ -55,6 +56,33 @@ public class SobotPicassoImageLoader extends SobotImageLoader {
...
@@ -55,6 +56,33 @@ public class SobotPicassoImageLoader extends SobotImageLoader {
}
}
});
});
}
}
@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
)
{
return
;
}
RequestCreator
creator
=
Picasso
.
get
().
load
(
imgUri
);
if
(
loadingResId
!=
0
)
{
creator
.
placeholder
(
loadingResId
);
}
if
(
failResId
!=
0
)
{
creator
.
error
(
failResId
);
}
creator
.
config
(
Bitmap
.
Config
.
RGB_565
);
if
(
width
!=
0
||
height
!=
0
)
{
creator
.
resize
(
width
,
height
);
}
else
{
creator
.
fit
();
}
creator
.
into
(
imageView
,
new
Callback
.
EmptyCallback
()
{
@Override
public
void
onSuccess
()
{
if
(
listener
!=
null
)
{
listener
.
onSuccess
(
imageView
,
imgUri
.
getPath
());
}
}
});
}
@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
)
{
...
...
sobot_pictureframe/src/main/java/com/sobot/pictureframe/SobotUILImageLoader.java
View file @
14ee710a
...
@@ -3,6 +3,8 @@ package com.sobot.pictureframe;
...
@@ -3,6 +3,8 @@ 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.view.View
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
...
@@ -50,6 +52,29 @@ public class SobotUILImageLoader extends SobotImageLoader {
...
@@ -50,6 +52,29 @@ public class SobotUILImageLoader extends SobotImageLoader {
}
}
},
null
);
},
null
);
}
}
@Override
public
void
displayImage
(
Context
context
,
ImageView
imageView
,
Uri
imgUri
,
@DrawableRes
int
loadingResId
,
@DrawableRes
int
failResId
,
int
width
,
int
height
,
final
SobotDisplayImageListener
listener
)
{
initImageLoader
(
context
);
DisplayImageOptions
options
=
new
DisplayImageOptions
.
Builder
()
.
showImageOnLoading
(
loadingResId
)
.
showImageOnFail
(
failResId
)
.
showImageForEmptyUri
(
failResId
)
.
cacheInMemory
(
true
)
.
cacheOnDisk
(
true
)
.
bitmapConfig
(
Bitmap
.
Config
.
RGB_565
)
.
build
();
ImageSize
imageSize
=
width
!=
0
||
height
!=
0
?
new
ImageSize
(
width
,
height
)
:
null
;
ImageLoader
.
getInstance
().
displayImage
(
imgUri
,
new
ImageViewAware
(
imageView
),
options
,
imageSize
,
new
SimpleImageLoadingListener
()
{
@Override
public
void
onLoadingComplete
(
String
imageUri
,
View
view
,
Bitmap
loadedImage
)
{
if
(
listener
!=
null
)
{
listener
.
onSuccess
(
view
,
imageUri
);
}
}
},
null
);
}
@Override
@Override
public
void
displayImage
(
Context
context
,
ImageView
imageView
,
@DrawableRes
int
targetResId
,
@DrawableRes
int
loadingResId
,
@DrawableRes
int
failResId
,
int
width
,
int
height
,
final
SobotDisplayImageListener
listener
)
{
public
void
displayImage
(
Context
context
,
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