List of usage examples for android.animation AnimatorSet start
@SuppressWarnings("unchecked") @Override public void start()
Starting this AnimatorSet
will, in turn, start the animations for which it is responsible.
From source file:org.telegram.ui.ArticleViewer.java
private boolean open(final MessageObject messageObject, boolean first) { if (parentActivity == null || isVisible && !collapsed || messageObject == null) { return false; }// w w w. j a v a 2s . com if (first) { TLRPC.TL_messages_getWebPage req = new TLRPC.TL_messages_getWebPage(); req.url = messageObject.messageOwner.media.webpage.url; if (messageObject.messageOwner.media.webpage.cached_page instanceof TLRPC.TL_pagePart) { req.hash = 0; } else { req.hash = messageObject.messageOwner.media.webpage.hash; } ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { if (response instanceof TLRPC.TL_webPage) { final TLRPC.TL_webPage webPage = (TLRPC.TL_webPage) response; if (webPage.cached_page == null) { return; } AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { if (!pagesStack.isEmpty() && pagesStack.get(0) == messageObject.messageOwner.media.webpage && webPage.cached_page != null) { messageObject.messageOwner.media.webpage = webPage; pagesStack.set(0, webPage); if (pagesStack.size() == 1) { currentPage = webPage; ApplicationLoader.applicationContext .getSharedPreferences("articles", Activity.MODE_PRIVATE).edit() .remove("article" + currentPage.id).commit(); updateInterfaceForCurrentPage(false); } } } }); HashMap<Long, TLRPC.WebPage> webpages = new HashMap<>(); webpages.put(webPage.id, webPage); MessagesStorage.getInstance().putWebPages(webpages); } } }); } pagesStack.clear(); collapsed = false; backDrawable.setRotation(0, false); containerView.setTranslationX(0); containerView.setTranslationY(0); listView.setTranslationY(0); listView.setAlpha(1.0f); windowView.setInnerTranslationX(0); actionBar.setVisibility(View.GONE); bottomLayout.setVisibility(View.GONE); captionTextViewNew.setVisibility(View.GONE); captionTextViewOld.setVisibility(View.GONE); shareContainer.setAlpha(0.0f); backButton.setAlpha(0.0f); layoutManager.scrollToPositionWithOffset(0, 0); checkScroll(-AndroidUtilities.dp(56)); TLRPC.WebPage webPage = messageObject.messageOwner.media.webpage; String webPageUrl = webPage.url.toLowerCase(); int index; String anchor = null; for (int a = 0; a < messageObject.messageOwner.entities.size(); a++) { TLRPC.MessageEntity entity = messageObject.messageOwner.entities.get(a); if (entity instanceof TLRPC.TL_messageEntityUrl) { try { String url = messageObject.messageOwner.message .substring(entity.offset, entity.offset + entity.length).toLowerCase(); if (url.contains(webPageUrl) || webPageUrl.contains(url)) { if ((index = url.lastIndexOf('#')) != -1) { anchor = url.substring(index + 1); } break; } } catch (Exception e) { FileLog.e(e); } } } addPageToStack(webPage, anchor); lastInsets = null; if (!isVisible) { WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE); if (attachedToWindow) { try { wm.removeView(windowView); } catch (Exception e) { //ignore } } try { if (Build.VERSION.SDK_INT >= 21) { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; } windowLayoutParams.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; windowView.setFocusable(false); containerView.setFocusable(false); wm.addView(windowView, windowLayoutParams); } catch (Exception e) { FileLog.e(e); return false; } } else { windowLayoutParams.flags &= ~WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE); wm.updateViewLayout(windowView, windowLayoutParams); } isVisible = true; animationInProgress = 1; windowView.setAlpha(0); containerView.setAlpha(0); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(windowView, "alpha", 0, 1.0f), ObjectAnimator.ofFloat(containerView, "alpha", 0.0f, 1.0f), ObjectAnimator.ofFloat(windowView, "translationX", AndroidUtilities.dp(56), 0)); animationEndRunnable = new Runnable() { @Override public void run() { if (containerView == null || windowView == null) { return; } if (Build.VERSION.SDK_INT >= 18) { containerView.setLayerType(View.LAYER_TYPE_NONE, null); } animationInProgress = 0; } }; animatorSet.setDuration(150); animatorSet.setInterpolator(interpolator); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { NotificationCenter.getInstance().setAnimationInProgress(false); if (animationEndRunnable != null) { animationEndRunnable.run(); animationEndRunnable = null; } } }); } }); transitionAnimationStartTime = System.currentTimeMillis(); AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { NotificationCenter.getInstance() .setAllowedNotificationsDutingAnimation(new int[] { NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats, NotificationCenter.mediaCountDidLoaded, NotificationCenter.mediaDidLoaded, NotificationCenter.dialogPhotosLoaded }); NotificationCenter.getInstance().setAnimationInProgress(true); animatorSet.start(); } }); if (Build.VERSION.SDK_INT >= 18) { containerView.setLayerType(View.LAYER_TYPE_HARDWARE, null); } showActionBar(200); return true; }
From source file:net.bluehack.ui.PhotoViewer.java
public boolean openPhoto(final MessageObject messageObject, final TLRPC.FileLocation fileLocation, final ArrayList<MessageObject> messages, final ArrayList<Object> photos, final int index, final PhotoViewerProvider provider, ChatActivity chatActivity, long dialogId, long mDialogId) { if (parentActivity == null || isVisible || provider == null && checkAnimation() || messageObject == null && fileLocation == null && messages == null && photos == null) { return false; }//from w w w . j a va 2s.c o m final PlaceProviderObject object = provider.getPlaceForPhoto(messageObject, fileLocation, index); if (object == null && photos == null) { return false; } WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE); if (attachedToWindow) { try { wm.removeView(windowView); } catch (Exception e) { //don't promt } } try { windowLayoutParams.type = WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; if (Build.VERSION.SDK_INT >= 21) { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; } else { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; } windowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION; windowView.setFocusable(false); containerView.setFocusable(false); wm.addView(windowView, windowLayoutParams); } catch (Exception e) { FileLog.e("tmessages", e); return false; } parentChatActivity = chatActivity; actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, 1, 1)); NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidFailedLoad); NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileLoadProgressChanged); NotificationCenter.getInstance().addObserver(this, NotificationCenter.mediaCountDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.mediaDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.dialogPhotosLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded); placeProvider = provider; mergeDialogId = mDialogId; currentDialogId = dialogId; if (velocityTracker == null) { velocityTracker = VelocityTracker.obtain(); } isVisible = true; toggleActionBar(true, false); if (object != null) { disableShowCheck = true; animationInProgress = 1; if (messageObject != null) { currentAnimation = object.imageReceiver.getAnimation(); } onPhotoShow(messageObject, fileLocation, messages, photos, index, object); final Rect drawRegion = object.imageReceiver.getDrawRegion(); int orientation = object.imageReceiver.getOrientation(); int animatedOrientation = object.imageReceiver.getAnimatedOrientation(); if (animatedOrientation != 0) { orientation = animatedOrientation; } animatingImageView.setVisibility(View.VISIBLE); animatingImageView.setRadius(object.radius); animatingImageView.setOrientation(orientation); animatingImageView.setNeedRadius(object.radius != 0); animatingImageView.setImageBitmap(object.thumb); animatingImageView.setAlpha(1.0f); animatingImageView.setPivotX(0.0f); animatingImageView.setPivotY(0.0f); animatingImageView.setScaleX(object.scale); animatingImageView.setScaleY(object.scale); animatingImageView.setTranslationX(object.viewX + drawRegion.left * object.scale); animatingImageView.setTranslationY(object.viewY + drawRegion.top * object.scale); final ViewGroup.LayoutParams layoutParams = animatingImageView.getLayoutParams(); layoutParams.width = (drawRegion.right - drawRegion.left); layoutParams.height = (drawRegion.bottom - drawRegion.top); animatingImageView.setLayoutParams(layoutParams); float scaleX = (float) AndroidUtilities.displaySize.x / layoutParams.width; float scaleY = (float) (AndroidUtilities.displaySize.y + (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0)) / layoutParams.height; float scale = scaleX > scaleY ? scaleY : scaleX; float width = layoutParams.width * scale; float height = layoutParams.height * scale; float xPos = (AndroidUtilities.displaySize.x - width) / 2.0f; float yPos = ((AndroidUtilities.displaySize.y + (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0)) - height) / 2.0f; int clipHorizontal = Math.abs(drawRegion.left - object.imageReceiver.getImageX()); int clipVertical = Math.abs(drawRegion.top - object.imageReceiver.getImageY()); int coords2[] = new int[2]; object.parentView.getLocationInWindow(coords2); int clipTop = coords2[1] - (Build.VERSION.SDK_INT >= 21 ? 0 : AndroidUtilities.statusBarHeight) - (object.viewY + drawRegion.top) + object.clipTopAddition; if (clipTop < 0) { clipTop = 0; } int clipBottom = (object.viewY + drawRegion.top + layoutParams.height) - (coords2[1] + object.parentView.getHeight() - (Build.VERSION.SDK_INT >= 21 ? 0 : AndroidUtilities.statusBarHeight)) + object.clipBottomAddition; if (clipBottom < 0) { clipBottom = 0; } clipTop = Math.max(clipTop, clipVertical); clipBottom = Math.max(clipBottom, clipVertical); animationValues[0][0] = animatingImageView.getScaleX(); animationValues[0][1] = animatingImageView.getScaleY(); animationValues[0][2] = animatingImageView.getTranslationX(); animationValues[0][3] = animatingImageView.getTranslationY(); animationValues[0][4] = clipHorizontal * object.scale; animationValues[0][5] = clipTop * object.scale; animationValues[0][6] = clipBottom * object.scale; animationValues[0][7] = animatingImageView.getRadius(); animationValues[1][0] = scale; animationValues[1][1] = scale; animationValues[1][2] = xPos; animationValues[1][3] = yPos; animationValues[1][4] = 0; animationValues[1][5] = 0; animationValues[1][6] = 0; animationValues[1][7] = 0; animatingImageView.setAnimationProgress(0); backgroundDrawable.setAlpha(0); containerView.setAlpha(0); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(animatingImageView, "animationProgress", 0.0f, 1.0f), ObjectAnimator.ofInt(backgroundDrawable, "alpha", 0, 255), ObjectAnimator.ofFloat(containerView, "alpha", 0.0f, 1.0f)); animationEndRunnable = new Runnable() { @Override public void run() { if (containerView == null || windowView == null) { return; } if (Build.VERSION.SDK_INT >= 18) { containerView.setLayerType(View.LAYER_TYPE_NONE, null); } animationInProgress = 0; transitionAnimationStartTime = 0; setImages(); containerView.invalidate(); animatingImageView.setVisibility(View.GONE); if (showAfterAnimation != null) { showAfterAnimation.imageReceiver.setVisible(true, true); } if (hideAfterAnimation != null) { hideAfterAnimation.imageReceiver.setVisible(false, true); } if (photos != null && sendPhotoType != 3) { if (Build.VERSION.SDK_INT >= 21) { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; } else { windowLayoutParams.flags = 0; } windowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION; WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE); wm.updateViewLayout(windowView, windowLayoutParams); windowView.setFocusable(true); containerView.setFocusable(true); } } }; animatorSet.setDuration(200); animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { NotificationCenter.getInstance().setAnimationInProgress(false); if (animationEndRunnable != null) { animationEndRunnable.run(); animationEndRunnable = null; } } }); } }); transitionAnimationStartTime = System.currentTimeMillis(); AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { NotificationCenter.getInstance() .setAllowedNotificationsDutingAnimation(new int[] { NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats, NotificationCenter.mediaCountDidLoaded, NotificationCenter.mediaDidLoaded, NotificationCenter.dialogPhotosLoaded }); NotificationCenter.getInstance().setAnimationInProgress(true); animatorSet.start(); } }); if (Build.VERSION.SDK_INT >= 18) { containerView.setLayerType(View.LAYER_TYPE_HARDWARE, null); } backgroundDrawable.drawRunnable = new Runnable() { @Override public void run() { disableShowCheck = false; object.imageReceiver.setVisible(false, true); } }; } else { if (photos != null && sendPhotoType != 3) { if (Build.VERSION.SDK_INT >= 21) { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; } else { windowLayoutParams.flags = 0; } windowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION; wm.updateViewLayout(windowView, windowLayoutParams); windowView.setFocusable(true); containerView.setFocusable(true); } backgroundDrawable.setAlpha(255); containerView.setAlpha(1.0f); onPhotoShow(messageObject, fileLocation, messages, photos, index, object); } return true; }
From source file:kr.wdream.ui.PhotoViewer.java
public boolean openPhoto(final MessageObject messageObject, final TLRPC.FileLocation fileLocation, final ArrayList<MessageObject> messages, final ArrayList<Object> photos, final int index, final PhotoViewerProvider provider, ChatActivity chatActivity, long dialogId, long mDialogId) { if (parentActivity == null || isVisible || provider == null && checkAnimation() || messageObject == null && fileLocation == null && messages == null && photos == null) { return false; }/*from ww w . j a v a2s .com*/ final PlaceProviderObject object = provider.getPlaceForPhoto(messageObject, fileLocation, index); if (object == null && photos == null) { return false; } WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE); if (attachedToWindow) { try { wm.removeView(windowView); } catch (Exception e) { //don't promt } } try { windowLayoutParams.type = WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; if (Build.VERSION.SDK_INT >= 21) { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; } else { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; } windowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION; windowView.setFocusable(false); containerView.setFocusable(false); wm.addView(windowView, windowLayoutParams); } catch (Exception e) { FileLog.e("tmessages", e); return false; } parentChatActivity = chatActivity; actionBar.setTitle(LocaleController.formatString("Of", kr.wdream.storyshop.R.string.Of, 1, 1)); NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidFailedLoad); NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileLoadProgressChanged); NotificationCenter.getInstance().addObserver(this, NotificationCenter.mediaCountDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.mediaDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.dialogPhotosLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded); placeProvider = provider; mergeDialogId = mDialogId; currentDialogId = dialogId; if (velocityTracker == null) { velocityTracker = VelocityTracker.obtain(); } isVisible = true; toggleActionBar(true, false); if (object != null) { disableShowCheck = true; animationInProgress = 1; if (messageObject != null) { currentAnimation = object.imageReceiver.getAnimation(); } onPhotoShow(messageObject, fileLocation, messages, photos, index, object); final Rect drawRegion = object.imageReceiver.getDrawRegion(); int orientation = object.imageReceiver.getOrientation(); int animatedOrientation = object.imageReceiver.getAnimatedOrientation(); if (animatedOrientation != 0) { orientation = animatedOrientation; } animatingImageView.setVisibility(View.VISIBLE); animatingImageView.setRadius(object.radius); animatingImageView.setOrientation(orientation); animatingImageView.setNeedRadius(object.radius != 0); animatingImageView.setImageBitmap(object.thumb); animatingImageView.setAlpha(1.0f); animatingImageView.setPivotX(0.0f); animatingImageView.setPivotY(0.0f); animatingImageView.setScaleX(object.scale); animatingImageView.setScaleY(object.scale); animatingImageView.setTranslationX(object.viewX + drawRegion.left * object.scale); animatingImageView.setTranslationY(object.viewY + drawRegion.top * object.scale); final ViewGroup.LayoutParams layoutParams = animatingImageView.getLayoutParams(); layoutParams.width = (drawRegion.right - drawRegion.left); layoutParams.height = (drawRegion.bottom - drawRegion.top); animatingImageView.setLayoutParams(layoutParams); float scaleX = (float) AndroidUtilities.displaySize.x / layoutParams.width; float scaleY = (float) (AndroidUtilities.displaySize.y + (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0)) / layoutParams.height; float scale = scaleX > scaleY ? scaleY : scaleX; float width = layoutParams.width * scale; float height = layoutParams.height * scale; float xPos = (AndroidUtilities.displaySize.x - width) / 2.0f; float yPos = ((AndroidUtilities.displaySize.y + (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0)) - height) / 2.0f; int clipHorizontal = Math.abs(drawRegion.left - object.imageReceiver.getImageX()); int clipVertical = Math.abs(drawRegion.top - object.imageReceiver.getImageY()); int coords2[] = new int[2]; object.parentView.getLocationInWindow(coords2); int clipTop = coords2[1] - (Build.VERSION.SDK_INT >= 21 ? 0 : AndroidUtilities.statusBarHeight) - (object.viewY + drawRegion.top) + object.clipTopAddition; if (clipTop < 0) { clipTop = 0; } int clipBottom = (object.viewY + drawRegion.top + layoutParams.height) - (coords2[1] + object.parentView.getHeight() - (Build.VERSION.SDK_INT >= 21 ? 0 : AndroidUtilities.statusBarHeight)) + object.clipBottomAddition; if (clipBottom < 0) { clipBottom = 0; } clipTop = Math.max(clipTop, clipVertical); clipBottom = Math.max(clipBottom, clipVertical); animationValues[0][0] = animatingImageView.getScaleX(); animationValues[0][1] = animatingImageView.getScaleY(); animationValues[0][2] = animatingImageView.getTranslationX(); animationValues[0][3] = animatingImageView.getTranslationY(); animationValues[0][4] = clipHorizontal * object.scale; animationValues[0][5] = clipTop * object.scale; animationValues[0][6] = clipBottom * object.scale; animationValues[0][7] = animatingImageView.getRadius(); animationValues[1][0] = scale; animationValues[1][1] = scale; animationValues[1][2] = xPos; animationValues[1][3] = yPos; animationValues[1][4] = 0; animationValues[1][5] = 0; animationValues[1][6] = 0; animationValues[1][7] = 0; animatingImageView.setAnimationProgress(0); backgroundDrawable.setAlpha(0); containerView.setAlpha(0); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(animatingImageView, "animationProgress", 0.0f, 1.0f), ObjectAnimator.ofInt(backgroundDrawable, "alpha", 0, 255), ObjectAnimator.ofFloat(containerView, "alpha", 0.0f, 1.0f)); animationEndRunnable = new Runnable() { @Override public void run() { if (containerView == null || windowView == null) { return; } if (Build.VERSION.SDK_INT >= 18) { containerView.setLayerType(View.LAYER_TYPE_NONE, null); } animationInProgress = 0; transitionAnimationStartTime = 0; setImages(); containerView.invalidate(); animatingImageView.setVisibility(View.GONE); if (showAfterAnimation != null) { showAfterAnimation.imageReceiver.setVisible(true, true); } if (hideAfterAnimation != null) { hideAfterAnimation.imageReceiver.setVisible(false, true); } if (photos != null && sendPhotoType != 3) { if (Build.VERSION.SDK_INT >= 21) { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; } else { windowLayoutParams.flags = 0; } windowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION; WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE); wm.updateViewLayout(windowView, windowLayoutParams); windowView.setFocusable(true); containerView.setFocusable(true); } } }; animatorSet.setDuration(200); animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { NotificationCenter.getInstance().setAnimationInProgress(false); if (animationEndRunnable != null) { animationEndRunnable.run(); animationEndRunnable = null; } } }); } }); transitionAnimationStartTime = System.currentTimeMillis(); AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { NotificationCenter.getInstance() .setAllowedNotificationsDutingAnimation(new int[] { NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats, NotificationCenter.mediaCountDidLoaded, NotificationCenter.mediaDidLoaded, NotificationCenter.dialogPhotosLoaded }); NotificationCenter.getInstance().setAnimationInProgress(true); animatorSet.start(); } }); if (Build.VERSION.SDK_INT >= 18) { containerView.setLayerType(View.LAYER_TYPE_HARDWARE, null); } backgroundDrawable.drawRunnable = new Runnable() { @Override public void run() { disableShowCheck = false; object.imageReceiver.setVisible(false, true); } }; } else { if (photos != null && sendPhotoType != 3) { if (Build.VERSION.SDK_INT >= 21) { windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS; } else { windowLayoutParams.flags = 0; } windowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION; wm.updateViewLayout(windowView, windowLayoutParams); windowView.setFocusable(true); containerView.setFocusable(true); } backgroundDrawable.setAlpha(255); containerView.setAlpha(1.0f); onPhotoShow(messageObject, fileLocation, messages, photos, index, object); } return true; }
From source file:org.telegram.ui.PassportActivity.java
public void setPage(int page, boolean animated, Bundle params) { if (page == 3) { doneItem.setVisibility(View.GONE); }/*from ww w .j av a 2 s. c o m*/ final SlideView outView = views[currentViewNum]; final SlideView newView = views[page]; currentViewNum = page; newView.setParams(params, false); newView.onShow(); if (animated) { newView.setTranslationX(AndroidUtilities.displaySize.x); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.setDuration(300); animatorSet.playTogether( ObjectAnimator.ofFloat(outView, "translationX", -AndroidUtilities.displaySize.x), ObjectAnimator.ofFloat(newView, "translationX", 0)); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { newView.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animation) { outView.setVisibility(View.GONE); outView.setX(0); } }); animatorSet.start(); } else { newView.setTranslationX(0); newView.setVisibility(View.VISIBLE); if (outView != newView) { outView.setVisibility(View.GONE); } } }
From source file:org.telegram.ui.ArticleViewer.java
public void collapse() { if (parentActivity == null || !isVisible || checkAnimation()) { return;/* ww w.j ava 2 s .c om*/ } if (fullscreenVideoContainer.getVisibility() == View.VISIBLE) { if (customView != null) { fullscreenVideoContainer.setVisibility(View.INVISIBLE); customViewCallback.onCustomViewHidden(); fullscreenVideoContainer.removeView(customView); customView = null; } else if (fullscreenedVideo != null) { fullscreenedVideo.exitFullscreen(); } } if (isPhotoVisible) { closePhoto(false); } try { if (visibleDialog != null) { visibleDialog.dismiss(); visibleDialog = null; } } catch (Exception e) { FileLog.e(e); } AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether( ObjectAnimator.ofFloat(containerView, "translationX", containerView.getMeasuredWidth() - AndroidUtilities.dp(56)), ObjectAnimator.ofFloat(containerView, "translationY", ActionBar.getCurrentActionBarHeight() + (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0)), ObjectAnimator.ofFloat(windowView, "alpha", 0.0f), ObjectAnimator.ofFloat(listView, "alpha", 0.0f), ObjectAnimator.ofFloat(listView, "translationY", -AndroidUtilities.dp(56)), ObjectAnimator.ofFloat(headerView, "translationY", 0), ObjectAnimator.ofFloat(backButton, "scaleX", 1.0f), ObjectAnimator.ofFloat(backButton, "scaleY", 1.0f), ObjectAnimator.ofFloat(backButton, "translationY", 0), ObjectAnimator.ofFloat(shareContainer, "scaleX", 1.0f), ObjectAnimator.ofFloat(shareContainer, "translationY", 0), ObjectAnimator.ofFloat(shareContainer, "scaleY", 1.0f)); collapsed = true; animationInProgress = 2; animationEndRunnable = new Runnable() { @Override public void run() { if (containerView == null) { return; } if (Build.VERSION.SDK_INT >= 18) { containerView.setLayerType(View.LAYER_TYPE_NONE, null); } animationInProgress = 0; //windowLayoutParams.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE); wm.updateViewLayout(windowView, windowLayoutParams); //onClosed(); //containerView.setScaleX(1.0f); //containerView.setScaleY(1.0f); } }; animatorSet.setInterpolator(new DecelerateInterpolator()); animatorSet.setDuration(250); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (animationEndRunnable != null) { animationEndRunnable.run(); animationEndRunnable = null; } } }); transitionAnimationStartTime = System.currentTimeMillis(); if (Build.VERSION.SDK_INT >= 18) { containerView.setLayerType(View.LAYER_TYPE_HARDWARE, null); } backDrawable.setRotation(1, true); animatorSet.start(); }
From source file:org.telegram.ui.ArticleViewer.java
public boolean openPhoto(TLRPC.PageBlock block) { if (parentActivity == null || isPhotoVisible || checkPhotoAnimation() || block == null) { return false; }/* www. ja v a 2 s . com*/ final PlaceProviderObject object = getPlaceForPhoto(block); if (object == null) { return false; } NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidFailedLoad); NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileLoadProgressChanged); NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded); if (velocityTracker == null) { velocityTracker = VelocityTracker.obtain(); } isPhotoVisible = true; toggleActionBar(true, false); actionBar.setAlpha(0.0f); bottomLayout.setAlpha(0.0f); captionTextView.setAlpha(0.0f); photoBackgroundDrawable.setAlpha(0); disableShowCheck = true; photoAnimationInProgress = 1; if (block != null) { currentAnimation = object.imageReceiver.getAnimation(); } int index = photoBlocks.indexOf(block); imagesArr.clear(); if (!(block instanceof TLRPC.TL_pageBlockVideo) || isVideoBlock(block)) { imagesArr.addAll(photoBlocks); } else { imagesArr.add(block); index = 0; } onPhotoShow(index, object); final Rect drawRegion = object.imageReceiver.getDrawRegion(); int orientation = object.imageReceiver.getOrientation(); int animatedOrientation = object.imageReceiver.getAnimatedOrientation(); if (animatedOrientation != 0) { orientation = animatedOrientation; } animatingImageView.setVisibility(View.VISIBLE); animatingImageView.setRadius(object.radius); animatingImageView.setOrientation(orientation); animatingImageView.setNeedRadius(object.radius != 0); animatingImageView.setImageBitmap(object.thumb); animatingImageView.setAlpha(1.0f); animatingImageView.setPivotX(0.0f); animatingImageView.setPivotY(0.0f); animatingImageView.setScaleX(object.scale); animatingImageView.setScaleY(object.scale); animatingImageView.setTranslationX(object.viewX + drawRegion.left * object.scale); animatingImageView.setTranslationY(object.viewY + drawRegion.top * object.scale); final ViewGroup.LayoutParams layoutParams = animatingImageView.getLayoutParams(); layoutParams.width = (drawRegion.right - drawRegion.left); layoutParams.height = (drawRegion.bottom - drawRegion.top); animatingImageView.setLayoutParams(layoutParams); float scaleX = (float) AndroidUtilities.displaySize.x / layoutParams.width; float scaleY = (float) (AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight) / layoutParams.height; float scale = scaleX > scaleY ? scaleY : scaleX; float width = layoutParams.width * scale; float height = layoutParams.height * scale; float xPos = (AndroidUtilities.displaySize.x - width) / 2.0f; if (Build.VERSION.SDK_INT >= 21 && lastInsets != null) { xPos += ((WindowInsets) lastInsets).getSystemWindowInsetLeft(); } float yPos = ((AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight) - height) / 2.0f; int clipHorizontal = Math.abs(drawRegion.left - object.imageReceiver.getImageX()); int clipVertical = Math.abs(drawRegion.top - object.imageReceiver.getImageY()); int coords2[] = new int[2]; object.parentView.getLocationInWindow(coords2); int clipTop = coords2[1] - (object.viewY + drawRegion.top) + object.clipTopAddition; if (clipTop < 0) { clipTop = 0; } int clipBottom = (object.viewY + drawRegion.top + layoutParams.height) - (coords2[1] + object.parentView.getHeight()) + object.clipBottomAddition; if (clipBottom < 0) { clipBottom = 0; } clipTop = Math.max(clipTop, clipVertical); clipBottom = Math.max(clipBottom, clipVertical); animationValues[0][0] = animatingImageView.getScaleX(); animationValues[0][1] = animatingImageView.getScaleY(); animationValues[0][2] = animatingImageView.getTranslationX(); animationValues[0][3] = animatingImageView.getTranslationY(); animationValues[0][4] = clipHorizontal * object.scale; animationValues[0][5] = clipTop * object.scale; animationValues[0][6] = clipBottom * object.scale; animationValues[0][7] = animatingImageView.getRadius(); animationValues[1][0] = scale; animationValues[1][1] = scale; animationValues[1][2] = xPos; animationValues[1][3] = yPos; animationValues[1][4] = 0; animationValues[1][5] = 0; animationValues[1][6] = 0; animationValues[1][7] = 0; photoContainerView.setVisibility(View.VISIBLE); photoContainerBackground.setVisibility(View.VISIBLE); animatingImageView.setAnimationProgress(0); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(animatingImageView, "animationProgress", 0.0f, 1.0f), ObjectAnimator.ofInt(photoBackgroundDrawable, "alpha", 0, 255), ObjectAnimator.ofFloat(actionBar, "alpha", 0, 1.0f), ObjectAnimator.ofFloat(bottomLayout, "alpha", 0, 1.0f), ObjectAnimator.ofFloat(captionTextView, "alpha", 0, 1.0f)); photoAnimationEndRunnable = new Runnable() { @Override public void run() { if (photoContainerView == null) { return; } if (Build.VERSION.SDK_INT >= 18) { photoContainerView.setLayerType(View.LAYER_TYPE_NONE, null); } photoAnimationInProgress = 0; photoTransitionAnimationStartTime = 0; setImages(); photoContainerView.invalidate(); animatingImageView.setVisibility(View.GONE); if (showAfterAnimation != null) { showAfterAnimation.imageReceiver.setVisible(true, true); } if (hideAfterAnimation != null) { hideAfterAnimation.imageReceiver.setVisible(false, true); } } }; animatorSet.setDuration(200); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { NotificationCenter.getInstance().setAnimationInProgress(false); if (photoAnimationEndRunnable != null) { photoAnimationEndRunnable.run(); photoAnimationEndRunnable = null; } } }); } }); photoTransitionAnimationStartTime = System.currentTimeMillis(); AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { NotificationCenter.getInstance() .setAllowedNotificationsDutingAnimation(new int[] { NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats, NotificationCenter.mediaCountDidLoaded, NotificationCenter.mediaDidLoaded, NotificationCenter.dialogPhotosLoaded }); NotificationCenter.getInstance().setAnimationInProgress(true); animatorSet.start(); } }); if (Build.VERSION.SDK_INT >= 18) { photoContainerView.setLayerType(View.LAYER_TYPE_HARDWARE, null); } photoBackgroundDrawable.drawRunnable = new Runnable() { @Override public void run() { disableShowCheck = false; object.imageReceiver.setVisible(false, true); } }; return true; }
From source file:net.bluehack.ui.ChatActivity.java
private void createMenu(View v, boolean single) { if (actionBar.isActionModeShowed()) { return;//from www . j ava 2 s .c o m } MessageObject message = null; if (v instanceof ChatMessageCell) { message = ((ChatMessageCell) v).getMessageObject(); } else if (v instanceof ChatActionCell) { message = ((ChatActionCell) v).getMessageObject(); } if (message == null) { return; } final int type = getMessageType(message); if (single && message.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) { scrollToMessageId(message.messageOwner.reply_to_msg_id, 0, true, 0); return; } selectedObject = null; forwaringMessage = null; for (int a = 1; a >= 0; a--) { selectedMessagesCanCopyIds[a].clear(); selectedMessagesIds[a].clear(); } cantDeleteMessagesCount = 0; actionBar.hideActionMode(); updatePinnedMessageView(true); boolean allowChatActions = true; boolean allowPin = message.getDialogId() != mergeDialogId && message.getId() > 0 && ChatObject.isChannel(currentChat) && currentChat.megagroup && (currentChat.creator || currentChat.editor) && (message.messageOwner.action == null || message.messageOwner.action instanceof TLRPC.TL_messageActionEmpty); boolean allowUnpin = message.getDialogId() != mergeDialogId && info != null && info.pinned_msg_id == message.getId() && (currentChat.creator || currentChat.editor); boolean allowEdit = message.canEditMessage(currentChat) && !chatActivityEnterView.hasAudioToSend() && message.getDialogId() != mergeDialogId; if (currentEncryptedChat != null && AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) < 46 || type == 1 && message.getDialogId() == mergeDialogId || currentEncryptedChat == null && message.getId() < 0 || isBroadcast || currentChat != null && (ChatObject.isNotInChat(currentChat) || ChatObject.isChannel(currentChat) && !currentChat.creator && !currentChat.editor && !currentChat.megagroup)) { allowChatActions = false; } if (single || type < 2 || type == 20) { if (type >= 0) { selectedObject = message; if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); ArrayList<CharSequence> items = new ArrayList<>(); final ArrayList<Integer> options = new ArrayList<>(); if (type == 0) { items.add(LocaleController.getString("Retry", R.string.Retry)); options.add(0); items.add(LocaleController.getString("Delete", R.string.Delete)); options.add(1); } else if (type == 1) { if (currentChat != null && !isBroadcast) { if (allowChatActions) { items.add(LocaleController.getString("Reply", R.string.Reply)); options.add(8); } if (allowUnpin) { items.add(LocaleController.getString("UnpinMessage", R.string.UnpinMessage)); options.add(14); } else if (allowPin) { items.add(LocaleController.getString("PinMessage", R.string.PinMessage)); options.add(13); } if (allowEdit) { items.add(LocaleController.getString("Edit", R.string.Edit)); options.add(12); } if (message.canDeleteMessage(currentChat)) { items.add(LocaleController.getString("Delete", R.string.Delete)); options.add(1); } } else { if (single && selectedObject.getId() > 0 && allowChatActions) { items.add(LocaleController.getString("Reply", R.string.Reply)); options.add(8); } if (message.canDeleteMessage(currentChat)) { items.add(LocaleController.getString("Delete", R.string.Delete)); options.add(1); } } } else if (type == 20) { items.add(LocaleController.getString("Retry", R.string.Retry)); options.add(0); items.add(LocaleController.getString("Copy", R.string.Copy)); options.add(3); items.add(LocaleController.getString("Delete", R.string.Delete)); options.add(1); } else { if (currentEncryptedChat == null) { if (allowChatActions) { items.add(LocaleController.getString("Reply", R.string.Reply)); options.add(8); } if (selectedObject.type == 0 || selectedObject.caption != null) { items.add(LocaleController.getString("Copy", R.string.Copy)); options.add(3); } if (type == 3) { if (selectedObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && MessageObject .isNewGifDocument(selectedObject.messageOwner.media.webpage.document)) { items.add(LocaleController.getString("SaveToGIFs", R.string.SaveToGIFs)); options.add(11); } } else if (type == 4) { if (selectedObject.isVideo()) { items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery)); options.add(4); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); } else if (selectedObject.isMusic()) { items.add(LocaleController.getString("SaveToMusic", R.string.SaveToMusic)); options.add(10); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); } else if (selectedObject.getDocument() != null) { if (MessageObject.isNewGifDocument(selectedObject.getDocument())) { items.add(LocaleController.getString("SaveToGIFs", R.string.SaveToGIFs)); options.add(11); } items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads)); options.add(10); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); } else { items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery)); options.add(4); } } else if (type == 5) { items.add(LocaleController.getString("ApplyLocalizationFile", R.string.ApplyLocalizationFile)); options.add(5); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); } else if (type == 6) { items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery)); options.add(7); items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads)); options.add(10); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); } else if (type == 7) { if (selectedObject.isMask()) { items.add(LocaleController.getString("AddToMasks", R.string.AddToMasks)); } else { items.add(LocaleController.getString("AddToStickers", R.string.AddToStickers)); } options.add(9); } else if (type == 8) { TLRPC.User user = MessagesController.getInstance() .getUser(selectedObject.messageOwner.media.user_id); if (user != null && user.id != UserConfig.getClientUserId() && ContactsController.getInstance().contactsDict.get(user.id) == null) { items.add(LocaleController.getString("AddContactTitle", R.string.AddContactTitle)); options.add(15); } if (selectedObject.messageOwner.media.phone_number != null || selectedObject.messageOwner.media.phone_number.length() != 0) { items.add(LocaleController.getString("Copy", R.string.Copy)); options.add(16); items.add(LocaleController.getString("Call", R.string.Call)); options.add(17); } } items.add(LocaleController.getString("Forward", R.string.Forward)); options.add(2); if (allowUnpin) { items.add(LocaleController.getString("UnpinMessage", R.string.UnpinMessage)); options.add(14); } else if (allowPin) { items.add(LocaleController.getString("PinMessage", R.string.PinMessage)); options.add(13); } if (allowEdit) { items.add(LocaleController.getString("Edit", R.string.Edit)); options.add(12); } if (message.canDeleteMessage(currentChat)) { items.add(LocaleController.getString("Delete", R.string.Delete)); options.add(1); } } else { if (allowChatActions) { items.add(LocaleController.getString("Reply", R.string.Reply)); options.add(8); } if (selectedObject.type == 0 || selectedObject.caption != null) { items.add(LocaleController.getString("Copy", R.string.Copy)); options.add(3); } if (type == 4) { if (selectedObject.isVideo()) { items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery)); options.add(4); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); } else if (selectedObject.isMusic()) { items.add(LocaleController.getString("SaveToMusic", R.string.SaveToMusic)); options.add(10); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); } else if (!selectedObject.isVideo() && selectedObject.getDocument() != null) { items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads)); options.add(10); items.add(LocaleController.getString("ShareFile", R.string.ShareFile)); options.add(6); } else { items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery)); options.add(4); } } else if (type == 5) { items.add(LocaleController.getString("ApplyLocalizationFile", R.string.ApplyLocalizationFile)); options.add(5); } else if (type == 7) { items.add(LocaleController.getString("AddToStickers", R.string.AddToStickers)); options.add(9); } items.add(LocaleController.getString("Delete", R.string.Delete)); options.add(1); } } if (options.isEmpty()) { return; } final CharSequence[] finalItems = items.toArray(new CharSequence[items.size()]); builder.setItems(finalItems, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (selectedObject == null || i < 0 || i >= options.size()) { return; } processSelectedOption(options.get(i)); } }); builder.setTitle(LocaleController.getString("Message", R.string.Message)); showDialog(builder.create()); } return; } final ActionBarMenu actionMode = actionBar.createActionMode(); View item = actionMode.getItem(forward); if (item != null) { item.setVisibility(View.VISIBLE); } item = actionMode.getItem(delete); if (item != null) { item.setVisibility(View.VISIBLE); } if (editDoneItem != null) { editDoneItem.setVisibility(View.GONE); } actionBar.showActionMode(); updatePinnedMessageView(true); AnimatorSet animatorSet = new AnimatorSet(); ArrayList<Animator> animators = new ArrayList<>(); for (int a = 0; a < actionModeViews.size(); a++) { View view = actionModeViews.get(a); AndroidUtilities.clearDrawableAnimation(view); animators.add(ObjectAnimator.ofFloat(view, "scaleY", 0.1f, 1.0f)); } animatorSet.playTogether(animators); animatorSet.setDuration(250); animatorSet.start(); addToSelectedMessages(message); selectedMessagesCountTextView.setNumber(1, false); updateVisibleRows(); }
From source file:kr.wdream.ui.ChatActivity.java
private void createMenu(View v, boolean single) { if (actionBar.isActionModeShowed()) { return;//from ww w. j av a 2 s. c o m } MessageObject message = null; if (v instanceof ChatMessageCell) { message = ((ChatMessageCell) v).getMessageObject(); } else if (v instanceof ChatActionCell) { message = ((ChatActionCell) v).getMessageObject(); } if (message == null) { return; } final int type = getMessageType(message); if (single && message.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) { scrollToMessageId(message.messageOwner.reply_to_msg_id, 0, true, 0); return; } selectedObject = null; forwaringMessage = null; for (int a = 1; a >= 0; a--) { selectedMessagesCanCopyIds[a].clear(); selectedMessagesIds[a].clear(); } cantDeleteMessagesCount = 0; actionBar.hideActionMode(); updatePinnedMessageView(true); boolean allowChatActions = true; boolean allowPin = message.getDialogId() != mergeDialogId && message.getId() > 0 && ChatObject.isChannel(currentChat) && currentChat.megagroup && (currentChat.creator || currentChat.editor) && (message.messageOwner.action == null || message.messageOwner.action instanceof TLRPC.TL_messageActionEmpty); boolean allowUnpin = message.getDialogId() != mergeDialogId && info != null && info.pinned_msg_id == message.getId() && (currentChat.creator || currentChat.editor); boolean allowEdit = message.canEditMessage(currentChat) && !chatActivityEnterView.hasAudioToSend() && message.getDialogId() != mergeDialogId; if (currentEncryptedChat != null && AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) < 46 || type == 1 && message.getDialogId() == mergeDialogId || currentEncryptedChat == null && message.getId() < 0 || isBroadcast || currentChat != null && (ChatObject.isNotInChat(currentChat) || ChatObject.isChannel(currentChat) && !currentChat.creator && !currentChat.editor && !currentChat.megagroup)) { allowChatActions = false; } if (single || type < 2 || type == 20) { if (type >= 0) { selectedObject = message; if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); ArrayList<CharSequence> items = new ArrayList<>(); final ArrayList<Integer> options = new ArrayList<>(); if (type == 0) { items.add(LocaleController.getString("Retry", kr.wdream.storyshop.R.string.Retry)); options.add(0); items.add(LocaleController.getString("Delete", kr.wdream.storyshop.R.string.Delete)); options.add(1); } else if (type == 1) { if (currentChat != null && !isBroadcast) { if (allowChatActions) { items.add(LocaleController.getString("Reply", kr.wdream.storyshop.R.string.Reply)); options.add(8); } if (allowUnpin) { items.add(LocaleController.getString("UnpinMessage", kr.wdream.storyshop.R.string.UnpinMessage)); options.add(14); } else if (allowPin) { items.add(LocaleController.getString("PinMessage", kr.wdream.storyshop.R.string.PinMessage)); options.add(13); } if (allowEdit) { items.add(LocaleController.getString("Edit", kr.wdream.storyshop.R.string.Edit)); options.add(12); } if (message.canDeleteMessage(currentChat)) { items.add(LocaleController.getString("Delete", kr.wdream.storyshop.R.string.Delete)); options.add(1); } } else { if (single && selectedObject.getId() > 0 && allowChatActions) { items.add(LocaleController.getString("Reply", kr.wdream.storyshop.R.string.Reply)); options.add(8); } if (message.canDeleteMessage(currentChat)) { items.add(LocaleController.getString("Delete", kr.wdream.storyshop.R.string.Delete)); options.add(1); } } } else if (type == 20) { items.add(LocaleController.getString("Retry", kr.wdream.storyshop.R.string.Retry)); options.add(0); items.add(LocaleController.getString("Copy", kr.wdream.storyshop.R.string.Copy)); options.add(3); items.add(LocaleController.getString("Delete", kr.wdream.storyshop.R.string.Delete)); options.add(1); } else { if (currentEncryptedChat == null) { if (allowChatActions) { items.add(LocaleController.getString("Reply", kr.wdream.storyshop.R.string.Reply)); options.add(8); } if (selectedObject.type == 0 || selectedObject.caption != null) { items.add(LocaleController.getString("Copy", kr.wdream.storyshop.R.string.Copy)); options.add(3); } if (type == 3) { if (selectedObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && MessageObject .isNewGifDocument(selectedObject.messageOwner.media.webpage.document)) { items.add(LocaleController.getString("SaveToGIFs", kr.wdream.storyshop.R.string.SaveToGIFs)); options.add(11); } } else if (type == 4) { if (selectedObject.isVideo()) { items.add(LocaleController.getString("SaveToGallery", kr.wdream.storyshop.R.string.SaveToGallery)); options.add(4); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else if (selectedObject.isMusic()) { items.add(LocaleController.getString("SaveToMusic", kr.wdream.storyshop.R.string.SaveToMusic)); options.add(10); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else if (selectedObject.getDocument() != null) { if (MessageObject.isNewGifDocument(selectedObject.getDocument())) { items.add(LocaleController.getString("SaveToGIFs", kr.wdream.storyshop.R.string.SaveToGIFs)); options.add(11); } items.add(LocaleController.getString("SaveToDownloads", kr.wdream.storyshop.R.string.SaveToDownloads)); options.add(10); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else { items.add(LocaleController.getString("SaveToGallery", kr.wdream.storyshop.R.string.SaveToGallery)); options.add(4); } } else if (type == 5) { items.add(LocaleController.getString("ApplyLocalizationFile", kr.wdream.storyshop.R.string.ApplyLocalizationFile)); options.add(5); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else if (type == 6) { items.add(LocaleController.getString("SaveToGallery", kr.wdream.storyshop.R.string.SaveToGallery)); options.add(7); items.add(LocaleController.getString("SaveToDownloads", kr.wdream.storyshop.R.string.SaveToDownloads)); options.add(10); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else if (type == 7) { if (selectedObject.isMask()) { items.add(LocaleController.getString("AddToMasks", kr.wdream.storyshop.R.string.AddToMasks)); } else { items.add(LocaleController.getString("AddToStickers", kr.wdream.storyshop.R.string.AddToStickers)); } options.add(9); } else if (type == 8) { TLRPC.User user = MessagesController.getInstance() .getUser(selectedObject.messageOwner.media.user_id); if (user != null && user.id != UserConfig.getClientUserId() && ContactsController.getInstance().contactsDict.get(user.id) == null) { items.add(LocaleController.getString("AddContactTitle", kr.wdream.storyshop.R.string.AddContactTitle)); options.add(15); } if (selectedObject.messageOwner.media.phone_number != null || selectedObject.messageOwner.media.phone_number.length() != 0) { items.add(LocaleController.getString("Copy", kr.wdream.storyshop.R.string.Copy)); options.add(16); items.add(LocaleController.getString("Call", kr.wdream.storyshop.R.string.Call)); options.add(17); } } items.add(LocaleController.getString("Forward", kr.wdream.storyshop.R.string.Forward)); options.add(2); if (allowUnpin) { items.add(LocaleController.getString("UnpinMessage", kr.wdream.storyshop.R.string.UnpinMessage)); options.add(14); } else if (allowPin) { items.add(LocaleController.getString("PinMessage", kr.wdream.storyshop.R.string.PinMessage)); options.add(13); } if (allowEdit) { items.add(LocaleController.getString("Edit", kr.wdream.storyshop.R.string.Edit)); options.add(12); } if (message.canDeleteMessage(currentChat)) { items.add(LocaleController.getString("Delete", kr.wdream.storyshop.R.string.Delete)); options.add(1); } } else { if (allowChatActions) { items.add(LocaleController.getString("Reply", kr.wdream.storyshop.R.string.Reply)); options.add(8); } if (selectedObject.type == 0 || selectedObject.caption != null) { items.add(LocaleController.getString("Copy", kr.wdream.storyshop.R.string.Copy)); options.add(3); } if (type == 4) { if (selectedObject.isVideo()) { items.add(LocaleController.getString("SaveToGallery", kr.wdream.storyshop.R.string.SaveToGallery)); options.add(4); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else if (selectedObject.isMusic()) { items.add(LocaleController.getString("SaveToMusic", kr.wdream.storyshop.R.string.SaveToMusic)); options.add(10); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else if (!selectedObject.isVideo() && selectedObject.getDocument() != null) { items.add(LocaleController.getString("SaveToDownloads", kr.wdream.storyshop.R.string.SaveToDownloads)); options.add(10); items.add(LocaleController.getString("ShareFile", kr.wdream.storyshop.R.string.ShareFile)); options.add(6); } else { items.add(LocaleController.getString("SaveToGallery", kr.wdream.storyshop.R.string.SaveToGallery)); options.add(4); } } else if (type == 5) { items.add(LocaleController.getString("ApplyLocalizationFile", kr.wdream.storyshop.R.string.ApplyLocalizationFile)); options.add(5); } else if (type == 7) { items.add(LocaleController.getString("AddToStickers", kr.wdream.storyshop.R.string.AddToStickers)); options.add(9); } items.add(LocaleController.getString("Delete", kr.wdream.storyshop.R.string.Delete)); options.add(1); } } if (options.isEmpty()) { return; } final CharSequence[] finalItems = items.toArray(new CharSequence[items.size()]); builder.setItems(finalItems, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (selectedObject == null || i < 0 || i >= options.size()) { return; } processSelectedOption(options.get(i)); } }); builder.setTitle(LocaleController.getString("Message", kr.wdream.storyshop.R.string.Message)); showDialog(builder.create()); } return; } final ActionBarMenu actionMode = actionBar.createActionMode(); View item = actionMode.getItem(forward); if (item != null) { item.setVisibility(View.VISIBLE); } item = actionMode.getItem(delete); if (item != null) { item.setVisibility(View.VISIBLE); } if (editDoneItem != null) { editDoneItem.setVisibility(View.GONE); } actionBar.showActionMode(); updatePinnedMessageView(true); AnimatorSet animatorSet = new AnimatorSet(); ArrayList<Animator> animators = new ArrayList<>(); for (int a = 0; a < actionModeViews.size(); a++) { View view = actionModeViews.get(a); AndroidUtilities.clearDrawableAnimation(view); animators.add(ObjectAnimator.ofFloat(view, "scaleY", 0.1f, 1.0f)); } animatorSet.playTogether(animators); animatorSet.setDuration(250); animatorSet.start(); addToSelectedMessages(message); selectedMessagesCountTextView.setNumber(1, false); updateVisibleRows(); }
From source file:kr.wdream.ui.PhotoViewer.java
public void closePhoto(boolean animated, boolean fromEditMode) { if (!fromEditMode && currentEditMode != 0) { if (currentEditMode == 3 && photoPaintView != null) { photoPaintView.maybeShowDismissalAlert(this, parentActivity, new Runnable() { @Override// w w w .j a va 2 s . com public void run() { switchToEditMode(0); } }); return; } if (currentEditMode == 1) { photoCropView.cancelAnimationRunnable(); } switchToEditMode(0); return; } try { if (visibleDialog != null) { visibleDialog.dismiss(); visibleDialog = null; } } catch (Exception e) { FileLog.e("tmessages", e); } if (currentEditMode != 0) { if (currentEditMode == 2) { photoFilterView.shutdown(); containerView.removeView(photoFilterView); photoFilterView = null; } else if (currentEditMode == 1) { editorDoneLayout.setVisibility(View.GONE); photoCropView.setVisibility(View.GONE); } currentEditMode = 0; } if (parentActivity == null || !isVisible || checkAnimation() || placeProvider == null) { return; } if (captionEditText.hideActionMode() && !fromEditMode) { return; } releasePlayer(); captionEditText.onDestroy(); parentChatActivity = null; NotificationCenter.getInstance().removeObserver(this, NotificationCenter.FileDidFailedLoad); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.FileDidLoaded); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.FileLoadProgressChanged); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mediaCountDidLoaded); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mediaDidLoaded); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.dialogPhotosLoaded); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.emojiDidLoaded); ConnectionsManager.getInstance().cancelRequestsForGuid(classGuid); isActionBarVisible = false; if (velocityTracker != null) { velocityTracker.recycle(); velocityTracker = null; } ConnectionsManager.getInstance().cancelRequestsForGuid(classGuid); final PlaceProviderObject object = placeProvider.getPlaceForPhoto(currentMessageObject, currentFileLocation, currentIndex); if (animated) { animationInProgress = 1; animatingImageView.setVisibility(View.VISIBLE); containerView.invalidate(); AnimatorSet animatorSet = new AnimatorSet(); final ViewGroup.LayoutParams layoutParams = animatingImageView.getLayoutParams(); Rect drawRegion = null; int orientation = centerImage.getOrientation(); int animatedOrientation = 0; if (object != null && object.imageReceiver != null) { animatedOrientation = object.imageReceiver.getAnimatedOrientation(); } if (animatedOrientation != 0) { orientation = animatedOrientation; } animatingImageView.setOrientation(orientation); if (object != null) { animatingImageView.setNeedRadius(object.radius != 0); drawRegion = object.imageReceiver.getDrawRegion(); layoutParams.width = drawRegion.right - drawRegion.left; layoutParams.height = drawRegion.bottom - drawRegion.top; animatingImageView.setImageBitmap(object.thumb); } else { animatingImageView.setNeedRadius(false); layoutParams.width = centerImage.getImageWidth(); layoutParams.height = centerImage.getImageHeight(); animatingImageView.setImageBitmap(centerImage.getBitmap()); } animatingImageView.setLayoutParams(layoutParams); float scaleX = (float) AndroidUtilities.displaySize.x / layoutParams.width; float scaleY = (float) (AndroidUtilities.displaySize.y + (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0)) / layoutParams.height; float scale2 = scaleX > scaleY ? scaleY : scaleX; float width = layoutParams.width * scale * scale2; float height = layoutParams.height * scale * scale2; float xPos = (AndroidUtilities.displaySize.x - width) / 2.0f; float yPos = ((AndroidUtilities.displaySize.y + (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0)) - height) / 2.0f; animatingImageView.setTranslationX(xPos + translationX); animatingImageView.setTranslationY(yPos + translationY); animatingImageView.setScaleX(scale * scale2); animatingImageView.setScaleY(scale * scale2); if (object != null) { object.imageReceiver.setVisible(false, true); int clipHorizontal = Math.abs(drawRegion.left - object.imageReceiver.getImageX()); int clipVertical = Math.abs(drawRegion.top - object.imageReceiver.getImageY()); int coords2[] = new int[2]; object.parentView.getLocationInWindow(coords2); int clipTop = coords2[1] - (Build.VERSION.SDK_INT >= 21 ? 0 : AndroidUtilities.statusBarHeight) - (object.viewY + drawRegion.top) + object.clipTopAddition; if (clipTop < 0) { clipTop = 0; } int clipBottom = (object.viewY + drawRegion.top + (drawRegion.bottom - drawRegion.top)) - (coords2[1] + object.parentView.getHeight() - (Build.VERSION.SDK_INT >= 21 ? 0 : AndroidUtilities.statusBarHeight)) + object.clipBottomAddition; if (clipBottom < 0) { clipBottom = 0; } clipTop = Math.max(clipTop, clipVertical); clipBottom = Math.max(clipBottom, clipVertical); animationValues[0][0] = animatingImageView.getScaleX(); animationValues[0][1] = animatingImageView.getScaleY(); animationValues[0][2] = animatingImageView.getTranslationX(); animationValues[0][3] = animatingImageView.getTranslationY(); animationValues[0][4] = 0; animationValues[0][5] = 0; animationValues[0][6] = 0; animationValues[0][7] = 0; animationValues[1][0] = object.scale; animationValues[1][1] = object.scale; animationValues[1][2] = object.viewX + drawRegion.left * object.scale; animationValues[1][3] = object.viewY + drawRegion.top * object.scale; animationValues[1][4] = clipHorizontal * object.scale; animationValues[1][5] = clipTop * object.scale; animationValues[1][6] = clipBottom * object.scale; animationValues[1][7] = object.radius; animatorSet.playTogether( ObjectAnimator.ofFloat(animatingImageView, "animationProgress", 0.0f, 1.0f), ObjectAnimator.ofInt(backgroundDrawable, "alpha", 0), ObjectAnimator.ofFloat(containerView, "alpha", 0.0f)); } else { int h = (AndroidUtilities.displaySize.y + (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0)); animatorSet.playTogether(ObjectAnimator.ofInt(backgroundDrawable, "alpha", 0), ObjectAnimator.ofFloat(animatingImageView, "alpha", 0.0f), ObjectAnimator.ofFloat(animatingImageView, "translationY", translationY >= 0 ? h : -h), ObjectAnimator.ofFloat(containerView, "alpha", 0.0f)); } animationEndRunnable = new Runnable() { @Override public void run() { if (Build.VERSION.SDK_INT >= 18) { containerView.setLayerType(View.LAYER_TYPE_NONE, null); } animationInProgress = 0; onPhotoClosed(object); } }; animatorSet.setDuration(200); animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { if (animationEndRunnable != null) { animationEndRunnable.run(); animationEndRunnable = null; } } }); } }); transitionAnimationStartTime = System.currentTimeMillis(); if (Build.VERSION.SDK_INT >= 18) { containerView.setLayerType(View.LAYER_TYPE_HARDWARE, null); } animatorSet.start(); } else { AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(containerView, "scaleX", 0.9f), ObjectAnimator.ofFloat(containerView, "scaleY", 0.9f), ObjectAnimator.ofInt(backgroundDrawable, "alpha", 0), ObjectAnimator.ofFloat(containerView, "alpha", 0.0f)); animationInProgress = 2; animationEndRunnable = new Runnable() { @Override public void run() { if (containerView == null) { return; } if (Build.VERSION.SDK_INT >= 18) { containerView.setLayerType(View.LAYER_TYPE_NONE, null); } animationInProgress = 0; onPhotoClosed(object); containerView.setScaleX(1.0f); containerView.setScaleY(1.0f); } }; animatorSet.setDuration(200); animatorSet.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Animator animation) { if (animationEndRunnable != null) { animationEndRunnable.run(); animationEndRunnable = null; } } }); transitionAnimationStartTime = System.currentTimeMillis(); if (Build.VERSION.SDK_INT >= 18) { containerView.setLayerType(View.LAYER_TYPE_HARDWARE, null); } animatorSet.start(); } if (currentAnimation != null) { currentAnimation.setSecondParentView(null); currentAnimation = null; centerImage.setImageBitmap((Drawable) null); } if (placeProvider instanceof EmptyPhotoViewerProvider) { placeProvider.cancelButtonPressed(); } }
From source file:org.telegram.ui.ArticleViewer.java
public void closePhoto(boolean animated) { if (parentActivity == null || !isPhotoVisible || checkPhotoAnimation()) { return;//from w w w . ja va2s .co m } releasePlayer(); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.FileDidFailedLoad); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.FileDidLoaded); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.FileLoadProgressChanged); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.emojiDidLoaded); isActionBarVisible = false; if (velocityTracker != null) { velocityTracker.recycle(); velocityTracker = null; } final PlaceProviderObject object = getPlaceForPhoto(currentMedia); if (animated) { photoAnimationInProgress = 1; animatingImageView.setVisibility(View.VISIBLE); photoContainerView.invalidate(); AnimatorSet animatorSet = new AnimatorSet(); final ViewGroup.LayoutParams layoutParams = animatingImageView.getLayoutParams(); Rect drawRegion = null; int orientation = centerImage.getOrientation(); int animatedOrientation = 0; if (object != null && object.imageReceiver != null) { animatedOrientation = object.imageReceiver.getAnimatedOrientation(); } if (animatedOrientation != 0) { orientation = animatedOrientation; } animatingImageView.setOrientation(orientation); if (object != null) { animatingImageView.setNeedRadius(object.radius != 0); drawRegion = object.imageReceiver.getDrawRegion(); layoutParams.width = drawRegion.right - drawRegion.left; layoutParams.height = drawRegion.bottom - drawRegion.top; animatingImageView.setImageBitmap(object.thumb); } else { animatingImageView.setNeedRadius(false); layoutParams.width = centerImage.getImageWidth(); layoutParams.height = centerImage.getImageHeight(); animatingImageView.setImageBitmap(centerImage.getBitmap()); } animatingImageView.setLayoutParams(layoutParams); float scaleX = (float) AndroidUtilities.displaySize.x / layoutParams.width; float scaleY = (float) (AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight) / layoutParams.height; float scale2 = scaleX > scaleY ? scaleY : scaleX; float width = layoutParams.width * scale * scale2; float height = layoutParams.height * scale * scale2; float xPos = (AndroidUtilities.displaySize.x - width) / 2.0f; if (Build.VERSION.SDK_INT >= 21 && lastInsets != null) { xPos += ((WindowInsets) lastInsets).getSystemWindowInsetLeft(); } float yPos = (AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight - height) / 2.0f; animatingImageView.setTranslationX(xPos + translationX); animatingImageView.setTranslationY(yPos + translationY); animatingImageView.setScaleX(scale * scale2); animatingImageView.setScaleY(scale * scale2); if (object != null) { object.imageReceiver.setVisible(false, true); int clipHorizontal = Math.abs(drawRegion.left - object.imageReceiver.getImageX()); int clipVertical = Math.abs(drawRegion.top - object.imageReceiver.getImageY()); int coords2[] = new int[2]; object.parentView.getLocationInWindow(coords2); int clipTop = coords2[1] - (object.viewY + drawRegion.top) + object.clipTopAddition; if (clipTop < 0) { clipTop = 0; } int clipBottom = (object.viewY + drawRegion.top + (drawRegion.bottom - drawRegion.top)) - (coords2[1] + object.parentView.getHeight()) + object.clipBottomAddition; if (clipBottom < 0) { clipBottom = 0; } clipTop = Math.max(clipTop, clipVertical); clipBottom = Math.max(clipBottom, clipVertical); animationValues[0][0] = animatingImageView.getScaleX(); animationValues[0][1] = animatingImageView.getScaleY(); animationValues[0][2] = animatingImageView.getTranslationX(); animationValues[0][3] = animatingImageView.getTranslationY(); animationValues[0][4] = 0; animationValues[0][5] = 0; animationValues[0][6] = 0; animationValues[0][7] = 0; animationValues[1][0] = object.scale; animationValues[1][1] = object.scale; animationValues[1][2] = object.viewX + drawRegion.left * object.scale; animationValues[1][3] = object.viewY + drawRegion.top * object.scale; animationValues[1][4] = clipHorizontal * object.scale; animationValues[1][5] = clipTop * object.scale; animationValues[1][6] = clipBottom * object.scale; animationValues[1][7] = object.radius; animatorSet.playTogether( ObjectAnimator.ofFloat(animatingImageView, "animationProgress", 0.0f, 1.0f), ObjectAnimator.ofInt(photoBackgroundDrawable, "alpha", 0), ObjectAnimator.ofFloat(actionBar, "alpha", 0), ObjectAnimator.ofFloat(bottomLayout, "alpha", 0), ObjectAnimator.ofFloat(captionTextView, "alpha", 0)); } else { int h = AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight; animatorSet.playTogether(ObjectAnimator.ofInt(photoBackgroundDrawable, "alpha", 0), ObjectAnimator.ofFloat(animatingImageView, "alpha", 0.0f), ObjectAnimator.ofFloat(animatingImageView, "translationY", translationY >= 0 ? h : -h), ObjectAnimator.ofFloat(actionBar, "alpha", 0), ObjectAnimator.ofFloat(bottomLayout, "alpha", 0), ObjectAnimator.ofFloat(captionTextView, "alpha", 0)); } photoAnimationEndRunnable = new Runnable() { @Override public void run() { if (Build.VERSION.SDK_INT >= 18) { photoContainerView.setLayerType(View.LAYER_TYPE_NONE, null); } photoContainerView.setVisibility(View.INVISIBLE); photoContainerBackground.setVisibility(View.INVISIBLE); photoAnimationInProgress = 0; onPhotoClosed(object); } }; animatorSet.setDuration(200); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { if (photoAnimationEndRunnable != null) { photoAnimationEndRunnable.run(); photoAnimationEndRunnable = null; } } }); } }); photoTransitionAnimationStartTime = System.currentTimeMillis(); if (Build.VERSION.SDK_INT >= 18) { photoContainerView.setLayerType(View.LAYER_TYPE_HARDWARE, null); } animatorSet.start(); } else { AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(photoContainerView, "scaleX", 0.9f), ObjectAnimator.ofFloat(photoContainerView, "scaleY", 0.9f), ObjectAnimator.ofInt(photoBackgroundDrawable, "alpha", 0), ObjectAnimator.ofFloat(actionBar, "alpha", 0), ObjectAnimator.ofFloat(bottomLayout, "alpha", 0), ObjectAnimator.ofFloat(captionTextView, "alpha", 0)); photoAnimationInProgress = 2; photoAnimationEndRunnable = new Runnable() { @Override public void run() { if (photoContainerView == null) { return; } if (Build.VERSION.SDK_INT >= 18) { photoContainerView.setLayerType(View.LAYER_TYPE_NONE, null); } photoContainerView.setVisibility(View.INVISIBLE); photoContainerBackground.setVisibility(View.INVISIBLE); photoAnimationInProgress = 0; onPhotoClosed(object); photoContainerView.setScaleX(1.0f); photoContainerView.setScaleY(1.0f); } }; animatorSet.setDuration(200); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (photoAnimationEndRunnable != null) { photoAnimationEndRunnable.run(); photoAnimationEndRunnable = null; } } }); photoTransitionAnimationStartTime = System.currentTimeMillis(); if (Build.VERSION.SDK_INT >= 18) { photoContainerView.setLayerType(View.LAYER_TYPE_HARDWARE, null); } animatorSet.start(); } if (currentAnimation != null) { currentAnimation.setSecondParentView(null); currentAnimation = null; centerImage.setImageBitmap((Drawable) null); } }