个人文档
This commit is contained in:
parent
2f721bf817
commit
e07f9b99ea
@ -241,4 +241,9 @@ public class PathConfig {
|
||||
public static final String PATH_MODULE_PAD_OA_FRAGMENT_WORK_REPORT = "/oamodule/fragment/workReport";//工作报告
|
||||
|
||||
public static final String PATH_MODULE_PAD_OA_FRAGMENT_MORE_FUNCTION = "/oamodule/fragment/functionList";//功能列表
|
||||
|
||||
public static final String PATH_MODULE_PAD_OA_FRAGMENT_DOCUMENT_ADD = "/oamodule/fragment/documentAdd";//文档添加
|
||||
public static final String PATH_MODULE_PAD_OA_FRAGMENT_DOCUMENT_DETAIL = "/oamodule/fragment/documentDetail";//文档详情
|
||||
public static final String PATH_MODULE_PAD_OA_FRAGMENT_DOCUMENT_EDIT = "/oamodule/fragment/documentEdit";//文档编辑
|
||||
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
|
||||
import com.bigkoo.pickerview.view.OptionsPickerView;
|
||||
import com.google.gson.Gson;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.leon.lfilepickerlibrary.LFilePicker;
|
||||
import com.leon.lfilepickerlibrary.utils.Constant;
|
||||
import com.tenlionsoft.baselib.constant.LionActions;
|
||||
import com.tenlionsoft.baselib.constant.PathConfig;
|
||||
@ -588,6 +589,21 @@ public class DocumentEditActivity extends BaseActivity {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void hasManageFileManage() {
|
||||
if (mFileMax == 0) {
|
||||
ToastUtils.show("超过最大上传数量限制");
|
||||
} else {
|
||||
new LFilePicker()
|
||||
.withActivity(this)
|
||||
.withRequestCode(LionActions.REQUEST_CODE_AC)
|
||||
.withTitle("文件选择")
|
||||
.withMaxNum(mFileMax)
|
||||
.withFileFilter(fileFilter)
|
||||
.start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建提交参数
|
||||
*/
|
||||
|
@ -424,7 +424,7 @@ public class PadMainActivity extends BaseActivity {
|
||||
*/
|
||||
public void addFragment(int source, BaseFragment fragment) {
|
||||
if (fragment != null) {
|
||||
mFragments.get(source).add(fragment);
|
||||
mFragments.get(mCurrentItem).add(fragment);
|
||||
switchFragment(fragment, "");
|
||||
} else {
|
||||
ToastUtils.show("未找到页面");
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.tenlionsoft.oamodule.pad.fragments;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -25,6 +24,7 @@ import com.tenlionsoft.baselib.constant.PathConfig;
|
||||
import com.tenlionsoft.baselib.core.retrofit_net.RetrofitManager;
|
||||
import com.tenlionsoft.baselib.core.retrofit_net.conver.RxTransformer;
|
||||
import com.tenlionsoft.baselib.core.widget.base.BaseFragment;
|
||||
import com.tenlionsoft.baselib.core.widget.base.FragmentUtils;
|
||||
import com.tenlionsoft.baselib.core.widget.views.CustomStateView;
|
||||
import com.tenlionsoft.baselib.core.widget.views.TextViewDrawable;
|
||||
import com.tenlionsoft.baselib.utils.ExceptionHandler;
|
||||
@ -32,20 +32,20 @@ import com.tenlionsoft.baselib.utils.LogUtils;
|
||||
import com.tenlionsoft.baselib.utils.UIUtil;
|
||||
import com.tenlionsoft.oamodule.R;
|
||||
import com.tenlionsoft.oamodule.R2;
|
||||
import com.tenlionsoft.oamodule.activity.document.DocumentAddActivity;
|
||||
import com.tenlionsoft.oamodule.activity.document.DocumentDetailActivity;
|
||||
import com.tenlionsoft.oamodule.adapter.DocumentAdapter;
|
||||
import com.tenlionsoft.oamodule.beans.DocTypeBean;
|
||||
import com.tenlionsoft.oamodule.beans.DocumentListBean;
|
||||
import com.tenlionsoft.oamodule.net.OAApi;
|
||||
import com.tenlionsoft.oamodule.pad.activitys.home.PadMainActivity;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.BindView;
|
||||
@ -102,6 +102,7 @@ public class PadDocFragment extends BaseFragment {
|
||||
private List<DocTypeBean> mDocTypes;
|
||||
private DocTypeBean mSelType;
|
||||
private ActivityResultLauncher<Intent> mLauncher;
|
||||
private PadMainActivity mMainActivity;
|
||||
|
||||
@Override
|
||||
protected int getContentViewId() {
|
||||
@ -142,10 +143,11 @@ public class PadDocFragment extends BaseFragment {
|
||||
mRlvDoc.setLayoutManager(new LinearLayoutManager(mActivity));
|
||||
mRlvDoc.setAdapter(mAdapter);
|
||||
mAdapter.addOnItemClickListener(rowsBean -> {
|
||||
Intent intent = new Intent(mActivity, DocumentDetailActivity.class);
|
||||
intent.putExtra("id", rowsBean.getFileUploadId());
|
||||
intent.putExtra("type", mType);
|
||||
mLauncher.launch(intent);
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("id", rowsBean.getFileUploadId());
|
||||
params.put("type", mType);
|
||||
BaseFragment fragment = FragmentUtils.getFragmentMap(PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_DOCUMENT_DETAIL, params);
|
||||
mMainActivity.addFragment(2, fragment);
|
||||
});
|
||||
|
||||
|
||||
@ -167,7 +169,10 @@ public class PadDocFragment extends BaseFragment {
|
||||
mKeywords = "";
|
||||
doRefresh();
|
||||
});
|
||||
mIvAdd.setOnClickListener(v -> mLauncher.launch(new Intent(mActivity, DocumentAddActivity.class)));
|
||||
mIvAdd.setOnClickListener(v -> {
|
||||
BaseFragment fragment = FragmentUtils.getFragment(PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_DOCUMENT_ADD);
|
||||
mMainActivity.addFragment(2, fragment);
|
||||
});
|
||||
mTvTitleType.setOnClickListener(v -> onShowDocType());
|
||||
mTvTitleType.setText("文档类型");
|
||||
doRefresh();
|
||||
@ -257,11 +262,7 @@ public class PadDocFragment extends BaseFragment {
|
||||
@Override
|
||||
public void onAttach(@androidx.annotation.NonNull @NotNull Context context) {
|
||||
super.onAttach(context);
|
||||
mLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
if (Activity.RESULT_OK == result.getResultCode()) {
|
||||
doRefresh();
|
||||
}
|
||||
});
|
||||
mMainActivity = (PadMainActivity) getActivity();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -339,6 +340,16 @@ public class PadDocFragment extends BaseFragment {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHiddenChanged(boolean hidden) {
|
||||
super.onHiddenChanged(hidden);
|
||||
if (!hidden) {
|
||||
if (mIsRefresh) {
|
||||
mIsRefresh = false;
|
||||
doRefresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void refreshView() {
|
||||
|
@ -0,0 +1,535 @@
|
||||
package com.tenlionsoft.oamodule.pad.fragments.document;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
|
||||
import com.bigkoo.pickerview.view.OptionsPickerView;
|
||||
import com.google.gson.Gson;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.leon.lfilepickerlibrary.LFilePicker;
|
||||
import com.leon.lfilepickerlibrary.utils.Constant;
|
||||
import com.tenlionsoft.baselib.constant.LionActions;
|
||||
import com.tenlionsoft.baselib.constant.PathConfig;
|
||||
import com.tenlionsoft.baselib.core.beans.AddFileBean;
|
||||
import com.tenlionsoft.baselib.core.beans.BaseSuccessBean;
|
||||
import com.tenlionsoft.baselib.core.beans.DicBean;
|
||||
import com.tenlionsoft.baselib.core.retrofit_net.BaseUrlApi;
|
||||
import com.tenlionsoft.baselib.core.retrofit_net.RetrofitManager;
|
||||
import com.tenlionsoft.baselib.core.retrofit_net.api.BaseApiService;
|
||||
import com.tenlionsoft.baselib.core.retrofit_net.conver.RxTransformer;
|
||||
import com.tenlionsoft.baselib.core.widget.base.AddFileAdapter;
|
||||
import com.tenlionsoft.baselib.core.widget.base.BaseFragment;
|
||||
import com.tenlionsoft.baselib.utils.ExceptionHandler;
|
||||
import com.tenlionsoft.baselib.utils.LogUtils;
|
||||
import com.tenlionsoft.baselib.utils.UIUtil;
|
||||
import com.tenlionsoft.oamodule.R;
|
||||
import com.tenlionsoft.oamodule.R2;
|
||||
import com.tenlionsoft.oamodule.beans.DocTypeBean;
|
||||
import com.tenlionsoft.oamodule.beans.SaveFileBean;
|
||||
import com.tenlionsoft.oamodule.net.OAApi;
|
||||
import com.tenlionsoft.oamodule.pad.activitys.home.PadMainActivity;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
/**
|
||||
* 作者: adam
|
||||
* 日期: 2022/5/10 - 15:56
|
||||
* 邮箱: itgaojian@163.com
|
||||
* 描述: 文档添加
|
||||
*/
|
||||
@Route(path = PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_DOCUMENT_ADD)
|
||||
public class DocumentAddFragment extends BaseFragment {
|
||||
|
||||
@BindView(R2.id.tv_doc_type)
|
||||
TextView mTvDocType;
|
||||
@BindView(R2.id.tv_file_type)
|
||||
TextView mTvFileType;
|
||||
@BindView(R2.id.rlv_files)
|
||||
RecyclerView mRlvFiles;
|
||||
@BindView(R2.id.et_summary)
|
||||
EditText mEtSummary;
|
||||
@BindView(R2.id.et_remark)
|
||||
EditText mEtRemark;
|
||||
@BindView(R2.id.btn_confirm)
|
||||
Button mBtnConfirm;
|
||||
private PadMainActivity mMainActivity;
|
||||
private String mDocType = "文件";
|
||||
private OptionsPickerView mDataSourcePicker;
|
||||
private List<DocTypeBean> mDocTypes;
|
||||
private DocTypeBean mSelType;
|
||||
private List<AddFileBean> mFileBeans = new ArrayList<>();
|
||||
private AddFileAdapter mAddFileAdapter;
|
||||
private String[] fileFilter = new String[]{".doc", ".docx", ".xls", ".xlsx", ".pptx", ".ppt", ".txt", ".pdf"};
|
||||
private int mFileMax = 9;
|
||||
|
||||
private List<DicBean> mFileTypeList;
|
||||
private OptionsPickerView<DicBean> mFileTypePicker;
|
||||
private ActivityResultLauncher<Intent> mFileLauncher;
|
||||
|
||||
@Override
|
||||
protected int getContentViewId() {
|
||||
return R.layout.fragment_document_add;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setDataToView(View dataView) {
|
||||
ButterKnife.bind(this, dataView);
|
||||
setTitleView(true);
|
||||
mTvFragmentTitle.setText("添加文档");
|
||||
mIvFragmentBack.setOnClickListener(v -> mMainActivity.backFragment(1, this));
|
||||
setStateView(STATE_SUCCESS);
|
||||
mSrlView.setEnableLoadMore(false);
|
||||
mSrlView.setEnableLoadMore(false);
|
||||
initViews();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull @NotNull Context context) {
|
||||
super.onAttach(context);
|
||||
mMainActivity = (PadMainActivity) getActivity();
|
||||
mFileLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
Intent data = result.getData();
|
||||
if (data != null) {
|
||||
ArrayList<String> paths = data.getStringArrayListExtra(Constant.RESULT_INFO);
|
||||
if (paths != null && paths.size() > 0) {
|
||||
doUploadFiles(paths);
|
||||
} else {
|
||||
ToastUtils.show("未选择文件");
|
||||
}
|
||||
} else {
|
||||
ToastUtils.show("路径有误,请稍后重试");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
mFileTypeList = new ArrayList<>();
|
||||
DicBean type1 = new DicBean();
|
||||
type1.setDataName("文件");
|
||||
type1.setDataId("文件");
|
||||
|
||||
DicBean type2 = new DicBean();
|
||||
type2.setDataName("图片");
|
||||
type2.setDataId("图片");
|
||||
|
||||
DicBean type3 = new DicBean();
|
||||
type3.setDataName("视频");
|
||||
type3.setDataId("视频");
|
||||
|
||||
DicBean type4 = new DicBean();
|
||||
type4.setDataName("音频");
|
||||
type4.setDataId("音频");
|
||||
|
||||
mFileTypeList.add(type1);
|
||||
mFileTypeList.add(type2);
|
||||
mFileTypeList.add(type3);
|
||||
mFileTypeList.add(type4);
|
||||
|
||||
mTvDocType.setOnClickListener(v -> onShowDocType());
|
||||
|
||||
mFileBeans.add(new AddFileBean());
|
||||
mAddFileAdapter = new AddFileAdapter(mActivity, mFileBeans);
|
||||
mAddFileAdapter.addOnItemClickListener(addFileBean -> {
|
||||
if (TextUtils.isEmpty(addFileBean.getId())) {
|
||||
checkManagePermission();
|
||||
} else {
|
||||
//TODO 预览
|
||||
}
|
||||
});
|
||||
//删除上传的文件
|
||||
mAddFileAdapter.addOnDeleteListener((bean, i) -> {
|
||||
//删除list中的某个数据
|
||||
mFileBeans.remove(i);
|
||||
mAddFileAdapter.notifyDataSetChanged();
|
||||
++mFileMax;
|
||||
});
|
||||
mRlvFiles.setLayoutManager(new LinearLayoutManager(mActivity));
|
||||
mRlvFiles.setAdapter(mAddFileAdapter);
|
||||
mBtnConfirm.setOnClickListener(v -> doSave());
|
||||
mTvFileType.setOnClickListener(v -> onShowFileType());
|
||||
mTvFileType.setText(mDocType);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void hasManageFileManage() {
|
||||
if (mFileMax == 0) {
|
||||
ToastUtils.show("超过最大上传数量限制");
|
||||
} else {
|
||||
new LFilePicker()
|
||||
.withFragmentLauncher(mFileLauncher)
|
||||
.withFragment(this)
|
||||
.withRequestCode(LionActions.REQUEST_CODE_AC)
|
||||
.withTitle("文件选择")
|
||||
.withMaxNum(mFileMax)
|
||||
.withFileFilter(fileFilter)
|
||||
.start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件类型选择
|
||||
*/
|
||||
private void onShowFileType() {
|
||||
if (mFileTypePicker == null) {
|
||||
mFileTypePicker = new OptionsPickerBuilder(mActivity, (o1, o2, o3, v) -> {
|
||||
//判断是否进行了切换
|
||||
if (mDocType.equals(mFileTypeList.get(o1).getDataId())) return;
|
||||
mDocType = mFileTypeList.get(o1).getDataId();
|
||||
mTvFileType.setText(mDocType);
|
||||
//判断当前文档是是否与选择的一致
|
||||
switch (mDocType) {
|
||||
case "文件":
|
||||
mDocType = "文件";
|
||||
fileFilter = new String[]{".doc", ".docx", ".xls", ".xlsx", ".pptx", ".ppt", ".txt", ".pdf"};
|
||||
mFileMax = 9;//9
|
||||
break;
|
||||
case "图片":
|
||||
mDocType = "图片";
|
||||
fileFilter = new String[]{".jpg", ".jpeg", ".png"};
|
||||
mFileMax = 20;//20
|
||||
break;
|
||||
case "视频":
|
||||
mDocType = "视频";
|
||||
fileFilter = new String[]{".mp4", ".avi", ".mkv", ".flv"};
|
||||
mFileMax = 5;//5
|
||||
break;
|
||||
case "音频":
|
||||
mDocType = "音频";
|
||||
fileFilter = new String[]{".mp3", ".wmv", ".amr"};
|
||||
mFileMax = 5;//5
|
||||
break;
|
||||
}
|
||||
mFileBeans.clear();
|
||||
mFileBeans.add(new AddFileBean());
|
||||
mAddFileAdapter.notifyDataSetChanged();
|
||||
})
|
||||
.setTitleText("请选择")
|
||||
.setCancelColor(Color.parseColor("#1189FF"))
|
||||
.setSubmitColor(Color.parseColor("#1189FF"))
|
||||
.setTitleColor(Color.parseColor("#1189FF"))
|
||||
.build();
|
||||
mFileTypePicker.setPicker(mFileTypeList);
|
||||
}
|
||||
mFileTypePicker.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存文件
|
||||
*/
|
||||
private void doSave() {
|
||||
if (checkParams()) {
|
||||
RequestBody body = buildParams();
|
||||
ProgressDialog dialog = UIUtil.initDialog(mActivity, "保存中...");
|
||||
dialog.show();
|
||||
RetrofitManager.getInstance()
|
||||
.create(OAApi.class)
|
||||
.doSaveFiles(body)
|
||||
.compose(RxTransformer.getTransformer())
|
||||
.subscribe(new Observer<BaseSuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@io.reactivex.rxjava3.annotations.NonNull BaseSuccessBean baseSuccessBean) {
|
||||
if (dialog.isShowing()) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
ToastUtils.show("保存成功");
|
||||
BaseFragment preFragment = mMainActivity.getPreFragment();
|
||||
if (preFragment != null) {
|
||||
preFragment.mIsRefresh = true;
|
||||
}
|
||||
mMainActivity.backFragment(1, DocumentAddFragment.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||
if (dialog.isShowing()) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param paths
|
||||
*/
|
||||
private int mUploadCount = 0;
|
||||
|
||||
private void doUploadFiles(ArrayList<String> paths) {
|
||||
LogUtils.e(paths);
|
||||
|
||||
ProgressDialog progressDialog = UIUtil.initDialog(mActivity, "上传中...");
|
||||
progressDialog.show();
|
||||
List<Observable> requests = new ArrayList<>();
|
||||
List<String> fileNames = new ArrayList<>();
|
||||
for (int i = 0; i < paths.size(); i++) {
|
||||
File file = new File(paths.get(i));
|
||||
Observable observable = createObservable(file);
|
||||
if (observable == null) return;
|
||||
requests.add(observable);
|
||||
fileNames.add(file.getName());
|
||||
}
|
||||
Observable<BaseSuccessBean>[] observables1 = requests.toArray(new Observable[requests.size()]);
|
||||
|
||||
Observable.mergeArrayDelayError(observables1)
|
||||
.compose(RxTransformer.getTransformer())
|
||||
.subscribe(new Observer() {
|
||||
@Override
|
||||
public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull Object o) {
|
||||
++mUploadCount;
|
||||
if (o instanceof BaseSuccessBean) {
|
||||
--mFileMax;
|
||||
//刷新文件
|
||||
BaseSuccessBean bean = (BaseSuccessBean) o;
|
||||
AddFileBean fileBean = new AddFileBean();
|
||||
fileBean.setId(bean.getData());
|
||||
fileBean.setPath(BaseUrlApi.BASE_IMG_URL + bean.getData());
|
||||
fileBean.setFileName(fileNames.get(mUploadCount - 1));
|
||||
// 判断文件类型
|
||||
if ("文件".equals(mDocType)) {
|
||||
fileBean.setFileType(1);
|
||||
} else if ("图片".equals(mDocType)) {
|
||||
fileBean.setFileType(2);
|
||||
} else if ("视频".equals(mDocType)) {
|
||||
fileBean.setFileType(3);
|
||||
} else if ("音频".equals(mDocType)) {
|
||||
fileBean.setFileType(4);
|
||||
}
|
||||
mFileBeans.add(0, fileBean);
|
||||
}
|
||||
mAddFileAdapter.notifyDataSetChanged();
|
||||
if (mUploadCount == paths.size()) {
|
||||
mUploadCount = 0;
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||
e.printStackTrace();
|
||||
mUploadCount = 0;
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ToastUtils.show("上传失败,请稍后重试.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Observable createObservable(File file) {
|
||||
LogUtils.e(file.exists());
|
||||
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file);
|
||||
MultipartBody.Part body;
|
||||
if ("文件".equals(mDocType)) {
|
||||
body = MultipartBody.Part.createFormData("file", file.getName(), requestFile);
|
||||
return RetrofitManager.getInstance()
|
||||
.create(BaseApiService.class)
|
||||
.uploadFile(body)
|
||||
.compose(RxTransformer.getTransformer());
|
||||
|
||||
} else if ("图片".equals(mDocType)) {
|
||||
|
||||
body = MultipartBody.Part.createFormData("image", file.getName(), requestFile);
|
||||
return RetrofitManager.getInstance()
|
||||
.create(BaseApiService.class)
|
||||
.uploadImage(body)
|
||||
.compose(RxTransformer.getTransformer());
|
||||
|
||||
} else if ("视频".equals(mDocType)) {
|
||||
|
||||
body = MultipartBody.Part.createFormData("video", file.getName(), requestFile);
|
||||
return RetrofitManager.getInstance()
|
||||
.create(BaseApiService.class)
|
||||
.uploadVideo(body)
|
||||
.compose(RxTransformer.getTransformer());
|
||||
|
||||
} else if ("音频".equals(mDocType)) {
|
||||
body = MultipartBody.Part.createFormData("audio", file.getName(), requestFile);
|
||||
|
||||
return RetrofitManager.getInstance()
|
||||
.create(BaseApiService.class)
|
||||
.uploadAudio(body)
|
||||
.compose(RxTransformer.getTransformer());
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示文档类型
|
||||
*/
|
||||
private void onShowDocType() {
|
||||
mActivity.hideSoftKeyboard();
|
||||
if (mDocTypes != null && mDocTypes.size() > 0) {
|
||||
if (mDataSourcePicker == null) {
|
||||
mDataSourcePicker = new OptionsPickerBuilder(mActivity, (o1, o2, o3, v) -> {
|
||||
mSelType = mDocTypes.get(o1);
|
||||
mTvDocType.setText(mSelType.getTypeName());
|
||||
})
|
||||
.setTitleText("请选择")
|
||||
.setCancelColor(Color.parseColor("#1189FF"))
|
||||
.setSubmitColor(Color.parseColor("#1189FF"))
|
||||
.setTitleColor(Color.parseColor("#1189FF"))
|
||||
.build();
|
||||
mDataSourcePicker.setPicker(mDocTypes);
|
||||
}
|
||||
mDataSourcePicker.show();
|
||||
} else {
|
||||
getDocTypes();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档类型
|
||||
*/
|
||||
private void getDocTypes() {
|
||||
ProgressDialog dialog = UIUtil.initDialog(mActivity, "加载中...");
|
||||
dialog.show();
|
||||
RetrofitManager.getInstance()
|
||||
.create(OAApi.class)
|
||||
.getDocTypes()
|
||||
.compose(RxTransformer.getTransformer())
|
||||
.subscribe(new Observer<List<DocTypeBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@io.reactivex.rxjava3.annotations.NonNull List<DocTypeBean> docTypeBeans) {
|
||||
dialog.dismiss();
|
||||
if (docTypeBeans.size() > 0) {
|
||||
mDocTypes = docTypeBeans;
|
||||
onShowDocType();
|
||||
} else {
|
||||
ToastUtils.show("暂无数据");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||
dialog.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean checkParams() {
|
||||
if (mSelType == null) {
|
||||
ToastUtils.show("请选择文档类型");
|
||||
return false;
|
||||
}
|
||||
LogUtils.e(mFileBeans.size());
|
||||
if (mFileBeans.size() < 2) {
|
||||
ToastUtils.show("请上传文件");
|
||||
return false;
|
||||
}
|
||||
String summary = mEtSummary.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(summary)) {
|
||||
ToastUtils.show("请输入文件说明");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建提交参数
|
||||
*/
|
||||
private RequestBody buildParams() {
|
||||
SaveFileBean fileBean = new SaveFileBean();
|
||||
fileBean.setFileType(mDocType);
|
||||
fileBean.setFileTypeId(mSelType.getFileTypeId());
|
||||
if (mFileBeans.size() == 2) {
|
||||
fileBean.setFileModular("单文件");
|
||||
} else {
|
||||
fileBean.setFileModular("多文件");
|
||||
}
|
||||
|
||||
StringBuilder fileId = new StringBuilder();
|
||||
for (AddFileBean bean : mFileBeans) {
|
||||
if (!TextUtils.isEmpty(bean.getId())) {
|
||||
fileId.append(bean.getId()).append(",");
|
||||
}
|
||||
}
|
||||
if (fileId.toString().endsWith(",")) {
|
||||
fileId = new StringBuilder(fileId.substring(0, fileId.length() - 1));
|
||||
}
|
||||
fileBean.setFileId(fileId.toString());
|
||||
String summary = mEtSummary.getText().toString().trim();
|
||||
fileBean.setContent(summary);
|
||||
String remark = mEtRemark.getText().toString().trim();
|
||||
fileBean.setRemake(remark);
|
||||
Gson gson = new Gson();
|
||||
String obj = gson.toJson(fileBean);
|
||||
return RequestBody.create(obj, MediaType.parse("application/json; charset=utf-8"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void refreshView() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadMoreData() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,444 @@
|
||||
package com.tenlionsoft.oamodule.pad.fragments.document;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.google.gson.Gson;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.tenlionsoft.baselib.constant.PathConfig;
|
||||
import com.tenlionsoft.baselib.core.beans.AddFileBean;
|
||||
import com.tenlionsoft.baselib.core.beans.BaseSuccessBean;
|
||||
import com.tenlionsoft.baselib.core.retrofit_net.BaseUrlApi;
|
||||
import com.tenlionsoft.baselib.core.retrofit_net.RetrofitManager;
|
||||
import com.tenlionsoft.baselib.core.retrofit_net.api.BaseApiService;
|
||||
import com.tenlionsoft.baselib.core.retrofit_net.bean.FileInfoBean;
|
||||
import com.tenlionsoft.baselib.core.retrofit_net.conver.RxTransformer;
|
||||
import com.tenlionsoft.baselib.core.widget.base.AddFileAdapter;
|
||||
import com.tenlionsoft.baselib.core.widget.base.BaseFragment;
|
||||
import com.tenlionsoft.baselib.core.widget.base.FragmentUtils;
|
||||
import com.tenlionsoft.baselib.core.widget.views.ShareDocDialog;
|
||||
import com.tenlionsoft.baselib.utils.ExceptionHandler;
|
||||
import com.tenlionsoft.baselib.utils.UIUtil;
|
||||
import com.tenlionsoft.oamodule.R;
|
||||
import com.tenlionsoft.oamodule.R2;
|
||||
import com.tenlionsoft.oamodule.activity.car.ChooseUserActivity;
|
||||
import com.tenlionsoft.oamodule.beans.DocumentDetailBean;
|
||||
import com.tenlionsoft.oamodule.beans.SaveDocShareBean;
|
||||
import com.tenlionsoft.oamodule.net.OAApi;
|
||||
import com.tenlionsoft.oamodule.pad.activitys.home.PadMainActivity;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
import static com.tenlionsoft.baselib.core.widget.PhotoActivity.TAG_IMGURL;
|
||||
|
||||
/**
|
||||
* 作者: adam
|
||||
* 日期: 2022/5/10 - 16:30
|
||||
* 邮箱: itgaojian@163.com
|
||||
* 描述: 平板文档详情
|
||||
*/
|
||||
@Route(path = PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_DOCUMENT_DETAIL)
|
||||
public class DocumentDetailFragment extends BaseFragment {
|
||||
@BindView(R2.id.tv_doc_type)
|
||||
TextView mTvDocType;
|
||||
@BindView(R2.id.tv_file_type)
|
||||
TextView mTvFileType;
|
||||
@BindView(R2.id.rlv_files)
|
||||
RecyclerView mRlvFiles;
|
||||
@BindView(R2.id.tv_summary)
|
||||
TextView mTvSummary;
|
||||
@BindView(R2.id.tv_remark)
|
||||
TextView mTvRemark;
|
||||
@BindView(R2.id.btn_del)
|
||||
Button mBtnDel;
|
||||
@BindView(R2.id.btn_edit)
|
||||
Button mBtnEdit;
|
||||
@BindView(R2.id.btn_share)
|
||||
Button mBtnShare;
|
||||
private String mId;
|
||||
private DocumentDetailBean mDetailBean;
|
||||
private ShareDocDialog mDialog;
|
||||
private String mSelUserIds;
|
||||
private String mSelUserNames;
|
||||
private String mType;
|
||||
private PadMainActivity mMainActivity;
|
||||
private ActivityResultLauncher<Intent> mShareLauncher;
|
||||
|
||||
@Override
|
||||
protected int getContentViewId() {
|
||||
return R.layout.fragment_document_detail;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setDataToView(View dataView) {
|
||||
ButterKnife.bind(this, dataView);
|
||||
setTitleView(true);
|
||||
mTvFragmentTitle.setText("文档详情");
|
||||
mIvFragmentBack.setOnClickListener(v -> mMainActivity.backFragment(2, this));
|
||||
Bundle bundle = getArguments();
|
||||
if (bundle != null) {
|
||||
mId = bundle.getString("id");
|
||||
mType = bundle.getString("type");
|
||||
}
|
||||
if (TextUtils.isEmpty(mId)) {
|
||||
ToastUtils.show("文档数据有误");
|
||||
mMainActivity.backFragment(2, this);
|
||||
} else {
|
||||
getDocumentDetail();
|
||||
}
|
||||
|
||||
mBtnDel.setOnClickListener(v -> onShowConfirm());//删除
|
||||
mBtnEdit.setOnClickListener(v -> {
|
||||
BaseFragment fragment = FragmentUtils.getFragmentOne(PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_DOCUMENT_EDIT, "id", mId);
|
||||
mMainActivity.addFragment(2, fragment);
|
||||
});//编辑
|
||||
mBtnShare.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(mActivity, ChooseUserActivity.class);
|
||||
intent.putExtra("isSingle", false);
|
||||
mShareLauncher.launch(intent);
|
||||
});//分享
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@androidx.annotation.NonNull @NotNull Context context) {
|
||||
super.onAttach(context);
|
||||
mMainActivity = (PadMainActivity) getActivity();
|
||||
mShareLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
Intent data = result.getData();
|
||||
if (data != null) {
|
||||
mSelUserIds = data.getStringExtra("id");
|
||||
mSelUserNames = data.getStringExtra("name");
|
||||
if (!TextUtils.isEmpty(mSelUserIds)) {
|
||||
if ("个人文档".equals(mDetailBean.getCatalogueType())) {
|
||||
doShare(mSelUserIds, "", "", "", "");
|
||||
} else if ("公共文档".equals(mDetailBean.getCatalogueType())) {
|
||||
if (mDialog != null && mDialog.isShowing()) {
|
||||
mDialog.setNames(mSelUserIds, mSelUserNames);
|
||||
} else {
|
||||
showShare();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ToastUtils.show("请选择要分享的人员");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showShare() {
|
||||
mDialog = new ShareDocDialog.DialogBuilder(mActivity).build();
|
||||
mDialog.addOnChangeListener(new ShareDocDialog.OnChangeListener() {
|
||||
@Override
|
||||
public void doChange(String ids, String add, String edit, String del, String share) {
|
||||
mDialog.dismiss();
|
||||
doShare(ids, add, edit, del, share);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doSel() {
|
||||
Intent intent = new Intent(mActivity, ChooseUserActivity.class);
|
||||
intent.putExtra("isSingle", false);
|
||||
mShareLauncher.launch(intent);
|
||||
}
|
||||
});
|
||||
mDialog.show();
|
||||
mDialog.setNames(mSelUserIds, mSelUserNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分享成功
|
||||
*/
|
||||
private void doShare(String ids, String add, String edit, String del, String share) {
|
||||
ProgressDialog dialog = UIUtil.initDialog(mActivity, "共享中...");
|
||||
dialog.show();
|
||||
RequestBody body = buildShareParams(ids, add, edit, del, share);
|
||||
RetrofitManager.getInstance()
|
||||
.create(OAApi.class)
|
||||
.doShareDoc(body)
|
||||
.compose(RxTransformer.getTransformer())
|
||||
.subscribe(new Observer<BaseSuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseSuccessBean baseSuccessBean) {
|
||||
if (dialog.isShowing()) dialog.dismiss();
|
||||
ToastUtils.show("共享成功");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
if (dialog.isShowing()) dialog.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private RequestBody buildShareParams(String ids, String add, String edit, String del, String share) {
|
||||
SaveDocShareBean bean = new SaveDocShareBean();
|
||||
bean.setUserId(ids);
|
||||
bean.setFileUploadId(mId);
|
||||
bean.setAddRole(add);
|
||||
bean.setDelRole(del);
|
||||
bean.setEditRole(edit);
|
||||
bean.setShareRole(share);
|
||||
return RequestBody.create(new Gson().toJson(bean), MediaType.parse("application/json; charset=utf-8"));
|
||||
}
|
||||
|
||||
private void onShowConfirm() {
|
||||
new AlertDialog.Builder(mActivity)
|
||||
.setTitle("提示")
|
||||
.setMessage("确定要删除该文档吗?")
|
||||
.setPositiveButton("确定", (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
doDelDoc();
|
||||
})
|
||||
.setNegativeButton("取消", (dialog, which) -> dialog.dismiss())
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除文档
|
||||
*/
|
||||
private void doDelDoc() {
|
||||
ProgressDialog dialog = UIUtil.initDialog(mActivity, "删除中...");
|
||||
dialog.show();
|
||||
RetrofitManager.getInstance()
|
||||
.create(OAApi.class)
|
||||
.doDelDoc(mId)
|
||||
.compose(RxTransformer.getTransformer())
|
||||
.subscribe(new Observer<BaseSuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseSuccessBean baseSuccessBean) {
|
||||
if (dialog.isShowing()) dialog.dismiss();
|
||||
ToastUtils.show("删除成功");
|
||||
BaseFragment preFragment = mMainActivity.getPreFragment();
|
||||
if (preFragment != null) {
|
||||
preFragment.mIsRefresh = true;
|
||||
}
|
||||
mMainActivity.backFragment(2, DocumentDetailFragment.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
if (dialog.isShowing()) dialog.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档详情
|
||||
*/
|
||||
private void getDocumentDetail() {
|
||||
RetrofitManager.getInstance()
|
||||
.create(OAApi.class)
|
||||
.getDocumentDetail(mId)
|
||||
.compose(RxTransformer.getTransformer())
|
||||
.subscribe(new Observer<DocumentDetailBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull DocumentDetailBean documentDetailBean) {
|
||||
setDataToView(documentDetailBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
ExceptionHandler.handleException(e);
|
||||
setStateView(STATE_ERROR);
|
||||
mSrlView.setEnableLoadMore(false);
|
||||
mSrlView.setEnableRefresh(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 回显数据
|
||||
*/
|
||||
private void setDataToView(DocumentDetailBean documentDetailBean) {
|
||||
setStateView(STATE_SUCCESS);
|
||||
mSrlView.setEnableLoadMore(false);
|
||||
mSrlView.setEnableRefresh(false);
|
||||
mDetailBean = documentDetailBean;
|
||||
mTvDocType.setText(mDetailBean.getFileTypeName());
|
||||
mTvFileType.setText(mDetailBean.getFileType());
|
||||
//回显文件数据
|
||||
List<AddFileBean> files = new ArrayList<>();
|
||||
String[] split = mDetailBean.getFileId().split(",");
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
AddFileBean bean = new AddFileBean();
|
||||
bean.setId(split[i]);
|
||||
bean.setPath(BaseUrlApi.BASE_IMG_URL + split[i]);
|
||||
switch (mDetailBean.getFileType()) {
|
||||
case "文件":
|
||||
bean.setFileType(1);
|
||||
break;
|
||||
case "图片":
|
||||
bean.setFileType(2);
|
||||
break;
|
||||
case "视频":
|
||||
bean.setFileType(3);
|
||||
break;
|
||||
case "音频":
|
||||
bean.setFileType(4);
|
||||
break;
|
||||
}
|
||||
files.add(bean);
|
||||
}
|
||||
doGetFileInfos(mDetailBean.getFileId(), files);
|
||||
|
||||
mTvSummary.setText(Html.fromHtml(mDetailBean.getContent()));
|
||||
mTvRemark.setText(Html.fromHtml(mDetailBean.getRemake()));
|
||||
|
||||
if ("个人文档".equals(mType)) {
|
||||
mBtnDel.setVisibility(View.VISIBLE);
|
||||
mBtnEdit.setVisibility(View.VISIBLE);
|
||||
mBtnShare.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if ("是".equals(mDetailBean.getDelRole())) mBtnDel.setVisibility(View.VISIBLE);
|
||||
if ("是".equals(mDetailBean.getEditRole())) mBtnEdit.setVisibility(View.VISIBLE);
|
||||
if ("是".equals(mDetailBean.getShareRole())) mBtnShare.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void doGetFileInfos(String fileId, List<AddFileBean> files) {
|
||||
ProgressDialog dialog = UIUtil.initDialog(mActivity, "获取中...");
|
||||
dialog.show();
|
||||
RetrofitManager.getInstance()
|
||||
.create(BaseApiService.class)
|
||||
.getFileInfoList(fileId)
|
||||
.compose(RxTransformer.getTransformer())
|
||||
.subscribe(new Observer<List<FileInfoBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull List<FileInfoBean> fileInfoBeans) {
|
||||
if (dialog.isShowing()) dialog.dismiss();
|
||||
if (fileInfoBeans.size() > 0) {
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
for (int j = 0; j < fileInfoBeans.size(); j++) {
|
||||
if (files.get(i).getId().equals(fileInfoBeans.get(j).getFileId())) {
|
||||
files.get(i).setFileName(fileInfoBeans.get(j).getFileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
AddFileAdapter adapter = new AddFileAdapter(mActivity, files);
|
||||
mRlvFiles.setLayoutManager(new LinearLayoutManager(mActivity));
|
||||
mRlvFiles.setAdapter(adapter);
|
||||
adapter.addOnItemClickListener(addFileBean -> {
|
||||
if (addFileBean.getFileType() == 1) {
|
||||
//文档
|
||||
ARouter.getInstance()
|
||||
.build(PathConfig.PATH_MODULE_BASELIB_ACTIVITY_PREVIEW_FILE)
|
||||
.withString("fileName", addFileBean.getFileName())
|
||||
.withString("fileId", addFileBean.getId())
|
||||
.navigation();
|
||||
} else if (2 == addFileBean.getFileType()) {
|
||||
//图片预览
|
||||
//遍历文件获取所有图片文件
|
||||
ArrayList<String> imgUrls = new ArrayList<>();
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
AddFileBean fileBean = files.get(i);
|
||||
String url = BaseUrlApi.BASE_IMG_URL + fileBean.getId();
|
||||
imgUrls.add(url);
|
||||
}
|
||||
ARouter.getInstance()
|
||||
.build(PathConfig.PATH_MODULE_BASELIB_SHOW_IMG)
|
||||
.withStringArrayList(TAG_IMGURL, imgUrls)
|
||||
.navigation();
|
||||
} else if (3 == addFileBean.getFileType() || 4 == addFileBean.getFileType()) {
|
||||
//TODO 视频或音频预览
|
||||
ARouter.getInstance()
|
||||
.build(PathConfig.PATH_MODULE_PLAYER_SIMPLE_VIDEO)
|
||||
.withString("title", addFileBean.getFileName().substring(0, addFileBean.getFileName().lastIndexOf(".")))
|
||||
.withString("url", BaseUrlApi.BASE_IMG_URL + addFileBean.getId())
|
||||
.withString("type", addFileBean.getFileType() == 4 ? "audio" : "video")
|
||||
.navigation();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ToastUtils.show("未找到文档信息");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
if (dialog.isShowing()) dialog.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void refreshView() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadMoreData() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,669 @@
|
||||
package com.tenlionsoft.oamodule.pad.fragments.document;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
|
||||
import com.bigkoo.pickerview.view.OptionsPickerView;
|
||||
import com.google.gson.Gson;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.leon.lfilepickerlibrary.LFilePicker;
|
||||
import com.leon.lfilepickerlibrary.utils.Constant;
|
||||
import com.tenlionsoft.baselib.constant.LionActions;
|
||||
import com.tenlionsoft.baselib.constant.PathConfig;
|
||||
import com.tenlionsoft.baselib.core.beans.AddFileBean;
|
||||
import com.tenlionsoft.baselib.core.beans.BaseSuccessBean;
|
||||
import com.tenlionsoft.baselib.core.beans.DicBean;
|
||||
import com.tenlionsoft.baselib.core.retrofit_net.BaseUrlApi;
|
||||
import com.tenlionsoft.baselib.core.retrofit_net.RetrofitManager;
|
||||
import com.tenlionsoft.baselib.core.retrofit_net.api.BaseApiService;
|
||||
import com.tenlionsoft.baselib.core.retrofit_net.bean.FileInfoBean;
|
||||
import com.tenlionsoft.baselib.core.retrofit_net.conver.RxTransformer;
|
||||
import com.tenlionsoft.baselib.core.widget.base.AddFileAdapter;
|
||||
import com.tenlionsoft.baselib.core.widget.base.BaseFragment;
|
||||
import com.tenlionsoft.baselib.utils.ExceptionHandler;
|
||||
import com.tenlionsoft.baselib.utils.FileUtils;
|
||||
import com.tenlionsoft.baselib.utils.LogUtils;
|
||||
import com.tenlionsoft.baselib.utils.UIUtil;
|
||||
import com.tenlionsoft.oamodule.R;
|
||||
import com.tenlionsoft.oamodule.R2;
|
||||
import com.tenlionsoft.oamodule.beans.DocTypeBean;
|
||||
import com.tenlionsoft.oamodule.beans.DocumentDetailBean;
|
||||
import com.tenlionsoft.oamodule.beans.SaveFileBean;
|
||||
import com.tenlionsoft.oamodule.net.OAApi;
|
||||
import com.tenlionsoft.oamodule.pad.activitys.home.PadMainActivity;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
/**
|
||||
* 作者: adam
|
||||
* 日期: 2022/5/10 - 16:40
|
||||
* 邮箱: itgaojian@163.com
|
||||
* 描述:
|
||||
*/
|
||||
@Route(path = PathConfig.PATH_MODULE_PAD_OA_FRAGMENT_DOCUMENT_EDIT)
|
||||
public class DocumentEditFragment extends BaseFragment {
|
||||
|
||||
@BindView(R2.id.tv_doc_type)
|
||||
TextView mTvDocType;
|
||||
@BindView(R2.id.tv_file_type)
|
||||
TextView mTvFileType;
|
||||
@BindView(R2.id.rlv_files)
|
||||
RecyclerView mRlvFiles;
|
||||
@BindView(R2.id.et_summary)
|
||||
EditText mEtSummary;
|
||||
@BindView(R2.id.et_remark)
|
||||
EditText mEtRemark;
|
||||
@BindView(R2.id.btn_confirm)
|
||||
Button mBtnConfirm;
|
||||
private PadMainActivity mMainActivity;
|
||||
private String mDocType = "文件";
|
||||
private OptionsPickerView mDataSourcePicker;
|
||||
private List<DocTypeBean> mDocTypes;
|
||||
private DocTypeBean mSelType;
|
||||
private List<AddFileBean> mFileBeans = new ArrayList<>();
|
||||
private AddFileAdapter mAddFileAdapter;
|
||||
private String[] fileFilter = new String[]{".doc", ".docx", ".xls", ".xlsx", ".pptx", ".ppt", ".txt", ".pdf"};
|
||||
private int mFileMax = 9;
|
||||
private String mId;
|
||||
private DocumentDetailBean mDetailBean;
|
||||
|
||||
private List<DicBean> mFileTypeList;
|
||||
private OptionsPickerView<DicBean> mFileTypePicker;
|
||||
private ActivityResultLauncher<Intent> mFileLauncher;
|
||||
|
||||
@Override
|
||||
protected int getContentViewId() {
|
||||
return R.layout.fragment_document_edit;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setDataToView(View dataView) {
|
||||
ButterKnife.bind(this, dataView);
|
||||
setTitleView(true);
|
||||
mTvFragmentTitle.setText("文档编辑");
|
||||
mIvFragmentBack.setOnClickListener(v -> mMainActivity.backFragment(2, this));
|
||||
Bundle bundle = getArguments();
|
||||
if (bundle != null) {
|
||||
mId = bundle.getString("id");
|
||||
}
|
||||
initViews();
|
||||
if (TextUtils.isEmpty(mId)) {
|
||||
ToastUtils.show("数据有误");
|
||||
mMainActivity.backFragment(2, this);
|
||||
} else {
|
||||
getDocDetail();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull @NotNull Context context) {
|
||||
super.onAttach(context);
|
||||
mMainActivity = (PadMainActivity) getActivity();
|
||||
mFileLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||
Intent data = result.getData();
|
||||
if (data != null) {
|
||||
ArrayList<String> paths = data.getStringArrayListExtra(Constant.RESULT_INFO);
|
||||
if (paths != null && paths.size() > 0) {
|
||||
doUploadFiles(paths);
|
||||
} else {
|
||||
ToastUtils.show("未选择文件");
|
||||
}
|
||||
} else {
|
||||
ToastUtils.show("路径有误,请稍后重试");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void hasManageFileManage() {
|
||||
if (mFileMax == 0) {
|
||||
ToastUtils.show("超过最大上传数量限制");
|
||||
} else {
|
||||
new LFilePicker()
|
||||
.withFragmentLauncher(mFileLauncher)
|
||||
.withFragment(this)
|
||||
.withRequestCode(LionActions.REQUEST_CODE_AC)
|
||||
.withTitle("文件选择")
|
||||
.withMaxNum(mFileMax)
|
||||
.withFileFilter(fileFilter)
|
||||
.start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档详情
|
||||
*/
|
||||
private void getDocDetail() {
|
||||
RetrofitManager.getInstance()
|
||||
.create(OAApi.class)
|
||||
.getDocumentDetail(mId)
|
||||
.compose(RxTransformer.getTransformer())
|
||||
.subscribe(new Observer<DocumentDetailBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@io.reactivex.rxjava3.annotations.NonNull DocumentDetailBean documentDetailBean) {
|
||||
setDataToView(documentDetailBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||
setStateView(STATE_ERROR);
|
||||
mSrlView.setEnableRefresh(false);
|
||||
mSrlView.setEnableLoadMore(false);
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setDataToView(DocumentDetailBean bean) {
|
||||
setStateView(STATE_SUCCESS);
|
||||
mSrlView.setEnableLoadMore(false);
|
||||
mSrlView.setEnableRefresh(false);
|
||||
mDetailBean = bean;
|
||||
mTvDocType.setText(mDetailBean.getFileTypeName());
|
||||
mSelType = new DocTypeBean();
|
||||
mSelType.setTypeName(mDetailBean.getFileTypeName());
|
||||
mSelType.setFileTypeId(mDetailBean.getFileTypeId());
|
||||
|
||||
mDocType = mDetailBean.getFileType();
|
||||
switch (mDetailBean.getFileType()) {
|
||||
case "文件":
|
||||
mDocType = "文件";
|
||||
fileFilter = new String[]{".doc", ".docx", ".xls", ".xlsx", ".pptx", ".ppt", ".txt", ".pdf"};
|
||||
mFileMax = 9;//9
|
||||
break;
|
||||
case "图片":
|
||||
mDocType = "图片";
|
||||
fileFilter = new String[]{".jpg", ".jpeg", ".png"};
|
||||
mFileMax = 20;//20
|
||||
break;
|
||||
case "视频":
|
||||
mDocType = "视频";
|
||||
fileFilter = new String[]{".mp4", ".avi", ".mkv", ".flv"};
|
||||
mFileMax = 5;//5
|
||||
break;
|
||||
case "音频":
|
||||
mDocType = "音频";
|
||||
fileFilter = new String[]{".mp3", ".wmv", ".amr"};
|
||||
mFileMax = 5;//5
|
||||
break;
|
||||
}
|
||||
//回显文件数据
|
||||
doGetFileInfo(mDetailBean.getFileId());
|
||||
mEtSummary.setText(Html.fromHtml(mDetailBean.getContent()));
|
||||
mEtRemark.setText(Html.fromHtml(mDetailBean.getRemake()));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件详细信息
|
||||
*/
|
||||
private void doGetFileInfo(String fileId) {
|
||||
ProgressDialog dialog = UIUtil.initDialog(mActivity, "获取中...");
|
||||
dialog.show();
|
||||
RetrofitManager.getInstance()
|
||||
.create(BaseApiService.class)
|
||||
.getFileInfoList(fileId)
|
||||
.compose(RxTransformer.getTransformer())
|
||||
.subscribe(new Observer<List<FileInfoBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@io.reactivex.rxjava3.annotations.NonNull List<FileInfoBean> fileInfoBeans) {
|
||||
if (dialog.isShowing()) dialog.dismiss();
|
||||
if (fileInfoBeans.size() > 0) {
|
||||
for (int i = 0; i < fileInfoBeans.size(); i++) {
|
||||
FileInfoBean infoBean = fileInfoBeans.get(i);
|
||||
AddFileBean bean = new AddFileBean();
|
||||
bean.setId(infoBean.getFileId());
|
||||
bean.setPath(BaseUrlApi.BASE_IMG_URL + infoBean.getFileId());
|
||||
bean.setFileType(FileUtils.getFileType(infoBean.getFileName()));
|
||||
bean.setFileName(infoBean.getFileName());
|
||||
mFileBeans.add(0, bean);
|
||||
--mFileMax;
|
||||
}
|
||||
mAddFileAdapter.setData(mFileBeans);
|
||||
} else {
|
||||
ToastUtils.show("未找到文档信息");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||
if (dialog.isShowing()) dialog.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void initViews() {
|
||||
mFileTypeList = new ArrayList<>();
|
||||
DicBean type1 = new DicBean();
|
||||
type1.setDataName("文件");
|
||||
type1.setDataId("文件");
|
||||
|
||||
DicBean type2 = new DicBean();
|
||||
type2.setDataName("图片");
|
||||
type2.setDataId("图片");
|
||||
|
||||
DicBean type3 = new DicBean();
|
||||
type3.setDataName("视频");
|
||||
type3.setDataId("视频");
|
||||
|
||||
DicBean type4 = new DicBean();
|
||||
type4.setDataName("音频");
|
||||
type4.setDataId("音频");
|
||||
|
||||
mFileTypeList.add(type1);
|
||||
mFileTypeList.add(type2);
|
||||
mFileTypeList.add(type3);
|
||||
mFileTypeList.add(type4);
|
||||
|
||||
mTvDocType.setOnClickListener(v -> onShowDocType());
|
||||
|
||||
mFileBeans.add(new AddFileBean());
|
||||
mAddFileAdapter = new AddFileAdapter(mActivity, mFileBeans);
|
||||
mAddFileAdapter.addOnItemClickListener(addFileBean -> {
|
||||
if (TextUtils.isEmpty(addFileBean.getId())) {
|
||||
checkManagePermission();
|
||||
} else {
|
||||
//TODO 预览
|
||||
}
|
||||
});
|
||||
//删除上传的文件
|
||||
mAddFileAdapter.addOnDeleteListener((bean, i) -> {
|
||||
//删除list中的某个数据
|
||||
mFileBeans.remove(i);
|
||||
mAddFileAdapter.notifyDataSetChanged();
|
||||
++mFileMax;
|
||||
});
|
||||
mRlvFiles.setLayoutManager(new LinearLayoutManager(mActivity));
|
||||
mRlvFiles.setAdapter(mAddFileAdapter);
|
||||
mBtnConfirm.setOnClickListener(v -> doSave());
|
||||
mTvFileType.setOnClickListener(v -> onShowFileType());
|
||||
mTvFileType.setText(mDocType);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 文件类型选择
|
||||
*/
|
||||
private void onShowFileType() {
|
||||
if (mFileTypePicker == null) {
|
||||
mFileTypePicker = new OptionsPickerBuilder(mActivity, (o1, o2, o3, v) -> {
|
||||
//判断是否进行了切换
|
||||
if (mDocType.equals(mFileTypeList.get(o1).getDataId())) return;
|
||||
mDocType = mFileTypeList.get(o1).getDataId();
|
||||
mTvFileType.setText(mDocType);
|
||||
//判断当前文档是是否与选择的一致
|
||||
switch (mDocType) {
|
||||
case "文件":
|
||||
mDocType = "文件";
|
||||
fileFilter = new String[]{".doc", ".docx", ".xls", ".xlsx", ".pptx", ".ppt", ".txt", ".pdf"};
|
||||
mFileMax = 9;//9
|
||||
break;
|
||||
case "图片":
|
||||
mDocType = "图片";
|
||||
fileFilter = new String[]{".jpg", ".jpeg", ".png"};
|
||||
mFileMax = 20;//20
|
||||
break;
|
||||
case "视频":
|
||||
mDocType = "视频";
|
||||
fileFilter = new String[]{".mp4", ".avi", ".mkv", ".flv"};
|
||||
mFileMax = 5;//5
|
||||
break;
|
||||
case "音频":
|
||||
mDocType = "音频";
|
||||
fileFilter = new String[]{".mp3", ".wmv", ".amr"};
|
||||
mFileMax = 5;//5
|
||||
break;
|
||||
}
|
||||
mFileBeans.clear();
|
||||
mFileBeans.add(new AddFileBean());
|
||||
mAddFileAdapter.notifyDataSetChanged();
|
||||
})
|
||||
.setTitleText("请选择")
|
||||
.setCancelColor(Color.parseColor("#1189FF"))
|
||||
.setSubmitColor(Color.parseColor("#1189FF"))
|
||||
.setTitleColor(Color.parseColor("#1189FF"))
|
||||
.build();
|
||||
mFileTypePicker.setPicker(mFileTypeList);
|
||||
}
|
||||
mFileTypePicker.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存文件
|
||||
*/
|
||||
private void doSave() {
|
||||
if (checkParams()) {
|
||||
RequestBody body = buildParams();
|
||||
ProgressDialog dialog = UIUtil.initDialog(mActivity, "保存中...");
|
||||
dialog.show();
|
||||
RetrofitManager.getInstance()
|
||||
.create(OAApi.class)
|
||||
.doEditDoc(mId, body)
|
||||
.compose(RxTransformer.getTransformer())
|
||||
.subscribe(new Observer<BaseSuccessBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@io.reactivex.rxjava3.annotations.NonNull BaseSuccessBean baseSuccessBean) {
|
||||
if (dialog.isShowing()) dialog.dismiss();
|
||||
ToastUtils.show("修改成功");
|
||||
BaseFragment preFragment = mMainActivity.getPreFragment();
|
||||
if (preFragment != null) {
|
||||
preFragment.mIsRefresh = true;
|
||||
}
|
||||
mMainActivity.backFragment(2, DocumentEditFragment.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||
if (dialog.isShowing()) dialog.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param paths
|
||||
*/
|
||||
private int mUploadCount = 0;
|
||||
|
||||
private void doUploadFiles(ArrayList<String> paths) {
|
||||
LogUtils.e(paths);
|
||||
|
||||
ProgressDialog progressDialog = UIUtil.initDialog(mActivity, "上传中...");
|
||||
progressDialog.show();
|
||||
List<Observable> requests = new ArrayList<>();
|
||||
for (int i = 0; i < paths.size(); i++) {
|
||||
File file = new File(paths.get(i));
|
||||
Observable observable = createObservable(file);
|
||||
if (observable == null) return;
|
||||
requests.add(observable);
|
||||
}
|
||||
Observable<BaseSuccessBean>[] observables1 = requests.toArray(new Observable[requests.size()]);
|
||||
|
||||
Observable.mergeArrayDelayError(observables1)
|
||||
.compose(RxTransformer.getTransformer())
|
||||
.subscribe(new Observer() {
|
||||
@Override
|
||||
public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull Object o) {
|
||||
++mUploadCount;
|
||||
if (o instanceof BaseSuccessBean) {
|
||||
--mFileMax;
|
||||
//刷新文件
|
||||
BaseSuccessBean bean = (BaseSuccessBean) o;
|
||||
AddFileBean fileBean = new AddFileBean();
|
||||
fileBean.setId(bean.getData());
|
||||
fileBean.setPath(BaseUrlApi.BASE_IMG_URL + bean.getData());
|
||||
// 判断文件类型
|
||||
if ("文件".equals(mDocType)) {
|
||||
fileBean.setFileType(1);
|
||||
} else if ("图片".equals(mDocType)) {
|
||||
fileBean.setFileType(2);
|
||||
} else if ("视频".equals(mDocType)) {
|
||||
fileBean.setFileType(3);
|
||||
} else if ("音频".equals(mDocType)) {
|
||||
fileBean.setFileType(4);
|
||||
}
|
||||
mFileBeans.add(0, fileBean);
|
||||
}
|
||||
mAddFileAdapter.notifyDataSetChanged();
|
||||
if (mUploadCount == paths.size()) {
|
||||
mUploadCount = 0;
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||
e.printStackTrace();
|
||||
mUploadCount = 0;
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
ToastUtils.show("上传失败,请稍后重试.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Observable createObservable(File file) {
|
||||
LogUtils.e(file.exists());
|
||||
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file);
|
||||
MultipartBody.Part body;
|
||||
if ("文件".equals(mDocType)) {
|
||||
body = MultipartBody.Part.createFormData("file", file.getName(), requestFile);
|
||||
return RetrofitManager.getInstance()
|
||||
.create(BaseApiService.class)
|
||||
.uploadFile(body)
|
||||
.compose(RxTransformer.getTransformer());
|
||||
|
||||
} else if ("图片".equals(mDocType)) {
|
||||
|
||||
body = MultipartBody.Part.createFormData("image", file.getName(), requestFile);
|
||||
return RetrofitManager.getInstance()
|
||||
.create(BaseApiService.class)
|
||||
.uploadImage(body)
|
||||
.compose(RxTransformer.getTransformer());
|
||||
|
||||
} else if ("视频".equals(mDocType)) {
|
||||
|
||||
body = MultipartBody.Part.createFormData("video", file.getName(), requestFile);
|
||||
return RetrofitManager.getInstance()
|
||||
.create(BaseApiService.class)
|
||||
.uploadVideo(body)
|
||||
.compose(RxTransformer.getTransformer());
|
||||
|
||||
} else if ("音频".equals(mDocType)) {
|
||||
body = MultipartBody.Part.createFormData("audio", file.getName(), requestFile);
|
||||
|
||||
return RetrofitManager.getInstance()
|
||||
.create(BaseApiService.class)
|
||||
.uploadAudio(body)
|
||||
.compose(RxTransformer.getTransformer());
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示文档类型
|
||||
*/
|
||||
private void onShowDocType() {
|
||||
mMainActivity.hideSoftKeyboard();
|
||||
if (mDocTypes != null && mDocTypes.size() > 0) {
|
||||
if (mDataSourcePicker == null) {
|
||||
mDataSourcePicker = new OptionsPickerBuilder(mActivity, (o1, o2, o3, v) -> {
|
||||
mSelType = mDocTypes.get(o1);
|
||||
mTvDocType.setText(mSelType.getTypeName());
|
||||
})
|
||||
.setTitleText("请选择")
|
||||
.setCancelColor(Color.parseColor("#1189FF"))
|
||||
.setSubmitColor(Color.parseColor("#1189FF"))
|
||||
.setTitleColor(Color.parseColor("#1189FF"))
|
||||
.build();
|
||||
mDataSourcePicker.setPicker(mDocTypes);
|
||||
}
|
||||
mDataSourcePicker.show();
|
||||
} else {
|
||||
getDocTypes();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文档类型
|
||||
*/
|
||||
private void getDocTypes() {
|
||||
ProgressDialog dialog = UIUtil.initDialog(mActivity, "加载中...");
|
||||
dialog.show();
|
||||
RetrofitManager.getInstance()
|
||||
.create(OAApi.class)
|
||||
.getDocTypes()
|
||||
.compose(RxTransformer.getTransformer())
|
||||
.subscribe(new Observer<List<DocTypeBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@io.reactivex.rxjava3.annotations.NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@io.reactivex.rxjava3.annotations.NonNull List<DocTypeBean> docTypeBeans) {
|
||||
dialog.dismiss();
|
||||
if (docTypeBeans.size() > 0) {
|
||||
mDocTypes = docTypeBeans;
|
||||
onShowDocType();
|
||||
} else {
|
||||
ToastUtils.show("暂无数据");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||
dialog.dismiss();
|
||||
ExceptionHandler.handleException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean checkParams() {
|
||||
if (mSelType == null) {
|
||||
ToastUtils.show("请选择文档类型");
|
||||
return false;
|
||||
}
|
||||
LogUtils.e(mFileBeans.size());
|
||||
if (mFileBeans.size() < 2) {
|
||||
ToastUtils.show("请上传文件");
|
||||
return false;
|
||||
}
|
||||
String summary = mEtSummary.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(summary)) {
|
||||
ToastUtils.show("请输入文件说明");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建提交参数
|
||||
*/
|
||||
private RequestBody buildParams() {
|
||||
SaveFileBean fileBean = new SaveFileBean();
|
||||
//fileBean.setCatalogueId(mSelType.get)
|
||||
fileBean.setFileType(mDocType);
|
||||
fileBean.setFileTypeId(mSelType.getFileTypeId());
|
||||
if (mFileBeans.size() == 2) {
|
||||
fileBean.setFileModular("单文件");
|
||||
} else {
|
||||
fileBean.setFileModular("多文件");
|
||||
}
|
||||
|
||||
StringBuilder fileId = new StringBuilder();
|
||||
for (AddFileBean bean : mFileBeans) {
|
||||
if (!TextUtils.isEmpty(bean.getId())) {
|
||||
fileId.append(bean.getId()).append(",");
|
||||
}
|
||||
}
|
||||
if (fileId.toString().endsWith(",")) {
|
||||
fileId = new StringBuilder(fileId.substring(0, fileId.length() - 1));
|
||||
}
|
||||
fileBean.setFileId(fileId.toString());
|
||||
String summary = mEtSummary.getText().toString().trim();
|
||||
fileBean.setContent(summary);
|
||||
String remark = mEtRemark.getText().toString().trim();
|
||||
fileBean.setRemake(remark);
|
||||
Gson gson = new Gson();
|
||||
String obj = gson.toJson(fileBean);
|
||||
return RequestBody.create(obj, MediaType.parse("application/json; charset=utf-8"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void refreshView() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadMoreData() {
|
||||
|
||||
}
|
||||
}
|
176
oamodule/src/main/res/layout/fragment_document_add.xml
Normal file
176
oamodule/src/main/res/layout/fragment_document_add.xml
Normal file
@ -0,0 +1,176 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/gray_f0"
|
||||
android:orientation="vertical"
|
||||
tools:context=".activity.document.DocumentAddActivity">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginBottom="70dp"
|
||||
android:background="@color/white"
|
||||
android:scrollbars="none">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout style="@style/item_hor_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="文档类型"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_doc_type"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:clickable="true"
|
||||
android:drawableRight="@drawable/ic_arrow_right"
|
||||
android:focusable="true"
|
||||
android:gravity="right"
|
||||
android:hint="请选择文档类型"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout style="@style/item_hor_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="文件类型"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_file_type"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:clickable="true"
|
||||
android:drawableRight="@drawable/ic_arrow_right"
|
||||
android:focusable="true"
|
||||
android:gravity="right"
|
||||
android:hint="请选择文件类型"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout style="@style/item_ver">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="文档文件"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@drawable/shp_rectangle_gray"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rlv_files"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:itemCount="3" />
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout style="@style/item_ver">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="文件说明"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@drawable/shp_rectangle_gray"
|
||||
android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_summary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@null"
|
||||
android:gravity="left"
|
||||
android:hint="请输入文件说明"
|
||||
android:minLines="3"
|
||||
android:padding="5dp"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout style="@style/item_ver">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="备注"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@drawable/shp_rectangle_gray"
|
||||
android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_remark"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@null"
|
||||
android:gravity="left"
|
||||
android:hint="请输入备注"
|
||||
android:minLines="3"
|
||||
android:padding="5dp"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_confirm"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_margin="10dp"
|
||||
android:background="@drawable/sel_btn_submit"
|
||||
android:text="上传"
|
||||
android:textColor="@color/col_white_gray_press" />
|
||||
|
||||
</RelativeLayout>
|
205
oamodule/src/main/res/layout/fragment_document_detail.xml
Normal file
205
oamodule/src/main/res/layout/fragment_document_detail.xml
Normal file
@ -0,0 +1,205 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/gray_f0"
|
||||
android:orientation="vertical"
|
||||
tools:context=".activity.document.DocumentAddActivity">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginBottom="65dp"
|
||||
android:background="@color/white"
|
||||
android:scrollbars="none">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout style="@style/item_hor_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="文档类型"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_doc_type"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="right"
|
||||
android:hint="未录入"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout style="@style/item_hor_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="文件类型"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_file_type"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="right"
|
||||
android:hint="未录入"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout style="@style/item_ver">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="文档文件"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@drawable/shp_rectangle_gray"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rlv_files"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:itemCount="3" />
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout style="@style/item_ver">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="文件说明"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@drawable/shp_rectangle_gray"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_summary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@null"
|
||||
android:gravity="left"
|
||||
android:hint="未录入"
|
||||
android:minLines="3"
|
||||
android:padding="5dp"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout style="@style/item_ver">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="备注"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@drawable/shp_rectangle_gray"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_remark"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@null"
|
||||
android:gravity="left"
|
||||
android:hint="未录入"
|
||||
android:minLines="3"
|
||||
android:padding="5dp"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@color/white"
|
||||
android:orientation="horizontal"
|
||||
android:padding="5dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_del"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/sel_btn_submit"
|
||||
android:text="删除"
|
||||
android:textColor="@color/col_white_gray_press"
|
||||
android:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_edit"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/sel_btn_submit"
|
||||
android:text="编辑"
|
||||
android:textColor="@color/col_white_gray_press"
|
||||
android:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_share"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/sel_btn_submit"
|
||||
android:text="分享"
|
||||
android:textColor="@color/col_white_gray_press"
|
||||
android:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
176
oamodule/src/main/res/layout/fragment_document_edit.xml
Normal file
176
oamodule/src/main/res/layout/fragment_document_edit.xml
Normal file
@ -0,0 +1,176 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/gray_f0"
|
||||
android:orientation="vertical"
|
||||
tools:context=".activity.document.DocumentAddActivity">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginBottom="70dp"
|
||||
android:background="@color/white"
|
||||
android:scrollbars="none">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout style="@style/item_hor_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="文档类型"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_doc_type"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:clickable="true"
|
||||
android:drawableRight="@drawable/ic_arrow_right"
|
||||
android:focusable="true"
|
||||
android:gravity="right"
|
||||
android:hint="请选择文档类型"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout style="@style/item_hor_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="文件类型"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_file_type"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:clickable="true"
|
||||
android:drawableRight="@drawable/ic_arrow_right"
|
||||
android:focusable="true"
|
||||
android:gravity="right"
|
||||
android:hint="请选择文件类型"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout style="@style/item_ver">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="文档文件"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@drawable/shp_rectangle_gray"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rlv_files"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:itemCount="3" />
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout style="@style/item_ver">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="文件说明"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@drawable/shp_rectangle_gray"
|
||||
android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_summary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@null"
|
||||
android:gravity="left"
|
||||
android:hint="请输入文件说明"
|
||||
android:minLines="3"
|
||||
android:padding="5dp"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout style="@style/item_ver">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="备注"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@drawable/shp_rectangle_gray"
|
||||
android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_remark"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@null"
|
||||
android:gravity="left"
|
||||
android:hint="请输入备注"
|
||||
android:minLines="3"
|
||||
android:padding="5dp"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_confirm"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_margin="10dp"
|
||||
android:background="@drawable/sel_btn_submit"
|
||||
android:text="保存"
|
||||
android:textColor="@color/col_white_gray_press" />
|
||||
|
||||
</RelativeLayout>
|
Loading…
Reference in New Issue
Block a user