List of usage examples for android.view.animation TranslateAnimation TranslateAnimation
public TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue, int fromYType, float fromYValue, int toYType, float toYValue)
From source file:com.melvin.share.zxing.activity.CaptureActivity.java
@Override protected void initView() { Window window = getWindow();//from ww w . ja va 2 s . c o m window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_capture); initWindow(); toolbar = (Toolbar) findViewById(R.id.toolbar); initToolbar(toolbar); 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); 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); }
From source file:com.dtr.zxing.activity.CaptureActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Window window = getWindow();//from w w w.ja v a 2s . co m window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_qr_scan); 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); mFlash = (ImageView) findViewById(R.id.capture_flash); mFlash.setOnClickListener(this); 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); }
From source file:com.xys.libzxing.zxing.activity.CaptureActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) //?? != PackageManager.PERMISSION_GRANTED) { //??/*w ww.j a v a2 s . c o m*/ ActivityCompat.requestPermissions(CaptureActivity.this, new String[] { Manifest.permission.CAMERA }, 1); } Window window = getWindow(); requestWindowFeature(Window.FEATURE_NO_TITLE); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_capture); m_oCaptureActivity = this; 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); trunoff_on = (ImageView) findViewById(R.id.trunoff_on); trunoff_on.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (isOpen) { // ? cameraManager.offLight(); isOpen = false; } else { //? cameraManager.openLight(); isOpen = true; } } }); 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); }
From source file:com.kuaichumen.whistle.admin.CaptureActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Window window = getWindow();//from w ww . jav a 2s .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:eu.thedarken.rootvalidator.ValidatorFragment.java
private void animateFAB(boolean out) { Animation animation;//w ww . ja v a 2s . c o m if (out) { animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1.0f); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mFab.setVisibility(View.INVISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); } else { animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { mFab.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); } animation.setDuration(600); animation.setInterpolator(new AnticipateOvershootInterpolator(1.2f)); mFab.startAnimation(animation); }
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);/* w ww . j a v a 2 s. c o m*/ 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.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/*w w w .java 2s .co m*/ 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:ezy.ui.view.NoticeView.java
private Animation anim(float from, float to) { final TranslateAnimation anim = new TranslateAnimation(0, 0f, 0, 0f, Animation.RELATIVE_TO_PARENT, from, Animation.RELATIVE_TO_PARENT, to); anim.setDuration(mDuration);/* www . j a va2 s .c o m*/ anim.setFillAfter(false); anim.setInterpolator(new LinearInterpolator()); return anim; }
From source file:com.aosijia.dragonbutler.ui.widget.ActionSheet.java
private Animation createTranslationInAnimation() { int type = TranslateAnimation.RELATIVE_TO_SELF; TranslateAnimation an = new TranslateAnimation(type, 0, type, 0, type, 1, type, 0); an.setDuration(TRANSLATE_DURATION);/*from w ww.ja v a 2 s . co m*/ return an; }
From source file:com.justwayward.reader.ui.activity.SubjectBookListActivity.java
private void showTagGroup() { if (mTagList.isEmpty()) { ToastUtils.showToast(getString(R.string.network_error_tips)); return;// w w w . j a v a 2s .co m } Animation mShowAction = 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); mShowAction.setDuration(400); rsvTags.startAnimation(mShowAction); rsvTags.setVisibility(View.VISIBLE); }