Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
RvApp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
lify
RvApp
Commits
620ba824
Commit
620ba824
authored
Jul 30, 2019
by
jianglx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改图片保存路径
parent
56953f5b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
8 deletions
+43
-8
BillPresenter.java
...e/src/main/java/com/rv/share/presenter/BillPresenter.java
+5
-1
ReativeBillPresenter.java
...ain/java/com/rv/share/presenter/ReativeBillPresenter.java
+17
-4
StorageUtils.java
..._share/src/main/java/com/rv/share/utils/StorageUtils.java
+21
-3
No files found.
plugin_share/src/main/java/com/rv/share/presenter/BillPresenter.java
View file @
620ba824
...
@@ -102,7 +102,11 @@ public class BillPresenter extends CommonPresenter {
...
@@ -102,7 +102,11 @@ public class BillPresenter extends CommonPresenter {
public
File
saveBitmapFile
(
Bitmap
bitmap
)
{
public
File
saveBitmapFile
(
Bitmap
bitmap
)
{
File
file
=
new
File
(
StorageUtils
.
getCachePath
(
getPresenterContext
())
+
System
.
currentTimeMillis
()
+
".jpg"
);
//将要保存图片的路径
File
parent
=
new
File
(
StorageUtils
.
getPhotoSavePath
(
getPresenterContext
()));
if
(!
parent
.
exists
())
{
parent
.
mkdirs
();
}
File
file
=
new
File
(
parent
,
System
.
currentTimeMillis
()
+
".jpg"
);
//将要保存图片的路径
try
{
try
{
BufferedOutputStream
bos
=
new
BufferedOutputStream
(
new
FileOutputStream
(
file
));
BufferedOutputStream
bos
=
new
BufferedOutputStream
(
new
FileOutputStream
(
file
));
bitmap
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
100
,
bos
);
bitmap
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
100
,
bos
);
...
...
plugin_share/src/main/java/com/rv/share/presenter/ReativeBillPresenter.java
View file @
620ba824
...
@@ -94,19 +94,32 @@ public class ReativeBillPresenter extends CommonPresenter {
...
@@ -94,19 +94,32 @@ public class ReativeBillPresenter extends CommonPresenter {
}
}
private
File
saveBitmapFile
(
Bitmap
bitmap
)
{
private
File
saveBitmapFile
(
Bitmap
bitmap
)
{
File
file
=
new
File
(
StorageUtils
.
getCachePath
(
getPresenterContext
())
+
(
int
)
(
System
.
currentTimeMillis
()
/
1000000
)
+
".jpg"
);
//将要保存图片的路径
File
parent
=
new
File
(
StorageUtils
.
getPhotoSavePath
(
getPresenterContext
()));
if
(!
parent
.
exists
())
{
parent
.
mkdirs
();
}
File
file
=
new
File
(
parent
,
((
int
)
(
System
.
currentTimeMillis
()
/
1000000
))
+
".jpg"
);
//将要保存图片的路径
if
(
file
.
exists
())
{
if
(
file
.
exists
())
{
return
file
;
return
file
;
}
}
BufferedOutputStream
bos
=
null
;
try
{
try
{
BufferedOutputStream
bos
=
new
BufferedOutputStream
(
new
FileOutputStream
(
file
));
bos
=
new
BufferedOutputStream
(
new
FileOutputStream
(
file
));
bitmap
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
100
,
bos
);
bitmap
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
100
,
bos
);
bos
.
flush
();
bos
.
flush
();
bos
.
close
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
finally
{
if
(
bos
!=
null
)
{
try
{
bos
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
StorageUtils
.
notifyImageChange
(
getPresenterContext
(),
file
.
getPath
());
return
file
;
return
file
;
}
}
}
}
plugin_share/src/main/java/com/rv/share/utils/StorageUtils.java
View file @
620ba824
package
com
.
rv
.
share
.
utils
;
package
com
.
rv
.
share
.
utils
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.os.Environment
;
import
android.os.Environment
;
import
java.io.File
;
public
class
StorageUtils
{
public
class
StorageUtils
{
public
static
String
getCachePath
(
Context
context
)
{
private
final
static
String
DIR
=
"image"
;
/********
* 获取图片保存路径
* @param context
* @return
*/
public
static
String
getPhotoSavePath
(
Context
context
)
{
String
cachePath
=
null
;
String
cachePath
=
null
;
if
(
Environment
.
MEDIA_MOUNTED
.
equals
(
Environment
.
getExternalStorageState
())
if
(
Environment
.
MEDIA_MOUNTED
.
equals
(
Environment
.
getExternalStorageState
())
||
!
Environment
.
isExternalStorageRemovable
())
{
||
!
Environment
.
isExternalStorageRemovable
())
{
cachePath
=
context
.
getExternalCacheDir
().
getPath
();
cachePath
=
Environment
.
getExternalStorageDirectory
().
getPath
();
}
else
{
}
else
{
cachePath
=
context
.
getCacheDir
().
getPath
();
cachePath
=
context
.
getCacheDir
().
getPath
();
}
}
return
cachePath
;
return
cachePath
+
File
.
separator
+
DIR
+
File
.
separator
;
}
public
static
void
notifyImageChange
(
Context
context
,
String
filePath
)
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_MEDIA_SCANNER_SCAN_FILE
);
Uri
uri
=
Uri
.
fromFile
(
new
File
(
filePath
));
intent
.
setData
(
uri
);
context
.
sendBroadcast
(
intent
);
// 发送广播通知相册
}
}
}
}
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