文档中心UI调整,添加目录管理功能

This commit is contained in:
itgaojian 2023-03-31 15:44:00 +08:00
parent 7d7c2b8223
commit 104acb6636
14 changed files with 980 additions and 21 deletions

View File

@ -148,6 +148,7 @@ public class PathConfig {
public static final String PATH_MODULE_OA_ACTIVITY_DOCUMENT_ADD = "/oamodule/activity/documentAdd";//文档上传
public static final String PATH_MODULE_OA_ACTIVITY_DOCUMENT_EDIT = "/oamodule/activity/documentEdit";//文档编辑
public static final String PATH_MODULE_OA_ACTIVITY_DOCUMENT_DETAIL = "/oamodule/activity/documentDetail";//文档上传
public static final String PATH_MODULE_OA_ACTIVITY_DOCUMENT_CATEGORY_MANAGE = "/oamodule/activity/documentCategoryManage";//文档类型管理
public static final String PATH_MODULE_OA_ACTIVITY_DOCUMENT_TYPE_LIST = "/oamodule/activity/documentTypeList";//文档类型 列表
public static final String PATH_MODULE_OA_ACTIVITY_DOCUMENT_TYPE_ADD = "/oamodule/activity/documentTypeAdd";//文档类型 添加

View File

@ -3,6 +3,13 @@
package="com.tenlionsoft.oamodule">
<application>
<activity
android:name=".activity.document.DocumentCategoryActivity"
android:configChanges="keyboardHidden|screenSize|orientation"
android:exported="false"
android:launchMode="singleTop"
android:windowSoftInputMode="stateVisible|adjustResize" />
<activity
android:name=".activity.workreports.WorkReportFragmentActivity"
android:configChanges="keyboardHidden|screenSize|orientation"

View File

@ -0,0 +1,486 @@
package com.tenlionsoft.oamodule.activity.document;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Color;
import android.view.View;
import android.widget.Button;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.google.android.flexbox.FlexDirection;
import com.google.android.flexbox.FlexWrap;
import com.google.android.flexbox.FlexboxLayoutManager;
import com.google.gson.Gson;
import com.hjq.toast.ToastUtils;
import com.tenlionsoft.baselib.constant.PathConfig;
import com.tenlionsoft.baselib.core.beans.BaseSuccessBean;
import com.tenlionsoft.baselib.core.retrofit_net.RetrofitManager;
import com.tenlionsoft.baselib.core.retrofit_net.conver.RxTransformer;
import com.tenlionsoft.baselib.core.widget.base.BaseActivity;
import com.tenlionsoft.baselib.core.widget.views.CustomStateView;
import com.tenlionsoft.baselib.core.widget.views.ItemSplitDivider;
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.adapter.DocumentCategoryManageAdapter;
import com.tenlionsoft.oamodule.adapter.SelDocTypeAdapter;
import com.tenlionsoft.oamodule.adapter.SelectedDocTypeAdapter;
import com.tenlionsoft.oamodule.beans.DocumentTypeList;
import com.tenlionsoft.oamodule.beans.SaveDocumentTypeBean;
import com.tenlionsoft.oamodule.net.OAApi;
import com.tenlionsoft.oamodule.widget.CenterDocTypeView;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
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;
/**
* 文档中心-目录管理
*/
@Route(path = PathConfig.PATH_MODULE_OA_ACTIVITY_DOCUMENT_CATEGORY_MANAGE)
public class DocumentCategoryActivity extends BaseActivity {
@BindView(R2.id.rlv_sel)
RecyclerView mRlvSel;
@BindView(R2.id.rlv_content)
RecyclerView mRlvContent;
@BindView(R2.id.csv_state)
CustomStateView mCsvState;
@BindView(R2.id.rlv_selected)
RecyclerView mRlvSelected;
@BindView(R2.id.btn_edit_type)
Button mBtnEditType;
@BindView(R2.id.btn_add_type)
Button mBtnAddType;
private List<Object> mSelCatalog = new ArrayList<>();
private SelDocTypeAdapter mTypeAdapter;
private List<DocumentTypeList> mDatas = new ArrayList<>();
private DocumentCategoryManageAdapter mAdapter;
private List<DocumentTypeList> mSelectedCatalog = new ArrayList<>();
private SelectedDocTypeAdapter mSelectedDocTypeAdapter;
private String mSelCatalogId;
private boolean mIsSingle;
@Override
protected int setLayoutId() {
return R.layout.activity_document_category;
}
@Override
public void initData() {
ButterKnife.bind(this);
mTvBaseTitle.setText("目录管理");
mIsSingle = getIntent().getBooleanExtra("isSingle", false);
initView();
}
/**
* 初始化视图
*/
private void initView() {
refreshView(STATE_LOAD_SUCCESS);
DocumentTypeList rootBean = new DocumentTypeList();
rootBean.setName("根目录");
rootBean.setFileCatalogueId("0");
mSelCatalog.add(rootBean);
mSelCatalogId = "0";
LinearLayoutManager manager = new LinearLayoutManager(mActivity);
manager.setOrientation(LinearLayoutManager.HORIZONTAL);
mRlvSel.setLayoutManager(manager);
mTypeAdapter = new SelDocTypeAdapter(mActivity, mSelCatalog);
mRlvSel.setAdapter(mTypeAdapter);
mAdapter = new DocumentCategoryManageAdapter(mActivity, mDatas, 1);
mRlvContent.setLayoutManager(new LinearLayoutManager(mActivity));
mRlvContent.addItemDecoration(new ItemSplitDivider(mActivity, LinearLayoutManager.VERTICAL, 1, Color.parseColor("#F4F4F4")));
mRlvContent.setAdapter(mAdapter);
mCsvState.setState(CustomStateView.STATE_LOAD);
mTvPublish.setVisibility(View.GONE);
getCataLogList();
mAdapter.addOnItemCheckChange(new DocumentCategoryManageAdapter.OnItemCheckChange() {
@Override
public void onItemCheckChange(DocumentTypeList bean, boolean isCheck, int pos) {
if (mIsSingle) {
mSelectedCatalog.clear();
}
for (int i = 0; i < mDatas.size(); i++) {
if (bean.getFileCatalogueId().equals(mDatas.get(i).getFileCatalogueId())) {
mDatas.get(i).setChecked(isCheck);
} else {
if (mIsSingle) {
mDatas.get(i).setChecked(false);
}
}
}
mAdapter.notifyDataSetChanged();
if (isCheck) {
mSelectedCatalog.add(bean);
} else {
Iterator<DocumentTypeList> iterator = mSelectedCatalog.iterator();
while (iterator.hasNext()) {
DocumentTypeList next = iterator.next();
if (next.getFileCatalogueId().equals(bean.getFileCatalogueId())) {
iterator.remove();
}
}
}
mSelectedDocTypeAdapter.setData(mSelectedCatalog);
}
@Override
public void onLowerDept(DocumentTypeList bean, int pos) {
//添加到当前选中的集合中
mSelCatalog.add(bean);
mTypeAdapter.setData(mSelCatalog);
mSelCatalogId = bean.getFileCatalogueId();
mCsvState.setState(CustomStateView.STATE_LOAD);
getCataLogList();
//获取当前选中的下一级
mRlvSel.scrollToPosition(mSelCatalog.size() - 1);
}
});
mTypeAdapter.setOnItemChoose((bean, pos) -> {
List<Object> departmentListBeans = mSelCatalog.subList(0, pos + 1);
mSelCatalog = departmentListBeans;
mTypeAdapter.setData(mSelCatalog);
mRlvSel.scrollToPosition(mSelCatalog.size() - 1);
if (bean instanceof DocumentTypeList) {
DocumentTypeList b = (DocumentTypeList) bean;
mSelCatalogId = b.getFileCatalogueId();
mCsvState.setState(CustomStateView.STATE_LOAD);
getCataLogList();
}
});
//当前选中的
mSelectedDocTypeAdapter = new SelectedDocTypeAdapter(mActivity, mSelectedCatalog);
FlexboxLayoutManager manage = new FlexboxLayoutManager(mActivity, FlexDirection.ROW, FlexWrap.WRAP) {
@Override
public boolean canScrollHorizontally() {
return false;
}
};
mRlvSelected.setLayoutManager(manage);
mRlvSelected.setAdapter(mSelectedDocTypeAdapter);
mSelectedDocTypeAdapter.addOnDelListener((bean1, pos) -> {
mSelectedCatalog.remove(pos);
mSelectedDocTypeAdapter.setData(mSelectedCatalog);
for (int i = 0; i < mDatas.size(); i++) {
DocumentTypeList typeList = mDatas.get(i);
if (typeList.getFileCatalogueId().equals(bean1.getFileCatalogueId())) {
typeList.setChecked(false);
}
}
mAdapter.setData(mDatas);
});
mBtnAddType.setOnClickListener(v -> {
showAddTypeDialog();
});
mBtnEditType.setOnClickListener(v -> {
int type = mAdapter.getType();
if (type == 1) {
mAdapter.setType(2);
mBtnEditType.setText("取消");
mBtnEditType.setBackground(getResources().getDrawable(R.drawable.shape_btn_nomal_gray_no_size));
} else {
mAdapter.setType(1);
mBtnEditType.setText("编辑");
mBtnEditType.setBackground(getResources().getDrawable(R.drawable.sel_btn_activity_sign_up));
}
});
//编辑或删除
mAdapter.addOnControlListener(new DocumentCategoryManageAdapter.OnControlListener() {
@Override
public void doEdit(DocumentTypeList bean, int pos) {
showEditDialog(bean);
}
@Override
public void doDel(DocumentTypeList bean, int pos) {
new AlertDialog.Builder(mActivity)
.setTitle("提示")
.setMessage("删除后该目录下所有文件将被删除,确定要删除该目录吗?")
.setPositiveButton("删除", (dialog, which) -> {
dialog.dismiss();
doDelType(bean);
})
.setNegativeButton("取消", (dialog, which) -> dialog.dismiss())
.create()
.show();
}
});
}
private void showEditDialog(DocumentTypeList bean) {
CenterDocTypeView typeDialog = new CenterDocTypeView.DialogBuilder(mActivity)
.setBean(bean)
.build();
typeDialog.addOnChoseListener((name, order, remark) -> {
//当前选中的目录
typeDialog.dismiss();
typeDialog.hideSoftKeyBoardDialog(mActivity);
doEditType(name, order, remark, bean);
});
typeDialog.show();
}
/**
* 编辑
*/
private void doEditType(String name, String order, String remark, DocumentTypeList bean) {
ProgressDialog dialog = UIUtil.initDialog(mActivity, "保存中...");
dialog.show();
RequestBody body = buildTypeEditParams(name, order, remark, bean);
RetrofitManager.getInstance()
.create(OAApi.class)
.doEditDocumentType(bean.getFileCatalogueId(), body)
.compose(RxTransformer.getTransformer())
.subscribe(new Observer<BaseSuccessBean>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull BaseSuccessBean baseSuccessBean) {
dialog.dismiss();
ToastUtils.show("修改成功");
getCataLogList();
}
@Override
public void onError(@NonNull Throwable e) {
dialog.dismiss();
ExceptionHandler.handleException(e);
}
@Override
public void onComplete() {
}
});
}
/**
* 删除
*
* @param bean
*/
private void doDelType(DocumentTypeList bean) {
ProgressDialog dialog = UIUtil.initDialog(mActivity, "删除中...");
dialog.show();
RetrofitManager.getInstance()
.create(OAApi.class)
.doDelDocumentType(bean.getFileCatalogueId())
.compose(RxTransformer.getTransformer())
.subscribe(new Observer<BaseSuccessBean>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull BaseSuccessBean baseSuccessBean) {
dialog.dismiss();
ToastUtils.show("删除成功");
getCataLogList();
}
@Override
public void onError(@NonNull Throwable e) {
dialog.dismiss();
ExceptionHandler.handleException(e);
}
@Override
public void onComplete() {
}
});
}
/**
* 显示目录添加
*/
private void showAddTypeDialog() {
CenterDocTypeView typeDialog = new CenterDocTypeView.DialogBuilder(mActivity)
.build();
typeDialog.addOnChoseListener((name, order, remark) -> {
//当前选中的目录
typeDialog.dismiss();
typeDialog.hideSoftKeyBoardDialog(mActivity);
doSaveType(name, order, remark);
});
typeDialog.show();
}
/**
* 保存目录
*/
private void doSaveType(String name, String order, String remark) {
ProgressDialog dialog = UIUtil.initDialog(mActivity, "保存中...");
dialog.show();
RequestBody body = buildTypeParams(name, order, remark);
RetrofitManager.getInstance()
.create(OAApi.class)
.doSaveDocumentType(body)
.compose(RxTransformer.getTransformer())
.subscribe(new Observer<BaseSuccessBean>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull BaseSuccessBean baseSuccessBean) {
dialog.dismiss();
ToastUtils.show("保存成功");
//刷新
getCataLogList();
}
@Override
public void onError(@NonNull Throwable e) {
dialog.dismiss();
ExceptionHandler.handleException(e);
}
@Override
public void onComplete() {
}
});
}
private RequestBody buildTypeParams(String name, String order, String remark) {
SaveDocumentTypeBean bean = new SaveDocumentTypeBean();
bean.setName(name);
bean.setSortNum(Integer.parseInt(order));
bean.setRemake(remark);
bean.setType("0");
bean.setViewRange("0");
Object o = mSelCatalog.get(mSelCatalog.size() - 1);
DocumentTypeList b = (DocumentTypeList) o;
bean.setParentId(b.getFileCatalogueId());
return RequestBody.create(new Gson().toJson(bean), MediaType.parse("application/json; charset=utf-8"));
}
private RequestBody buildTypeEditParams(String name, String order, String remark, DocumentTypeList b) {
SaveDocumentTypeBean bean = new SaveDocumentTypeBean();
bean.setName(name);
bean.setSortNum(Integer.parseInt(order));
bean.setRemake(remark);
bean.setType("0");
bean.setViewRange("0");
bean.setParentId(b.getParentId());
return RequestBody.create(new Gson().toJson(bean), MediaType.parse("application/json; charset=utf-8"));
}
/**
* 确认选择
*/
private void doConfirm() {
if (mSelectedCatalog != null && mSelectedCatalog.size() > 0) {
if (mIsSingle) {
DocumentTypeList bean = mSelectedCatalog.get(0);
Intent intent = new Intent();
intent.putExtra("bean", bean);
setResult(RESULT_OK, intent);
finish();
} else {
String ids = "";
String names = "";
for (int i = 0; i < mSelectedCatalog.size(); i++) {
DocumentTypeList bean = mSelectedCatalog.get(i);
ids += bean.getFileCatalogueId() + ",";
names += bean.getName() + ",";
}
ids = ids.substring(0, ids.length() - 1);
names = names.substring(0, names.length() - 1);
Intent intent = new Intent();
intent.putExtra("name", names);
intent.putExtra("id", ids);
setResult(RESULT_OK, intent);
finish();
}
} else {
ToastUtils.show("请选择目录");
}
}
/**
* 获取目录列表
*/
private void getCataLogList() {
mCsvState.setState(CustomStateView.STATE_LOAD);
mDatas.clear();
mAdapter.setData(mDatas);
RetrofitManager.getInstance()
.create(OAApi.class)
.getDocumentTypeListByPid(mSelCatalogId, "0")
.compose(RxTransformer.getTransformer())
.subscribe(new Observer<List<DocumentTypeList>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull List<DocumentTypeList> documentTypeLists) {
if (documentTypeLists.size() > 0) {
mCsvState.setState(CustomStateView.STATE_SUCCESS);
mDatas.addAll(documentTypeLists);
for (int i = 0; i < mSelectedCatalog.size(); i++) {
DocumentTypeList selBean = mSelectedCatalog.get(i);
for (int j = 0; j < mDatas.size(); j++) {
DocumentTypeList bean = mDatas.get(j);
if (selBean.getFileCatalogueId().equals(bean.getFileCatalogueId())) {
bean.setChecked(true);
}
}
}
} else {
mCsvState.setState(CustomStateView.STATE_EMPTY);
}
mAdapter.setData(mDatas);
}
@Override
public void onError(@NonNull Throwable e) {
ExceptionHandler.handleException(e);
mAdapter.setData(mDatas);
mCsvState.setState(CustomStateView.STATE_ERROR);
}
@Override
public void onComplete() {
}
});
}
@Override
protected void doSearchByTitle() {
}
@Override
protected void clearSearch() {
}
}

View File

@ -38,22 +38,22 @@ public class DocumentAdapter extends BaseRecyclerAdapter<Object, FileHolder> {
if (o instanceof DocumentListBean.RowsBean) {
DocumentListBean.RowsBean b = (DocumentListBean.RowsBean) o;
Glide.with(mContext)
.load(R.drawable.ic_file_word_new)
.into(h.mIvIcon);
.load(R.drawable.ic_file_word_new)
.into(h.mIvIcon);
h.mTvName.setText(b.getContent());
h.mTvFileType.setText(b.getFileType());
} else if (o instanceof DocumentTypeList) {
DocumentTypeList b = (DocumentTypeList) o;
Glide.with(mContext)
.load(R.drawable.ic_folder_icon)
.into(h.mIvIcon);
.load(R.drawable.ic_folder_icon)
.into(h.mIvIcon);
h.mTvName.setText(b.getName());
h.mTvFileType.setText(b.getRemake());
} else if (o instanceof DocTypeTreeListBean) {
DocTypeTreeListBean b = (DocTypeTreeListBean) o;
Glide.with(mContext)
.load(R.drawable.ic_folder_icon)
.into(h.mIvIcon);
.load(R.drawable.ic_folder_icon)
.into(h.mIvIcon);
h.mTvName.setText(b.getName());
h.mTvFileType.setText("");
}

View File

@ -0,0 +1,91 @@
package com.tenlionsoft.oamodule.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.tenlionsoft.baselib.core.widget.base.BaseRecyclerAdapter;
import com.tenlionsoft.oamodule.R;
import com.tenlionsoft.oamodule.beans.DeptBean;
import com.tenlionsoft.oamodule.beans.DocumentTypeList;
import com.tenlionsoft.oamodule.holder.DocumentCategoryManageHolder;
import java.util.ArrayList;
import java.util.List;
/**
* 作者: adam
* 日期: 2020/11/24 - 9:16 AM
* 邮箱: itgaojian@163.com
* 描述: 文档目录管理
*/
public class DocumentCategoryManageAdapter extends BaseRecyclerAdapter<DocumentTypeList, DocumentCategoryManageHolder> {
public List<DeptBean> mSelBeans = new ArrayList<>();
public int mType = 1;
public DocumentCategoryManageAdapter(Context ctx, List<DocumentTypeList> list, int type) {
super(ctx, list);
this.mType = type;
}
@Override
public DocumentCategoryManageHolder createHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(mContext).inflate(R.layout.item_category_manage, parent, false);
return new DocumentCategoryManageHolder(itemView);
}
public void setType(int type) {
this.mType = type;
notifyDataSetChanged();
}
public int getType() {
return mType;
}
@Override
public void bindHolder(DocumentCategoryManageHolder holder, int i) {
DocumentTypeList bean = mData.get(i);
holder.mTvName.setText(bean.getName());
holder.mTvName.setOnClickListener(v -> mLis.onLowerDept(bean, i));
if (mType == 1) {
//默认选择
holder.mLlBtns.setVisibility(View.GONE);
holder.mIvArrow.setVisibility(View.VISIBLE);
} else {
//编辑
holder.mLlBtns.setVisibility(View.VISIBLE);
holder.mIvArrow.setVisibility(View.GONE);
}
if (mControlListener != null) {
holder.mBtnDel.setOnClickListener(v -> mControlListener.doDel(bean, i));
holder.mBtnEdit.setOnClickListener(v -> mControlListener.doEdit(bean, i));
}
}
private OnItemCheckChange mLis;
public void addOnItemCheckChange(OnItemCheckChange lis) {
this.mLis = lis;
}
public interface OnItemCheckChange {
void onItemCheckChange(DocumentTypeList bean, boolean isCheck, int pos);
void onLowerDept(DocumentTypeList bean, int pos);
}
private OnControlListener mControlListener;
public void addOnControlListener(OnControlListener listener) {
this.mControlListener = listener;
}
public interface OnControlListener {
void doEdit(DocumentTypeList bean, int pos);
void doDel(DocumentTypeList bean, int pos);
}
}

View File

@ -0,0 +1,61 @@
package com.tenlionsoft.oamodule.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.bumptech.glide.Glide;
import com.tenlionsoft.baselib.core.widget.base.BaseRecyclerAdapter;
import com.tenlionsoft.oamodule.R;
import com.tenlionsoft.oamodule.beans.DocTypeTreeListBean;
import com.tenlionsoft.oamodule.beans.DocumentListBean;
import com.tenlionsoft.oamodule.beans.DocumentTypeList;
import com.tenlionsoft.oamodule.holder.FileGridHolder;
import java.util.List;
/**
* 作者: adam
* 日期: 2022/4/12 - 10:42 上午
* 邮箱: itgaojian@163.com
* 描述: 文档宫格排列
*/
public class DocumentGridAdapter extends BaseRecyclerAdapter<Object, FileGridHolder> {
public DocumentGridAdapter(Context ctx, List<Object> list) {
super(ctx, list);
}
@Override
public FileGridHolder createHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(mContext).inflate(R.layout.item_document_grid, parent, false);
return new FileGridHolder(itemView);
}
@Override
public void bindHolder(FileGridHolder h, int i) {
Object o = mData.get(i);
if (o instanceof DocumentListBean.RowsBean) {
DocumentListBean.RowsBean b = (DocumentListBean.RowsBean) o;
Glide.with(mContext)
.load(R.drawable.ic_file_word_new)
.into(h.mIvIcon);
h.mTvName.setText(b.getContent());
h.mTvFileType.setText(b.getFileType());
} else if (o instanceof DocumentTypeList) {
DocumentTypeList b = (DocumentTypeList) o;
Glide.with(mContext)
.load(R.drawable.ic_folder_icon)
.into(h.mIvIcon);
h.mTvName.setText(b.getName());
h.mTvFileType.setText(b.getRemake());
} else if (o instanceof DocTypeTreeListBean) {
DocTypeTreeListBean b = (DocTypeTreeListBean) o;
Glide.with(mContext)
.load(R.drawable.ic_folder_icon)
.into(h.mIvIcon);
h.mTvName.setText(b.getName());
h.mTvFileType.setText("");
}
}
}

View File

@ -17,6 +17,12 @@ import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.view.OptionsPickerView;
@ -28,6 +34,7 @@ import com.tenlionsoft.baselib.core.beans.OperateBean;
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.views.OperatePopup;
import com.tenlionsoft.baselib.core.widget.views.TypeFaceTextView;
import com.tenlionsoft.baselib.utils.ExceptionHandler;
import com.tenlionsoft.baselib.utils.LogUtils;
@ -35,8 +42,9 @@ 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.DocumentCategoryActivity;
import com.tenlionsoft.oamodule.activity.document.DocumentDetailActivity;
import com.tenlionsoft.oamodule.adapter.DocumentAdapter;
import com.tenlionsoft.oamodule.adapter.DocumentGridAdapter;
import com.tenlionsoft.oamodule.adapter.SelDocTypeAdapter;
import com.tenlionsoft.oamodule.beans.DocTypeBean;
import com.tenlionsoft.oamodule.beans.DocTypeTreeListBean;
@ -49,10 +57,6 @@ 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 butterknife.Unbinder;
@ -106,7 +110,7 @@ public class DocFragment extends BaseFragment {
private Unbinder mBind;
private List<Object> mDatas;
private DocumentAdapter mAdapter;
private DocumentGridAdapter mAdapter;
private int mCurrentPage = 1;
private String mKeywords = "";
private String mType = "个人文档";//个人文档 共享文档 公共文档
@ -115,7 +119,8 @@ public class DocFragment extends BaseFragment {
private OptionsPickerView mDataSourcePicker;
private List<DocTypeBean> mDocTypes;
private DocTypeBean mSelType;
private ActivityResultLauncher<Intent> mLauncher;
private ActivityResultLauncher<Intent> mLauncher;//添加文件
private ActivityResultLauncher<Intent> mCategoryLauncher;//管理目录
private List<OperateBean> mControls;
private List<Object> mSelCatalog = new ArrayList<>();//选中的文档目录
private SelDocTypeAdapter mSelCatalogAdapter;
@ -169,8 +174,10 @@ public class DocFragment extends BaseFragment {
mSrlContent.setOnLoadMoreListener(v -> doLoadMore());
mSrlContent.setOnRefreshListener(v -> doRefresh());
mDatas = new ArrayList<>();
mAdapter = new DocumentAdapter(mActivity, mDatas);
mRlvDoc.setLayoutManager(new LinearLayoutManager(mActivity));
mAdapter = new DocumentGridAdapter(mActivity, mDatas);
// mRlvDoc.setLayoutManager(new LinearLayoutManager(mActivity));
mRlvDoc.setLayoutManager(new GridLayoutManager(mActivity, 4));
mRlvDoc.setAdapter(mAdapter);
mAdapter.addOnItemClickListener(rowsBean -> {
if (rowsBean instanceof DocTypeTreeListBean) {
@ -213,7 +220,9 @@ public class DocFragment extends BaseFragment {
mKeywords = "";
doRefresh();
});
mIvAdd.setOnClickListener(v -> mLauncher.launch(new Intent(mActivity, DocumentAddActivity.class)));
// 直接添加文件
// mIvAdd.setOnClickListener(v -> mLauncher.launch(new Intent(mActivity, DocumentAddActivity.class)));
mIvAdd.setOnClickListener(v -> onShowOperatePopup());
setTouchDelegate(mIvAdd, 25);
// mTvTitleType.setOnClickListener(v -> onShowDocType());
// mTvTitleType.setText("文档中心");
@ -246,6 +255,16 @@ public class DocFragment extends BaseFragment {
mSelCatalogId = "0";
mSelCatalog.add(mRootPersonBean);
doRefresh();
mControls = new ArrayList<>();
OperateBean addFileBean = new OperateBean();
addFileBean.setId("addFile");
addFileBean.setName("文档上传");
mControls.add(addFileBean);
OperateBean manageCategoryBean = new OperateBean();
manageCategoryBean.setId("manageCategory");
manageCategoryBean.setName("目录管理");
mControls.add(manageCategoryBean);
}
/**
@ -266,6 +285,25 @@ public class DocFragment extends BaseFragment {
}
/**
* 显示操作
*/
private void onShowOperatePopup() {
OperatePopup popup = new OperatePopup(mActivity, mControls);
popup.addOnCheckChange((bean) -> {
popup.dismiss();
switch (bean.getId()) {
case "addFile"://添加文件
mLauncher.launch(new Intent(mActivity, DocumentAddActivity.class));
break;
case "manageCategory"://目录管理
mCategoryLauncher.launch(new Intent(mActivity, DocumentCategoryActivity.class));
break;
}
});
popup.setOffsetX(-70);
popup.showPopupWindow(mIvAdd);
}
/**
* 显示文档类型
@ -347,6 +385,11 @@ public class DocFragment extends BaseFragment {
doRefresh();
}
});
mCategoryLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
if (Activity.RESULT_OK == result.getResultCode()) {
doRefresh();
}
});
}
/**

View File

@ -0,0 +1,37 @@
package com.tenlionsoft.oamodule.holder;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.tenlionsoft.baselib.core.widget.base.BaseViewHolder;
import com.tenlionsoft.oamodule.R2;
import butterknife.BindView;
/**
* 作者: adam
* 日期: 2020/11/24 - 9:10 AM
* 邮箱: itgaojian@163.com
* 描述: 文档目录
*/
public class DocumentCategoryManageHolder extends BaseViewHolder {
@BindView(R2.id.tv_name)
public TextView mTvName;
@BindView(R2.id.iv_arrow)
public ImageView mIvArrow;
@BindView(R2.id.ll_btns)
public LinearLayout mLlBtns;
@BindView(R2.id.btn_edit)
public Button mBtnEdit;
@BindView(R2.id.btn_del)
public Button mBtnDel;
public DocumentCategoryManageHolder(@NonNull View itemView) {
super(itemView);
}
}

View File

@ -0,0 +1,33 @@
package com.tenlionsoft.oamodule.holder;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.tenlionsoft.baselib.core.widget.base.BaseViewHolder;
import com.tenlionsoft.oamodule.R2;
import org.jetbrains.annotations.NotNull;
import butterknife.BindView;
/**
* 作者: adam
* 日期: 2022/4/12 - 10:39 上午
* 邮箱: itgaojian@163.com
* 描述:
*/
public class FileGridHolder extends BaseViewHolder {
@BindView(R2.id.tv_name)
public TextView mTvName;
@BindView(R2.id.tv_file_type)
public TextView mTvFileType;
@BindView(R2.id.iv_icon)
public ImageView mIvIcon;
public FileGridHolder(@NonNull @NotNull View itemView) {
super(itemView);
}
}

View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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_f2"
android:orientation="vertical"
tools:context=".activity.document.ChooseDocTypeActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rlv_sel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@color/gray_f8"
tools:itemCount="1"
tools:listitem="@layout/item_dept_sel_layout" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rlv_selected"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:visibility="gone"
android:layout_marginRight="10dp"
android:background="@color/gray_f8"
android:padding="5dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rlv_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="65dp"
android:background="@color/gray_f8"
tools:listitem="@layout/item_choose_doc_type" />
<com.tenlionsoft.baselib.core.widget.views.CustomStateView
android:id="@+id/csv_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:padding="10dp">
<Button
android:id="@+id/btn_add_type"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/sel_btn_blue_gray_cir"
android:text="新增"
android:textColor="@color/col_white_gray_press" />
<Button
android:id="@+id/btn_edit_type"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="@drawable/sel_btn_activity_sign_up"
android:text="编辑"
android:textColor="@color/col_white_gray_press" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>

View File

@ -112,17 +112,18 @@
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp">
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="@color/white">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rlv_doc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white" />
android:layout_height="match_parent" />
<LinearLayout
android:id="@+id/ll_hint"

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="horizontal">
<com.tenlionsoft.baselib.core.widget.views.TypeFaceTextView
android:id="@+id/tv_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:drawableLeft="@drawable/ic_folder_icon"
android:drawablePadding="10dp"
android:focusable="true"
android:gravity="center_vertical"
android:padding="10dp"
android:textColor="@color/black"
android:textSize="15sp"
tools:text="测试" />
<ImageView
android:id="@+id/iv_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_arrow_cir" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_btns"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<Button
android:id="@+id/btn_del"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/sel_btn_red_gray_re_5"
android:minWidth="0dp"
android:minHeight="0dp"
android:padding="5dp"
android:text="删除"
android:textColor="@color/col_white_gray_press"
android:textSize="@dimen/text_12" />
<Button
android:id="@+id/btn_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@drawable/sel_btn_blue_gray_re_5"
android:minWidth="0dp"
android:minHeight="0dp"
android:padding="5dp"
android:text="编辑"
android:textColor="@color/col_white_gray_press"
android:textSize="@dimen/text_12" />
</LinearLayout>
</LinearLayout>

View File

@ -4,7 +4,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/shape_rectangle_white"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="2dp">

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:gravity="center"
android:orientation="vertical"
android:padding="10dp">
<ImageView
android:id="@+id/iv_icon"
android:layout_width="25dp"
android:layout_height="25dp"
android:scaleType="fitXY"
tools:src="@drawable/ic_folder_icon" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="vertical">
<com.tenlionsoft.baselib.core.widget.views.TypeFaceTextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:minLines="2"
android:textColor="@color/black"
android:textSize="@dimen/text_12"
tools:text="文档名称" />
<com.tenlionsoft.baselib.core.widget.views.TypeFaceTextView
android:id="@+id/tv_file_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:ellipsize="end"
android:maxLines="1"
android:textSize="@dimen/text_12"
android:visibility="gone"
tools:text="文件类型" />
</LinearLayout>
</LinearLayout>