| | |
| | | package com.application.zhangshi_app_android.ui.home; |
| | | |
| | | import android.annotation.SuppressLint; |
| | | import android.graphics.drawable.ColorDrawable; |
| | | import android.os.Bundle; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.PopupWindow; |
| | | |
| | | import com.android.app_base.base.view.BaseFragment; |
| | | import com.android.app_base.widget.LinearItemDecoration; |
| | | import androidx.databinding.DataBindingUtil; |
| | | import androidx.lifecycle.Observer; |
| | | |
| | | import com.android.app_base.manager.AppManager; |
| | | import com.android.app_base.utils.ScreenSizeUtils; |
| | | import com.application.zhangshi_app_android.BR; |
| | | import com.application.zhangshi_app_android.R; |
| | | import com.application.zhangshi_app_android.adapter.HomeMemberAdapter; |
| | | import com.application.zhangshi_app_android.bean.HomeMemberBean; |
| | | import com.application.zhangshi_app_android.bean.HomeRootBean; |
| | | import com.application.zhangshi_app_android.databinding.FragmentHomeBinding; |
| | | import com.hjq.bar.TitleBar; |
| | | import com.application.zhangshi_app_android.databinding.PopBasicInformationDoubleBinding; |
| | | import com.application.zhangshi_app_android.databinding.PopBasicInformationSingleBinding; |
| | | import com.application.zhangshi_app_android.ui.DLBaseFragment; |
| | | import com.application.zhangshi_app_android.widget.HomeMindMapLayout; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author Ljj |
| | | * @date 2023.3.15 |
| | | * @desc 首页 Fragment |
| | | */ |
| | | public class HomeFragment extends BaseFragment<FragmentHomeBinding,HomeFragmentViewModel> { |
| | | private PopupWindow mPopupWindow; |
| | | private HomeMemberAdapter homeMemberAdapter; |
| | | |
| | | public class HomeFragment extends DLBaseFragment<FragmentHomeBinding,HomeFragmentViewModel> { |
| | | private PopupWindow mOperatePopupWindow; |
| | | public HomeFragment() { |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | @SuppressLint("ClickableViewAccessibility") |
| | | @Override |
| | | protected void initView() { |
| | | mPopupWindow = new PopupWindow(getSelfActivity()); |
| | | mPopupWindow.setContentView(View.inflate(getSelfActivity(),R.layout.pop_basic_information,null)); |
| | | mPopupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT); |
| | | mPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); |
| | | mPopupWindow.setBackgroundDrawable(new ColorDrawable(0x0000)); |
| | | mPopupWindow.setAnimationStyle(com.android.app_base.R.style.pop_info); |
| | | mPopupWindow.setFocusable(true); |
| | | mPopupWindow.setTouchable(true); |
| | | mPopupWindow.setOutsideTouchable(true); |
| | | mOperatePopupWindow = initPopUpWindow(View.inflate(getSelfActivity(),R.layout.pop_operate_home_root_net,null)); |
| | | binding.ivOperate.setOnClickListener(v -> { |
| | | mOperatePopupWindow.showAsDropDown(binding.ivOperate,-ScreenSizeUtils.dip2px(getSelfActivity(),120) +binding.ivOperate.getWidth(),0); |
| | | }); |
| | | mOperatePopupWindow.getContentView().findViewById(R.id.tv_family).setOnClickListener(v -> { |
| | | AppManager.getAppManager().startActivity(GenealogyActivity.class); |
| | | mOperatePopupWindow.dismiss(); |
| | | }); |
| | | binding.scrollHomeMindMapLayout.setOnItemClickListener(new HomeMindMapLayout.OnItemClickListener() { |
| | | @Override |
| | | public void onItemClick(View view, HomeRootBean bean) { |
| | | View contentView; |
| | | if (bean.getSpouse()!=null) { |
| | | bean.getSpouse().setSpouse(bean); |
| | | PopBasicInformationDoubleBinding binding= DataBindingUtil.inflate(getLayoutInflater(),R.layout.pop_basic_information_double,null,false); |
| | | binding.setSelfBean(bean); |
| | | binding.setSpouseBean(bean.getSpouse()); |
| | | contentView = binding.getRoot(); |
| | | }else { |
| | | PopBasicInformationSingleBinding binding = DataBindingUtil.inflate(getLayoutInflater(),R.layout.pop_basic_information_single,null,false); |
| | | binding.setSelfBean(bean); |
| | | contentView = binding.getRoot(); |
| | | } |
| | | PopupWindow popupWindow = new PopupWindow(); |
| | | // 设置布局文件 |
| | | popupWindow.setContentView(contentView); |
| | | // 为了避免部分机型不显示,需要重新设置一下宽高 |
| | | 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_info); |
| | | // 设置pop获取焦点,如果为false点击返回按钮会退出当前Activity,如果pop中有Editor的话,focusable必须要为true |
| | | popupWindow.setFocusable(true); |
| | | // 设置pop可点击,为false点击事件无效,默认为true |
| | | popupWindow.setTouchable(true); |
| | | // 设置点击pop外侧消失,默认为false;在focusable为true时点击外侧始终消失 |
| | | popupWindow.setOutsideTouchable(false); |
| | | |
| | | homeMemberAdapter = new HomeMemberAdapter(getSelfActivity()); |
| | | LinearItemDecoration itemDecoration = new LinearItemDecoration(); |
| | | itemDecoration.setBottomSpace((int) getResources().getDimension(com.android.app_base.R.dimen.dp_8)); |
| | | itemDecoration.setHorizontalSpace((int) getResources().getDimension(com.android.app_base.R.dimen.dp_20)); |
| | | itemDecoration.setFirstTop((int) getResources().getDimension(com.android.app_base.R.dimen.dp_20)); |
| | | binding.rvHomeMember.addItemDecoration(itemDecoration); |
| | | binding.rvHomeMember.setAdapter(homeMemberAdapter); |
| | | |
| | | popupWindow.setHeight(binding.zoomLayout.getHeight()); |
| | | popupWindow.setWidth(binding.zoomLayout.getWidth()); |
| | | popupWindow.showAsDropDown(binding.titleBar,0,0); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | protected void initData() { |
| | | |
| | | viewModel.getHomeRootBeanList(); |
| | | } |
| | | |
| | | @Override |
| | | protected void initLiveDataObserve() { |
| | | |
| | | viewModel.getHomeRootBeanLiveData().observe(this, new Observer<List<HomeRootBean>>() { |
| | | @Override |
| | | public void onChanged(List<HomeRootBean> homeRootBeans) { |
| | | if (homeRootBeans == null || homeRootBeans.size() == 0) { |
| | | return; |
| | | } |
| | | binding.scrollHomeMindMapLayout.setRootMember(homeRootBeans.get(0)); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return true; |
| | | } |
| | | |
| | | private boolean isShow = true; |
| | | @Override |
| | | public void onLeftClick(TitleBar titleBar) { |
| | | // if (isShow) { |
| | | // |
| | | // mPopupWindow.setHeight(binding.treeView.getHeight()); |
| | | // mPopupWindow.showAsDropDown(binding.titleBar,0,0); |
| | | // isShow = false; |
| | | // }else { |
| | | // binding.rvHomeMember.setVisibility(View.VISIBLE); |
| | | // binding.treeView.setVisibility(View.GONE); |
| | | // binding.layoutHomeRootNet.setVisibility(View.GONE); |
| | | // homeMemberAdapter.addItem(new HomeMemberBean("第一代","张三","男",null,"2023.09.09","2023.09.09","12345678901","张氏公司","张四")); |
| | | // homeMemberAdapter.addItem(new HomeMemberBean("第一代","张三","男",null,"2023.09.09","2023.09.09","12345678901","张氏公司","张四")); |
| | | // homeMemberAdapter.addItem(new HomeMemberBean("第一代","张三","男",null,"2023.09.09","2023.09.09","12345678901","张氏公司","张四")); |
| | | // homeMemberAdapter.addItem(new HomeMemberBean("第一代","张三","男",null,"2023.09.09","2023.09.09","12345678901","张氏公司","张四")); |
| | | // homeMemberAdapter.addItem(new HomeMemberBean("第一代","张三","男",null,"2023.09.09","2023.09.09","12345678901","张氏公司","张四")); |
| | | // homeMemberAdapter.addItem(new HomeMemberBean("第一代","张三","男",null,"2023.09.09","2023.09.09","12345678901","张氏公司","张四")); |
| | | // isShow = true; |
| | | // } |
| | | |
| | | |
| | | } |
| | | } |