List of usage examples for android.view.animation Animation setStartOffset
public void setStartOffset(long startOffset)
From source file:Steps.StepsFragment.java
/** * Animate the new sticker rotating them on left and right and back again * * @param sticker//from www. ja va 2s . com * @param durationMillis */ private void animate(final RelativeLayout sticker, long durationMillis) { //final AnimationSet as = new AnimationSet(true); as.setFillEnabled(true); as.setFillAfter(true); //left rotations final RotateAnimation rotateLeft = new RotateAnimation((float) 320, (float) 375, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); rotateLeft.setDuration(durationMillis); rotateLeft.setFillEnabled(true); if (firstTime) as.addAnimation(rotateLeft); //right rotations Animation rotateRight = new RotateAnimation((float) 375, (float) 320, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); rotateRight.setStartOffset(durationMillis); rotateRight.setDuration(durationMillis); rotateRight.setFillEnabled(true); rotateRight.setFillAfter(true); if (firstTime) as.addAnimation(rotateRight); //sticker.clearAnimation(); sticker.startAnimation(as); firstTime = false; }
From source file:com.brandao.tictactoe.board.BoardFragment.java
public void animateSingleSquare(int inAnim, int outAnim, final int index) { final Animation shrink = AnimationUtils.loadAnimation(getActivity(), outAnim); shrink.setStartOffset(325); shrink.setAnimationListener(new AnimationListener() { @Override//from w w w. j a v a 2 s . c o m public void onAnimationEnd(Animation animation) { mAnimating = false; } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { mAnimating = true; } }); Animation grow = AnimationUtils.loadAnimation(getActivity(), inAnim); grow.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { mAnimating = false; mScreens[index].startAnimation(shrink); } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationStart(Animation animation) { mAnimating = true; } }); mScreens[index].startAnimation(grow); }
From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.TimeLineActivity.java
/** * On click image view to start stop recording * /*from www . j a v a 2 s . co m*/ * Records time SYNCHRONOUSLY * * @param v */ public void onClickSwitchAction(View v) { Drawable drwStart = getResources().getDrawable(R.drawable.play); Drawable drwStop = getResources().getDrawable(R.drawable.stop); LinearLayout lllFrag = (LinearLayout) v.getParent(); LinearLayout llTimePicker = (LinearLayout) lllFrag.findViewById(R.id.llTimePicker); LinearLayout llStatus = (LinearLayout) lllFrag.findViewById(R.id.llStatus); TextView tvRecording = (TextView) llStatus.findViewById(R.id.tvRecording); ImageView ivRecording = (ImageView) llStatus.findViewById(R.id.ivRecording); Animation anim = new AlphaAnimation(0.0f, 1.0f); Log.d(CLASSNAME, "BEFORE: " + Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).toString()); ImageView iv = (ImageView) v; int currentStatus = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).getStatus(); if (currentStatus == ActivitySession.STATUS_STOPPED) { Log.d(CLASSNAME, "Status is STOPPED. Shift to STARTED"); iv.setImageDrawable(drwStop); llTimePicker.setVisibility(View.INVISIBLE); anim.setDuration(500); anim.setStartOffset(20); anim.setRepeatMode(Animation.REVERSE); anim.setRepeatCount(Animation.INFINITE); Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).doCheckIn(); } else { Log.d(CLASSNAME, "Status is STARTED. Shift to STOPPED"); iv.setImageDrawable(drwStart); llTimePicker.setVisibility(View.VISIBLE); anim.setRepeatCount(0); ActivitySession as = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()); String sSubjectId = as.getId_subject(); double dLat = as.getLocation_latitude(); double dLong = as.getLocation_longitude(); long lCheckOut = new Date().getTime(); long lCheckIn = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).doCheckOut(); // Save data into both databases DateUtils du = new DateUtils(); Log.i(CLASSNAME, "Recording activity into both databasees:" + as.getId_subject() + " / " + du.duration(lCheckIn, lCheckOut)); // TODO make some control here to make this transactional // Save in backend recordActivityBackend(sSubjectId, lCheckIn, lCheckOut, dLat, dLong, ActivityDO.ACTIVITY_RECORD_MODE_SYNCHRONOUS); // Save in local database recordActivitySQLite(sSubjectId, lCheckIn, lCheckOut, dLat, dLong); TextView tvDuration = (TextView) lllFrag.findViewById(R.id.tvDuration); tvDuration.setText( du.duration(Session.getSingleInstance().getDatabaseHandler().getAccumulatedTime(sSubjectId))); Toast.makeText(getApplicationContext(), "Recorded " + du.duration(lCheckIn, lCheckOut), Toast.LENGTH_SHORT).show(); // // Update history layout // LayoutInflater inflater = LayoutInflater.from(this); LinearLayout llParent = (LinearLayout) inflater.inflate(R.layout.check_item, null); LinearLayout liContent = (LinearLayout) llParent.getChildAt(0); // ImageView ivParent = (ImageView) liContent.findViewById(R.id.imageViewStart); // ivParent.setImageResource(R.drawable.rec_50x); //TextView tvTimeStamp = (TextView) liContent.getChildAt(1); TextView tvTimeStamp = (TextView) liContent.findViewById(R.id.textViewTimeStamp); tvTimeStamp.setText(Constants.TIME_FORMAT.format(lCheckIn)); tvTimeStamp.setTag(Long.valueOf(lCheckIn)); TextView tvDurRecord = (TextView) liContent.findViewById(R.id.textViewDuration); tvDurRecord.setText(" [" + du.duration(lCheckIn, lCheckOut) + "]"); // Passing subject id as parameter tvDurRecord.setTag(sSubjectId); LinearLayout llHistory = (LinearLayout) lllFrag.findViewById(R.id.llHistory); // Set index number so that the record can be removed int iTag = (llHistory.getChildCount() - 1) / 2; llParent.setTag(iTag); llHistory.addView(inflater.inflate(R.layout.tag_divider, llHistory, false), 1); llHistory.addView(llParent, 2); } tvRecording.startAnimation(anim); ivRecording.startAnimation(anim); Log.d(CLASSNAME, "AFTER: " + Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).toString()); }
From source file:fm.krui.kruifm.StreamFragment.java
/** * Moves the stream status bar into view to show messages regarding stream status. Use indefinite time constraints * @param message String to display in the status bar. * @param isIndefinite true if the message should be displayed until explicitly cancelled by a broadcast message. *///from w w w.ja v a 2 s. c o m public void showStreamStatusBar(String message, boolean isIndefinite) { final LinearLayout statusContainer = (LinearLayout) getActivity() .findViewById(R.id.stream_status_container_linearlayout); // Apply label text, then bring the status bar into view TextView statusLabel = (TextView) getActivity().findViewById(R.id.stream_status_label_textview); statusLabel.setText(message); statusContainer.setVisibility(View.VISIBLE); // Construct translation animations from xml. final Animation animIn = AnimationUtils.loadAnimation(getActivity(), R.anim.translate_up); final Animation animOut = AnimationUtils.loadAnimation(getActivity(), R.anim.translate_down); statusContainer.startAnimation(animIn); if (!isIndefinite) { // When fade in is completed, trigger a fade out animation. animIn.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { animOut.setStartOffset(1200); statusContainer.startAnimation(animOut); } @Override public void onAnimationRepeat(Animation animation) { } }); // When the animation has completely faded out, hide its parent container animOut.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { statusContainer.setVisibility(View.INVISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); } }
From source file:fm.krui.kruifm.StreamActivity.java
/** * Moves the stream status bar into view to show messages regarding stream status. Use indefinite time constraints * @param message String to display in the status bar. * @param isIndefinite true if the message should be displayed until explicitly cancelled by a broadcast message. *//* www . ja v a 2 s . c o m*/ public void showStreamStatusBar(String message, boolean isIndefinite) { final LinearLayout statusContainer = (LinearLayout) this .findViewById(R.id.stream_status_container_linearlayout); // Apply label text, then bring the status bar into view TextView statusLabel = (TextView) this.findViewById(R.id.stream_status_label_textview); statusLabel.setText(message); statusContainer.setVisibility(View.VISIBLE); // Construct translation animations from xml. final Animation animIn = AnimationUtils.loadAnimation(this, R.anim.translate_up); final Animation animOut = AnimationUtils.loadAnimation(this, R.anim.translate_down); statusContainer.startAnimation(animIn); if (!isIndefinite) { // When fade in is completed, trigger a fade out animation. animIn.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { animOut.setStartOffset(1200); statusContainer.startAnimation(animOut); } @Override public void onAnimationRepeat(Animation animation) { } }); // When the animation has completely faded out, hide its parent container animOut.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { statusContainer.setVisibility(View.INVISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); } }
From source file:com.saphion.stencilweather.activities.MainActivity.java
public void bounceScaleAnimation(View mView, int delay) { // YoYo.with(Techniques.ZoomIn).interpolate(new BounceInterpolator()).duration(180).delay(delay).playOn(mView); Animation pulse = AnimationUtils.loadAnimation(this, R.anim.pulse); pulse.setStartOffset(delay); mView.startAnimation(pulse);/*from ww w. j av a 2 s . co m*/ }
From source file:com.yahala.ui.LaunchActivity.java
public void checkConnectionState() { final Animation animScalin; try {// w ww.j a v a 2 s . c o m final Animation animScalout; animScalin = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_down); animScalin.setFillEnabled(true); animScalin.setFillAfter(true); animScalin.setFillBefore(true); animScalout = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_up); animScalout.setFillEnabled(true); animScalout.setFillAfter(true); animScalout.setStartOffset(3000); connectionStatusLayout.setVisibility(View.VISIBLE); connectionStatusLayout.setAlpha(1); isVisible = true; animScalout.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { isVisible = false; } @Override public void onAnimationEnd(Animation animation) { isVisible = false; connectionStatusLayout.setVisibility(View.GONE); connectionStatusLayout.setAlpha(0); } @Override public void onAnimationRepeat(Animation animation) { } }); // connectionStatusLayout.startAnimation(animScalin); if (XMPPManager.getInstance().connectionState == ConnectionState.ONLINE) { connectionStatus.setText(LocaleController.getString("WaitingForNetwork", R.string.Updating)); connectionStatusLayout.startAnimation(animScalout); } else if (XMPPManager.getInstance().connectionState == ConnectionState.RECONNECT_NETWORK) { connectionStatusLayout.startAnimation(animScalin); connectionStatus .setText(LocaleController.getString("WaitingForNetwork", R.string.WaitingForNetwork)); } else if (XMPPManager.getInstance().connectionState == ConnectionState.DISCONNECTED) { connectionStatusLayout.startAnimation(animScalin); connectionStatus .setText(LocaleController.getString("WaitingForNetwork", R.string.WaitingForNetwork)); } else if (XMPPManager.getInstance().connectionState == ConnectionState.RECONNECT_DELAYED) { connectionStatusLayout.startAnimation(animScalin); connectionStatus .setText(LocaleController.getString("WaitingForNetwork", R.string.WaitingForNetwork)); } else if (XMPPManager.getInstance().connectionState == ConnectionState.CONNECTING) { connectionStatusLayout.startAnimation(animScalin); connectionStatus.setText(LocaleController.getString("WaitingForNetwork", R.string.Connecting)); } } catch (Exception e) { FileLog.e("Yahala", e); } }
From source file:chickennugget.spaceengineersdata.material.widgets.ListPopupWindow.java
/** * Show the popup list. If the list is already showing, this method * will recalculate the popup's size and position. *///ww w .java 2 s. c o m public void show() { int height = buildDropDown(); int widthSpec = 0; int heightSpec = 0; boolean noInputMethod = isInputMethodNotNeeded(); if (mPopup.isShowing()) { if (mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT) { // The call to PopupWindow's update method below can accept -1 for any // value you do not want to update. widthSpec = -1; } else if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) { widthSpec = getAnchorView().getWidth(); } else { widthSpec = mDropDownWidth; } if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) { // The call to PopupWindow's update method below can accept -1 for any // value you do not want to update. heightSpec = noInputMethod ? height : ViewGroup.LayoutParams.MATCH_PARENT; if (noInputMethod) { mPopup.setWindowLayoutMode(mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT ? ViewGroup.LayoutParams.MATCH_PARENT : 0, 0); } else { mPopup.setWindowLayoutMode(mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT ? ViewGroup.LayoutParams.MATCH_PARENT : 0, ViewGroup.LayoutParams.MATCH_PARENT); } } else if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) { heightSpec = height; } else { heightSpec = mDropDownHeight; } mPopup.setOutsideTouchable(!mForceIgnoreOutsideTouch && !mDropDownAlwaysVisible); mPopup.update(getAnchorView(), mDropDownHorizontalOffset, mDropDownVerticalOffset, widthSpec, heightSpec); } else { if (mDropDownWidth == ViewGroup.LayoutParams.MATCH_PARENT) { widthSpec = ViewGroup.LayoutParams.MATCH_PARENT; } else { if (mDropDownWidth == ViewGroup.LayoutParams.WRAP_CONTENT) { mPopup.setWidth(getAnchorView().getWidth()); } else { mPopup.setWidth(mDropDownWidth); } } if (mDropDownHeight == ViewGroup.LayoutParams.MATCH_PARENT) { heightSpec = ViewGroup.LayoutParams.MATCH_PARENT; } else { if (mDropDownHeight == ViewGroup.LayoutParams.WRAP_CONTENT) { mPopup.setHeight(height); } else { mPopup.setHeight(mDropDownHeight); } } mPopup.setWindowLayoutMode(widthSpec, heightSpec); setPopupClipToScreenEnabled(true); // use outside touchable to dismiss drop down when touching outside of it, so // only set this if the dropdown is not always visible mPopup.setOutsideTouchable(!mForceIgnoreOutsideTouch && !mDropDownAlwaysVisible); mPopup.setTouchInterceptor(mTouchInterceptor); PopupWindowCompat.showAsDropDown(mPopup, getAnchorView(), mDropDownHorizontalOffset, mDropDownVerticalOffset, mDropDownGravity); mDropDownList.setSelection(ListView.INVALID_POSITION); if (!mModal || mDropDownList.isInTouchMode()) { clearListSelection(); } if (!mModal) { mHandler.post(mHideSelector); } // show item animation if (mItemAnimationId != 0) mPopup.getContentView().getViewTreeObserver() .addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { mPopup.getContentView().getViewTreeObserver().removeOnPreDrawListener(this); for (int i = 0, count = mDropDownList.getChildCount(); i < count; i++) { View v = mDropDownList.getChildAt(i); Animation anim = AnimationUtils.loadAnimation(mContext, mItemAnimationId); anim.setStartOffset(mItemAnimationOffset * i); v.startAnimation(anim); } return false; } }); } }
From source file:org.kiwix.kiwixmobile.KiwixMobileActivity.java
@Override public void webViewPageChanged(int page, int maxPages) { if (isBackToTopEnabled) { if (getCurrentWebView().getScrollY() > 200) { if (backToTopButton.getVisibility() == View.INVISIBLE && TTSControls.getVisibility() == View.GONE) { backToTopButton.setText(R.string.button_backtotop); backToTopButton.setVisibility(View.VISIBLE); backToTopButton.startAnimation( AnimationUtils.loadAnimation(KiwixMobileActivity.this, android.R.anim.fade_in)); backToTopButton.setVisibility(View.INVISIBLE); Animation fadeAnimation = AnimationUtils.loadAnimation(KiwixMobileActivity.this, android.R.anim.fade_out); fadeAnimation.setStartOffset(1200); backToTopButton.startAnimation(fadeAnimation); }// www . j av a 2 s. co m } else { if (backToTopButton.getVisibility() == View.VISIBLE) { backToTopButton.setVisibility(View.INVISIBLE); backToTopButton.clearAnimation(); backToTopButton.startAnimation( AnimationUtils.loadAnimation(KiwixMobileActivity.this, android.R.anim.fade_out)); } else { backToTopButton.clearAnimation(); } } } }