List of usage examples for android.view.animation TranslateAnimation setDuration
public void setDuration(long durationMillis)
From source file:org.digitalcampus.oppia.activity.OppiaMobileActivity.java
private void animateScanMediaMessage() { TranslateAnimation anim = new TranslateAnimation(0, 0, -200, 0); anim.setDuration(900); messageContainer.startAnimation(anim); messageContainer.measure(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); ValueAnimator animator = ValueAnimator.ofInt(initialCourseListPadding, messageContainer.getMeasuredHeight()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { //@Override public void onAnimationUpdate(ValueAnimator valueAnimator) { courseList.setPadding(0, (Integer) valueAnimator.getAnimatedValue(), 0, 0); courseList.setSelectionAfterHeaderView(); }/*from w ww . j a v a 2 s . co m*/ }); animator.setStartDelay(200); animator.setDuration(700); animator.start(); }
From source file:com.chiemy.zxing.activity.CaptureActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Window window = getWindow();/*w w w . jav a 2 s. co m*/ window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(getLayoutId()); scanPreview = (SurfaceView) findViewById(R.id.capture_preview); scanContainer = (RelativeLayout) findViewById(R.id.capture_container); scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view); scanLine = (ImageView) findViewById(R.id.capture_scan_line); //inactivityTimer = new InactivityTimer(this); beepManager = new BeepManager(this); getWindow().getDecorView().post(new Runnable() { @Override public void run() { TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.9f); animation.setDuration(4500); animation.setRepeatCount(-1); animation.setRepeatMode(Animation.RESTART); scanLine.startAnimation(animation); } }); redecodeHandler = new Handler(); redecodeRunnable = new RedecodeRunnable(this); }
From source file:com.giovanniterlingen.windesheim.view.Adapters.ScheduleAdapter.java
@Override public void onBindViewHolder(final ViewHolder holder, int position) { final TextView lessonName = holder.lessonName; final TextView lessonTime = holder.lessonTime; final TextView lessonRoom = holder.lessonRoom; final TextView lessonComponent = holder.lessonComponent; final RelativeLayout menuButton = holder.menuButton; final ImageView menuButtonImage = holder.menuButtonImage; final View scheduleIdentifier = holder.scheduleIdentifier; Lesson lesson = this.lessons[position]; long databaseDateStart = Long .parseLong(lesson.getDate().replaceAll("-", "") + lesson.getStartTime().replaceAll(":", "")); long databaseDateEnd = Long .parseLong(lesson.getDate().replaceAll("-", "") + lesson.getEndTime().replaceAll(":", "")); SimpleDateFormat yearMonthDayDateFormat = CalendarController.getInstance().getYearMonthDayDateTimeFormat(); long currentDate = Long.parseLong(yearMonthDayDateFormat.format(new Date())); lessonName.setText(lesson.getSubject()); lessonRoom.setText(lesson.getRoom()); lessonComponent.setText(lesson.getScheduleType() == 2 ? lesson.getClassName() : lesson.getTeacher()); lessonComponent.setSelected(true);//from w w w.j a va2 s . com if (databaseDateStart <= currentDate && databaseDateEnd >= currentDate) { lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorAccent)); lessonTime.setText( ApplicationLoader.applicationContext.getResources().getString(R.string.lesson_started)); holder.cardView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Lesson lesson = ScheduleAdapter.this.lessons[holder.getAdapterPosition()]; if (!lessonTime.getText().toString().equals(ApplicationLoader.applicationContext.getResources() .getString(R.string.lesson_started))) { TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f); animation.setDuration(100); lessonTime.setAnimation(animation); lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorAccent)); lessonTime.setText(ApplicationLoader.applicationContext.getResources() .getString(R.string.lesson_started)); } else { TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f); animation.setDuration(100); lessonTime.setAnimation(animation); String lessonTimes = lesson.getStartTime() + " - " + lesson.getEndTime(); lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorSecondaryText)); lessonTime.setText(lessonTimes); } } }); } else if (databaseDateEnd < currentDate) { lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorAccent)); lessonTime.setText(ApplicationLoader.applicationContext.getResources().getString(R.string.finished)); holder.cardView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Lesson lesson = ScheduleAdapter.this.lessons[holder.getAdapterPosition()]; if (!lessonTime.getText().toString().equals( ApplicationLoader.applicationContext.getResources().getString(R.string.finished))) { TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f); animation.setDuration(100); lessonTime.setAnimation(animation); lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorAccent)); lessonTime.setText( ApplicationLoader.applicationContext.getResources().getString(R.string.finished)); } else { TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f); animation.setDuration(100); lessonTime.setAnimation(animation); String lessonTimes = lesson.getStartTime() + " - " + lesson.getEndTime(); lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorSecondaryText)); lessonTime.setText(lessonTimes); } } }); } else { String lessonTimes = lesson.getStartTime() + " - " + lesson.getEndTime(); lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorSecondaryText)); lessonTime.setText(lessonTimes); holder.cardView.setOnClickListener(null); } menuButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { menuButtonImage.setImageDrawable( ResourcesCompat.getDrawable(activity.getResources(), R.drawable.overflow_open, null)); PopupMenu popupMenu = new PopupMenu(activity, menuButton); popupMenu.inflate(R.menu.menu_schedule); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { Lesson lesson = ScheduleAdapter.this.lessons[holder.getAdapterPosition()]; if (item.getItemId() == R.id.hide_lesson) { showPromptDialog(lesson.getSubject()); return true; } if (item.getItemId() == R.id.save_lesson) { showCalendarDialog(lesson.getRowId()); } return true; } }); popupMenu.setOnDismissListener(new PopupMenu.OnDismissListener() { @Override public void onDismiss(PopupMenu menu) { menuButtonImage.setImageDrawable(ResourcesCompat.getDrawable(activity.getResources(), R.drawable.overflow_normal, null)); } }); popupMenu.show(); } }); scheduleIdentifier.setBackgroundColor(ColorController.getInstance().getColorById(lesson.getScheduleId())); }
From source file:com.aniruddhc.acemusic.player.ListViewFragment.ListViewFragment.java
/** * Displays the search field./*w ww . j ava 2 s.com*/ */ private void showSearch() { mSearchLayout.setVisibility(View.VISIBLE); final TranslateAnimation searchAnim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, -2f, Animation.RELATIVE_TO_SELF, 0f); searchAnim.setDuration(500l); searchAnim.setInterpolator(new AccelerateDecelerateInterpolator()); final TranslateAnimation gridListAnim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 2f); gridListAnim.setDuration(500l); gridListAnim.setInterpolator(new LinearInterpolator()); gridListAnim.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { mListView.setAdapter(null); } @Override public void onAnimationRepeat(Animation animation) { // TODO Auto-generated method stub } @Override public void onAnimationStart(Animation animation) { mSearchLayout.startAnimation(searchAnim); mSearchLayout.setVisibility(View.VISIBLE); } }); searchAnim.setAnimationListener(new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { if (mSearchEditText.requestFocus()) { mFragment.getActivity().getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } @Override public void onAnimationRepeat(Animation animation) { // TODO Auto-generated method stub } @Override public void onAnimationStart(Animation animation) { // TODO Auto-generated method stub } }); mListView.startAnimation(gridListAnim); }
From source file:com.kuaichumen.whistle.admin.CaptureActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Window window = getWindow();/*from w w w .jav a 2 s .c o m*/ window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_capture); getSupportActionBar().hide(); CameraManager.init(getApplication()); scanPreview = (SurfaceView) findViewById(R.id.capture_preview); scanContainer = (RelativeLayout) findViewById(R.id.capture_container); scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view); scanLine = (ImageView) findViewById(R.id.capture_scan_line); title = (TextView) findViewById(R.id.title); flashLight = (LinearLayout) findViewById(R.id.flash_light); ll_back = (LinearLayout) findViewById(R.id.ll_back); flash = (ImageView) findViewById(R.id.flash); flashLight.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { light(); } }); ll_back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); inactivityTimer = new InactivityTimer(this); beepManager = new BeepManager(this); TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.9f); animation.setDuration(4500); animation.setRepeatCount(-1); animation.setRepeatMode(Animation.RESTART); scanLine.startAnimation(animation); EventBus.getDefault().register(this); InitData(); }
From source file:com.sociablue.nanodegree_p1.MovieListFragment.java
private void initializeFab(View rootView) { final RelativeLayout buttonContainer = (RelativeLayout) rootView.findViewById(R.id.menu_button_container); final FloatingActionButton Fab = (FloatingActionButton) rootView.findViewById(R.id.fab); final ImageView bottomBar = (ImageView) rootView.findViewById(R.id.menu_bottom_bar); final ImageView topBar = (ImageView) rootView.findViewById(R.id.menu_top_bar); Fab.setOnClickListener(new View.OnClickListener() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override//from ww w.j a v a 2 s . c om public void onClick(View v) { //Menu Button Icon Animation //Setting up necessary variables long animationDuration = 500; float containerHeight = buttonContainer.getHeight(); float containerCenterY = containerHeight / 2; float containerCenterX = buttonContainer.getWidth() / 2; float topBarCenter = topBar.getTop() + topBar.getHeight() / 2; float widthOfBar = topBar.getWidth(); float heightOfBar = topBar.getHeight(); final float distanceBetweenBars = (containerCenterY - topBarCenter); /** *TODO: Refactor block of code to use Value Property Animator. Should be more efficient to animate multiple properties *and objects at the same time. Also, will try to break intialization into smaller functions. */ //Setting up animations of hamburger bars and rotation /** * Animation For Top Menu Button Icon Bar. Sliding from the top to rest on top of the middle bar. * Y Translation is 1/2 the height of the hamburger bar minus the distance. * Subtracting the distance from the height because the distance between bars is * calculated of the exact center of the button. * With out the subtraction the bar would translate slightly below the middle bar. */ float yTranslation = heightOfBar / 2 - distanceBetweenBars; float xTranslation = widthOfBar / 2 + heightOfBar / 2; TranslateAnimation topBarTranslationAnim = new TranslateAnimation(Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, 0F, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, distanceBetweenBars); topBarTranslationAnim.setDuration((long) (animationDuration * 0.8)); topBarTranslationAnim.setFillAfter(true); //Animation for bottom hamburger bar. Translates and Rotates to create 'X' AnimationSet bottomBarAnimation = new AnimationSet(true); bottomBarAnimation.setFillAfter(true); //Rotate to create cross. (The cross becomes the X after the button rotation completes" RotateAnimation bottomBarRotationAnimation = new RotateAnimation(0f, 90f, Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 1f); bottomBarRotationAnimation.setDuration(animationDuration); bottomBarAnimation.addAnimation(bottomBarRotationAnimation); //Translate to correct X alignment TranslateAnimation bottomBarTranslationAnimation = new TranslateAnimation(Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, -xTranslation, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, -yTranslation); bottomBarTranslationAnimation.setDuration(animationDuration); bottomBarAnimation.addAnimation(bottomBarTranslationAnimation); //Button Specific Animations //Rotate Button Container RotateAnimation containerRotationAnimation = new RotateAnimation(0, 135f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); containerRotationAnimation.setDuration(animationDuration); containerRotationAnimation.setFillAfter(true); //Animate change of button color between Active and Disabled colors that have been //defined in color.xml int activeColor = getResources().getColor(R.color.active_button); int disabledColor = getResources().getColor(R.color.disabled_button); //Need to use ValueAnimator because property animator does not support BackgroundTint ValueAnimator buttonColorAnimation = ValueAnimator.ofArgb(activeColor, disabledColor); buttonColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Fab.setBackgroundTintList(ColorStateList.valueOf((int) animation.getAnimatedValue())); } }); buttonColorAnimation.setDuration(animationDuration); //Start all the animations topBar.startAnimation(topBarTranslationAnim); bottomBar.startAnimation(bottomBarAnimation); buttonContainer.startAnimation(containerRotationAnimation); buttonColorAnimation.start(); //Toogle mMenu open and closed if (mMenu.isOpen()) { //If mMenu is open, do the reverse of the animation containerRotationAnimation .setInterpolator(new ReverseInterpolator(new AccelerateInterpolator())); topBarTranslationAnim.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator())); bottomBarAnimation.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator())); buttonColorAnimation.setInterpolator(new ReverseInterpolator(new LinearInterpolator())); mMenu.close(); } else { bottomBarAnimation.setInterpolator(new AccelerateInterpolator()); mMenu.open(); } } }); }
From source file:org.noorganization.instalist.view.activity.MainShoppingListView.java
private void slideDrawer(float _MoveFactor) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mFrameLayout.setTranslationX(_MoveFactor); } else {// w w w . j a v a 2s . c o m TranslateAnimation anim = new TranslateAnimation(mLastDrawerTranslate, _MoveFactor, 0.0f, 0.0f); anim.setDuration(0); anim.setFillAfter(true); mFrameLayout.startAnimation(anim); mLastDrawerTranslate = _MoveFactor; } }
From source file:com.ibuildapp.romanblack.MultiContactsPlugin.MultiContactsPlugin.java
public void moveToLeft() { positionLayoutCenterX = moveLayout.getLeft(); TranslateAnimation animation = new TranslateAnimation(0, -positionLayoutCenterX, 0.0f, 0.0f); animation.setDuration(500); animation.setAnimationListener(new Animation.AnimationListener() { @Override/*from w w w . ja v a 2s. c o m*/ public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { moveLayout.layout(0, 0, moveLayout.getWidth(), moveLayout.getHeight()); } @Override public void onAnimationRepeat(Animation animation) { } }); moveLayout.startAnimation(animation); }
From source file:org.mariotaku.gallery3d.ImageViewerGLActivity.java
private void showBars() { if (mShowBars) return;/* ww w .ja va 2 s. c om*/ mShowBars = true; mActionBar.show(); mMenuBar.setVisibility(View.VISIBLE); final TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0); anim.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime)); mMenuBar.startAnimation(anim); }
From source file:com.turingtechnologies.materialscrollbar.MaterialScrollBar.java
/** * Animates the bar into view/*from ww w .j a va 2s. com*/ */ private void fadeIn() { if (hidden && hide && !totallyHidden) { hidden = false; TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); anim.setDuration(500); anim.setFillAfter(true); startAnimation(anim); } }