|
|
@@ -0,0 +1,200 @@
|
|
|
+package cn.muchinfo.rma.view.base.home.reportquery.reportdetail;
|
|
|
+
|
|
|
+import android.annotation.SuppressLint;
|
|
|
+import android.content.Context;
|
|
|
+import android.content.Intent;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.view.LayoutInflater;
|
|
|
+import android.view.MotionEvent;
|
|
|
+import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+import android.view.ViewTreeObserver;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import androidx.annotation.NonNull;
|
|
|
+import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
+import androidx.recyclerview.widget.RecyclerView;
|
|
|
+
|
|
|
+import com.blankj.utilcode.util.ActivityUtils;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import cn.muchinfo.rma.R;
|
|
|
+import cn.muchinfo.rma.global.data.AreaStockReportData;
|
|
|
+import cn.muchinfo.rma.global.data.ReportCommonDetailData;
|
|
|
+import cn.muchinfo.rma.view.autoWidget.CustomHorizontalScrollView;
|
|
|
+import cn.muchinfo.rma.view.base.app.Constant;
|
|
|
+import cn.muchinfo.rma.view.base.home.inventory.inventorymanager.InventoryDetailsActivity;
|
|
|
+import cn.muchinfo.rma.view.base.procurement.RightScrollAdapter;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 用于库存管理当前库存的列表adapter
|
|
|
+ */
|
|
|
+public class RecordDetailsAdapter extends RecyclerView.Adapter<RecordDetailsAdapter.ItemViewHolder> {
|
|
|
+
|
|
|
+ private Context context;
|
|
|
+ private List<ReportCommonDetailData> datas;
|
|
|
+ private int index = -1;
|
|
|
+ private int position = -1;
|
|
|
+ private List<ItemViewHolder> mViewHolderList = new ArrayList<>();
|
|
|
+ public int offestX = 0;
|
|
|
+ private OnContentScrollListener onContentScrollListener;
|
|
|
+ private String querytype = "1";
|
|
|
+ private String querydate;
|
|
|
+
|
|
|
+
|
|
|
+ public interface OnContentScrollListener {
|
|
|
+ void onScroll(MotionEvent event);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setOnContentScrollListener(OnContentScrollListener onContentScrollListener) {
|
|
|
+ this.onContentScrollListener = onContentScrollListener;
|
|
|
+ }
|
|
|
+
|
|
|
+ public RecordDetailsAdapter(Context context) {
|
|
|
+ this.context = context;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setDatas(List<ReportCommonDetailData> datas) {
|
|
|
+ this.datas = datas;
|
|
|
+ notifyDataSetChanged();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置是日报表还是月报表 1是日报表 2是月报表
|
|
|
+ * @param querytype
|
|
|
+ */
|
|
|
+ public void setquerytype(String querytype){
|
|
|
+ this.querytype = querytype;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置查询的时间
|
|
|
+ * @param querydate
|
|
|
+ */
|
|
|
+ public void setquerydate(String querydate){
|
|
|
+ this.querydate = querydate;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setPosition(int position){
|
|
|
+ if (this.position == position) {
|
|
|
+ this.position = -1;
|
|
|
+ notifyItemChanged(index);
|
|
|
+ } else {
|
|
|
+ this.position = position;
|
|
|
+ notifyItemChanged(position);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @NonNull
|
|
|
+ @Override
|
|
|
+ public ItemViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
|
|
|
+ View view = LayoutInflater.from(context).inflate(R.layout.layout_item_inventory_current, viewGroup, false);
|
|
|
+ return new ItemViewHolder(view);
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressLint("SetTextI18n")
|
|
|
+ @Override
|
|
|
+ public void onBindViewHolder(@NonNull final ItemViewHolder itemViewHolder, int i) {
|
|
|
+ this.index = i;
|
|
|
+ itemViewHolder.exposure_tvLeftTitle.setText(datas.get(i).getLeftContent());
|
|
|
+ //右边滑动部分
|
|
|
+ LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
|
|
|
+ linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
|
|
+ itemViewHolder.exposure_rvItemRight.setLayoutManager(linearLayoutManager);
|
|
|
+ itemViewHolder.exposure_rvItemRight.setHasFixedSize(true);
|
|
|
+ RightScrollAdapter rightScrollAdapter = new RightScrollAdapter(context);
|
|
|
+ rightScrollAdapter.setDatas(datas.get(i).getRightData());
|
|
|
+ itemViewHolder.exposure_rvItemRight.setAdapter(rightScrollAdapter);
|
|
|
+ //缓存当前holder
|
|
|
+ if (!mViewHolderList.contains(itemViewHolder)) {
|
|
|
+ mViewHolderList.add(itemViewHolder);
|
|
|
+ }
|
|
|
+ if (i == this.position){
|
|
|
+ itemViewHolder.exposure_roots_view.setBackgroundColor(context.getResources().getColor(R.color.rma_list_select_color));
|
|
|
+ itemViewHolder.exposure_allView.setVisibility(View.VISIBLE);
|
|
|
+ }else {
|
|
|
+ itemViewHolder.exposure_roots_view.setBackgroundColor(context.getResources().getColor(R.color.white));
|
|
|
+ itemViewHolder.exposure_allView.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+
|
|
|
+ itemViewHolder.exposure_all_click_View.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //入库明细
|
|
|
+ itemViewHolder.futures_subsidiary.setOnClickListener(view -> {
|
|
|
+
|
|
|
+ });
|
|
|
+ //出库明细
|
|
|
+ itemViewHolder.place_the_order.setOnClickListener(view -> {
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ itemViewHolder.exposure_horItemScrollview.setEventListener(event -> {
|
|
|
+ if (null != onContentScrollListener) onContentScrollListener.onScroll(event);
|
|
|
+ });
|
|
|
+ //由于viewHolder的缓存,在1级缓存取出来是2个viewholder,并且不会被重新赋值,所以这里需要处理缓存的viewholder的位移
|
|
|
+ itemViewHolder.exposure_horItemScrollview.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
|
+ @Override
|
|
|
+ public void onGlobalLayout() {
|
|
|
+ if (!itemViewHolder.isLayoutFinish()) {
|
|
|
+ itemViewHolder.exposure_horItemScrollview.scrollTo(offestX, 0);
|
|
|
+ itemViewHolder.setLayoutFinish(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getItemCount() {
|
|
|
+ return null == datas ? 0 : datas.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<ItemViewHolder> getViewHolderCacheList() {
|
|
|
+ return mViewHolderList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getOffestX() {
|
|
|
+ return offestX;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static class ItemViewHolder extends RecyclerView.ViewHolder {
|
|
|
+ LinearLayout exposure_roots_view;//根部布局
|
|
|
+ TextView futures_subsidiary;//
|
|
|
+ TextView place_the_order;//
|
|
|
+ LinearLayout exposure_allView;//隐藏的底部操作空间
|
|
|
+ LinearLayout exposure_all_click_View;//item左侧点击控件
|
|
|
+ TextView exposure_tvLeftTitle;//左边
|
|
|
+ TextView exposure_tv_left_bottom_title;//合同编号
|
|
|
+ RecyclerView exposure_rvItemRight;//右方的列表
|
|
|
+ public CustomHorizontalScrollView exposure_horItemScrollview;//右方的滑动控件
|
|
|
+ private boolean isLayoutFinish;//自定义字段,用于标记layout
|
|
|
+
|
|
|
+ public boolean isLayoutFinish() {
|
|
|
+ return isLayoutFinish;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setLayoutFinish(boolean layoutFinish) {
|
|
|
+ isLayoutFinish = layoutFinish;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ItemViewHolder(@NonNull View itemView) {
|
|
|
+ super(itemView);
|
|
|
+ futures_subsidiary = itemView.findViewById(R.id.futures_subsidiary);
|
|
|
+ place_the_order = itemView.findViewById(R.id.place_the_order);
|
|
|
+ exposure_tvLeftTitle = itemView.findViewById(R.id.exposure_tv_left_title);
|
|
|
+ exposure_rvItemRight = itemView.findViewById(R.id.exposure_rv_item_right);
|
|
|
+ exposure_horItemScrollview = itemView.findViewById(R.id.exposure_hor_item_scrollview);
|
|
|
+ exposure_allView = itemView.findViewById(R.id.exposure_all_view);
|
|
|
+ exposure_tv_left_bottom_title = itemView.findViewById(R.id.exposure_tv_left_bottom_title);
|
|
|
+ exposure_all_click_View = itemView.findViewById(R.id.exposure_all_click_View);
|
|
|
+ exposure_roots_view = itemView.findViewById(R.id.exposure_roots_view);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|