@Override protected void addHeaderView(ListView listView) { Intent intent = getIntent(); mForumInfo = intent.getParcelableExtra(AppConstants.PARCELABLE_KEY); mBlockInfo = intent.getParcelableExtra(AppConstants.PARCELABLE_KEY_TWO); if (null == mForumInfo) JumpManager.doJumpBack(mActivity); if (TextUtils.isEmpty(mForumInfo.getSectionname())) mForumInfo.setSectionname( null == mBlockInfo ? getString(R.string.string_history) : mBlockInfo.getSectionname()); ReadHistoryManager.add(mForumInfo); HeaderForumDetailBinding inflate = DataBindingUtil.inflate( LayoutInflater.from(mActivity), R.layout.header_forum_detail, null, false); inflate.setImgInfo( new ImgBinding( mForumInfo.getUserImage(), R.drawable.ic_default_head, R.dimen.dimen_30, 10)); inflate.tvName.setOnClickListener( v -> UserManager.jumpToOtherPeople(mActivity, mForumInfo.getPkUser())); inflate.setInfo(mForumInfo); String images = mForumInfo.getImages(); if (!TextUtils.isEmpty(images)) { String[] split = images.split(","); inflate.llImgContent.removeAllViews(); ArrayList<ImgInfo> imgList = new ArrayList<>(); for (String url : split) { ImgInfo info = new ImgInfo(); info.setPath(url); imgList.add(info); } for (int position = 0; position < imgList.size(); position++) { ItemForumImageBinding imgBinding = DataBindingUtil.inflate( LayoutInflater.from(mActivity), R.layout.item_forum_image, null, false); imgBinding.setImgInfo( new ImgBinding(imgList.get(position).getPath(), R.drawable.ic_default_img)); final int currentPosition = position; imgBinding.ivInfo.setOnClickListener( v -> { Intent photoIntent = new Intent(mActivity, PhotoPreviewActivity.class); photoIntent.putParcelableArrayListExtra(AppConstants.PARCELABLE_KEY, imgList); photoIntent.putExtra(PhotoPreviewActivity.POSITION, currentPosition); photoIntent.putExtra(PhotoPreviewActivity.HIDENDELETE, true); JumpManager.doJumpForward(mActivity, photoIntent); }); inflate.llImgContent.addView(imgBinding.getRoot()); } } inflate.tvForumName.setText( mBlockInfo == null ? mForumInfo.getSectionname() : mBlockInfo.getSectionname()); inflate.tvForumName.setOnClickListener(v -> JumpManager.doJumpBack(mActivity)); inflate.ivShowAction.setOnClickListener(v -> showAction(inflate)); listView.addHeaderView(inflate.getRoot()); }
@Override public void initView(ViewDataBinding viewDataBinding) { super.initView(viewDataBinding); mBinding = (ActivityForumDetailBinding) viewDataBinding; mBinding.titleBar.setLeftText(R.string.back); mBinding.titleBar.setLeftListener(v -> JumpManager.doJumpBack(mActivity)); mBinding.titleBar.setRightText(R.string.title_right_store); mBinding.titleBar.setRightListener(V -> doStore()); mRefreshList.getRefreshableView().setVerticalScrollBarEnabled(false); mBinding.rlContent.setChanged( (w, h, oldw, oldh) -> { maxHeight = Math.max(maxHeight, h); if (maxHeight > h) { mRefreshList .getRefreshableView() .setOnTouchListener( (v, event) -> { hidenReply(); return false; }); } else { mRefreshList.getRefreshableView().setOnTouchListener((v, event) -> false); } }); requestAddReadCount(); }
/** 显示选择列表 */ private void showAction(HeaderForumDetailBinding floor) { ((ForumDetailActivity) mActivity).hidenReply(); PopuFloorHostBinding inflate = DataBindingUtil.inflate( LayoutInflater.from(mActivity), R.layout.popu_floor_host, null, false); View rootView = inflate.getRoot(); ImageView parentView = floor.ivShowAction; AppPopupWindow popupWindow = new AppPopupWindow(mActivity, parentView); inflate.btnReply.setVisibility(View.GONE); inflate.btnComment.setOnClickListener( v -> { popupWindow.dismiss(); Intent intent = new Intent(mActivity, ReplyCommentActivity.class); intent.putExtra(AppConstants.EXTRA_STRING, mForumInfo.getPkPosts()); JumpManager.doJumpForwardWithResult(mActivity, intent, 1002); }); inflate.btnReport.setOnClickListener( v -> { popupWindow.dismiss(); Intent intent = new Intent(mActivity, ReprotActivity.class); intent.putExtra(ReprotActivity.PK_POSTS, mForumInfo.getPkPosts()); intent.putExtra(ReprotActivity.PK_USER, mForumInfo.getPkUser()); intent.putExtra(ReprotActivity.CONTENT, mForumInfo.getContent()); JumpManager.doJumpForward(mActivity, intent); }); popupWindow.setWidth(LinearLayout.LayoutParams.WRAP_CONTENT); popupWindow.setHeight(LinearLayout.LayoutParams.WRAP_CONTENT); popupWindow.setBackgroundDrawable(new BitmapDrawable()); popupWindow.setOutsideTouchable(true); popupWindow.setFocusable(true); popupWindow.setContentView(rootView); int[] location = new int[2]; parentView.getLocationOnScreen(location); int x = location[0]; int y = location[1]; rootView.measure(0, 0); popupWindow.showAtLocation( parentView, Gravity.NO_GRAVITY, x + parentView.getWidth() - rootView.getMeasuredWidth(), y + parentView.getHeight() / 2 - rootView.getMeasuredHeight() / 2); }