List of usage examples for android.animation AnimatorSet AnimatorSet
public AnimatorSet()
From source file:com.alimuzaffar.lib.pin.PinEntryEditText.java
private void animateBottomUp(CharSequence text, final int start) { mCharBottom[start] = mLineCoords[start].bottom - mTextBottomPadding; ValueAnimator animUp = ValueAnimator.ofFloat(mCharBottom[start] + getPaint().getTextSize(), mCharBottom[start]);//from w w w .j a v a2s. c om animUp.setDuration(300); animUp.setInterpolator(new OvershootInterpolator()); animUp.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Float value = (Float) animation.getAnimatedValue(); mCharBottom[start] = value; PinEntryEditText.this.invalidate(); } }); mLastCharPaint.setAlpha(255); ValueAnimator animAlpha = ValueAnimator.ofInt(0, 255); animAlpha.setDuration(300); animAlpha.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Integer value = (Integer) animation.getAnimatedValue(); mLastCharPaint.setAlpha(value); } }); AnimatorSet set = new AnimatorSet(); if (text.length() == mMaxLength && mOnPinEnteredListener != null) { set.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mOnPinEnteredListener.onPinEntered(getText()); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); } set.playTogether(animUp, animAlpha); set.start(); }
From source file:com.pitchedapps.primenumbercalculator.Calculator.java
License:asdf
private void reveal(View sourceView, AnimatorListener listener) { final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) getWindow().getDecorView().getOverlay(); final Rect displayRect = new Rect(); mDisplayView.getGlobalVisibleRect(displayRect); // Make reveal cover the display and status bar. final View revealView = new View(this); revealView.setBottom(displayRect.bottom); revealView.setLeft(displayRect.left); revealView.setRight(displayRect.right); revealView.setBackgroundColor(themeClearAccent); groupOverlay.add(revealView);//from w w w . j a v a2 s . c o m final int[] clearLocation = new int[2]; sourceView.getLocationInWindow(clearLocation); clearLocation[0] += sourceView.getWidth() / 2; clearLocation[1] += sourceView.getHeight() / 2; final int revealCenterX = clearLocation[0] - revealView.getLeft(); final int revealCenterY = clearLocation[1] - revealView.getTop(); final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2); final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2); final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2); final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2)); final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX, revealCenterY, 0.0f, revealRadius); revealAnimator.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime)); final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); alphaAnimator.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime)); alphaAnimator.addListener(listener); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(revealAnimator).before(alphaAnimator); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { groupOverlay.remove(revealView); mCurrentAnimator = null; } }); mCurrentAnimator = animatorSet; animatorSet.start(); }
From source file:com.android.deskclock.timer.TimerFragment.java
/** * @param toView one of {@link #mTimersView} or {@link #mCreateTimerView} * @param timerToRemove the timer to be removed during the animation; {@code null} if no timer * should be removed// w w w . j av a 2 s.co m */ private void animateToView(View toView, final Timer timerToRemove) { if (mCurrentView == toView) { throw new IllegalStateException("toView is already the current view"); } final boolean toTimers = toView == mTimersView; // Avoid double-taps by enabling/disabling the set of buttons active on the new view. mLeftButton.setEnabled(toTimers); mRightButton.setEnabled(toTimers); mCancelCreateButton.setEnabled(!toTimers); final Animator rotateFrom = ObjectAnimator.ofFloat(mCurrentView, SCALE_X, 1, 0); rotateFrom.setDuration(mShortAnimationDuration); rotateFrom.setInterpolator(new DecelerateInterpolator()); rotateFrom.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (timerToRemove != null) { DataModel.getDataModel().removeTimer(timerToRemove); Events.sendTimerEvent(R.string.action_delete, R.string.label_deskclock); } mCurrentView.setScaleX(1); if (toTimers) { showTimersView(); } else { showCreateTimerView(); } } }); final Animator rotateTo = ObjectAnimator.ofFloat(toView, SCALE_X, 0, 1); rotateTo.setDuration(mShortAnimationDuration); rotateTo.setInterpolator(new AccelerateInterpolator()); final float preScale = toTimers ? 0 : 1; final float postScale = toTimers ? 1 : 0; final Animator fabAnimator = getScaleAnimator(mFab, preScale, postScale); final Animator leftButtonAnimator = getScaleAnimator(mLeftButton, preScale, postScale); final Animator rightButtonAnimator = getScaleAnimator(mRightButton, preScale, postScale); final AnimatorSet buttons = new AnimatorSet(); buttons.setDuration(toTimers ? mMediumAnimationDuration : mShortAnimationDuration); buttons.play(leftButtonAnimator).with(rightButtonAnimator).with(fabAnimator); buttons.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mLeftButton.setVisibility(toTimers ? VISIBLE : INVISIBLE); mRightButton.setVisibility(toTimers ? VISIBLE : INVISIBLE); mFab.setScaleX(1); mFab.setScaleY(1); mLeftButton.setScaleX(1); mLeftButton.setScaleY(1); mRightButton.setScaleX(1); mRightButton.setScaleY(1); } }); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(rotateFrom).before(rotateTo).with(buttons); animatorSet.start(); }
From source file:com.sbgapps.scoreit.ui.ScoreItActivity.java
public void setActionButtonProperties(boolean animate) { if (animate) { ObjectAnimator scaleX = ObjectAnimator.ofFloat(mActionButton, "scaleX", 0f); ObjectAnimator scaleY = ObjectAnimator.ofFloat(mActionButton, "scaleY", 0f); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.addListener(new Animator.AnimatorListener() { @Override// ww w . j a va 2s.co m public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { setActionButtonColor(); setActionButtonPosition(); ObjectAnimator scaleX = ObjectAnimator.ofFloat(mActionButton, "scaleX", 1f); ObjectAnimator scaleY = ObjectAnimator.ofFloat(mActionButton, "scaleY", 1f); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(scaleX).with(scaleY); animatorSet.start(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); animatorSet.play(scaleX).with(scaleY); animatorSet.start(); } else { setActionButtonPosition(); } }
From source file:org.protocoderrunner.apprunner.api.PUI.java
@ProtocoderScript @APIMethod(description = "Makes the view jump", example = "") @APIParam(params = { "View" }) public void jump(View v) { ValueAnimator w = ObjectAnimator.ofFloat(v, "scaleX", 1f, 0.9f, 1.2f, 1f); w.setDuration(AppSettings.animGeneralSpeed); ValueAnimator h = ObjectAnimator.ofFloat(v, "scaleY", 1f, 0.9f, 1.2f, 1f); h.setDuration(AppSettings.animGeneralSpeed); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(w).with(h);/*from w ww . j ava 2 s .c o m*/ animatorSet.start(); }
From source file:org.telegram.ui.Components.StickersAlert.java
private void init(Context context) { shadowDrawable = context.getResources().getDrawable(R.drawable.sheet_shadow); containerView = new FrameLayout(context) { private int lastNotifyWidth; @Override/*from w w w. ja va 2 s . c o m*/ public boolean onInterceptTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN && scrollOffsetY != 0 && ev.getY() < scrollOffsetY) { dismiss(); return true; } return super.onInterceptTouchEvent(ev); } @Override public boolean onTouchEvent(MotionEvent e) { return !isDismissed() && super.onTouchEvent(e); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int height = MeasureSpec.getSize(heightMeasureSpec); if (Build.VERSION.SDK_INT >= 21) { height -= AndroidUtilities.statusBarHeight; } int contentSize; if (stickerSetCovereds != null) { contentSize = AndroidUtilities.dp(48 + 8) + AndroidUtilities.dp(60) * stickerSetCovereds.size() + adapter.stickersRowCount * AndroidUtilities.dp(82); } else { contentSize = AndroidUtilities.dp(48 + 48) + Math.max(3, (stickerSet != null ? (int) Math.ceil(stickerSet.documents.size() / 5.0f) : 0)) * AndroidUtilities.dp(82) + backgroundPaddingTop; } int padding = contentSize < (height / 5 * 3.2) ? 0 : (height / 5 * 2); if (padding != 0 && contentSize < height) { padding -= (height - contentSize); } if (padding == 0) { padding = backgroundPaddingTop; } if (stickerSetCovereds != null) { padding += AndroidUtilities.dp(8); } if (gridView.getPaddingTop() != padding) { ignoreLayout = true; gridView.setPadding(AndroidUtilities.dp(10), padding, AndroidUtilities.dp(10), 0); emptyView.setPadding(0, padding, 0, 0); ignoreLayout = false; } super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Math.min(contentSize, height), MeasureSpec.EXACTLY)); } @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { if (lastNotifyWidth != right - left) { lastNotifyWidth = right - left; if (adapter != null && stickerSetCovereds != null) { adapter.notifyDataSetChanged(); } } super.onLayout(changed, left, top, right, bottom); updateLayout(); } @Override public void requestLayout() { if (ignoreLayout) { return; } super.requestLayout(); } @Override protected void onDraw(Canvas canvas) { shadowDrawable.setBounds(0, scrollOffsetY - backgroundPaddingTop, getMeasuredWidth(), getMeasuredHeight()); shadowDrawable.draw(canvas); } }; containerView.setWillNotDraw(false); containerView.setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, 0); titleTextView = new TextView(context); titleTextView.setLines(1); titleTextView.setSingleLine(true); titleTextView.setTextColor( ContextCompat.getColor(context, R.color.primary_text) /*Theme.STICKERS_SHEET_TITLE_TEXT_COLOR*/); titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); titleTextView.setEllipsize(TextUtils.TruncateAt.MIDDLE); titleTextView.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0); titleTextView.setGravity(Gravity.CENTER_VERTICAL); titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); containerView.addView(titleTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48)); titleTextView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); shadow[0] = new View(context); shadow[0].setBackgroundResource(R.drawable.header_shadow); shadow[0].setAlpha(0.0f); shadow[0].setVisibility(View.INVISIBLE); shadow[0].setTag(1); containerView.addView(shadow[0], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.TOP | Gravity.LEFT, 0, 48, 0, 0)); gridView = new RecyclerListView(context) { @Override public boolean onInterceptTouchEvent(MotionEvent event) { boolean result = StickerPreviewViewer.getInstance().onInterceptTouchEvent(event, gridView, 0); return super.onInterceptTouchEvent(event) || result; } @Override public void requestLayout() { if (ignoreLayout) { return; } super.requestLayout(); } }; gridView.setTag(14); gridView.setLayoutManager(layoutManager = new GridLayoutManager(getContext(), 5)); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { if (stickerSetCovereds != null && adapter.cache.get(position) instanceof Integer || position == adapter.totalItems) { return adapter.stickersPerRow; } return 1; } }); gridView.setAdapter(adapter = new GridAdapter(context)); gridView.setVerticalScrollBarEnabled(false); gridView.addItemDecoration(new RecyclerView.ItemDecoration() { @Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { outRect.left = 0; outRect.right = 0; outRect.bottom = 0; outRect.top = 0; } }); gridView.setPadding(AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), 0); gridView.setClipToPadding(false); gridView.setEnabled(true); gridView.setGlowColor(0xfff5f6f7); gridView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return StickerPreviewViewer.getInstance().onTouch(event, gridView, 0, stickersOnItemClickListener); } }); gridView.setOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { updateLayout(); } }); stickersOnItemClickListener = new RecyclerListView.OnItemClickListener() { @Override public void onItemClick(View view, int position) { if (stickerSetCovereds != null) { TLRPC.StickerSetCovered pack = adapter.positionsToSets.get(position); if (pack != null) { dismiss(); TLRPC.TL_inputStickerSetID inputStickerSetID = new TLRPC.TL_inputStickerSetID(); inputStickerSetID.access_hash = pack.set.access_hash; inputStickerSetID.id = pack.set.id; StickersAlert alert = new StickersAlert(parentActivity, parentFragment, inputStickerSetID, null, null); alert.show(); } } else { if (stickerSet == null || position < 0 || position >= stickerSet.documents.size()) { return; } selectedSticker = stickerSet.documents.get(position); boolean set = false; for (int a = 0; a < selectedSticker.attributes.size(); a++) { TLRPC.DocumentAttribute attribute = selectedSticker.attributes.get(a); if (attribute instanceof TLRPC.TL_documentAttributeSticker) { if (attribute.alt != null && attribute.alt.length() > 0) { stickerEmojiTextView.setText(Emoji.replaceEmoji(attribute.alt, stickerEmojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(30), false)); set = true; } break; } } if (!set) { stickerEmojiTextView .setText(Emoji.replaceEmoji(StickersQuery.getEmojiForSticker(selectedSticker.id), stickerEmojiTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(30), false)); } stickerImageView.getImageReceiver().setImage(selectedSticker, null, selectedSticker.thumb.location, null, "webp", true); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) stickerPreviewLayout .getLayoutParams(); layoutParams.topMargin = scrollOffsetY; stickerPreviewLayout.setLayoutParams(layoutParams); stickerPreviewLayout.setVisibility(View.VISIBLE); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(ObjectAnimator.ofFloat(stickerPreviewLayout, "alpha", 0.0f, 1.0f)); animatorSet.setDuration(200); animatorSet.start(); } } }; gridView.setOnItemClickListener(stickersOnItemClickListener); containerView.addView(gridView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 48, 0, 48)); emptyView = new FrameLayout(context) { @Override public void requestLayout() { if (ignoreLayout) { return; } super.requestLayout(); } }; containerView.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 48)); gridView.setEmptyView(emptyView); emptyView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); ProgressBar progressView = new ProgressBar(context); emptyView.addView(progressView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); shadow[1] = new View(context); shadow[1].setBackgroundResource(R.drawable.header_shadow_reverse); containerView.addView(shadow[1], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.BOTTOM | Gravity.LEFT, 0, 0, 0, 48)); pickerBottomLayout = new PickerBottomLayout(context, false); containerView.addView(pickerBottomLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.BOTTOM)); pickerBottomLayout.cancelButton.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0); pickerBottomLayout.cancelButton.setTextColor(Theme.STICKERS_SHEET_CLOSE_TEXT_COLOR); pickerBottomLayout.cancelButton.setText(LocaleController.getString("Close", R.string.Close).toUpperCase()); pickerBottomLayout.cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dismiss(); } }); pickerBottomLayout.doneButton.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0); pickerBottomLayout.doneButtonBadgeTextView.setBackgroundResource(R.drawable.stickercounter); stickerPreviewLayout = new FrameLayout(context); if ((context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_YES) != 0) { stickerPreviewLayout.setBackgroundColor( 0x00ffffff & ContextCompat.getColor(context, R.color.card_background) | 0xdf000000); } else { stickerPreviewLayout.setBackgroundColor(0xdfffffff); } stickerPreviewLayout.setVisibility(View.GONE); stickerPreviewLayout.setSoundEffectsEnabled(false); containerView.addView(stickerPreviewLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); stickerPreviewLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hidePreview(); } }); ImageView closeButton = new ImageView(context); closeButton.setImageResource(R.drawable.delete_reply); closeButton.setScaleType(ImageView.ScaleType.CENTER); if (Build.VERSION.SDK_INT >= 21) { closeButton.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.INPUT_FIELD_SELECTOR_COLOR)); } stickerPreviewLayout.addView(closeButton, LayoutHelper.createFrame(48, 48, Gravity.RIGHT | Gravity.TOP)); closeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hidePreview(); } }); stickerImageView = new BackupImageView(context); stickerImageView.setAspectFit(true); stickerPreviewLayout.addView(stickerImageView); stickerEmojiTextView = new TextView(context); stickerEmojiTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 30); stickerEmojiTextView.setGravity(Gravity.BOTTOM | Gravity.RIGHT); stickerPreviewLayout.addView(stickerEmojiTextView); previewSendButton = new TextView(context); previewSendButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); previewSendButton.setTextColor(Theme.STICKERS_SHEET_SEND_TEXT_COLOR); previewSendButton.setGravity(Gravity.CENTER); previewSendButton.setBackgroundColor(ContextCompat.getColor(context, R.color.background)); previewSendButton.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0); previewSendButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); stickerPreviewLayout.addView(previewSendButton, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM | Gravity.LEFT)); previewSendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { delegate.onStickerSelected(selectedSticker); dismiss(); } }); previewSendButtonShadow = new View(context); previewSendButtonShadow.setBackgroundResource(R.drawable.header_shadow_reverse); stickerPreviewLayout.addView(previewSendButtonShadow, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.BOTTOM | Gravity.LEFT, 0, 0, 0, 48)); NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded); updateFields(); updateSendButton(); adapter.notifyDataSetChanged(); }
From source file:org.chromium.chrome.browser.payments.ui.EditorView.java
@Override public void onShow(DialogInterface dialog) { assert mDialogInOutAnimator == null; // Hide keyboard and disable EditText views for animation efficiency. if (getCurrentFocus() != null) UiUtils.hideKeyboard(getCurrentFocus()); for (int i = 0; i < mEditableTextFields.size(); i++) { mEditableTextFields.get(i).setEnabled(false); }/* w w w .j av a2s .c o m*/ mLayout.setLayerType(View.LAYER_TYPE_HARDWARE, null); mLayout.buildLayer(); Animator popUp = ObjectAnimator.ofFloat(mLayout, View.TRANSLATION_Y, mLayout.getHeight(), 0f); Animator fadeIn = ObjectAnimator.ofFloat(mLayout, View.ALPHA, 0f, 1f); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(popUp, fadeIn); mDialogInOutAnimator = animatorSet; mDialogInOutAnimator.setDuration(DIALOG_ENTER_ANIMATION_MS); mDialogInOutAnimator.setInterpolator(new LinearOutSlowInInterpolator()); mDialogInOutAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mLayout.setLayerType(View.LAYER_TYPE_NONE, null); for (int i = 0; i < mEditableTextFields.size(); i++) { mEditableTextFields.get(i).setEnabled(true); } // Note that keyboard will not show for dropdown field since it's not necessary. if (getCurrentFocus() != null) UiUtils.showKeyboard(getCurrentFocus()); mDialogInOutAnimator = null; initFocus(); } }); mDialogInOutAnimator.start(); }
From source file:com.projecttango.examples.java.greenscreen.GreenScreenActivity.java
/** * Here is where you would set up your rendering logic. We're replacing it with a minimalistic, * dummy example, using a standard GLSurfaceView and a basic renderer, for illustration purposes * only./*from w w w.j ava2 s. c om*/ */ private void setupRenderer() { mSurfaceView.setEGLContextClientVersion(2); mRenderer = new GreenScreenRenderer(this, new GreenScreenRenderer.RenderCallback() { @Override public void preRender() { // This is the work that you would do on your main OpenGL render thread. // We need to be careful to not run any Tango-dependent code in the // OpenGL thread unless we know the Tango Service to be properly set up // and connected. if (!mIsConnected) { return; } // Synchronize against concurrently disconnecting the service triggered // from the UI thread. synchronized (GreenScreenActivity.this) { // Connect the Tango SDK to the OpenGL texture ID where we are // going to render the camera. // NOTE: This must be done after both the texture is generated // and the Tango Service is connected. if (mConnectedTextureIdGlThread != mRenderer.getTextureId()) { mTango.connectTextureId(TangoCameraIntrinsics.TANGO_CAMERA_COLOR, mRenderer.getTextureId()); mConnectedTextureIdGlThread = mRenderer.getTextureId(); Log.d(TAG, "connected to texture id: " + mRenderer.getTextureId()); // Set up scene camera projection to match RGB camera intrinsics. mRenderer.setProjectionMatrix(projectionMatrixFromCameraIntrinsics(mIntrinsics)); mRenderer.setCameraIntrinsics(mIntrinsics); } // If there is a new RGB camera frame available, update the texture and // scene camera pose. if (mIsFrameAvailableTangoThread.compareAndSet(true, false)) { double depthTimestamp = 0; TangoPointCloudData pointCloud = mPointCloudManager.getLatestPointCloud(); if (pointCloud != null) { mRenderer.updatePointCloud(pointCloud); depthTimestamp = pointCloud.timestamp; } try { // {@code mRgbTimestampGlThread} contains the exact timestamp at // which the rendered RGB frame was acquired. mRgbTimestampGlThread = mTango.updateTexture(TangoCameraIntrinsics.TANGO_CAMERA_COLOR); // In the following code, we define t0 as the depth timestamp // and t1 as the color camera timestamp. // Calculate the relative pose between color camera frame at // timestamp color_timestamp t1 and depth. TangoPoseData poseColort1Tdeptht0; poseColort1Tdeptht0 = TangoSupport.calculateRelativePose(mRgbTimestampGlThread, TangoPoseData.COORDINATE_FRAME_CAMERA_COLOR, depthTimestamp, TangoPoseData.COORDINATE_FRAME_CAMERA_DEPTH); if (poseColort1Tdeptht0.statusCode == TangoPoseData.POSE_VALID) { float[] colort1Tdeptht0 = poseToMatrix(poseColort1Tdeptht0); mRenderer.updateModelMatrix(colort1Tdeptht0); } else { Log.w(TAG, "Could not get relative pose from camera depth" + " " + "at " + depthTimestamp + " to camera color at " + mRgbTimestampGlThread); } } catch (Exception e) { Log.e(TAG, "Exception on the OpenGL thread", e); } } } } /** * This method is called by the renderer when the screenshot has been taken. */ @Override public void onScreenshotTaken(final Bitmap screenshotBitmap) { // Give immediate feedback to the user. MediaActionSound sound = new MediaActionSound(); sound.play(MediaActionSound.SHUTTER_CLICK); runOnUiThread(new Runnable() { @Override public void run() { mPanelFlash.setVisibility(View.VISIBLE); // Run a fade in and out animation of a white screen. ObjectAnimator fadeIn = ObjectAnimator.ofFloat(mPanelFlash, View.ALPHA, 0, 1); fadeIn.setDuration(100); fadeIn.setInterpolator(new DecelerateInterpolator()); ObjectAnimator fadeOut = ObjectAnimator.ofFloat(mPanelFlash, View.ALPHA, 1, 0); fadeOut.setInterpolator(new AccelerateInterpolator()); fadeOut.setDuration(100); AnimatorSet animation = new AnimatorSet(); animation.playSequentially(fadeIn, fadeOut); animation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mPanelFlash.setVisibility(View.GONE); } }); animation.start(); } }); // Save bitmap to gallery in background. new BitmapSaverTask(screenshotBitmap).execute(); } }); mSurfaceView.setRenderer(mRenderer); }
From source file:com.alburivan.slickform.tooltip.SimpleTooltip.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void startAnimation() { final String property = mGravity == Gravity.TOP || mGravity == Gravity.BOTTOM ? "translationY" : "translationX"; final ObjectAnimator anim1 = ObjectAnimator.ofFloat(mContentLayout, property, -mAnimationPadding, mAnimationPadding);// w w w . j a va 2 s .c o m anim1.setDuration(mAnimationDuration); anim1.setInterpolator(new AccelerateDecelerateInterpolator()); final ObjectAnimator anim2 = ObjectAnimator.ofFloat(mContentLayout, property, mAnimationPadding, -mAnimationPadding); anim2.setDuration(mAnimationDuration); anim2.setInterpolator(new AccelerateDecelerateInterpolator()); mAnimator = new AnimatorSet(); mAnimator.playSequentially(anim1, anim2); mAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (!dismissed && isShowing()) { animation.start(); } } }); mAnimator.start(); }
From source file:com.wizardsofm.deskclock.timer.TimerFragment.java
/** * @param timerToRemove the timer to be removed during the animation *///from w w w . j ava2 s.c o m private void animateTimerRemove(final Timer timerToRemove) { final long duration = UiDataModel.getUiDataModel().getShortAnimationDuration(); final Animator fadeOut = ObjectAnimator.ofFloat(mViewPager, ALPHA, 1, 0); fadeOut.setDuration(duration); fadeOut.setInterpolator(new DecelerateInterpolator()); fadeOut.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { DataModel.getDataModel().removeTimer(timerToRemove); Events.sendTimerEvent(com.wizardsofm.deskclock.R.string.action_delete, com.wizardsofm.deskclock.R.string.label_deskclock); } }); final Animator fadeIn = ObjectAnimator.ofFloat(mViewPager, ALPHA, 0, 1); fadeIn.setDuration(duration); fadeIn.setInterpolator(new AccelerateInterpolator()); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(fadeOut).before(fadeIn); animatorSet.start(); }