List of usage examples for android.view View animate
public ViewPropertyAnimator animate()
From source file:ca.zadrox.dota2esportticker.ui.BaseActivity.java
protected void onActionBarAutoShowOrHide(boolean shown) { if (mStatusBarColorAnimator != null) { mStatusBarColorAnimator.cancel(); }/*from ww w.j av a 2 s .co m*/ mStatusBarColorAnimator = ObjectAnimator .ofInt((mDrawerLayout != null) ? mDrawerLayout : mLUtils, (mDrawerLayout != null) ? "statusBarBackgroundColor" : "statusBarColor", shown ? Color.BLACK : mNormalStatusBarColor, shown ? mNormalStatusBarColor : Color.BLACK) .setDuration(250); if (mDrawerLayout != null) { mStatusBarColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { ViewCompat.postInvalidateOnAnimation(mDrawerLayout); } }); } mStatusBarColorAnimator.setEvaluator(ARGB_EVALUATOR); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.L) { mStatusBarColorAnimator.start(); } updateSwipeRefreshProgressBarTop(); for (View view : mHideableHeaderViews) { if (shown) { view.animate().translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION) .setInterpolator(new DecelerateInterpolator()); } else { view.animate().translationY(-UIUtils.calculateActionBarSize(this)).alpha(1) .setDuration(HEADER_HIDE_ANIM_DURATION).setInterpolator(new DecelerateInterpolator()); } } }
From source file:org.secuso.privacyfriendlynetmonitor.Activities.MainActivity.java
private void activateReportView() { setContentView(R.layout.activity_report); super.setToolbar(); getNavigationDrawerID();/*from ww w .j a v a2 s . c om*/ //Initiate ListView functionality swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout); reportMap = Collector.provideSimpleReports(); expListView = (ExpandableListView) findViewById(R.id.list); final ExpandableReportAdapter reportAdapter = new ExpandableReportAdapter(this, new ArrayList<>(reportMap.keySet()), reportMap); expListView.setAdapter(reportAdapter); swipeRefreshLayout.setOnRefreshListener(this); //Showing Swipe Refresh animation on activity create swipeRefreshLayout.post(new Runnable() { @Override public void run() { swipeRefreshLayout.setRefreshing(true); refreshAdapter(); } }); expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView expandableListView, View view, final int i, final int i1, final long l) { expListView = (ExpandableListView) findViewById(R.id.list); ExpandableReportAdapter adapter = (ExpandableReportAdapter) expListView.getExpandableListAdapter(); final Report r = (Report) adapter.getChild(i, i1); if (mSharedPreferences.getBoolean(Const.IS_DETAIL_MODE, false)) { view.animate().setDuration(500).alpha((float) 0.5).withEndAction(new Runnable() { @Override public void run() { Collector.provideDetail(r.uid, r.remoteAddHex); Intent intent = new Intent(getApplicationContext(), ReportDetailActivity.class); startActivity(intent); } }); return true; // if no detail mode and server analysis is complete, goto SSL Labs } else if (mSharedPreferences.getBoolean(Const.IS_CERTVAL, false) && Collector.hasHostName(r.remoteAdd.getHostAddress()) && Collector.hasGrade(Collector.getDnsHostName(r.remoteAdd.getHostAddress()))) { String url = Const.SSLLABS_URL + Collector.getCertHost(Collector.getDnsHostName(r.remoteAdd.getHostAddress())); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(browserIntent); return false; } else { return false; } } }); }
From source file:de.tap.easy_xkcd.fragments.comics.ComicFragment.java
protected void animateToolbar() { Toolbar toolbar = ((MainActivity) getActivity()).getToolbar(); if (toolbar.getAlpha() == 0) { toolbar.setTranslationY(-300);//from w ww.j ava 2s. com toolbar.animate().setDuration(300).translationY(0).alpha(1); View view; for (int i = 0; i < toolbar.getChildCount(); i++) { view = toolbar.getChildAt(i); view.setTranslationY(-300); view.animate().setStartDelay(50 * (i + 1)).setDuration(70 * (i + 1)).translationY(0); } } }
From source file:edu.uark.spARK.SwipeDismissListViewTouchListener.java
private void dismiss(final View view, final int position, boolean dismissRight) { ++mDismissAnimationRefCount;//from w w w.j av a 2 s .c om if (view == null) { // No view, shortcut to calling onDismiss to let it deal with adapter // updates and all that. mCallbacks.onDismiss(mListView, new int[] { position }); return; } view.animate().translationX(dismissRight ? mViewWidth : -mViewWidth).alpha(0).setDuration(mAnimationTime) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { performDismiss(view, position); } }); }
From source file:org.starfishrespect.myconsumption.android.ui.BaseActivity.java
protected void onActionBarAutoShowOrHide(boolean shown) { if (mStatusBarColorAnimator != null) { mStatusBarColorAnimator.cancel(); }/*from w w w . j a v a 2s. c om*/ mStatusBarColorAnimator = ObjectAnimator .ofInt(mDrawerLayout, (mDrawerLayout != null) ? "statusBarBackgroundColor" : "statusBarColor", shown ? Color.BLACK : mNormalStatusBarColor, shown ? mNormalStatusBarColor : Color.BLACK) .setDuration(250); if (mDrawerLayout != null) { mStatusBarColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { ViewCompat.postInvalidateOnAnimation(mDrawerLayout); } }); } mStatusBarColorAnimator.setEvaluator(ARGB_EVALUATOR); mStatusBarColorAnimator.start(); for (View view : mHideableHeaderViews) { if (shown) { view.animate().translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION) .setInterpolator(new DecelerateInterpolator()); } else { view.animate().translationY(-view.getBottom()).alpha(0).setDuration(HEADER_HIDE_ANIM_DURATION) .setInterpolator(new DecelerateInterpolator()); } } }
From source file:com.tsoliveira.android.listeners.DragDropTouchListener.java
private void doSwitch(final View switchView, final int originalViewPos, final int switchViewPos) { View originalView = getViewByPosition(originalViewPos); int switchViewTop = switchView.getTop(); int originalViewTop = originalView.getTop(); int delta = originalViewTop - switchViewTop; onItemSwitch(recyclerView, originalViewPos, switchViewPos); switchView.setVisibility(View.INVISIBLE); originalView.setVisibility(View.VISIBLE); originalView.setTranslationY(-delta); originalView.animate().translationYBy(delta).setDuration(MOVE_DURATION); mobileViewCurrentPos = switchViewPos; }
From source file:com.gabm.fancyplaces.ui.MainWindow.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.clear();//from w ww. j a v a2 s . c o m getMenuInflater().inflate(curState.curMenu, menu); Toolbar toolbar = (Toolbar) findViewById(R.id.main_window_toolbar); if (curState.curMenu == R.menu.menu_main_window_multi_select) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); toolbar.setTitle(getString(R.string.main_multi_selection_title)); toolbar.setBackgroundColor(getResources().getColor(R.color.ColorPrimaryDark)); int noOfChild = toolbar.getChildCount(); View view; // animate toolbar elements for (int i = 1; i < noOfChild; i++) { view = toolbar.getChildAt(i); view.setAlpha(0); view.setScaleY(0); view.setPivotY((float) 0.5 * view.getHeight()); view.animate().setDuration(200).scaleY(1).alpha(1); } } else if (curState.curMenu == R.menu.menu_main_window) { getSupportActionBar().setDisplayHomeAsUpEnabled(false); setDefaultTitle(); toolbar.setBackgroundColor(getResources().getColor(R.color.ColorPrimary)); } return super.onPrepareOptionsMenu(menu); }
From source file:org.glucosio.android.activity.MainActivity.java
private void hideFabAnimation() { final View fab = findViewById(R.id.activity_main_fab_add_reading); fab.animate().translationY(-5).alpha(0.0f).setListener(new AnimatorListenerAdapter() { @Override//from w w w . j a v a 2 s .c om public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); fab.setVisibility(View.INVISIBLE); } }); }
From source file:acr.browser.lightning.browser.fragment.anim.HorizontalItemAnimator.java
private void clearInterpolator(View view) { if (mDefaultInterpolator == null) { mDefaultInterpolator = new ValueAnimator().getInterpolator(); }//from w w w .ja v a 2 s. c om view.animate().setInterpolator(mDefaultInterpolator); }
From source file:cf.obsessiveorange.rhcareerfairlayout.ui.fragments.VPParentFragment.java
/** * Private helper method to animate toolbar and related views to a position. * @param toY New Y position./* ww w . j ava2 s . com*/ * @param completionHandlers any handlers to be fired after completion of the animation */ private void animateToolbar(final float toY, final Runnable... completionHandlers) { float layoutTranslationY = mInterceptionLayout.getTranslationY(); if (layoutTranslationY != toY) { // get translation final float translationY = -layoutTranslationY + toY; final View toolbarView = getActivity().findViewById(R.id.toolbar); final SearchBox searchView = ((MainActivity) getActivity()).getSearch(); // Need to offset for the -6dp margin on search bar Resources r = getResources(); float offset = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6, r.getDisplayMetrics()); // Start animating all the items mInterceptionLayout.animate().y(toY).setDuration(200); toolbarView.animate().y(toY).setDuration(200); searchView.animate().y(toY - offset).setDuration(200); // Relayout child view at animation completion final FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mInterceptionLayout.getLayoutParams(); new Handler().postDelayed(new Runnable() { public void run() { lp.height = (int) (Math.max(0, -translationY) + getScreenHeight()); mInterceptionLayout.requestLayout(); } }, translationY < 0 ? 0 : 200); // Start calling all handlers, giving time for re-layout to occur. new Handler().postDelayed(new Runnable() { public void run() { for (Runnable completionHandler : completionHandlers) { completionHandler.run(); } } }, 250); } }