List of usage examples for android.view View startAnimation
public void startAnimation(Animation animation)
From source file:com.wms.opensource.shopfast.fragment.ProductsInCollectionFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (layout != null) { ViewGroup parent = (ViewGroup) layout.getParent(); parent.removeView(layout);/*from w w w. j a v a2 s . c o m*/ return layout; } if (listView == null) { layout = new RelativeLayout(getActivity()); listView = new ListView(getActivity()); layout.addView(listView); imageViewPreview = new ImageView(getActivity()); RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); imageViewParams.addRule(RelativeLayout.CENTER_IN_PARENT); imageViewPreview.setLayoutParams(imageViewParams); imageViewPreview.setVisibility(View.INVISIBLE); imageViewPreview.setOnClickListener(new ImageView.OnClickListener() { @Override public void onClick(View v) { // Dismiss the image view v.setVisibility(View.INVISIBLE); Animation myAnim = AnimationUtils.loadAnimation(ProductsInCollectionFragment.this.getActivity(), R.anim.fadeout); v.startAnimation(myAnim); } }); layout.addView(imageViewPreview); progressBar = new ProgressBar(getActivity(), null, android.R.attr.progressBarStyleLarge); RelativeLayout.LayoutParams progressBarBarams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); progressBarBarams.addRule(RelativeLayout.CENTER_IN_PARENT); progressBar.setLayoutParams(progressBarBarams); progressBar.setVisibility(View.INVISIBLE); layout.addView(progressBar); // Before reloading products, display products if they have been saved before. String productsFilePath = StorageUtil.getTempDirectoryPath(getActivity()) + "/" + PersistFileNameProvider.getProductsFileName(collectionID, page); boolean productsFileExists = FileUtil.fileExist(productsFilePath); if (productsFileExists) { loadProductsFromLocalTask = new LoadCachedProductsInCollectionTask(getActivity(), loadProductsHandler, progressBar, page); loadProductsFromLocalTask.execute(collectionID); } else { NetworkStatus networkStatus = NetworkUtil.getNetworkConnection(getActivity()); if (networkStatus.equals(NetworkStatus.WIFI_CONNECTED) || networkStatus.equals(NetworkStatus.MOBILE_CONNECTED)) { loadShopifyProductsTask = new LoadProductsInCollectionTask(getActivity(), loadProductsHandler, progressBar, page); loadShopifyProductsTask.execute(collectionID); } else { Toast.makeText(getActivity(), getString(R.string.noNetworkAvailable), Toast.LENGTH_LONG).show(); } } } return layout; }
From source file:com.freshdigitable.udonroad.UserInfoActivity.java
private void setUpAppbar() { binding.userInfoToolbar.setTitle(""); final TextView toolbarTitle = binding.userInfoToolbarTitle; binding.userInfoAppbarLayout.addOnOffsetChangedListener(new OnOffsetChangedListener() { private boolean isTitleVisible = toolbarTitle.getVisibility() == View.VISIBLE; @Override// w ww.j a va 2 s . co m public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { final int totalScrollRange = appBarLayout.getTotalScrollRange(); final float percent = (float) Math.abs(verticalOffset) / (float) totalScrollRange; if (percent > 0.9) { if (!isTitleVisible) { startAnimation(toolbarTitle, View.VISIBLE); isTitleVisible = true; } } else { if (isTitleVisible) { startAnimation(toolbarTitle, View.INVISIBLE); isTitleVisible = false; } } } private void startAnimation(View v, int visibility) { AlphaAnimation animation = (visibility == View.VISIBLE) ? new AlphaAnimation(0f, 1f) : new AlphaAnimation(1f, 0f); animation.setDuration(200); animation.setFillAfter(true); v.startAnimation(animation); } }); }
From source file:com.nikola.despotoski.drawerlayouttoggles.FadingDrawerToggle.java
@SuppressLint("NewApi") @Override//from w w w . ja v a2 s . c o m public void onDrawerSlide(View drawerView, float slideOffset) { if (!mEnabled) return; float currentViewAlpha = slideOffset * MAX_VIEW_ALPHA; float currentDrawableAlpha = slideOffset * MAX_DRAWABLE_ALPHA; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { drawerView.setAlpha(currentViewAlpha); } else { AlphaAnimation alphaAnimation = new AlphaAnimation(mPreviousViewAlpha, currentViewAlpha); alphaAnimation.setFillAfter(true); alphaAnimation.setDuration(0); drawerView.startAnimation(alphaAnimation); mPreviousViewAlpha = currentViewAlpha; } drawerView.getBackground().setAlpha((int) currentDrawableAlpha); }
From source file:com.develop.autorus.MainActivity.java
public static void expand(final View v) { v.measure(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); final int targetHeight = v.getMeasuredHeight(); // Older versions of android (pre API 21) cancel animations for views with a height of 0. v.getLayoutParams().height = 1;//from w ww . j a va2 s .c o m v.setVisibility(View.VISIBLE); Animation a = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { v.getLayoutParams().height = interpolatedTime == 1 ? LinearLayout.LayoutParams.WRAP_CONTENT : (int) (targetHeight * interpolatedTime); v.requestLayout(); } @Override public boolean willChangeBounds() { return true; } }; // 1dp/ms a.setDuration((int) (targetHeight / v.getContext().getResources().getDisplayMetrics().density)); v.startAnimation(a); }
From source file:org.runbuddy.tomahawk.views.PageIndicator.java
private void rotateArrow(View arrow, boolean reverse) { RotateAnimation rotate;/*ww w . j a va 2 s . co m*/ if (reverse) { rotate = new RotateAnimation(180, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); } else { rotate = new RotateAnimation(360, 180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); } rotate.setDuration(AnimationUtils.DURATION_ARROWROTATE); arrow.startAnimation(rotate); rotate.setFillAfter(true); }
From source file:fr.shywim.antoinedaniel.utils.Utils.java
/** * Second part of the click animation.//from w w w .j av a 2s . c om * * @param v View who will have the effect. * @param isRoot Whether the passed view is the ViewGroup parent. */ public static void clickAnimUp(View v, boolean isRoot) { RelativeLayout root; if (isRoot) root = (RelativeLayout) v; else root = (RelativeLayout) v.getParent(); final View rectView = root.findViewById(R.id.rect_view_id); if (rectView != null) { AlphaAnimation rectAnim = new AlphaAnimation(0.4f, 0f); rectAnim.setFillAfter(true); rectAnim.setInterpolator(new DecelerateInterpolator()); rectAnim.setDuration(150); rectAnim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { new Handler().post(new Runnable() { @Override public void run() { ViewGroup parent = (ViewGroup) rectView.getParent(); rectView.setVisibility(View.GONE); if (parent != null) parent.removeView(rectView); } }); } @Override public void onAnimationRepeat(Animation animation) { } }); rectView.clearAnimation(); rectView.startAnimation(rectAnim); } }
From source file:com.syncedsynapse.kore2.ui.RemoteFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); hostManager = HostManager.getInstance(getActivity()); hostConnectionObserver = hostManager.getHostConnectionObserver(); buttonInAnim = AnimationUtils.loadAnimation(getActivity(), R.anim.button_in); buttonOutAnim = AnimationUtils.loadAnimation(getActivity(), R.anim.button_out); feedbackTouckListener = new View.OnTouchListener() { @Override//from w w w . jav a2 s .com public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: buttonInAnim.setFillAfter(true); v.startAnimation(buttonInAnim); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: v.startAnimation(buttonOutAnim); break; } return false; } }; }
From source file:com.andrada.sitracker.ui.fragment.AuthorsFragment.java
private void toggleUpdatingState() { mIsUpdating = !mIsUpdating;/*from w w w. ja v a2 s . c o m*/ ActionBar bar = ((ActionBarActivity) getActivity()).getSupportActionBar(); bar.setDisplayShowHomeEnabled(!mIsUpdating); bar.setDisplayShowTitleEnabled(!mIsUpdating); bar.setDisplayShowCustomEnabled(mIsUpdating); EventBus.getDefault().post(new ProgressBarToggleEvent(mIsUpdating)); if (mIsUpdating) { View mLogoView = LayoutInflater.from(getActivity()).inflate(R.layout.updating_actionbar_layout, null); bar.setCustomView(mLogoView, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mLogoView.clearAnimation(); mLogoView.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.ab_custom_view_anim)); } getActivity().supportInvalidateOptionsMenu(); }
From source file:com.android.camera.v2.uimanager.SettingManager.java
private void startFadeInAnimation(View view) { if (mFadeIn == null) { mFadeIn = AnimationUtils.loadAnimation(mActivity, R.anim.setting_popup_grow_fade_in); }/* w w w. j av a 2s. c om*/ if (view != null && mFadeIn != null) { view.startAnimation(mFadeIn); } }
From source file:br.com.oficinatablet.chats.fragments.ChatSectionFragment.java
/** * Here is the key method to apply the animation *//*from w w w.java2s .c o m*/ private void setAnimation(View viewToAnimate, int position) { // If the bound view wasn't previously displayed on screen, it's animated if (position > lastPosition) { Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_in_down); viewToAnimate.startAnimation(animation); lastPosition = position; } }