Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
门心叼龙
android-mvp-mvvm-flytour
提交
1c2c4ef3
A
android-mvp-mvvm-flytour
项目概览
门心叼龙
/
android-mvp-mvvm-flytour
通知
7
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
6
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
android-mvp-mvvm-flytour
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
6
Issue
6
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1c2c4ef3
编写于
1月 08, 2019
作者:
门心叼龙
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
recview
上级
249c332d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
95 addition
and
1 deletion
+95
-1
lib_common/src/main/java/com/fly/tour/common/util/BitmapUtil.java
...on/src/main/java/com/fly/tour/common/util/BitmapUtil.java
+19
-1
lib_common/src/main/java/com/fly/tour/common/util/FileUtil.java
...mmon/src/main/java/com/fly/tour/common/util/FileUtil.java
+76
-0
未找到文件。
lib_common/src/main/java/com/fly/tour/common/util/BitmapUtil.java
浏览文件 @
1c2c4ef3
...
...
@@ -13,7 +13,6 @@ import android.util.Log;
import
android.view.View
;
import
android.view.View.MeasureSpec
;
import
android.widget.ScrollView
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
...
...
@@ -407,4 +406,23 @@ public class BitmapUtil {
options
.
inJustDecodeBounds
=
false
;
return
BitmapFactory
.
decodeFile
(
path
,
options
);
}
public
static
int
[]
getImageSize
(
String
url
)
{
int
[]
size
=
new
int
[]{
0
,
0
};
if
(
FileUtil
.
isImageFile
(
url
))
{
BitmapFactory
.
Options
options
=
new
BitmapFactory
.
Options
();
// 设置为true,表示解析Bitmap对象,该对象不占内存
options
.
inJustDecodeBounds
=
true
;
BitmapFactory
.
decodeFile
(
url
,
options
);
options
.
inPreferredConfig
=
Bitmap
.
Config
.
RGB_565
;
// 图片宽高
switch
(
getBitmapDegree
(
url
))
{
case
90
:
case
270
:
return
new
int
[]{
options
.
outHeight
,
options
.
outWidth
};
default
:
return
new
int
[]{
options
.
outWidth
,
options
.
outHeight
};
}
}
return
size
;
}
}
\ No newline at end of file
lib_common/src/main/java/com/fly/tour/common/util/FileUtil.java
0 → 100644
浏览文件 @
1c2c4ef3
package
com.fly.tour.common.util
;
import
android.text.TextUtils
;
import
java.io.BufferedInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
* Description: <FileUtil><br>
* Author: gxl<br>
* Date: 2018/7/13<br>
* Version: V1.0.0<br>
* Update: <br>
*/
public
class
FileUtil
{
public
static
boolean
isImageFile
(
String
url
){
if
(
TextUtils
.
isEmpty
(
url
)){
return
false
;
}
String
reg
=
".+(\\.jpeg|\\.jpg|\\.gif|\\.bmp|\\.png).*"
;
Pattern
pattern
=
Pattern
.
compile
(
reg
);
Matcher
matcher
=
pattern
.
matcher
(
url
.
toLowerCase
());
return
matcher
.
find
();
}
public
static
boolean
isVideoFile
(
String
url
){
if
(
TextUtils
.
isEmpty
(
url
)){
return
false
;
}
String
reg
=
".+(\\.avi|\\.wmv|\\.mpeg|\\.mp4|\\.mov|\\.mkv|\\.flv|\\.f4v|\\.m4v|\\.rmvb|\\.rm|\\.rmvb|\\.3gp|\\.dat|\\.ts|\\.mts|\\.vob).*"
;
Pattern
pattern
=
Pattern
.
compile
(
reg
);
Matcher
matcher
=
pattern
.
matcher
(
url
.
toLowerCase
());
return
matcher
.
find
();
}
public
static
boolean
isUrl
(
String
url
){
if
(
TextUtils
.
isEmpty
(
url
)){
return
false
;
}
String
reg
=
"(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]"
;
return
url
.
matches
(
reg
);
}
public
static
byte
[]
getFileByte
(
String
filename
)
{
File
f
=
new
File
(
filename
);
if
(!
f
.
exists
())
{
return
null
;
}
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
((
int
)
f
.
length
());
BufferedInputStream
in
=
null
;
try
{
in
=
new
BufferedInputStream
(
new
FileInputStream
(
f
));
int
buf_size
=
1024
;
byte
[]
buffer
=
new
byte
[
buf_size
];
int
len
=
0
;
while
(-
1
!=
(
len
=
in
.
read
(
buffer
,
0
,
buf_size
)))
{
bos
.
write
(
buffer
,
0
,
len
);
}
in
.
close
();
return
bos
.
toByteArray
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
bos
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
return
null
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录