| | |
| | | |
| | | import androidx.lifecycle.LiveData; |
| | | import androidx.lifecycle.MutableLiveData; |
| | | import androidx.recyclerview.widget.GridLayoutManager; |
| | | |
| | | import com.android.app_base.base.BaseConfig; |
| | | import com.android.app_base.base.adapter.BaseRVAdapter; |
| | |
| | | import com.application.zhangshi_app_android.ui.function.FamilyMemorabiliaActivityViewModel; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | |
| | | } |
| | | |
| | | @Override |
| | | protected MyViewHolder getViewHolder(ItemFamilyMemorabiliaBinding itemBind) { |
| | | protected MyViewHolder getViewHolder(ItemFamilyMemorabiliaBinding itemBind,int viewType) { |
| | | return new MyViewHolder(itemBind); |
| | | } |
| | | |
| | |
| | | holder.getBinding().checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { |
| | | @Override |
| | | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { |
| | | List<FamilyMemorabiliaBean> list = new ArrayList<>(Objects.requireNonNull(viewModel.getCheckListLiveData().getValue())); |
| | | if (viewModel.getCheckListLiveData().getValue() == null){ |
| | | viewModel.getCheckListLiveData().setValue(new ArrayList<>()); |
| | | } |
| | | List<FamilyMemorabiliaBean> list = new ArrayList<>(viewModel.getCheckListLiveData().getValue()); |
| | | if (isChecked){ |
| | | list.add(mDataList.get(position)); |
| | | if (!list.contains(mDataList.get(position))){ |
| | | list.add(mDataList.get(position)); |
| | | } |
| | | }else{ |
| | | list.remove(mDataList.get(position)); |
| | | } |
| | | viewModel.getCheckListLiveData().postValue(list); |
| | | viewModel.getCheckListLiveData().setValue(list); |
| | | } |
| | | }); |
| | | holder.getBinding().checkbox.setChecked(viewModel.getCheckListLiveData().getValue().contains(mDataList.get(position))); |
| | |
| | | holder.getBinding().cardView.startAnimation(a); |
| | | holder.isExpended = true; |
| | | } |
| | | holder.getBinding().layoutModify.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | AppManager.getAppManager().startActivity( |
| | | new Intent(getRecyclerView().getContext(), CreateFamilyProjectActivity.class) |
| | | .putExtra(BaseConfig.EXTRA_TYPE,0) |
| | | .putExtra("bean",mDataList.get(position))); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | holder.getBinding().layoutModify.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | AppManager.getAppManager().startActivity( |
| | | new Intent(getRecyclerView().getContext(), CreateFamilyProjectActivity.class) |
| | | .putExtra(BaseConfig.EXTRA_TYPE,0) |
| | | .putExtra("bean",mDataList.get(position))); |
| | | } |
| | | }); |
| | | holder.getBinding().layoutDelete.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | |
| | | } |
| | | }); |
| | | ImageRvAdapter adapter = new ImageRvAdapter(mContext); |
| | | mDataList.get(position).setUrl(mDataList.get(position).getUrl()); |
| | | adapter.setData(mDataList.get(position).getUrlList()); |
| | | holder.getBinding().rvImage.setLayoutManager(new GridLayoutManager(mContext,3)); |
| | | holder.getBinding().rvImage.setAdapter(adapter); |
| | | } |
| | | |
| | | public void setCheckable(boolean b) { |