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
f59ad090
Commit
f59ad090
authored
Jul 09, 2024
by
郭倩芳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 相册预览图显示不全
parent
e52c69cf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
105 additions
and
10 deletions
+105
-10
build.gradle
sobot_album/build.gradle
+1
-1
sobot-album_publish-mavencentral.gradle
sobot_album/sobot-album_publish-mavencentral.gradle
+1
-1
ImageFragment.java
...main/java/com/sobot/album/app/fragment/ImageFragment.java
+103
-1
PreviewView.java
...rc/main/java/com/sobot/album/app/preview/PreviewView.java
+0
-7
No files found.
sobot_album/build.gradle
View file @
f59ad090
...
...
@@ -22,7 +22,7 @@ dependencies {
compileOnly
'androidx.recyclerview:recyclerview:1.0.0'
compileOnly
'com.google.android.material:material:1.4.0'
api
'com.sobot.library:widget_x:1.2.7'
api
'com.sobot.library:
picture_x:1.2.0
'
api
'com.sobot.library:
sobotcommon_x:1.7.7.3
'
}
...
...
sobot_album/sobot-album_publish-mavencentral.gradle
View file @
f59ad090
...
...
@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
ext
{
PUBLISH_GROUP_ID
=
"com.sobot.library"
//项目包名
PUBLISH_ARTIFACT_ID
=
'album'
//项目名
PUBLISH_VERSION
=
'1.0.4.
2
'
//版本号
PUBLISH_VERSION
=
'1.0.4.
4
'
//版本号
}
...
...
sobot_album/src/main/java/com/sobot/album/app/fragment/ImageFragment.java
View file @
f59ad090
package
com
.
sobot
.
album
.
app
.
fragment
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.view.LayoutInflater
;
import
android.view.SoundEffectConstants
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ImageView
;
import
android.widget.RelativeLayout
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
...
...
@@ -16,6 +21,18 @@ import com.sobot.album.R;
import
com.sobot.album.SobotAlbum
;
import
com.sobot.album.widget.photoview.AttacherImageView
;
import
com.sobot.album.widget.photoview.PhotoViewAttacher
;
import
com.sobot.common.utils.SobotImageUtils
;
import
com.sobot.common.utils.SobotPathManager
;
import
com.sobot.network.http.HttpBaseUtils
;
import
com.sobot.pictureframe.SobotBitmapUtil
;
import
com.sobot.utils.SobotDensityUtil
;
import
com.sobot.utils.SobotLogUtils
;
import
com.sobot.utils.SobotMD5Util
;
import
com.sobot.utils.SobotStringUtils
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
public
class
ImageFragment
extends
Fragment
implements
PhotoViewAttacher
.
OnViewTapListener
,
View
.
OnLongClickListener
{
private
View
mRootView
;
...
...
@@ -23,6 +40,8 @@ public class ImageFragment extends Fragment implements PhotoViewAttacher.OnViewT
public
AlbumFile
mAlbum
;
private
View
.
OnClickListener
mItemClickListener
;
private
View
.
OnClickListener
mItemLongClickListener
;
private
String
imageUrL
;
private
Bitmap
bitmap
;
@Nullable
@Override
...
...
@@ -56,10 +75,93 @@ public class ImageFragment extends Fragment implements PhotoViewAttacher.OnViewT
private
void
initDate
()
{
if
(
mAlbum
!=
null
)
{
SobotAlbum
.
getAlbumConfig
().
getAlbumLoader
().
load
(
imageView
,
mAlbum
);
//设置地址
if
(
SobotStringUtils
.
isNoEmpty
(
mAlbum
.
getPath
()))
{
imageUrL
=
mAlbum
.
getPath
();
}
else
if
(
mAlbum
.
getUri
()!=
null
){
imageUrL
=
mAlbum
.
getUri
().
getPath
();
}
else
{
imageUrL
=
""
;
}
if
(
imageUrL
.
startsWith
(
"http"
))
{
String
dirPath
=
SobotPathManager
.
getInstance
().
getPicDir
();
String
encode
=
SobotMD5Util
.
encode
(
imageUrL
)
+
getFileName
(
imageUrL
);
File
savePath
=
new
File
(
SobotStringUtils
.
checkStringIsNull
(
dirPath
),
encode
);
if
(!
savePath
.
exists
())
{
if
(
imageUrL
.
contains
(
"?"
))
{
imageUrL
=
imageUrL
.
substring
(
0
,
imageUrL
.
indexOf
(
"?"
));
}
displayImage
(
imageUrL
,
savePath
);
}
else
{
showView
(
savePath
.
getAbsolutePath
());
}
}
else
{
File
gifSavePath
=
new
File
(
imageUrL
);
if
(
gifSavePath
.
exists
())
{
showView
(
imageUrL
);
}
}
}
}
public
String
getFileName
(
String
filePath
)
{
try
{
if
(
filePath
.
indexOf
(
"/"
)
!=
-
1
)
{
return
filePath
.
substring
(
filePath
.
lastIndexOf
(
"/"
)
+
1
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
void
showView
(
String
savePath
)
{
if
(!
TextUtils
.
isEmpty
(
imageUrL
))
{
bitmap
=
SobotBitmapUtil
.
compress
(
savePath
,
getContext
(),
true
);
//判断图片是否有旋转,有的话旋转后再显示
try
{
int
degree
=
SobotImageUtils
.
readPictureDegree
(
savePath
);
if
(
degree
>
0
)
{
bitmap
=
SobotImageUtils
.
rotateBitmap
(
bitmap
,
degree
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
if
(
bitmap
!=
null
)
{
imageView
.
setImageBitmap
(
bitmap
);
}
imageView
.
setVisibility
(
View
.
VISIBLE
);
imageView
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
imageView
.
playSoundEffect
(
SoundEffectConstants
.
CLICK
);
}
});
}
}
public
void
displayImage
(
String
url
,
File
saveFile
)
{
// 下载图片
HttpBaseUtils
.
getInstance
().
download
(
url
,
saveFile
,
new
HttpBaseUtils
.
FileCallBack
()
{
@Override
public
void
onResponse
(
File
file
)
{
SobotLogUtils
.
i
(
"down load onSuccess gif"
+
file
.
getAbsolutePath
());
// 把图片文件打开为文件流,然后解码为bitmap
showView
(
file
.
getAbsolutePath
());
}
@Override
public
void
onError
(
Exception
e
,
String
msg
,
int
responseCode
)
{
SobotLogUtils
.
w
(
"图片下载失败:"
+
msg
,
e
);
}
@Override
public
void
inProgress
(
int
progress
)
{
//SobotLogUtils.i("图片下载进度:" + progress);
}
});
}
@Override
public
void
onViewTap
(
View
v
,
float
x
,
float
y
)
{
if
(
mItemClickListener
!=
null
)
{
...
...
sobot_album/src/main/java/com/sobot/album/app/preview/PreviewView.java
View file @
f59ad090
...
...
@@ -18,16 +18,10 @@ package com.sobot.album.app.preview;
import
android.app.Activity
;
import
android.net.Uri
;
import
android.os.Handler
;
import
android.text.SpannableStringBuilder
;
import
android.text.Spanned
;
import
android.text.style.ForegroundColorSpan
;
import
android.view.Menu
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.widget.CheckBox
;
import
android.widget.FrameLayout
;
import
android.widget.HorizontalScrollView
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
...
...
@@ -37,7 +31,6 @@ import androidx.viewpager.widget.ViewPager;
import
com.sobot.album.AlbumFile
;
import
com.sobot.album.R
;
import
com.sobot.album.SobotAlbum
;
import
com.sobot.album.api.widget.Widget
;
import
com.sobot.album.app.Contract
;
import
com.sobot.album.app.fragment.ImageFragment
;
...
...
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