Skip to content
项目
Groups
代码片段
帮助
正在加载...
Sign in / Register
Toggle navigation
W
workoffice
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图表
统计图
Create a new issue
作业
提交
议题看板
Open sidebar
冷广德
workoffice
Commits
2893e7d8
提交
2893e7d8
authored
10月 24, 2021
作者:
flexiblexd@163.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.mes
上级
e63d2f41
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
253 行增加
和
91 行删除
+253
-91
build.gradle
app/build.gradle
+4
-2
MesQualityAddActivity.java
...office/ui/activity/mes/quality/MesQualityAddActivity.java
+27
-13
MesTicketAddLogActivity.java
...ffice/ui/activity/mes/ticket/MesTicketAddLogActivity.java
+107
-40
MesTicketAddSummaryActivity.java
...e/ui/activity/mes/ticket/MesTicketAddSummaryActivity.java
+7
-4
MesOtherSupplierAddActivity.java
...ice/ui/activity/mes/user/MesOtherSupplierAddActivity.java
+6
-4
MesOtherSupplierModifyActivity.java
.../ui/activity/mes/user/MesOtherSupplierModifyActivity.java
+6
-4
MesPackageAddActivity.java
...orkoffice/ui/activity/mes/user/MesPackageAddActivity.java
+6
-4
MesPackageModifyActivity.java
...office/ui/activity/mes/user/MesPackageModifyActivity.java
+6
-4
MesThreeAddActivity.java
.../workoffice/ui/activity/mes/user/MesThreeAddActivity.java
+6
-4
MesThreeModifyActivity.java
...rkoffice/ui/activity/mes/user/MesThreeModifyActivity.java
+6
-4
ImgAdapter.java
...rc/main/java/com/wd/workoffice/ui/adapter/ImgAdapter.java
+4
-3
MesTicketLogAdapter.java
...ava/com/wd/workoffice/ui/adapter/MesTicketLogAdapter.java
+2
-2
WorkUtils.java
app/src/main/java/com/wd/workoffice/util/WorkUtils.java
+60
-2
activity_mes_ticket_log_add.xml
app/src/main/res/layout/activity_mes_ticket_log_add.xml
+6
-1
没有找到文件。
app/build.gradle
浏览文件 @
2893e7d8
...
...
@@ -6,8 +6,8 @@ android {
applicationId
"com.wd.workoffice"
minSdkVersion
21
targetSdkVersion
28
versionCode
8
versionName
"1.0.
8
"
versionCode
10
versionName
"1.0.
10
"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
manifestPlaceholders
=
[
JPUSH_PKGNAME:
applicationId
,
...
...
@@ -109,4 +109,6 @@ dependencies {
implementation
'com.huawei.storage:esdk-obs-android:3.1.3'
implementation
'com.blankj:utilcodex:1.29.0'
// implementation 'com.github.Shouheng88:compressor:latest-version'
implementation
'id.zelory:compressor:2.1.1'
}
app/src/main/java/com/wd/workoffice/ui/activity/mes/quality/MesQualityAddActivity.java
浏览文件 @
2893e7d8
...
...
@@ -3,8 +3,10 @@ package com.wd.workoffice.ui.activity.mes.quality;
import
android.Manifest
;
import
android.content.Intent
;
import
android.content.pm.ActivityInfo
;
import
android.graphics.Bitmap
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.os.Environment
;
import
android.text.TextUtils
;
import
android.view.Menu
;
import
android.view.MenuItem
;
...
...
@@ -18,6 +20,7 @@ import android.widget.TextView;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.blankj.utilcode.util.UriUtils
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.tbruyelle.rxpermissions2.RxPermissions
;
import
com.wd.workoffice.R
;
...
...
@@ -46,6 +49,7 @@ import com.zhihu.matisse.internal.entity.CaptureStrategy;
import
org.greenrobot.eventbus.EventBus
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -58,6 +62,7 @@ import butterknife.ButterKnife;
import
butterknife.OnClick
;
import
flexible.xd.android_base.network.rtfhttp.Transformer
;
import
flexible.xd.android_base.utils.FileUtils
;
import
id.zelory.compressor.Compressor
;
import
io.reactivex.Observable
;
import
io.reactivex.disposables.Disposable
;
import
okhttp3.MediaType
;
...
...
@@ -257,6 +262,10 @@ public class MesQualityAddActivity extends WorkToolBarActivity {
imgAddAdapter
.
setOnItemClickListener
(
new
BaseQuickAdapter
.
OnItemClickListener
()
{
@Override
public
void
onItemClick
(
BaseQuickAdapter
adapter
,
View
view
,
int
position
)
{
if
(
imgList
.
size
()
>
9
)
{
toast
(
"最大上传9张"
);
return
;
}
if
(
position
==
imgList
.
size
()
-
1
)
{
addImg
();
}
...
...
@@ -546,7 +555,7 @@ public class MesQualityAddActivity extends WorkToolBarActivity {
Matisse
.
from
(
MesQualityAddActivity
.
this
)
.
choose
(
MimeType
.
ofImage
())
.
countable
(
true
)
.
maxSelectable
(
3
).
capture
(
true
).
.
maxSelectable
(
9
).
capture
(
true
).
captureStrategy
(
new
CaptureStrategy
(
true
,
"com.wd.workoffice.fileprovider"
))
// .addFilter(new GifSizeFilter(320, 320, 5 * Filter.K * Filter.K))
// .gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size))
...
...
@@ -568,11 +577,13 @@ public class MesQualityAddActivity extends WorkToolBarActivity {
showLoading
();
File
file
;
if
(
uri
instanceof
Uri
)
{
file
=
WorkUtils
.
uriToFile
((
Uri
)
uri
,
this
);
// file = WorkUtils.uriToFile((Uri) uri, this);
file
=
UriUtils
.
uri2File
((
Uri
)
uri
);
}
else
{
file
=
new
File
(
uri
.
toString
());
}
RequestBody
requestFile
=
RequestBody
.
create
(
MediaType
.
parse
(
"multipart/form-data"
),
file
);
File
smallImg
=
WorkUtils
.
getSmallImg
(
file
,
this
);
RequestBody
requestFile
=
RequestBody
.
create
(
MediaType
.
parse
(
"multipart/form-data"
),
smallImg
);
RtfUtils
.
getMesRtf
().
upload
(
MultipartBody
.
Part
.
createFormData
(
"file"
,
file
.
getName
(),
requestFile
)).
compose
(
Transformer
.
schedule
()).
subscribe
(
new
WorkObserver
<
BaseMesBean
>()
{
...
...
@@ -594,16 +605,19 @@ public class MesQualityAddActivity extends WorkToolBarActivity {
toast
(
data
.
getMessage
());
return
;
}
toast
(
"上传成功"
);
ImageBean
imageBean
=
new
ImageBean
();
imageBean
.
setPath
(
data
.
getData
().
toString
());
imageBean
.
setName
(
file
.
getName
());
imageBean
.
setSize
(
FileUtils
.
getFileLength
(
file
));
imageBean
.
setType
(
data
.
getData
().
toString
().
split
(
"\\."
)[
1
]);
imgList
.
add
(
imgList
.
size
()
-
1
,
imageBean
);
imgAddAdapter
.
notifyDataSetChanged
();
imageBean
.
setUri
((
Uri
)
uri
);
if
(
imgList
.
size
()
<
10
)
{
toast
(
"上传成功"
);
ImageBean
imageBean
=
new
ImageBean
();
imageBean
.
setPath
(
data
.
getData
().
toString
());
imageBean
.
setName
(
smallImg
.
getName
());
imageBean
.
setSize
(
FileUtils
.
getFileLength
(
smallImg
));
imageBean
.
setType
(
data
.
getData
().
toString
().
split
(
"\\."
)[
1
]);
imgList
.
add
(
imgList
.
size
()
-
1
,
imageBean
);
imgAddAdapter
.
notifyDataSetChanged
();
imageBean
.
setUri
((
Uri
)
uri
);
}
}
});
}
...
...
app/src/main/java/com/wd/workoffice/ui/activity/mes/ticket/MesTicketAddLogActivity.java
浏览文件 @
2893e7d8
...
...
@@ -4,6 +4,7 @@ import android.Manifest;
import
android.content.Intent
;
import
android.content.pm.ActivityInfo
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.view.Menu
;
import
android.view.MenuItem
;
import
android.view.View
;
...
...
@@ -12,15 +13,19 @@ import android.widget.ImageView;
import
android.widget.TextView
;
import
com.alibaba.fastjson.JSON
;
import
com.blankj.utilcode.util.UriUtils
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.tbruyelle.rxpermissions2.RxPermissions
;
import
com.wd.workoffice.R
;
import
com.wd.workoffice.app.BaseMesBean
;
import
com.wd.workoffice.app.WorkToolBarActivity
;
import
com.wd.workoffice.bean.event.AddLogEvent
;
import
com.wd.workoffice.bean.mesBean.ImageBean
;
import
com.wd.workoffice.bean.mesBean.MesProBean
;
import
com.wd.workoffice.bean.mesBean.TicketBean
;
import
com.wd.workoffice.retrofit.RtfUtils
;
import
com.wd.workoffice.retrofit.WorkObserver
;
import
com.wd.workoffice.ui.adapter.ImgAddAdapter
;
import
com.wd.workoffice.util.Glide4Engine
;
import
com.wd.workoffice.util.GlideUtils
;
import
com.wd.workoffice.util.WorkUtils
;
...
...
@@ -37,6 +42,8 @@ import java.util.List;
import
java.util.Map
;
import
androidx.annotation.Nullable
;
import
androidx.recyclerview.widget.GridLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
butterknife.OnClick
;
...
...
@@ -72,9 +79,13 @@ public class MesTicketAddLogActivity extends WorkToolBarActivity {
ImageView
ivImg2
;
@BindView
(
R
.
id
.
iv_img3
)
ImageView
ivImg3
;
@BindView
(
R
.
id
.
rv_img
)
RecyclerView
rvImg
;
private
Map
<
String
,
Object
>
param
;
private
TicketBean
.
ListBean
data
;
private
Map
<
Integer
,
Object
>
annexMap
=
new
HashMap
<>();
private
List
<
ImageBean
>
imgList
;
private
ImgAddAdapter
imgAddAdapter
;
@Override
protected
void
initView
()
{
...
...
@@ -83,6 +94,7 @@ public class MesTicketAddLogActivity extends WorkToolBarActivity {
tvCode
.
setText
(
data
.
getJobNo
());
tvTime
.
setText
(
data
.
getCreateDateTime
());
tvCreatePerson
.
setText
(
data
.
getCreateUserName
());
rvImg
.
setLayoutManager
(
new
GridLayoutManager
(
this
,
3
,
RecyclerView
.
VERTICAL
,
false
));
// ivImg1.setImageResource(R.mipmap.ic_launcher);
// GlideUtils.getRequest().load(R.mipmap.ic_launcher).into(ivImg1);
}
...
...
@@ -91,6 +103,12 @@ public class MesTicketAddLogActivity extends WorkToolBarActivity {
protected
void
initData
()
{
param
=
WorkUtils
.
simpleParam
();
param
.
put
(
"jobNo"
,
data
.
getJobNo
());
imgList
=
new
ArrayList
<>();
ImageBean
imageBean
=
new
ImageBean
();
imageBean
.
setUri
(
null
);
imgList
.
add
(
imageBean
);
imgAddAdapter
=
new
ImgAddAdapter
(
R
.
layout
.
item_mes_ticket_img
,
imgList
);
imgAddAdapter
.
bindToRecyclerView
(
rvImg
);
}
private
void
submit
()
{
...
...
@@ -123,6 +141,25 @@ public class MesTicketAddLogActivity extends WorkToolBarActivity {
@Override
protected
void
initEvent
()
{
imgAddAdapter
.
setOnItemChildClickListener
(
new
BaseQuickAdapter
.
OnItemChildClickListener
()
{
@Override
public
void
onItemChildClick
(
BaseQuickAdapter
adapter
,
View
view
,
int
position
)
{
imgList
.
remove
(
position
);
imgAddAdapter
.
notifyDataSetChanged
();
}
});
imgAddAdapter
.
setOnItemClickListener
(
new
BaseQuickAdapter
.
OnItemClickListener
()
{
@Override
public
void
onItemClick
(
BaseQuickAdapter
adapter
,
View
view
,
int
position
)
{
if
(
imgList
.
size
()
>
3
)
{
toast
(
"最大上传3张"
);
return
;
}
if
(
position
==
imgList
.
size
()
-
1
)
{
addImg
();
}
}
});
}
@Override
...
...
@@ -146,7 +183,11 @@ public class MesTicketAddLogActivity extends WorkToolBarActivity {
param
.
put
(
"customerDemand"
,
client
);
param
.
put
(
"jobContent"
,
content
);
param
.
put
(
"problemDescription"
,
desc
);
param
.
put
(
"attachments"
,
getUploadImg
());
List
<
ImageBean
>
uploadImg
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
imgList
.
size
()
-
1
;
i
++)
{
uploadImg
.
add
(
imgList
.
get
(
i
));
}
param
.
put
(
"attachments"
,
uploadImg
);
submit
();
break
;
}
...
...
@@ -166,18 +207,18 @@ public class MesTicketAddLogActivity extends WorkToolBarActivity {
public
void
onViewClicked
(
View
view
)
{
switch
(
view
.
getId
())
{
case
R
.
id
.
iv_img1
:
addImg
(
1
);
//
addImg(1);
break
;
case
R
.
id
.
iv_img2
:
addImg
(
2
);
//
addImg(2);
break
;
case
R
.
id
.
iv_img3
:
addImg
(
3
);
//
addImg(3);
break
;
}
}
private
void
addImg
(
int
position
)
{
private
void
addImg
()
{
RxPermissions
rxPermissions
=
new
RxPermissions
(
this
);
rxPermissions
.
request
(
Manifest
.
permission
.
CAMERA
,
...
...
@@ -189,14 +230,14 @@ public class MesTicketAddLogActivity extends WorkToolBarActivity {
Matisse
.
from
(
MesTicketAddLogActivity
.
this
)
.
choose
(
MimeType
.
ofAll
())
.
countable
(
true
)
.
maxSelectable
(
1
).
capture
(
true
).
.
maxSelectable
(
3
).
capture
(
true
).
captureStrategy
(
new
CaptureStrategy
(
true
,
"com.wd.workoffice.fileprovider"
))
// .addFilter(new GifSizeFilter(320, 320, 5 * Filter.K * Filter.K))
// .gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size))
.
restrictOrientation
(
ActivityInfo
.
SCREEN_ORIENTATION_UNSPECIFIED
)
.
thumbnailScale
(
0.85f
)
.
imageEngine
(
new
Glide4Engine
())
.
forResult
(
1000
0
+
position
);
.
forResult
(
1000
1
);
}
else
{
// At least one permission is denied
toast
(
"您需要开启拍照、存储权限!"
);
...
...
@@ -210,31 +251,43 @@ public class MesTicketAddLogActivity extends WorkToolBarActivity {
if
(
resultCode
==
RESULT_OK
)
{
switch
(
requestCode
)
{
case
10001
:
if
(
Matisse
.
obtainResult
(
data
).
size
()
!=
0
)
{
Uri
uri
=
Matisse
.
obtainResult
(
data
).
get
(
0
);
upload
(
1
,
uri
);
// if (Matisse.obtainResult(data).size() != 0) {
// Uri uri = Matisse.obtainResult(data).get(0);
// upload(1, uri);
// }
List
<
Uri
>
dataUri
=
Matisse
.
obtainResult
(
data
);
for
(
Uri
uri
:
dataUri
)
{
upload
(
uri
);
}
break
;
case
10002
:
if
(
Matisse
.
obtainResult
(
data
).
size
()
!=
0
)
{
Uri
uri
=
Matisse
.
obtainResult
(
data
).
get
(
0
);
upload
(
2
,
uri
);
}
//
if (Matisse.obtainResult(data).size() != 0) {
//
Uri uri = Matisse.obtainResult(data).get(0);
//
upload(2, uri);
//
}
break
;
case
10003
:
if
(
Matisse
.
obtainResult
(
data
).
size
()
!=
0
)
{
Uri
uri
=
Matisse
.
obtainResult
(
data
).
get
(
0
);
upload
(
3
,
uri
);
}
//
if (Matisse.obtainResult(data).size() != 0) {
//
Uri uri = Matisse.obtainResult(data).get(0);
//
upload(3, uri);
//
}
break
;
}
}
}
private
void
upload
(
int
position
,
Uri
uri
)
{
private
void
upload
(
Uri
uri
)
{
showLoading
();
File
file
=
WorkUtils
.
uriToFile
(
uri
,
this
);
RequestBody
requestFile
=
RequestBody
.
create
(
MediaType
.
parse
(
"multipart/form-data"
),
file
);
// File file = WorkUtils.uriToFile(uri, this);
File
file
;
if
(
uri
instanceof
Uri
)
{
// file = WorkUtils.uriToFile((Uri) uri, this);
file
=
UriUtils
.
uri2File
((
Uri
)
uri
);
}
else
{
file
=
new
File
(
uri
.
toString
());
}
File
uploadFile
=
WorkUtils
.
getSmallImg
(
file
,
this
);
RequestBody
requestFile
=
RequestBody
.
create
(
MediaType
.
parse
(
"multipart/form-data"
),
uploadFile
);
RtfUtils
.
getMesRtf
().
upload
(
MultipartBody
.
Part
.
createFormData
(
"file"
,
file
.
getName
(),
requestFile
)).
compose
(
Transformer
.
schedule
()).
subscribe
(
new
WorkObserver
<
BaseMesBean
>()
{
...
...
@@ -256,27 +309,41 @@ public class MesTicketAddLogActivity extends WorkToolBarActivity {
toast
(
data
.
getMessage
());
return
;
}
toast
(
"上传成功"
);
ImageBean
imageBean
=
new
ImageBean
();
imageBean
.
setPath
(
data
.
getData
().
toString
());
imageBean
.
setName
(
file
.
getName
());
imageBean
.
setSize
(
FileUtils
.
getFileLength
(
file
));
imageBean
.
setType
(
data
.
getData
().
toString
().
split
(
"\\."
)[
1
]);
switch
(
position
)
{
case
1
:
GlideUtils
.
getRequest
().
load
(
uri
).
into
(
ivImg1
);
annexMap
.
put
(
1
,
imageBean
);
break
;
case
2
:
GlideUtils
.
getRequest
().
load
(
uri
).
into
(
ivImg2
);
annexMap
.
put
(
2
,
imageBean
);
break
;
case
3
:
GlideUtils
.
getRequest
().
load
(
uri
).
into
(
ivImg3
);
annexMap
.
put
(
3
,
imageBean
);
break
;
if
(
imgList
.
size
()
<
10
)
{
toast
(
"上传成功"
);
ImageBean
imageBean
=
new
ImageBean
();
imageBean
.
setPath
(
data
.
getData
().
toString
());
imageBean
.
setName
(
uploadFile
.
getName
());
imageBean
.
setSize
(
FileUtils
.
getFileLength
(
uploadFile
));
imageBean
.
setType
(
data
.
getData
().
toString
().
split
(
"\\."
)[
1
]);
imgList
.
add
(
imgList
.
size
()
-
1
,
imageBean
);
imgAddAdapter
.
notifyDataSetChanged
();
imageBean
.
setUri
((
Uri
)
uri
);
}
// toast("上传成功");
// ImageBean imageBean = new ImageBean();
// imageBean.setPath(data.getData().toString());
// imageBean.setName(file.getName());
// imageBean.setSize(FileUtils.getFileLength(file));
// imageBean.setType(data.getData().toString().split("\\.")[1]);
// switch (position) {
// case 1:
// GlideUtils.getRequest().load(uri).into(ivImg1);
// annexMap.put(1, imageBean);
// break;
// case 2:
// GlideUtils.getRequest().load(uri).into(ivImg2);
// annexMap.put(2, imageBean);
// break;
// case 3:
// GlideUtils.getRequest().load(uri).into(ivImg3);
// annexMap.put(3, imageBean);
// break;
// }
}
});
}
}
app/src/main/java/com/wd/workoffice/ui/activity/mes/ticket/MesTicketAddSummaryActivity.java
浏览文件 @
2893e7d8
...
...
@@ -16,6 +16,7 @@ import android.widget.RelativeLayout;
import
android.widget.TextView
;
import
com.alibaba.fastjson.JSON
;
import
com.blankj.utilcode.util.UriUtils
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.qmuiteam.qmui.widget.dialog.QMUIDialog
;
import
com.tbruyelle.rxpermissions2.RxPermissions
;
...
...
@@ -419,11 +420,13 @@ public class MesTicketAddSummaryActivity extends WorkToolBarActivity {
showLoading
();
File
file
;
if
(
uri
instanceof
Uri
)
{
file
=
WorkUtils
.
uriToFile
((
Uri
)
uri
,
this
);
// file = WorkUtils.uriToFile((Uri) uri, this);
file
=
UriUtils
.
uri2File
((
Uri
)
uri
);
}
else
{
file
=
new
File
(
uri
.
toString
());
}
RequestBody
requestFile
=
RequestBody
.
create
(
MediaType
.
parse
(
"multipart/form-data"
),
file
);
File
smallImg
=
WorkUtils
.
getSmallImg
(
file
,
this
);
RequestBody
requestFile
=
RequestBody
.
create
(
MediaType
.
parse
(
"multipart/form-data"
),
smallImg
);
RtfUtils
.
getMesRtf
().
upload
(
MultipartBody
.
Part
.
createFormData
(
"file"
,
file
.
getName
(),
requestFile
)).
compose
(
Transformer
.
schedule
()).
subscribe
(
new
WorkObserver
<
BaseMesBean
>()
{
...
...
@@ -448,8 +451,8 @@ public class MesTicketAddSummaryActivity extends WorkToolBarActivity {
toast
(
"上传成功"
);
ImageBean
imageBean
=
new
ImageBean
();
imageBean
.
setPath
(
data
.
getData
().
toString
());
imageBean
.
setName
(
file
.
getName
());
imageBean
.
setSize
(
FileUtils
.
getFileLength
(
file
));
imageBean
.
setName
(
smallImg
.
getName
());
imageBean
.
setSize
(
FileUtils
.
getFileLength
(
smallImg
));
imageBean
.
setType
(
data
.
getData
().
toString
().
split
(
"\\."
)[
1
]);
if
(
type
==
1
)
{
...
...
app/src/main/java/com/wd/workoffice/ui/activity/mes/user/MesOtherSupplierAddActivity.java
浏览文件 @
2893e7d8
...
...
@@ -12,6 +12,7 @@ import android.widget.EditText;
import
android.widget.ImageView
;
import
com.alibaba.fastjson.JSON
;
import
com.blankj.utilcode.util.UriUtils
;
import
com.tbruyelle.rxpermissions2.RxPermissions
;
import
com.wd.workoffice.R
;
import
com.wd.workoffice.app.BaseMesBean
;
...
...
@@ -237,8 +238,9 @@ public class MesOtherSupplierAddActivity extends WorkToolBarActivity {
private
void
upload
(
int
position
,
Uri
uri
)
{
showLoading
();
File
file
=
WorkUtils
.
uriToFile
(
uri
,
this
);
RequestBody
requestFile
=
RequestBody
.
create
(
MediaType
.
parse
(
"multipart/form-data"
),
file
);
File
file
=
UriUtils
.
uri2File
((
Uri
)
uri
);
File
smallImg
=
WorkUtils
.
getSmallImg
(
file
,
this
);
RequestBody
requestFile
=
RequestBody
.
create
(
MediaType
.
parse
(
"multipart/form-data"
),
smallImg
);
RtfUtils
.
getMesRtf
().
upload
(
MultipartBody
.
Part
.
createFormData
(
"file"
,
file
.
getName
(),
requestFile
)).
compose
(
Transformer
.
schedule
()).
subscribe
(
new
WorkObserver
<
BaseMesBean
>()
{
...
...
@@ -263,8 +265,8 @@ public class MesOtherSupplierAddActivity extends WorkToolBarActivity {
toast
(
"上传成功"
);
ImageBean
imageBean
=
new
ImageBean
();
imageBean
.
setPath
(
data
.
getData
().
toString
());
imageBean
.
setName
(
file
.
getName
());
imageBean
.
setSize
(
FileUtils
.
getFileLength
(
file
));
imageBean
.
setName
(
smallImg
.
getName
());
imageBean
.
setSize
(
FileUtils
.
getFileLength
(
smallImg
));
imageBean
.
setType
(
data
.
getData
().
toString
().
split
(
"\\."
)[
1
]);
switch
(
position
)
{
case
1
:
...
...
app/src/main/java/com/wd/workoffice/ui/activity/mes/user/MesOtherSupplierModifyActivity.java
浏览文件 @
2893e7d8
...
...
@@ -12,6 +12,7 @@ import android.widget.EditText;
import
android.widget.ImageView
;
import
com.alibaba.fastjson.JSON
;
import
com.blankj.utilcode.util.UriUtils
;
import
com.tbruyelle.rxpermissions2.RxPermissions
;
import
com.wd.workoffice.R
;
import
com.wd.workoffice.app.BaseMesBean
;
...
...
@@ -343,8 +344,9 @@ public class MesOtherSupplierModifyActivity extends WorkToolBarActivity {
private
void
upload
(
int
position
,
Uri
uri
)
{
showLoading
();
File
file
=
WorkUtils
.
uriToFile
(
uri
,
this
);
RequestBody
requestFile
=
RequestBody
.
create
(
MediaType
.
parse
(
"multipart/form-data"
),
file
);
File
file
=
UriUtils
.
uri2File
((
Uri
)
uri
);
File
smallImg
=
WorkUtils
.
getSmallImg
(
file
,
this
);
RequestBody
requestFile
=
RequestBody
.
create
(
MediaType
.
parse
(
"multipart/form-data"
),
smallImg
);
RtfUtils
.
getMesRtf
().
upload
(
MultipartBody
.
Part
.
createFormData
(
"file"
,
file
.
getName
(),
requestFile
)).
compose
(
Transformer
.
schedule
()).
subscribe
(
new
WorkObserver
<
BaseMesBean
>()
{
...
...
@@ -369,8 +371,8 @@ public class MesOtherSupplierModifyActivity extends WorkToolBarActivity {
toast
(
"上传成功"
);
ImageBean
imageBean
=
new
ImageBean
();
imageBean
.
setPath
(
data
.
getData
().
toString
());
imageBean
.
setName
(
file
.
getName
());
imageBean
.
setSize
(
FileUtils
.
getFileLength
(
file
));
imageBean
.
setName
(
smallImg
.
getName
());
imageBean
.
setSize
(
FileUtils
.
getFileLength
(
smallImg
));
imageBean
.
setType
(
data
.
getData
().
toString
().
split
(
"\\."
)[
1
]);
switch
(
position
)
{
case
1
:
...
...
app/src/main/java/com/wd/workoffice/ui/activity/mes/user/MesPackageAddActivity.java
浏览文件 @
2893e7d8
...
...
@@ -14,6 +14,7 @@ import android.widget.RelativeLayout;
import
android.widget.TextView
;
import
com.alibaba.fastjson.JSON
;
import
com.blankj.utilcode.util.UriUtils
;
import
com.tbruyelle.rxpermissions2.RxPermissions
;
import
com.wd.workoffice.R
;
import
com.wd.workoffice.app.BaseMesBean
;
...
...
@@ -261,8 +262,9 @@ public class MesPackageAddActivity extends WorkToolBarActivity {
private
void
upload
(
int
position
,
Uri
uri
)
{
showLoading
();
File
file
=
WorkUtils
.
uriToFile
(
uri
,
this
);
RequestBody
requestFile
=
RequestBody
.
create
(
MediaType
.
parse
(
"multipart/form-data"
),
file
);
File
file
=
UriUtils
.
uri2File
((
Uri
)
uri
);
File
smallImg
=
WorkUtils
.
getSmallImg
(
file
,
this
);
RequestBody
requestFile
=
RequestBody
.
create
(
MediaType
.
parse
(
"multipart/form-data"
),
smallImg
);
RtfUtils
.
getMesRtf
().
upload
(
MultipartBody
.
Part
.
createFormData
(
"file"
,
file
.
getName
(),
requestFile
)).
compose
(
Transformer
.
schedule
()).
subscribe
(
new
WorkObserver
<
BaseMesBean
>()
{
...
...
@@ -287,8 +289,8 @@ public class MesPackageAddActivity extends WorkToolBarActivity {
toast
(
"上传成功"
);
ImageBean
imageBean
=
new
ImageBean
();
imageBean
.
setPath
(
data
.
getData
().
toString
());
imageBean
.
setName
(
file
.
getName
());
imageBean
.
setSize
(
FileUtils
.
getFileLength
(
file
));
imageBean
.
setName
(
smallImg
.
getName
());
imageBean
.
setSize
(
FileUtils
.
getFileLength
(
smallImg
));
imageBean
.
setType
(
data
.
getData
().
toString
().
split
(
"\\."
)[
1
]);
switch
(
position
)
{
case
1
:
...
...
app/src/main/java/com/wd/workoffice/ui/activity/mes/user/MesPackageModifyActivity.java
浏览文件 @
2893e7d8
...
...
@@ -14,6 +14,7 @@ import android.widget.RelativeLayout;
import
android.widget.TextView
;
import
com.alibaba.fastjson.JSON
;
import
com.blankj.utilcode.util.UriUtils
;
import
com.tbruyelle.rxpermissions2.RxPermissions
;
import
com.wd.workoffice.R
;
import
com.wd.workoffice.app.BaseMesBean
;
...
...
@@ -374,8 +375,9 @@ public class MesPackageModifyActivity extends WorkToolBarActivity {
private
void
upload
(
int
position
,
Uri
uri
)
{
showLoading
();
File
file
=
WorkUtils
.
uriToFile
(
uri
,
this
);
RequestBody
requestFile
=
RequestBody
.
create
(
MediaType
.
parse
(
"multipart/form-data"
),
file
);
File
file
=
UriUtils
.
uri2File
((
Uri
)
uri
);
File
smallImg
=
WorkUtils
.
getSmallImg
(
file
,
this
);
RequestBody
requestFile
=
RequestBody
.
create
(
MediaType
.
parse
(
"multipart/form-data"
),
smallImg
);
RtfUtils
.
getMesRtf
().
upload
(
MultipartBody
.
Part
.
createFormData
(
"file"
,
file
.
getName
(),
requestFile
)).
compose
(
Transformer
.
schedule
()).
subscribe
(
new
WorkObserver
<
BaseMesBean
>()
{
...
...
@@ -400,8 +402,8 @@ public class MesPackageModifyActivity extends WorkToolBarActivity {
toast
(
"上传成功"
);
ImageBean
imageBean
=
new
ImageBean
();
imageBean
.
setPath
(
data
.
getData
().
toString
());
imageBean
.
setName
(
file
.
getName
());
imageBean
.
setSize
(
FileUtils
.
getFileLength
(
file
));
imageBean
.
setName
(
smallImg
.
getName
());
imageBean
.
setSize
(
FileUtils
.
getFileLength
(
smallImg
));
imageBean
.
setType
(
data
.
getData
().
toString
().
split
(
"\\."
)[
1
]);
switch
(
position
)
{
case
1
:
...
...
app/src/main/java/com/wd/workoffice/ui/activity/mes/user/MesThreeAddActivity.java
浏览文件 @
2893e7d8
...
...
@@ -15,6 +15,7 @@ import android.widget.RelativeLayout;
import
android.widget.TextView
;
import
com.alibaba.fastjson.JSON
;
import
com.blankj.utilcode.util.UriUtils
;
import
com.tbruyelle.rxpermissions2.RxPermissions
;
import
com.wd.workoffice.R
;
import
com.wd.workoffice.app.BaseMesBean
;
...
...
@@ -294,8 +295,9 @@ public class MesThreeAddActivity extends WorkToolBarActivity {
private
void
upload
(
int
position
,
Uri
uri
)
{
showLoading
();
File
file
=
WorkUtils
.
uriToFile
(
uri
,
this
);
RequestBody
requestFile
=
RequestBody
.
create
(
MediaType
.
parse
(
"multipart/form-data"
),
file
);
File
file
=
UriUtils
.
uri2File
((
Uri
)
uri
);
File
smallImg
=
WorkUtils
.
getSmallImg
(
file
,
this
);
RequestBody
requestFile
=
RequestBody
.
create
(
MediaType
.
parse
(
"multipart/form-data"
),
smallImg
);
RtfUtils
.
getMesRtf
().
upload
(
MultipartBody
.
Part
.
createFormData
(
"file"
,
file
.
getName
(),
requestFile
)).
compose
(
Transformer
.
schedule
()).
subscribe
(
new
WorkObserver
<
BaseMesBean
>()
{
...
...
@@ -320,8 +322,8 @@ public class MesThreeAddActivity extends WorkToolBarActivity {
toast
(
"上传成功"
);
ImageBean
imageBean
=
new
ImageBean
();
imageBean
.
setPath
(
data
.
getData
().
toString
());
imageBean
.
setName
(
file
.
getName
());
imageBean
.
setSize
(
FileUtils
.
getFileLength
(
file
));
imageBean
.
setName
(
smallImg
.
getName
());
imageBean
.
setSize
(
FileUtils
.
getFileLength
(
smallImg
));
imageBean
.
setType
(
data
.
getData
().
toString
().
split
(
"\\."
)[
1
]);
switch
(
position
)
{
case
1
:
...
...
app/src/main/java/com/wd/workoffice/ui/activity/mes/user/MesThreeModifyActivity.java
浏览文件 @
2893e7d8
...
...
@@ -14,6 +14,7 @@ import android.widget.RelativeLayout;
import
android.widget.TextView
;
import
com.alibaba.fastjson.JSON
;
import
com.blankj.utilcode.util.UriUtils
;
import
com.tbruyelle.rxpermissions2.RxPermissions
;
import
com.wd.workoffice.R
;
import
com.wd.workoffice.app.BaseMesBean
;
...
...
@@ -412,8 +413,9 @@ public class MesThreeModifyActivity extends WorkToolBarActivity {
private
void
upload
(
int
position
,
Uri
uri
)
{
showLoading
();
File
file
=
WorkUtils
.
uriToFile
(
uri
,
this
);
RequestBody
requestFile
=
RequestBody
.
create
(
MediaType
.
parse
(
"multipart/form-data"
),
file
);
File
file
=
UriUtils
.
uri2File
((
Uri
)
uri
);
File
smallImg
=
WorkUtils
.
getSmallImg
(
file
,
this
);
RequestBody
requestFile
=
RequestBody
.
create
(
MediaType
.
parse
(
"multipart/form-data"
),
smallImg
);
RtfUtils
.
getMesRtf
().
upload
(
MultipartBody
.
Part
.
createFormData
(
"file"
,
file
.
getName
(),
requestFile
)).
compose
(
Transformer
.
schedule
()).
subscribe
(
new
WorkObserver
<
BaseMesBean
>()
{
...
...
@@ -438,8 +440,8 @@ public class MesThreeModifyActivity extends WorkToolBarActivity {
toast
(
"上传成功"
);
ImageBean
imageBean
=
new
ImageBean
();
imageBean
.
setPath
(
data
.
getData
().
toString
());
imageBean
.
setName
(
file
.
getName
());
imageBean
.
setSize
(
FileUtils
.
getFileLength
(
file
));
imageBean
.
setName
(
smallImg
.
getName
());
imageBean
.
setSize
(
FileUtils
.
getFileLength
(
smallImg
));
imageBean
.
setType
(
data
.
getData
().
toString
().
split
(
"\\."
)[
1
]);
switch
(
position
)
{
case
1
:
...
...
app/src/main/java/com/wd/workoffice/ui/adapter/ImgAdapter.java
浏览文件 @
2893e7d8
...
...
@@ -9,6 +9,7 @@ import com.bumptech.glide.load.ImageHeaderParser;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.chad.library.adapter.base.BaseViewHolder
;
import
com.wd.workoffice.R
;
import
com.wd.workoffice.app.Config
;
import
com.wd.workoffice.bean.mesBean.ImageBean
;
import
com.wd.workoffice.ui.activity.mes.ImageActivity
;
import
com.wd.workoffice.util.GlideUtils
;
...
...
@@ -32,13 +33,13 @@ public class ImgAdapter extends BaseQuickAdapter<ImageBean, BaseViewHolder> {
@Override
protected
void
convert
(
BaseViewHolder
helper
,
ImageBean
item
)
{
ImageView
ivImg
=
helper
.
getView
(
R
.
id
.
iv_img
);
GlideUtils
.
getRequest
().
load
(
item
.
getUrl
()).
into
(
ivImg
);
GlideUtils
.
getRequest
().
load
(
"http://124.129.27.194:81/"
+
item
.
getPath
()).
into
(
ivImg
);
helper
.
addOnClickListener
(
R
.
id
.
iv_img
);
ivImg
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Intent
intent
=
new
Intent
(
helper
.
getConvertView
().
getContext
(),
ImageActivity
.
class
);
intent
.
putExtra
(
"url"
,
item
.
getUrl
());
Intent
intent
=
new
Intent
(
helper
.
getConvertView
().
getContext
(),
ImageActivity
.
class
);
intent
.
putExtra
(
"url"
,
"http://124.129.27.194:81/"
+
item
.
getPath
());
startActivity
(
intent
);
}
});
...
...
app/src/main/java/com/wd/workoffice/ui/adapter/MesTicketLogAdapter.java
浏览文件 @
2893e7d8
...
...
@@ -57,12 +57,12 @@ public class MesTicketLogAdapter extends BaseQuickAdapter<LogBean, BaseViewHolde
// JzvdStd.startFullscreenDirectly(context,
// JzvdStd.class, imgList.get(position).getUrl(), "");
Intent
intent
=
new
Intent
(
context
,
VideoActivity
.
class
);
intent
.
putExtra
(
"url"
,
imgList
.
get
(
position
).
getUrl
());
intent
.
putExtra
(
"url"
,
"http://124.129.27.194:81/"
+
imgList
.
get
(
position
).
getPath
());
startActivity
(
intent
);
}
else
{
Intent
intent
=
new
Intent
(
context
,
ImageActivity
.
class
);
intent
.
putExtra
(
"url"
,
imgList
.
get
(
position
).
getUrl
());
intent
.
putExtra
(
"url"
,
"http://124.129.27.194:81/"
+
imgList
.
get
(
position
).
getPath
());
startActivity
(
intent
);
}
}
...
...
app/src/main/java/com/wd/workoffice/util/WorkUtils.java
浏览文件 @
2893e7d8
...
...
@@ -4,8 +4,10 @@ import android.annotation.SuppressLint;
import
android.content.ContentResolver
;
import
android.content.Context
;
import
android.database.Cursor
;
import
android.graphics.Bitmap
;
import
android.net.Uri
;
import
android.os.CountDownTimer
;
import
android.os.Environment
;
import
android.provider.MediaStore
;
import
android.text.Editable
;
import
android.text.TextUtils
;
...
...
@@ -19,6 +21,8 @@ import android.widget.TextView;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.blankj.utilcode.util.FileUtils
;
import
com.blankj.utilcode.util.ImageUtils
;
import
com.bumptech.glide.load.ImageHeaderParser
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.wd.workoffice.R
;
...
...
@@ -39,7 +43,9 @@ import com.wd.workoffice.ui.adapter.StarAdapter;
import
org.greenrobot.eventbus.EventBus
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
...
...
@@ -53,6 +59,7 @@ import cn.jpush.android.api.JPushInterface;
import
flexible.xd.android_base.network.rtfhttp.RtfHelper
;
import
flexible.xd.android_base.network.rtfhttp.Transformer
;
import
flexible.xd.android_base.utils.LogUtils
;
import
id.zelory.compressor.Compressor
;
import
io.reactivex.disposables.Disposable
;
import
okhttp3.MediaType
;
import
okhttp3.RequestBody
;
...
...
@@ -936,9 +943,9 @@ public class WorkUtils {
returnContent
=
"购买服务"
;
break
;
case
"product"
:
if
(
TextUtils
.
equals
(
businessFormat
,
"PD"
))
{
if
(
TextUtils
.
equals
(
businessFormat
,
"PD"
))
{
returnContent
=
"产品生产"
;
}
else
{
}
else
{
returnContent
=
"产品转库存"
;
}
break
;
...
...
@@ -947,4 +954,55 @@ public class WorkUtils {
}
return
returnContent
;
}
/**
* @return
*/
public
static
File
getSmallImg
(
File
img
,
Context
context
)
{
long
size
=
FileUtils
.
getLength
(
img
);
if
(
size
/
1024
>
1024
)
{
Bitmap
bitmap
=
ImageUtils
.
getBitmap
(
img
);
Bitmap
bitmap1
=
ImageUtils
.
compressByScale
(
bitmap
,
bitmap
.
getWidth
()
/
3
*
2
,
bitmap
.
getHeight
()
/
3
*
2
);
// 0-100 100为不压缩
int
quality
=
80
;
File
file
=
new
File
(
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_PICTURES
).
getAbsolutePath
()
+
"/"
+
System
.
currentTimeMillis
());
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
// 把压缩后的数据存放到baos中
bitmap1
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
quality
,
baos
);
try
{
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
fos
.
write
(
baos
.
toByteArray
());
fos
.
flush
();
fos
.
close
();
long
endSize
=
FileUtils
.
getLength
(
file
);
if
(
endSize
/
1024
>
1024
)
{
return
getSmallImg
(
file
,
context
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
file
;
}
// long size = FileUtils.getLength(img);
// if (size / 1024 > 2 * 1024) {
// File compressedImage = null;
// try {
// compressedImage = new Compressor(context)
// .setQuality(30)
// .setCompressFormat(Bitmap.CompressFormat.JPEG)
//// .setDestinationDirectoryPath(Environment.getExternalStoragePublicDirectory(
//// Environment.DIRECTORY_PICTURES).getAbsolutePath())
// .compressToFile(img);
// long endSize = FileUtils.getLength(compressedImage);
// if (endSize / 1024 > 2 * 1024) {
// return getSmallImg(compressedImage,context);
// }
// } catch (IOException e) {
// e.printStackTrace();
// }
// return compressedImage;
// }
return
img
;
}
}
app/src/main/res/layout/activity_mes_ticket_log_add.xml
浏览文件 @
2893e7d8
...
...
@@ -165,8 +165,13 @@
android:paddingVertical=
"13mm"
android:text=
"上传现场照片/视频"
android:textSize=
"14sp"
/>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv_img"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"10mm"
/>
<LinearLayout
android:visibility=
"gone"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:paddingHorizontal=
"20mm"
>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论