@Override public void onClick(View v) { int[] location = new int[2]; firstBlock.getLocationOnScreen(location); LinearLayout map = (LinearLayout) findViewById(R.id.map); Log.v("Left", "" + location[0]); Log.v("Top", "" + location[1]); Log.v("Left", "" + map.getLeft()); Log.v("Top", "" + map.getTop()); // case R.id.restart: // BallStart(); }
@Override public void enterImageDetails( String sharedImageTransitionName, File imageFile, ImageView image, Image imageModel) { // ActivityOptions options = // ActivityOptions.makeSceneTransitionAnimation(this,image,sharedImageTransitionName); int[] los = new int[2]; image.getLocationOnScreen(los); ActivityOptions options1 = ActivityOptions.makeScaleUpAnimation( image, image.getWidth() / 2, image.getHeight() / 2, 0, 0); getWindow().setSharedElementEnterTransition(new ChangeImageTransform(this, null)); Intent intent = ImageDetailActivity.getStartIntent(this, sharedImageTransitionName, imageFile); startActivity(intent, options1.toBundle()); }
/** 显示选择列表 */ 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); }
// 处理游标移动 private void cursorMove(int index) { iv_cursor.setVisibility(View.VISIBLE); iv_cursor_monitor.setVisibility(View.GONE); int[] at_location = new int[2]; // 得到控件在屏幕中的位置 iv_at.getLocationOnScreen(at_location); int[] comment_location = new int[2]; iv_comment.getLocationOnScreen(comment_location); int[] message_location = new int[2]; iv_message.getLocationOnScreen(message_location); int[] notification_location = new int[2]; iv_notification.getLocationOnScreen(notification_location); Animation animation = null; switch (index) { case AT: if (currentIndex == COMMENT) { animation = new TranslateAnimation(comment_location[0], at_location[0], 0, 0); } else if (currentIndex == MESSAGE) { animation = new TranslateAnimation(message_location[0], at_location[0], 0, 0); } else if (currentIndex == NOTIFICATION) { animation = new TranslateAnimation(notification_location[0], at_location[0], 0, 0); } break; case COMMENT: if (currentIndex == AT) { animation = new TranslateAnimation(at_location[0], comment_location[0], 0, 0); } else if (currentIndex == MESSAGE) { animation = new TranslateAnimation(message_location[0], comment_location[0], 0, 0); } else if (currentIndex == NOTIFICATION) { animation = new TranslateAnimation(notification_location[0], comment_location[0], 0, 0); } break; case MESSAGE: if (currentIndex == AT) { animation = new TranslateAnimation(at_location[0], message_location[0], 0, 0); } else if (currentIndex == COMMENT) { animation = new TranslateAnimation(comment_location[0], message_location[0], 0, 0); } else if (currentIndex == NOTIFICATION) { animation = new TranslateAnimation(notification_location[0], message_location[0], 0, 0); } break; case NOTIFICATION: if (currentIndex == AT) { animation = new TranslateAnimation(at_location[0], notification_location[0], 0, 0); } else if (currentIndex == COMMENT) { animation = new TranslateAnimation(comment_location[0], notification_location[0], 0, 0); } else if (currentIndex == MESSAGE) { animation = new TranslateAnimation(message_location[0], notification_location[0], 0, 0); } break; } currentIndex = index; animation.setFillAfter(true); // True:图片停在动画结束位置 animation.setDuration(300); iv_cursor.startAnimation(animation); }