提交 d97fa26c authored 作者: lgd's avatar lgd

1.上传附件

2.//TODO erp用户是否选择新部门为空,质检接口数据无对应问题,内部交易订单审核,审核规则,领用申请列表/退件列表/参数,坩埚下单,mes,刷新token,编辑任务担当无法修改
上级 90bd4a91
...@@ -107,4 +107,5 @@ dependencies { ...@@ -107,4 +107,5 @@ dependencies {
implementation 'com.contrarywind:Android-PickerView:4.1.6' implementation 'com.contrarywind:Android-PickerView:4.1.6'
implementation 'com.zhihu.android:matisse:0.5.2-beta3' implementation 'com.zhihu.android:matisse:0.5.2-beta3'
implementation 'cn.jzvd:jiaozivideoplayer:7.3.0' implementation 'cn.jzvd:jiaozivideoplayer:7.3.0'
implementation 'me.rosuh:AndroidFilePicker:0.6.2'
} }
package com.wd.workoffice.bean.mesBean; package com.wd.workoffice.bean.mesBean;
import android.net.Uri;
/** /**
* author : flexible * author : flexible
* email : lgd19940421@163.com * email : lgd19940421@163.com
...@@ -21,6 +23,15 @@ public class ImageBean { ...@@ -21,6 +23,15 @@ public class ImageBean {
private String type; private String type;
private long size; private long size;
private String url; private String url;
private Uri uri;
public Uri getUri() {
return uri;
}
public void setUri(Uri uri) {
this.uri = uri;
}
public String getId() { public String getId() {
return id; return id;
......
...@@ -75,7 +75,7 @@ public class SummaryBean { ...@@ -75,7 +75,7 @@ public class SummaryBean {
private String updateUserName; private String updateUserName;
private String remark; private String remark;
private boolean delete; private boolean delete;
private List<AttachmentsBean> attachments; private List<ImageBean> attachments;
public String getId() { public String getId() {
return id; return id;
...@@ -325,77 +325,12 @@ public class SummaryBean { ...@@ -325,77 +325,12 @@ public class SummaryBean {
this.delete = delete; this.delete = delete;
} }
public List<AttachmentsBean> getAttachments() { public List<ImageBean> getAttachments() {
return attachments; return attachments;
} }
public void setAttachments(List<AttachmentsBean> attachments) { public void setAttachments(List<ImageBean> attachments) {
this.attachments = attachments; this.attachments = attachments;
} }
public static class AttachmentsBean {
/**
* id : a4224559878911ea8334fa163e1166bd
* name : 1.png
* path : group1/M00/00/0A/wKgAwV6lLjaABF2QAABBiqJSaT8874.png
* type : png
* size : 16778
* url : http://114.116.55.221/group1/M00/00/0A/wKgAwV6lLjaABF2QAABBiqJSaT8874.png
*/
private String id;
private String name;
private String path;
private String type;
private int size;
private String url;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
} }
package com.wd.workoffice.ui.activity.mes.ticket; package com.wd.workoffice.ui.activity.mes.ticket;
import android.Manifest;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
...@@ -14,7 +16,9 @@ import android.widget.RelativeLayout; ...@@ -14,7 +16,9 @@ import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog; import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.tbruyelle.rxpermissions2.RxPermissions;
import com.wd.workoffice.R; import com.wd.workoffice.R;
import com.wd.workoffice.app.BaseMesBean; import com.wd.workoffice.app.BaseMesBean;
import com.wd.workoffice.app.WorkToolBarActivity; import com.wd.workoffice.app.WorkToolBarActivity;
...@@ -29,8 +33,12 @@ import com.wd.workoffice.retrofit.WorkObserver; ...@@ -29,8 +33,12 @@ import com.wd.workoffice.retrofit.WorkObserver;
import com.wd.workoffice.ui.adapter.AnnexAdapter; import com.wd.workoffice.ui.adapter.AnnexAdapter;
import com.wd.workoffice.ui.adapter.ImgAddAdapter; import com.wd.workoffice.ui.adapter.ImgAddAdapter;
import com.wd.workoffice.util.DialogUtils; import com.wd.workoffice.util.DialogUtils;
import com.wd.workoffice.util.Glide4Engine;
import com.wd.workoffice.util.GlideUtils; import com.wd.workoffice.util.GlideUtils;
import com.wd.workoffice.util.WorkUtils; import com.wd.workoffice.util.WorkUtils;
import com.zhihu.matisse.Matisse;
import com.zhihu.matisse.MimeType;
import com.zhihu.matisse.internal.entity.CaptureStrategy;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
...@@ -46,7 +54,9 @@ import butterknife.BindView; ...@@ -46,7 +54,9 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import flexible.xd.android_base.network.rtfhttp.Transformer; import flexible.xd.android_base.network.rtfhttp.Transformer;
import flexible.xd.android_base.utils.FileUtils;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
import me.rosuh.filepicker.config.FilePickerManager;
import okhttp3.MediaType; import okhttp3.MediaType;
import okhttp3.MultipartBody; import okhttp3.MultipartBody;
import okhttp3.RequestBody; import okhttp3.RequestBody;
...@@ -154,6 +164,9 @@ public class MesTicketAddSummaryActivity extends WorkToolBarActivity { ...@@ -154,6 +164,9 @@ public class MesTicketAddSummaryActivity extends WorkToolBarActivity {
param.put("dataCollectionStatus", 1); param.put("dataCollectionStatus", 1);
annexList = new ArrayList<>(); annexList = new ArrayList<>();
imgList = new ArrayList<>(); imgList = new ArrayList<>();
ImageBean imageBean = new ImageBean();
imageBean.setUri(null);
imgList.add(imageBean);
imgAddAdapter = new ImgAddAdapter(R.layout.item_mes_ticket_img, imgList); imgAddAdapter = new ImgAddAdapter(R.layout.item_mes_ticket_img, imgList);
imgAddAdapter.bindToRecyclerView(rvPhoto); imgAddAdapter.bindToRecyclerView(rvPhoto);
annexAdapter = new AnnexAdapter(R.layout.item_mes_ticket_annex, annexList); annexAdapter = new AnnexAdapter(R.layout.item_mes_ticket_annex, annexList);
...@@ -162,6 +175,28 @@ public class MesTicketAddSummaryActivity extends WorkToolBarActivity { ...@@ -162,6 +175,28 @@ public class MesTicketAddSummaryActivity extends WorkToolBarActivity {
@Override @Override
protected void initEvent() { 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 (position==imgList.size()-1){
addImg();
}
}
});
annexAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
@Override
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
annexList.remove(position);
annexAdapter.notifyDataSetChanged();
}
});
} }
@Override @Override
...@@ -204,10 +239,11 @@ public class MesTicketAddSummaryActivity extends WorkToolBarActivity { ...@@ -204,10 +239,11 @@ public class MesTicketAddSummaryActivity extends WorkToolBarActivity {
public void onViewClicked(View view) { public void onViewClicked(View view) {
switch (view.getId()) { switch (view.getId()) {
case R.id.tv_upload: case R.id.tv_upload:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT); // Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE); // intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*"); // intent.setType("*/*");
startActivityForResult(intent, 10003); // startActivityForResult(intent, 10003);
addFile();
break; break;
case R.id.ll_design: case R.id.ll_design:
proDialog.show(); proDialog.show();
...@@ -232,8 +268,16 @@ public class MesTicketAddSummaryActivity extends WorkToolBarActivity { ...@@ -232,8 +268,16 @@ public class MesTicketAddSummaryActivity extends WorkToolBarActivity {
tvQualityPro.setText(choosePro.getProductName()); tvQualityPro.setText(choosePro.getProductName());
tvTechPro.setText(choosePro.getProductName()); tvTechPro.setText(choosePro.getProductName());
tvTryPro.setText(choosePro.getProductName()); tvTryPro.setText(choosePro.getProductName());
} else if (requestCode == 10003 && resultCode == RESULT_OK) { } else if (requestCode == 10002 && resultCode == RESULT_OK) {
upload(2, data.getData()); List<Uri> dataUri = Matisse.obtainResult(data);
for (Uri uri : dataUri) {
upload(1, uri);
}
} else if (requestCode == FilePickerManager.REQUEST_CODE && resultCode == RESULT_OK) {
List<String> annex = FilePickerManager.INSTANCE.obtainData();
for (String annexUri : annex) {
upload(2, annexUri);
}
} }
} }
...@@ -293,17 +337,66 @@ public class MesTicketAddSummaryActivity extends WorkToolBarActivity { ...@@ -293,17 +337,66 @@ public class MesTicketAddSummaryActivity extends WorkToolBarActivity {
}); });
} }
private void addImg() {
RxPermissions rxPermissions = new RxPermissions(this);
rxPermissions
.request(Manifest.permission.CAMERA,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
.subscribe(granted -> {
if (granted) {
// All requested permissions are granted
Matisse.from(MesTicketAddSummaryActivity.this)
.choose(MimeType.ofImage())
.countable(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(10002);
} else {
// At least one permission is denied
toast("您需要开启拍照、存储权限!");
}
});
}
private void addFile() {
RxPermissions rxPermissions = new RxPermissions(this);
rxPermissions
.request(Manifest.permission.CAMERA,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
.subscribe(granted -> {
if (granted) {
// All requested permissions are granted
FilePickerManager.INSTANCE
.from(this)
.forResult(FilePickerManager.REQUEST_CODE);
} else {
// At least one permission is denied
toast("您需要开启拍照、存储权限!");
}
});
}
/** /**
* type 1 图片 2 附件 * type 1 图片 2 附件
* *
* @param type * @param type
* @param uri * @param uri
*/ */
private void upload(int type, Uri uri) { private void upload(int type, Object uri) {
MediaType mediaType = type == 1 ? MediaType.parse("image/png") : MediaType.parse("text/plain");
showLoading(); showLoading();
File file = WorkUtils.uriToFile(uri, this); File file;
RequestBody requestFile = RequestBody.create(mediaType, file); if (uri instanceof Uri){
file = WorkUtils.uriToFile((Uri) uri, this);
}
else {
file =new File(uri.toString());
}
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file);
RtfUtils.getMesRtf(). RtfUtils.getMesRtf().
upload(MultipartBody.Part.createFormData("file", file.getName(), requestFile)). upload(MultipartBody.Part.createFormData("file", file.getName(), requestFile)).
compose(Transformer.schedule()).subscribe(new WorkObserver<BaseMesBean>() { compose(Transformer.schedule()).subscribe(new WorkObserver<BaseMesBean>() {
...@@ -321,18 +414,27 @@ public class MesTicketAddSummaryActivity extends WorkToolBarActivity { ...@@ -321,18 +414,27 @@ public class MesTicketAddSummaryActivity extends WorkToolBarActivity {
@Override @Override
public void onSuccess(BaseMesBean data) { public void onSuccess(BaseMesBean data) {
hideLoading(); hideLoading();
if (data.isSuccess()) { if (!data.isSuccess()) {
toast(data.getMessage()); toast(data.getMessage());
return; return;
} }
toast("上传成功"); toast("上传成功");
if (type == 1) { 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]);
if (type == 1) {
imgList.add(imgList.size()-1, imageBean);
imgAddAdapter.notifyDataSetChanged();
imageBean.setUri((Uri) uri);
} else { } else {
annexList.add(null); annexList.add(imageBean);
annexAdapter.notifyDataSetChanged(); annexAdapter.notifyDataSetChanged();
} }
} }
}); });
} }
} }
...@@ -16,6 +16,7 @@ import com.wd.workoffice.R; ...@@ -16,6 +16,7 @@ import com.wd.workoffice.R;
import com.wd.workoffice.app.BaseMesBean; import com.wd.workoffice.app.BaseMesBean;
import com.wd.workoffice.app.WorkToolBarActivity; import com.wd.workoffice.app.WorkToolBarActivity;
import com.wd.workoffice.bean.event.AddTicketEvent; import com.wd.workoffice.bean.event.AddTicketEvent;
import com.wd.workoffice.bean.mesBean.ImageBean;
import com.wd.workoffice.bean.mesBean.SummaryBean; import com.wd.workoffice.bean.mesBean.SummaryBean;
import com.wd.workoffice.bean.mesBean.TicketBean; import com.wd.workoffice.bean.mesBean.TicketBean;
import com.wd.workoffice.retrofit.RtfUtils; import com.wd.workoffice.retrofit.RtfUtils;
...@@ -111,7 +112,7 @@ public class MesTicketDetailFinishActivity extends WorkToolBarActivity { ...@@ -111,7 +112,7 @@ public class MesTicketDetailFinishActivity extends WorkToolBarActivity {
@BindView(R.id.tv_detail) @BindView(R.id.tv_detail)
TextView tvDetail; TextView tvDetail;
private SummaryBean dataBean; private SummaryBean dataBean;
private List<Object> imgList; private List<ImageBean> imgList;
private ImgAdapter imgAdapter; private ImgAdapter imgAdapter;
private TicketBean.ListBean data; private TicketBean.ListBean data;
...@@ -135,7 +136,6 @@ public class MesTicketDetailFinishActivity extends WorkToolBarActivity { ...@@ -135,7 +136,6 @@ public class MesTicketDetailFinishActivity extends WorkToolBarActivity {
imgList = new ArrayList<>(); imgList = new ArrayList<>();
imgAdapter = new ImgAdapter(R.layout.item_mes_ticket_img, imgList); imgAdapter = new ImgAdapter(R.layout.item_mes_ticket_img, imgList);
imgAdapter.bindToRecyclerView(rvImg); imgAdapter.bindToRecyclerView(rvImg);
imgAdapter.notifyDataSetChanged();
getData(); getData();
} }
...@@ -249,6 +249,8 @@ public class MesTicketDetailFinishActivity extends WorkToolBarActivity { ...@@ -249,6 +249,8 @@ public class MesTicketDetailFinishActivity extends WorkToolBarActivity {
tvTryPro.setText(dataBean.getProductsName()); tvTryPro.setText(dataBean.getProductsName());
} }
tvFinish.setText(dataBean.getCommunicativeSituation()); tvFinish.setText(dataBean.getCommunicativeSituation());
imgList.addAll(dataBean.getAttachments());
imgAdapter.notifyDataSetChanged();
} }
private void changView() { private void changView() {
......
package com.wd.workoffice.ui.adapter; package com.wd.workoffice.ui.adapter;
import android.net.Uri;
import android.widget.ImageView; import android.widget.ImageView;
import com.chad.library.adapter.base.BaseQuickAdapter; import com.chad.library.adapter.base.BaseQuickAdapter;
...@@ -21,11 +22,18 @@ public class ImgAddAdapter extends BaseQuickAdapter<ImageBean, BaseViewHolder> { ...@@ -21,11 +22,18 @@ public class ImgAddAdapter extends BaseQuickAdapter<ImageBean, BaseViewHolder> {
super(layoutResId, data); super(layoutResId, data);
} }
@Override @Override
protected void convert(BaseViewHolder helper, ImageBean item) { protected void convert(BaseViewHolder helper, ImageBean item) {
ImageView ivImg = helper.getView(R.id.iv_img); ImageView ivImg = helper.getView(R.id.iv_img);
GlideUtils.getRequest().load(item.getUrl()).into(ivImg); if (helper.getAdapterPosition() != getData().size() - 1) {
helper.setGone(R.id.iv_delete, true);
helper.addOnClickListener(R.id.iv_delete);
GlideUtils.getRequest().load(item.getUri()).into(ivImg);
} else {
helper.setGone(R.id.iv_delete, false);
GlideUtils.getRequest().load(R.mipmap.img_add).into(ivImg);
}
} }
} }
...@@ -593,6 +593,8 @@ ...@@ -593,6 +593,8 @@
android:id="@+id/tv_upload" android:id="@+id/tv_upload"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingHorizontal="20mm"
android:paddingVertical="13mm"
android:text="+ 上传附件" /> android:text="+ 上传附件" />
<TextView <TextView
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="6mm" android:layout_marginRight="6mm"
android:orientation="vertical"> android:orientation="vertical">
<ImageView
android:id="@+id/iv_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:visibility="gone"
android:src="@mipmap/img_delete" />
<ImageView <ImageView
android:id="@+id/iv_img" android:id="@+id/iv_img"
android:layout_width="104mm" android:layout_width="104mm"
android:layout_marginTop="5mm"
android:layout_height="104mm" android:layout_height="104mm"
android:src="@mipmap/ic_launcher" /> android:src="@mipmap/ic_launcher" />
</LinearLayout> </FrameLayout>
\ No newline at end of file \ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论