| | |
| | | package com.application.zhangshi_app_android.widget; |
| | | |
| | | import android.content.Context; |
| | | import android.graphics.Path; |
| | | import android.graphics.drawable.ColorDrawable; |
| | | import android.view.Gravity; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.ImageView; |
| | | import android.widget.PopupWindow; |
| | | import android.widget.TextView; |
| | | |
| | | import androidx.constraintlayout.utils.widget.ImageFilterView; |
| | | import androidx.databinding.DataBindingUtil; |
| | | |
| | | import com.android.app_base.manager.AppManager; |
| | | import com.android.app_base.utils.GlideUtil; |
| | | import com.android.app_base.utils.ScreenSizeUtils; |
| | | import com.application.zhangshi_app_android.R; |
| | | import com.application.zhangshi_app_android.bean.HomeRootBean; |
| | | import com.application.zhangshi_app_android.databinding.PopBasicInformationBinding; |
| | | import com.otaliastudios.zoom.ZoomLayout; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedList; |
| | |
| | | * @desc |
| | | */ |
| | | public abstract class Node{ |
| | | protected Context context; |
| | | protected HomeRootBean member;//成员 |
| | | protected Node parent;//父节点 |
| | | protected final List<Node> children = new ArrayList<>(); //子节点 |
| | |
| | | protected final List<Path> forkPathList = new ArrayList<>();//分叉连线 |
| | | protected final List<View> viewList = new ArrayList<>(); |
| | | |
| | | public Node(HomeRootBean member){ |
| | | public Node(Context context,HomeRootBean member){ |
| | | this.context = context; |
| | | this.member = member; |
| | | if (member != null) { |
| | | // 递归创建子节点 |
| | |
| | | if (child != null) { |
| | | Node node; |
| | | if (child.getSpouse() != null) { |
| | | node = new DoubleNode(child); |
| | | node = new DoubleNode(context,child); |
| | | } else { |
| | | node = new SimpleNode(child); |
| | | node = new SimpleNode(context,child); |
| | | } |
| | | node.parent = this; |
| | | children.add(node); |
| | |
| | | |
| | | protected View createItemView(HomeRootBean bean) { |
| | | // 使用布局填充器加载节点布局 |
| | | LayoutInflater inflater = LayoutInflater.from(AppManager.getAppManager().currentActivity()); |
| | | LayoutInflater inflater = LayoutInflater.from(context); |
| | | View familyMemberView = inflater.inflate(R.layout.item_family_member, null, false); |
| | | familyMemberView.measure(View.MeasureSpec.makeMeasureSpec((1 << 30) - 1, View.MeasureSpec.AT_MOST), |
| | | View.MeasureSpec.makeMeasureSpec((1 << 30) - 1, View.MeasureSpec.AT_MOST)); |
| | |
| | | } |
| | | tv_name.setText(bean.getNickName()); |
| | | tv_name.setSelected(true); |
| | | familyMemberView.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | PopBasicInformationBinding mBinding= DataBindingUtil.inflate(inflater,R.layout.pop_basic_information,null,false); |
| | | PopupWindow popupWindow = new PopupWindow(); |
| | | // 设置布局文件 |
| | | popupWindow.setContentView(mBinding.getRoot()); |
| | | // 为了避免部分机型不显示,需要重新设置一下宽高 |
| | | popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); |
| | | popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); |
| | | // 设置pop透明效果 |
| | | popupWindow.setBackgroundDrawable(new ColorDrawable(0x0000)); |
| | | // 设置pop出入动画 |
| | | popupWindow.setAnimationStyle(com.android.app_base.R.style.pop_operate); |
| | | // 设置pop获取焦点,如果为false点击返回按钮会退出当前Activity,如果pop中有Editor的话,focusable必须要为true |
| | | popupWindow.setFocusable(true); |
| | | // 设置pop可点击,为false点击事件无效,默认为true |
| | | popupWindow.setTouchable(true); |
| | | // 设置点击pop外侧消失,默认为false;在focusable为true时点击外侧始终消失 |
| | | popupWindow.setOutsideTouchable(false); |
| | | |
| | | mBinding.setSelfBean(bean); |
| | | mBinding.setSpouseBean(bean.getSpouse()); |
| | | ZoomLayout zoomLayout = (ZoomLayout) familyMemberView.getParent().getParent(); |
| | | popupWindow.setHeight(zoomLayout.getHeight()); |
| | | popupWindow.setWidth(zoomLayout.getWidth()); |
| | | popupWindow.showAtLocation((View) familyMemberView.getParent().getParent(), Gravity.BOTTOM,0,0); |
| | | } |
| | | }); |
| | | return familyMemberView; |
| | | } |
| | | |
| | | protected ImageView createExpandIconView() { |
| | | ImageView expandView = new ImageView(AppManager.getAppManager().currentActivity()); |
| | | FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(pathLength,pathLength); |