List of usage examples for android.view.animation AnimationUtils loadInterpolator
public static Interpolator loadInterpolator(Context context, @AnimRes @InterpolatorRes int id) throws NotFoundException
From source file:io.plaidapp.ui.DesignerNewsStory.java
private void doFabExpand() { // translate the chrome placeholder ui so that it is centered on the FAB int fabCenterX = (fab.getLeft() + fab.getRight()) / 2; int fabCenterY = ((fab.getTop() + fab.getBottom()) / 2) - fabExpand.getTop(); int translateX = fabCenterX - (fabExpand.getWidth() / 2); int translateY = fabCenterY - (fabExpand.getHeight() / 2); fabExpand.setTranslationX(translateX); fabExpand.setTranslationY(translateY); // then reveal the placeholder ui, starting from the center & same dimens as fab fabExpand.setVisibility(View.VISIBLE); Animator reveal = ViewAnimationUtils .createCircularReveal(fabExpand, fabExpand.getWidth() / 2, fabExpand.getHeight() / 2, fab.getWidth() / 2, (int) Math.hypot(fabExpand.getWidth() / 2, fabExpand.getHeight() / 2)) .setDuration(fabExpandDuration); // translate the placeholder ui back into position along an arc ArcMotion arcMotion = new ArcMotion(); arcMotion.setMinimumVerticalAngle(70f); Path motionPath = arcMotion.getPath(translateX, translateY, 0, 0); Animator position = ObjectAnimator.ofFloat(fabExpand, View.TRANSLATION_X, View.TRANSLATION_Y, motionPath) .setDuration(fabExpandDuration); // animate from the FAB colour to the placeholder background color Animator background = ObjectAnimator .ofArgb(fabExpand, ViewUtils.BACKGROUND_COLOR, ContextCompat.getColor(this, R.color.designer_news), ContextCompat.getColor(this, R.color.background_light)) .setDuration(fabExpandDuration); // fade out the fab (rapidly) Animator fadeOutFab = ObjectAnimator.ofFloat(fab, View.ALPHA, 0f).setDuration(60); // play 'em all together with the material interpolator AnimatorSet show = new AnimatorSet(); show.setInterpolator(/* w ww .j av a 2 s. c om*/ AnimationUtils.loadInterpolator(DesignerNewsStory.this, android.R.interpolator.fast_out_slow_in)); show.playTogether(reveal, background, position, fadeOutFab); show.start(); }
From source file:io.authme.sdk.widget.LockPatternView.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public LockPatternView(Context context, AttributeSet attrs) { super(context, attrs); senSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); senAccelerometer = senSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY); if (senAccelerometer == null) { senAccelerometer = senSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); }/*from w ww .j a v a 2 s . c o m*/ senSensorManager.registerListener(this, senAccelerometer, SensorManager.SENSOR_DELAY_GAME); sensGyro = senSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE); if (sensGyro != null) { senSensorManager.registerListener(this, sensGyro, SensorManager.SENSOR_DELAY_GAME); } senMagnetometer = senSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); if (senMagnetometer != null) { senSensorManager.registerListener(this, senMagnetometer, SensorManager.SENSOR_DELAY_GAME); } accelList = new ArrayList<>(); magnetics = new ArrayList<>(); gyrolist = new ArrayList<>(); rawXYList = new ArrayList<>(); velocityList = new ArrayList<>(); orientationArrayList = new ArrayList<>(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Alp_42447968_LockPatternView); final String aspect = a.getString(R.styleable.Alp_42447968_LockPatternView_alp_42447968_aspect); if ("square".equals(aspect)) { mAspect = ASPECT_SQUARE; } else if ("lock_width".equals(aspect)) { mAspect = ASPECT_LOCK_WIDTH; } else if ("lock_height".equals(aspect)) { mAspect = ASPECT_LOCK_HEIGHT; } else { mAspect = ASPECT_SQUARE; } setClickable(true); mPathPaint.setAntiAlias(true); mPathPaint.setDither(true); mRegularColor = getResources().getColor( ResourceUtils.resolveAttribute(getContext(), R.attr.alp_42447968_color_lock_pattern_view_regular)); mErrorColor = getResources().getColor( ResourceUtils.resolveAttribute(getContext(), R.attr.alp_42447968_color_lock_pattern_view_error)); mSuccessColor = getResources().getColor( ResourceUtils.resolveAttribute(getContext(), R.attr.alp_42447968_color_lock_pattern_view_success)); mRegularColor = a.getColor(R.styleable.Alp_42447968_LockPatternView_alp_42447968_regularColor, mRegularColor); mErrorColor = a.getColor(R.styleable.Alp_42447968_LockPatternView_alp_42447968_errorColor, mErrorColor); mSuccessColor = a.getColor(R.styleable.Alp_42447968_LockPatternView_alp_42447968_successColor, mSuccessColor); int pathColor = a.getColor(R.styleable.Alp_42447968_LockPatternView_alp_42447968_pathColor, mRegularColor); mPathPaint.setColor(pathColor); mPathPaint.setStyle(Paint.Style.STROKE); mPathPaint.setStrokeJoin(Paint.Join.ROUND); mPathPaint.setStrokeCap(Paint.Cap.ROUND); mPathWidth = getResources().getDimensionPixelSize(R.dimen.alp_42447968_lock_pattern_dot_line_width); mPathPaint.setStrokeWidth(mPathWidth); mDotSize = getResources().getDimensionPixelSize(R.dimen.alp_42447968_lock_pattern_dot_size); mDotSizeActivated = getResources() .getDimensionPixelSize(R.dimen.alp_42447968_lock_pattern_dot_size_activated); mPaint.setAntiAlias(true); mPaint.setDither(true); mCellStates = new CellState[MATRIX_WIDTH][MATRIX_WIDTH]; for (int i = 0; i < MATRIX_WIDTH; i++) { for (int j = 0; j < MATRIX_WIDTH; j++) { mCellStates[i][j] = new CellState(); mCellStates[i][j].size = mDotSize; } } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !isInEditMode()) { mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, android.R.interpolator.fast_out_slow_in); mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, android.R.interpolator.linear_out_slow_in); } // if }
From source file:us.phyxsi.gameshelf.ui.BoardgameDetails.java
/** * Animate in the title, description and author can't do this in a content transition as they * are within the ListView so do it manually. Also handle the FAB tanslation here so that it * plays nicely with #calculateFabPosition *///w w w .j ava2 s . c o m private void enterAnimation(boolean isOrientationChange) { Interpolator interp = AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in); int offset = title.getHeight(); viewEnterAnimation(title, offset, interp); viewEnterAnimation(byline, offset, interp); if (description.getVisibility() == View.VISIBLE) { offset *= 1.5f; viewEnterAnimation(description, offset, interp); } offset *= 1.5f; viewEnterAnimation(boardgameSummary, offset, interp); offset *= 1.5f; viewEnterAnimation(boardgameSummaryLine1, offset, interp); offset *= 1.5f; viewEnterAnimation(boardgameSummaryLine2, offset, interp); back.animate().alpha(1f).setDuration(600).setInterpolator(interp).start(); }
From source file:de.dmxcontrol.activity.ControlActivity.java
private Dialog createSplashDialog() { Dialog dialog = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar); dialog.setContentView(R.layout.dialog_splash); ImageView image = (ImageView) dialog.findViewById(R.id.image_splash); image.setImageResource(R.drawable.image_splash); AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(500);/* w w w . j av a 2s.co m*/ animation.setInterpolator( AnimationUtils.loadInterpolator(this, android.R.anim.accelerate_decelerate_interpolator)); set.addAnimation(animation); animation = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setDuration(1000); animation.setInterpolator( AnimationUtils.loadInterpolator(this, android.R.anim.accelerate_decelerate_interpolator)); set.addAnimation(animation); image.setAnimation(set); dismissSplashDelayed(); return dialog; }
From source file:babbq.com.searchplace.SearchActivity.java
@OnClick(R.id.results_scrim) protected void hideSaveConfimation() { if (confirmSaveContainer.getVisibility() == View.VISIBLE) { // contract the bubble & hide the scrim AnimatorSet hideConfirmation = new AnimatorSet(); hideConfirmation.playTogether(//from w ww . j av a 2 s . c o m ViewAnimationUtils.createCircularReveal(confirmSaveContainer, confirmSaveContainer.getWidth() / 2, confirmSaveContainer.getHeight() / 2, confirmSaveContainer.getWidth() / 2, fab.getWidth() / 2), ObjectAnimator.ofArgb(resultsScrim, ViewUtils.BACKGROUND_COLOR, Color.TRANSPARENT)); hideConfirmation.setDuration(150L); hideConfirmation.setInterpolator( AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in)); hideConfirmation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { confirmSaveContainer.setVisibility(View.GONE); resultsScrim.setVisibility(View.GONE); // fab.setVisibility(results.getVisibility()); } }); hideConfirmation.start(); } }
From source file:com.andrew.apollo.ui.activities.AudioPlayerActivity.java
/** * @param v The view to animate//from w w w.j a v a2 s .com * @param alpha The alpha to apply */ private void fade(final View v, final float alpha) { final ObjectAnimator fade = ObjectAnimator.ofFloat(v, "alpha", alpha); fade.setInterpolator( AnimationUtils.loadInterpolator(this, android.R.anim.accelerate_decelerate_interpolator)); fade.setDuration(400); fade.start(); }
From source file:android.support.v17.leanback.app.BackgroundManager.java
private BackgroundManager(Activity activity, boolean isSupportFragmentActivity) { mContext = activity;/*from w w w . j ava 2 s. c o m*/ mService = BackgroundContinuityService.getInstance(); mHeightPx = mContext.getResources().getDisplayMetrics().heightPixels; mWidthPx = mContext.getResources().getDisplayMetrics().widthPixels; mHandler = new Handler(); Interpolator defaultInterpolator = new FastOutLinearInInterpolator(); mAccelerateInterpolator = AnimationUtils.loadInterpolator(mContext, android.R.anim.accelerate_interpolator); mDecelerateInterpolator = AnimationUtils.loadInterpolator(mContext, android.R.anim.decelerate_interpolator); mAnimator = ValueAnimator.ofInt(0, FULL_ALPHA); mAnimator.addListener(mAnimationListener); mAnimator.addUpdateListener(mAnimationUpdateListener); mAnimator.setInterpolator(defaultInterpolator); mDimAnimator = new ValueAnimator(); mDimAnimator.addUpdateListener(mDimUpdateListener); TypedArray ta = activity.getTheme().obtainStyledAttributes(new int[] { android.R.attr.windowBackground }); mThemeDrawableResourceId = ta.getResourceId(0, -1); if (mThemeDrawableResourceId < 0) { if (DEBUG) Log.v(TAG, "BackgroundManager no window background resource!"); } ta.recycle(); if (isSupportFragmentActivity) { createSupportFragment((FragmentActivity) activity); } else { createFragment(activity); } }
From source file:com.ludoscity.findmybikes.activities.NearbyActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { //So that Utils::getBitmapDescriptor works on API < 21 //when doing Drawable vectorDrawable = ResourcesCompat.getDrawable(ctx.getResources(), id, null); //see https://medium.com/@chrisbanes/appcompat-v23-2-age-of-the-vectors-91cbafa87c88#.i8luinewc AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); setTheme(R.style.FindMyBikesTheme); //https://developer.android.com/topic/performance/launch-time.html super.onCreate(savedInstanceState); int mapInit = MapsInitializer.initialize(getApplicationContext()); if (mapInit != 0) { Log.e("NearbyActivity", "GooglePlayServicesNotAvailableException raised with error code :" + mapInit); }/*from w w w.j a va 2s . c o m*/ boolean autoCompleteLoadingProgressBarVisible = false; String showcaseTripTotalPlaceName = null; if (savedInstanceState != null) { mSavedInstanceCameraPosition = savedInstanceState.getParcelable("saved_camera_pos"); mRequestingLocationUpdates = savedInstanceState.getBoolean("requesting_location_updates"); mCurrentUserLatLng = savedInstanceState.getParcelable("user_location_latlng"); mClosestBikeAutoSelected = savedInstanceState.getBoolean("closest_bike_auto_selected"); mFavoriteSheetVisible = savedInstanceState.getBoolean("favorite_sheet_visible"); autoCompleteLoadingProgressBarVisible = savedInstanceState.getBoolean("place_autocomplete_loading"); mRefreshTabs = savedInstanceState.getBoolean("refresh_tabs"); mFavoritePicked = savedInstanceState.getBoolean("favorite_picked"); mDataOutdated = savedInstanceState.getBoolean("data_outdated"); showcaseTripTotalPlaceName = savedInstanceState.getString("onboarding_showcase_trip_total_place_name", null); } setContentView(R.layout.activity_nearby); setSupportActionBar((Toolbar) findViewById(R.id.toolbar_main)); setupActionBarStrings(); // Update Bar mStatusTextView = (TextView) findViewById(R.id.status_textView); mStatusBar = findViewById(R.id.app_status_bar); if (mDataOutdated) mStatusBar.setBackgroundColor(ContextCompat.getColor(NearbyActivity.this, R.color.theme_accent)); mStationListViewPager = (ViewPager) findViewById(R.id.station_list_viewpager); mStationListViewPager.setAdapter(new StationListPagerAdapter(getSupportFragmentManager())); mStationListViewPager.addOnPageChangeListener(this); // Give the TabLayout the ViewPager mTabLayout = (TabLayout) findViewById(R.id.sliding_tabs); mTabLayout.setupWithViewPager(mStationListViewPager); //Taking care of tabs icons here as pageradapter handles only title CharSequence for now for (int i = 0; i < mTabLayout.getTabCount() && i < TABS_ICON_RES_ID.length; ++i) { //noinspection ConstantConditions mTabLayout.getTabAt(i).setCustomView(R.layout.tab_custom_view); //noinspection ConstantConditions mTabLayout.getTabAt(i).setIcon(ContextCompat.getDrawable(this, TABS_ICON_RES_ID[i])); } mAppBarLayout = (AppBarLayout) findViewById(R.id.action_toolbar_layout); mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.snackbar_coordinator); mSplashScreen = findViewById(R.id.splashscreen); mSplashScreenTextTop = (TextView) findViewById(R.id.splashscreen_text_top); mSplashScreenTextBottom = (TextView) findViewById(R.id.splashscreen_text_bottom); mTripDetailsWidget = findViewById(R.id.trip_details); mTripDetailsProximityA = (TextView) findViewById(R.id.trip_details_proximity_a); mTripDetailsProximityB = (TextView) findViewById(R.id.trip_details_proximity_b); mTripDetailsProximitySearch = (TextView) findViewById(R.id.trip_details_proximity_search); mTripDetailsProximityTotal = (TextView) findViewById(R.id.trip_details_proximity_total); mTripDetailsSumSeparator = (FrameLayout) findViewById(R.id.trip_details_sum_separator); mTripDetailsBToDestinationRow = findViewById(R.id.trip_details_b_to_search); mTripDetailsPinSearch = findViewById(R.id.trip_details_to_search); mTripDetailsPinFavorite = findViewById(R.id.trip_details_to_favorite); mSearchFAB = (FloatingActionButton) findViewById(R.id.search_fab); mAddFavoriteFAB = (FloatingActionButton) findViewById(R.id.favorite_add_remove_fab); mDirectionsLocToAFab = (FloatingActionButton) findViewById(R.id.directions_loc_to_a_fab); mPlaceAutocompleteLoadingProgressBar = (ProgressBar) findViewById(R.id.place_autocomplete_loading); if (autoCompleteLoadingProgressBarVisible) mPlaceAutocompleteLoadingProgressBar.setVisibility(View.VISIBLE); if (showcaseTripTotalPlaceName != null) { setupShowcaseTripTotal(); mOnboardingShowcaseView .setContentText(String.format(getString(R.string.onboarding_showcase_total_time_text), DBHelper.getBikeNetworkName(this), showcaseTripTotalPlaceName)); mOnboardingShowcaseView.setTag(showcaseTripTotalPlaceName); } if (savedInstanceState == null) mSplashScreen.setVisibility(View.VISIBLE); setupDirectionsLocToAFab(); setupSearchFab(); setupFavoritePickerFab(); if (savedInstanceState != null && savedInstanceState.getParcelable("add_favorite_fab_data") != null) { setupAddFavoriteFab((FavoriteItemPlace) savedInstanceState.getParcelable("add_favorite_fab_data")); mAddFavoriteFAB.show(); } setupClearFab(); setupAutoselectBikeFab(); setStatusBarClickListener(); getListPagerAdapter().setCurrentUserLatLng(mCurrentUserLatLng); setupFavoriteSheet(); //noinspection ConstantConditions findViewById(R.id.trip_details_directions_loc_to_a).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mOnboardingShowcaseView != null) { mOnboardingShowcaseView.hide(); mOnboardingShowcaseView = null; } launchGoogleMapsForDirections(mCurrentUserLatLng, mStationMapFragment.getMarkerALatLng(), true); } }); //noinspection ConstantConditions findViewById(R.id.trip_details_directions_a_to_b).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mOnboardingShowcaseView != null) { mOnboardingShowcaseView.hide(); mOnboardingShowcaseView = null; } launchGoogleMapsForDirections(mStationMapFragment.getMarkerALatLng(), mStationMapFragment.getMarkerBVisibleLatLng(), false); } }); //noinspection ConstantConditions findViewById(R.id.trip_details_directions_b_to_destination).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mOnboardingShowcaseView != null) { mOnboardingShowcaseView.hide(); mOnboardingShowcaseView = null; } if (mStationMapFragment.isPickedPlaceMarkerVisible()) launchGoogleMapsForDirections(mStationMapFragment.getMarkerBVisibleLatLng(), mStationMapFragment.getMarkerPickedPlaceVisibleLatLng(), true); else //Either Place marker or Favorite marker is visible, but not both at once launchGoogleMapsForDirections(mStationMapFragment.getMarkerBVisibleLatLng(), mStationMapFragment.getMarkerPickedFavoriteVisibleLatLng(), true); } }); findViewById(R.id.trip_details_share).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //Je serai la station Bixi Hutchison/beaubien dans ~15min ! Partag via #findmybikes //I will be at the Bixi station Hutchison/beaubien in ~15min ! Shared via #findmybikes String message = String.format( getResources().getString(R.string.trip_details_share_message_content), DBHelper.getBikeNetworkName(getApplicationContext()), getListPagerAdapter() .getHighlightedStationForPage(StationListPagerAdapter.DOCK_STATIONS).getName(), mTripDetailsProximityTotal.getText().toString()); Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, message); sendIntent.setType("text/plain"); startActivity(Intent.createChooser(sendIntent, getString(R.string.trip_details_share_title))); } }); // Create an instance of GoogleAPIClient. if (mGoogleApiClient == null) { mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).addApi(LocationServices.API).build(); } setupLocationRequest(); mCircularRevealInterpolator = AnimationUtils.loadInterpolator(this, R.interpolator.msf_interpolator); //Not empty if RootApplication::onCreate got database data if (RootApplication.getBikeNetworkStationList().isEmpty()) { tryInitialSetup(); } }
From source file:com.hannesdorfmann.search.SearchActivity.java
@Override public void showContent() { castedViewState().setShowContent(adapter.getItems()); if (adapter.getItemCount() > 0) { if (results.getVisibility() != View.VISIBLE) { if (!isRestoringViewState()) { TransitionManager.beginDelayedTransition(container, auto); }/* w w w . j a v a 2s. c om*/ errorView.setVisibility(View.GONE); progress.setVisibility(View.GONE); results.setVisibility(View.VISIBLE); fab.setVisibility(View.VISIBLE); fab.setAlpha(0.6f); fab.setScaleX(0f); fab.setScaleY(0f); fab.animate().alpha(1f).scaleX(1f).scaleY(1f).setStartDelay(800L).setDuration(300L) .setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); } } else { if (!isRestoringViewState()) { TransitionManager.beginDelayedTransition(container, auto); } progress.setVisibility(View.GONE); errorView.setVisibility(View.GONE); setNoResultsVisibility(View.VISIBLE); } }
From source file:io.plaidapp.ui.DribbbleShot.java
private void expandImageAndFinish() { if (imageView.getOffset() != 0f) { Animator expandImage = ObjectAnimator.ofFloat(imageView, ParallaxScrimageView.OFFSET, 0f); expandImage.setDuration(80);//from w w w.j av a 2 s. c o m expandImage.setInterpolator( AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in)); expandImage.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { finishAfterTransition(); } }); expandImage.start(); } else { finishAfterTransition(); } }