List of usage examples for android.view VelocityTracker obtain
static public VelocityTracker obtain()
From source file:com.ferdi2005.secondgram.support.widget.RecyclerView.java
@Override public boolean onTouchEvent(MotionEvent e) { if (mLayoutFrozen || mIgnoreMotionEventTillDown) { return false; }/*from w w w.j a v a 2 s .c o m*/ if (dispatchOnItemTouch(e)) { cancelTouch(); return true; } if (mLayout == null) { return false; } final boolean canScrollHorizontally = mLayout.canScrollHorizontally(); final boolean canScrollVertically = mLayout.canScrollVertically(); if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } boolean eventAddedToVelocityTracker = false; final MotionEvent vtev = MotionEvent.obtain(e); final int action = MotionEventCompat.getActionMasked(e); final int actionIndex = MotionEventCompat.getActionIndex(e); if (action == MotionEvent.ACTION_DOWN) { mNestedOffsets[0] = mNestedOffsets[1] = 0; } vtev.offsetLocation(mNestedOffsets[0], mNestedOffsets[1]); switch (action) { case MotionEvent.ACTION_DOWN: { mScrollPointerId = e.getPointerId(0); mInitialTouchX = mLastTouchX = (int) (e.getX() + 0.5f); mInitialTouchY = mLastTouchY = (int) (e.getY() + 0.5f); int nestedScrollAxis = ViewCompat.SCROLL_AXIS_NONE; if (canScrollHorizontally) { nestedScrollAxis |= ViewCompat.SCROLL_AXIS_HORIZONTAL; } if (canScrollVertically) { nestedScrollAxis |= ViewCompat.SCROLL_AXIS_VERTICAL; } startNestedScroll(nestedScrollAxis); } break; case MotionEventCompat.ACTION_POINTER_DOWN: { mScrollPointerId = e.getPointerId(actionIndex); mInitialTouchX = mLastTouchX = (int) (e.getX(actionIndex) + 0.5f); mInitialTouchY = mLastTouchY = (int) (e.getY(actionIndex) + 0.5f); } break; case MotionEvent.ACTION_MOVE: { final int index = e.findPointerIndex(mScrollPointerId); if (index < 0) { Log.e(TAG, "Error processing scroll; pointer index for id " + mScrollPointerId + " not found. Did any MotionEvents get skipped?"); return false; } final int x = (int) (e.getX(index) + 0.5f); final int y = (int) (e.getY(index) + 0.5f); int dx = mLastTouchX - x; int dy = mLastTouchY - y; if (dispatchNestedPreScroll(dx, dy, mScrollConsumed, mScrollOffset)) { dx -= mScrollConsumed[0]; dy -= mScrollConsumed[1]; vtev.offsetLocation(mScrollOffset[0], mScrollOffset[1]); // Updated the nested offsets mNestedOffsets[0] += mScrollOffset[0]; mNestedOffsets[1] += mScrollOffset[1]; } if (mScrollState != SCROLL_STATE_DRAGGING) { boolean startScroll = false; if (canScrollHorizontally && Math.abs(dx) > mTouchSlop) { if (dx > 0) { dx -= mTouchSlop; } else { dx += mTouchSlop; } startScroll = true; } if (canScrollVertically && Math.abs(dy) > mTouchSlop) { if (dy > 0) { dy -= mTouchSlop; } else { dy += mTouchSlop; } startScroll = true; } if (startScroll) { setScrollState(SCROLL_STATE_DRAGGING); } } if (mScrollState == SCROLL_STATE_DRAGGING) { mLastTouchX = x - mScrollOffset[0]; mLastTouchY = y - mScrollOffset[1]; if (scrollByInternal(canScrollHorizontally ? dx : 0, canScrollVertically ? dy : 0, vtev)) { getParent().requestDisallowInterceptTouchEvent(true); } if (mGapWorker != null && (dx != 0 || dy != 0)) { mGapWorker.postFromTraversal(this, dx, dy); } } } break; case MotionEventCompat.ACTION_POINTER_UP: { onPointerUp(e); } break; case MotionEvent.ACTION_UP: { mVelocityTracker.addMovement(vtev); eventAddedToVelocityTracker = true; mVelocityTracker.computeCurrentVelocity(1000, mMaxFlingVelocity); final float xvel = canScrollHorizontally ? -VelocityTrackerCompat.getXVelocity(mVelocityTracker, mScrollPointerId) : 0; final float yvel = canScrollVertically ? -VelocityTrackerCompat.getYVelocity(mVelocityTracker, mScrollPointerId) : 0; if (!((xvel != 0 || yvel != 0) && fling((int) xvel, (int) yvel))) { setScrollState(SCROLL_STATE_IDLE); } resetTouch(); } break; case MotionEvent.ACTION_CANCEL: { cancelTouch(); } break; } if (!eventAddedToVelocityTracker) { mVelocityTracker.addMovement(vtev); } vtev.recycle(); 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; }/*w ww . j a v a 2s . 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", 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; }/* www . j av a2s .c om*/ 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:jmri.enginedriver.throttle.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @SuppressLint({ "Recycle", "SetJavaScriptEnabled", "ClickableViewAccessibility" }) @Override/*from w w w. j a va 2 s . c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { try { // restore the requested throttle direction so we can update the // direction indication while we wait for an update from WiT for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottlesCurrentScreen; throttleIndex++) { if (savedInstanceState .getSerializable("dir" + mainapp.throttleIntToString(throttleIndex)) != null) dirs[throttleIndex] = (int) savedInstanceState.getSerializable("dir" + throttleIndex); } } catch (Exception ignored) { // log the error, but otherwise keep going. Log.d("Engine_Driver", "Restore of saved instance state failed " + android.os.Build.VERSION.SDK_INT); } } mainapp = (threaded_application) this.getApplication(); prefs = getSharedPreferences("jmri.enginedriver_preferences", 0); if (mainapp.isForcingFinish()) { // expedite mainapp.appIsFinishing = true; return; } mainapp.applyTheme(this); setTitle(getApplicationContext().getResources().getString(R.string.app_name_throttle)); // needed in case the language was changed from the default // setContentView(R.layout.throttle); setContentView(layoutViewId); getCommonPrefs(true); // get all the common preferences setThottleNumLimits(); getDirectionButtonPrefs(); webViewIsOn = !webViewLocation.equals(WEB_VIEW_LOCATION_NONE); keepWebViewLocation = webViewLocation; isScreenLocked = false; // get the screen brightness on create screenBrightnessOriginal = getScreenBrightness(); screenBrightnessModeOriginal = getScreenBrightnessMode(); // myGesture = new GestureDetector(this); GestureOverlayView ov = findViewById(R.id.throttle_overlay); ov.addOnGestureListener(this); ov.setGestureVisible(false); direction_button_touch_listener dbtl; function_button_touch_listener fbtl; select_function_button_touch_listener sfbt; arrow_speed_button_touch_listener asbl; bSels = new Button[mainapp.maxThrottles]; bRSpds = new Button[mainapp.maxThrottles]; bLSpds = new Button[mainapp.maxThrottles]; tvLeftDirInds = new TextView[mainapp.maxThrottles]; tvRightDirInds = new TextView[mainapp.maxThrottles]; bFwds = new Button[mainapp.maxThrottles]; bStops = new Button[mainapp.maxThrottles]; bRevs = new Button[mainapp.maxThrottles]; sbs = new SeekBar[mainapp.maxThrottles]; tvGamePads = new TextView[mainapp.maxThrottles]; tvSpdLabs = new TextView[mainapp.maxThrottles]; tvSpdVals = new TextView[mainapp.maxThrottles]; tvVols = new TextView[mainapp.maxThrottles]; lls = new LinearLayout[mainapp.maxThrottles]; llSetSpds = new LinearLayout[mainapp.maxThrottles]; llLocoIds = new LinearLayout[mainapp.maxThrottles]; llLocoDirs = new LinearLayout[mainapp.maxThrottles]; fbs = new ViewGroup[mainapp.maxThrottles]; tops = new int[mainapp.maxThrottles]; bottoms = new int[mainapp.maxThrottles]; functionMaps = (LinkedHashMap<Integer, Button>[]) new LinkedHashMap<?, ?>[mainapp.maxThrottles]; displayUnitScales = new double[mainapp.maxThrottles]; changeTimers = new ChangeDelay[mainapp.maxThrottles]; // throttle layouts vThrotScr = findViewById(R.id.throttle_screen); vThrotScrWrap = findViewById(R.id.throttle_screen_wrapper); for (int i = 0; i < mainapp.maxThrottles; i++) { // set listener for select loco buttons Button bSel = findViewById(R.id.button_select_loco_0); TextView tvLeft = findViewById(R.id.loco_left_direction_indicaton_0); TextView tvRight = findViewById(R.id.loco_right_direction_indicaton_0); switch (i) { case 1: bSel = findViewById(R.id.button_select_loco_1); tvLeft = findViewById(R.id.loco_left_direction_indicaton_1); tvRight = findViewById(R.id.loco_right_direction_indicaton_1); break; case 2: bSel = findViewById(R.id.button_select_loco_2); tvLeft = findViewById(R.id.loco_left_direction_indicaton_2); tvRight = findViewById(R.id.loco_right_direction_indicaton_2); break; case 3: bSel = findViewById(R.id.button_select_loco_3); tvLeft = findViewById(R.id.loco_left_direction_indicaton_3); tvRight = findViewById(R.id.loco_right_direction_indicaton_3); break; case 4: bSel = findViewById(R.id.button_select_loco_4); tvLeft = findViewById(R.id.loco_left_direction_indicaton_4); tvRight = findViewById(R.id.loco_right_direction_indicaton_4); break; case 5: bSel = findViewById(R.id.button_select_loco_5); tvLeft = findViewById(R.id.loco_left_direction_indicaton_5); tvRight = findViewById(R.id.loco_right_direction_indicaton_5); break; } bSels[i] = bSel; bSels[i].setClickable(true); sfbt = new select_function_button_touch_listener(i); bSels[i].setOnClickListener(sfbt); bSels[i].setOnTouchListener(sfbt); bSels[i].setOnLongClickListener(sfbt); // Consist Light Edit tvLeftDirInds[i] = tvLeft; tvRightDirInds[i] = tvRight; // Arrow Keys try { Button bRight = findViewById(R.id.right_speed_button_0); Button bLeft = findViewById(R.id.left_speed_button_0); switch (i) { case 1: bRight = findViewById(R.id.right_speed_button_1); bLeft = findViewById(R.id.left_speed_button_1); break; case 2: bRight = findViewById(R.id.right_speed_button_2); bLeft = findViewById(R.id.left_speed_button_2); break; case 3: bRight = findViewById(R.id.right_speed_button_3); bLeft = findViewById(R.id.left_speed_button_3); break; case 4: bRight = findViewById(R.id.right_speed_button_4); bLeft = findViewById(R.id.left_speed_button_4); break; case 5: bRight = findViewById(R.id.right_speed_button_5); bLeft = findViewById(R.id.left_speed_button_5); break; } bRSpds[i] = bRight; bRSpds[i].setClickable(true); asbl = new arrow_speed_button_touch_listener(i, "right"); bRSpds[i].setOnLongClickListener(asbl); bRSpds[i].setOnTouchListener(asbl); bRSpds[i].setOnClickListener(asbl); bLSpds[i] = bLeft; bLSpds[i].setClickable(true); asbl = new arrow_speed_button_touch_listener(i, "left"); bLSpds[i].setOnLongClickListener(asbl); bLSpds[i].setOnTouchListener(asbl); bLSpds[i].setOnClickListener(asbl); } catch (Exception ex) { Log.d("debug", "onCreate: " + ex.getMessage()); } // set listeners for 3 direction buttons for each throttle //---------------------------------------- Button bFwd = findViewById(R.id.button_fwd_0); Button bStop = findViewById(R.id.button_stop_0); Button bRev = findViewById(R.id.button_rev_0); View v = findViewById(R.id.speed_cell_0); switch (i) { case 1: bFwd = findViewById(R.id.button_fwd_1); bStop = findViewById(R.id.button_stop_1); bRev = findViewById(R.id.button_rev_1); v = findViewById(R.id.speed_cell_1); break; case 2: bFwd = findViewById(R.id.button_fwd_2); bStop = findViewById(R.id.button_stop_2); bRev = findViewById(R.id.button_rev_2); v = findViewById(R.id.speed_cell_2); break; case 3: bFwd = findViewById(R.id.button_fwd_3); bStop = findViewById(R.id.button_stop_3); bRev = findViewById(R.id.button_rev_3); v = findViewById(R.id.speed_cell_3); break; case 4: bFwd = findViewById(R.id.button_fwd_4); bStop = findViewById(R.id.button_stop_4); bRev = findViewById(R.id.button_rev_4); v = findViewById(R.id.speed_cell_4); break; case 5: bFwd = findViewById(R.id.button_fwd_5); bStop = findViewById(R.id.button_stop_5); bRev = findViewById(R.id.button_rev_5); v = findViewById(R.id.speed_cell_5); break; } bFwds[i] = bFwd; dbtl = new direction_button_touch_listener(direction_button.LEFT, i); bFwds[i].setOnTouchListener(dbtl); bStops[i] = bStop; fbtl = new function_button_touch_listener(function_button.STOP, i); bStops[i].setOnTouchListener(fbtl); bRevs[i] = bRev; dbtl = new direction_button_touch_listener(direction_button.RIGHT, i); bRevs[i].setOnTouchListener(dbtl); fbtl = new function_button_touch_listener(function_button.SPEED_LABEL, i); v.setOnTouchListener(fbtl); // set up listeners for all throttles SeekBar s = findViewById(R.id.speed_0); switch (i) { case 1: s = findViewById(R.id.speed_1); break; case 2: s = findViewById(R.id.speed_2); break; case 3: s = findViewById(R.id.speed_3); break; case 4: s = findViewById(R.id.speed_4); break; case 5: s = findViewById(R.id.speed_5); break; } throttle_listener thl; sbs[i] = s; thl = new throttle_listener(i); sbs[i].setOnSeekBarChangeListener(thl); sbs[i].setOnTouchListener(thl); max_throttle_change = 1; // displaySpeedSteps = false; switch (i) { case 0: lls[i] = findViewById(R.id.throttle_0); // llSetSpds[i] = (LinearLayout) findViewById(R.id.throttle_0_setspeed); llLocoIds[i] = findViewById(R.id.loco_buttons_group_0); llLocoDirs[i] = findViewById(R.id.dir_buttons_table_0); tvVols[i] = findViewById(R.id.volume_indicator_0); // volume indicators tvGamePads[i] = findViewById(R.id.gamepad_indicator_0); // gamepad indicators tvSpdLabs[i] = findViewById(R.id.speed_label_0); // set_default_function_labels(); tvSpdVals[i] = findViewById(R.id.speed_value_label_0); //**// fbs[i] = (ViewGroup) findViewById(R.id.function_buttons_table_0); break; case 1: lls[i] = findViewById(R.id.throttle_1); // llSetSpds[i] = (LinearLayout) findViewById(R.id.throttle_1_setspeed); llLocoIds[i] = findViewById(R.id.loco_buttons_group_1); llLocoDirs[i] = findViewById(R.id.dir_buttons_table_1); tvVols[i] = findViewById(R.id.volume_indicator_1); // volume indicators tvGamePads[i] = findViewById(R.id.gamepad_indicator_1); // gamepad indicators tvSpdLabs[i] = findViewById(R.id.speed_label_1); // set_default_function_labels(); tvSpdVals[i] = findViewById(R.id.speed_value_label_1); //**// fbs[i] = (ViewGroup) findViewById(R.id.function_buttons_table_1); break; case 2: lls[i] = findViewById(R.id.throttle_2); // llSetSpds[i] = (LinearLayout) findViewById(R.id.throttle_2_setspeed); llLocoIds[i] = findViewById(R.id.loco_buttons_group_2); llLocoDirs[i] = findViewById(R.id.dir_buttons_table_2); tvVols[i] = findViewById(R.id.volume_indicator_2); // volume indicators tvGamePads[i] = findViewById(R.id.gamepad_indicator_2); // gamepad indicators tvSpdLabs[i] = findViewById(R.id.speed_label_2); // set_default_function_labels(); tvSpdVals[i] = findViewById(R.id.speed_value_label_2); //**// fbs[i] = (ViewGroup) findViewById(R.id.function_buttons_table_2); break; case 3: lls[i] = findViewById(R.id.throttle_3); // llSetSpds[i] = (LinearLayout) findViewById(R.id.throttle_3_setspeed); llLocoIds[i] = findViewById(R.id.loco_buttons_group_3); llLocoDirs[i] = findViewById(R.id.dir_buttons_table_3); tvVols[i] = findViewById(R.id.volume_indicator_3); // volume indicators tvGamePads[i] = findViewById(R.id.gamepad_indicator_3); // gamepad indicators tvSpdLabs[i] = findViewById(R.id.speed_label_3); // set_default_function_labels(); tvSpdVals[i] = findViewById(R.id.speed_value_label_3); //**// fbs[i] = (ViewGroup) findViewById(R.id.function_buttons_table_3); break; case 4: lls[i] = findViewById(R.id.throttle_4); // llSetSpds[i] = (LinearLayout) findViewById(R.id.throttle_4_setspeed); llLocoIds[i] = findViewById(R.id.loco_buttons_group_4); llLocoDirs[i] = findViewById(R.id.dir_buttons_table_4); tvVols[i] = findViewById(R.id.volume_indicator_4); // volume indicators tvGamePads[i] = findViewById(R.id.gamepad_indicator_4); // gamepad indicators tvSpdLabs[i] = findViewById(R.id.speed_label_4); // set_default_function_labels(); tvSpdVals[i] = findViewById(R.id.speed_value_label_4); //**// fbs[i] = (ViewGroup) findViewById(R.id.function_buttons_table_4); break; case 5: lls[i] = findViewById(R.id.throttle_5); // llSetSpds[i] = (LinearLayout) findViewById(R.id.throttle_5_setspeed); llLocoIds[i] = findViewById(R.id.loco_buttons_group_5); llLocoDirs[i] = findViewById(R.id.dir_buttons_table_5); tvVols[i] = findViewById(R.id.volume_indicator_5); // volume indicators tvGamePads[i] = findViewById(R.id.gamepad_indicator_5); // gamepad indicators tvSpdLabs[i] = findViewById(R.id.speed_label_5); // set_default_function_labels(); tvSpdVals[i] = findViewById(R.id.speed_value_label_5); //**// fbs[i] = (ViewGroup) findViewById(R.id.function_buttons_table_5); break; } // set throttle change delay timers changeTimers[i] = new ChangeDelay(i); } clearVolumeAndGamepadAdditionalIndicators(); setDirectionButtonLabels(); // set all the direction button labels // set label and dcc functions (based on settings) or hide if no label setAllFunctionLabelsAndListeners(); if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } setActiveThrottle(0); // set the throttle the volume keys control depending on the preference to the default 0 webView = findViewById(R.id.throttle_webview); String databasePath = webView.getContext().getDir("databases", Context.MODE_PRIVATE).getPath(); webView.getSettings().setDatabasePath(databasePath); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setBuiltInZoomControls(true); // Enable Multitouch // if supported webView.getSettings().setUseWideViewPort(true); // Enable greater // zoom-out webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR); webView.setInitialScale((int) (100 * scale)); // webView.getSettings().setLoadWithOverviewMode(true); // size image to // fill width // open all links inside the current view (don't start external web // browser) noUrl = getApplicationContext().getResources().getString(R.string.blank_page_url); WebViewClient EDWebClient = new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { return false; } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if (!noUrl.equals(url)) { // if url is legit currentUrl = url; if (firstUrl == null) { // if this is the first legit url firstUrl = url; clearHistory = true; } if (clearHistory) { // keep clearing history until off this page if (url.equals(firstUrl)) { // (works around Android bug) webView.clearHistory(); } else { clearHistory = false; } } } } }; webView.setWebViewClient(EDWebClient); if (currentUrl == null || savedInstanceState == null || webView.restoreState(savedInstanceState) == null) { load_webview(); // reload if no saved state or no page had loaded when state was saved } // put pointer to this activity's handler in main app's shared variable mainapp.throttle_msg_handler = new throttle_handler(); // set throttle change delay timers for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottles; throttleIndex++) { changeTimers[throttleIndex] = new ChangeDelay(throttleIndex); } // tone generator for feedback sounds try { tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, preferences.getIntPrefValue(prefs, "prefGamePadFeedbackVolume", getApplicationContext() .getResources().getString(R.string.prefGamePadFeedbackVolumeDefaultValue))); } catch (RuntimeException e) { Log.e("Engine_Driver", "new ToneGenerator failed. Runtime Exception, OS " + android.os.Build.VERSION.SDK_INT + " Message: " + e); } // set GamePad Support setGamepadKeys(); // initialise ESU MCII if (IS_ESU_MCII) { Log.d("Engine_Driver", "ESU_MCII: Initialise fragments..."); int zeroTrim = preferences.getIntPrefValue(prefs, "prefEsuMc2ZeroTrim", getApplicationContext().getResources().getString(R.string.prefEsuMc2ZeroTrimDefaultValue)); esuThrottleFragment = ThrottleFragment.newInstance(zeroTrim); esuThrottleFragment.setOnThrottleListener(esuOnThrottleListener); esuStopButtonFragment = StopButtonFragment.newInstance(); esuStopButtonFragment.setOnStopButtonListener(esuOnStopButtonListener); Log.d("Engine_Driver", "ESU_MCII: ...fragments initialised"); getSupportFragmentManager().beginTransaction().add(esuThrottleFragment, "mc2:throttle") .add(esuStopButtonFragment, "mc2:stopKey").commit(); esuMc2Led.setState(EsuMc2Led.RED, EsuMc2LedState.OFF, true); esuMc2Led.setState(EsuMc2Led.GREEN, EsuMc2LedState.STEADY_FLASH, true); // Now apply knob zero trim updateEsuMc2ZeroTrim(); Log.d("Engine_Driver", "ESU_MCII: Initialisation complete"); } setupSensor(); // setup the support for shake actions. setupTts(); if (prefs.getBoolean("prefImportServerAuto", getApplicationContext().getResources().getBoolean(R.bool.prefImportServerAutoDefaultValue))) { autoImportFromURL(); } }
From source file:org.telegram.ui.ArticleViewer.java
public boolean openPhoto(TLRPC.PageBlock block) { if (parentActivity == null || isPhotoVisible || checkPhotoAnimation() || block == null) { return false; }/*from ww w.j a v a2 s . co m*/ 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; }