List of usage examples for android.view.animation Animation getDuration
public long getDuration()
From source file:com.waz.zclient.utils.ViewUtils.java
public static long getNextAnimationDuration(Fragment fragment) { try {/*from w ww .j a v a 2 s . c om*/ // Attempt to get the resource ID of the next animation that // will be applied to the given fragment. Field nextAnimField = Fragment.class.getDeclaredField("mNextAnim"); nextAnimField.setAccessible(true); int nextAnimResource = nextAnimField.getInt(fragment); Animation nextAnim = AnimationUtils.loadAnimation(fragment.getActivity(), nextAnimResource); // ...and if it can be loaded, return that animation's duration return (nextAnim == null) ? DEFAULT_CHILD_ANIMATION_DURATION : nextAnim.getDuration(); } catch (NoSuchFieldException | IllegalAccessException | Resources.NotFoundException ex) { return DEFAULT_CHILD_ANIMATION_DURATION; } }
From source file:com.github.shareme.gwsmaterialuikit.library.material.app.ToolbarManager.java
private void animateOut() { ActionMenuView menuView = getMenuView(); int count = menuView == null ? 0 : menuView.getChildCount(); Animation slowestAnimation = null; mAnimations.clear();//www.ja v a2 s . co m mAnimations.ensureCapacity(count); for (int i = 0; i < count; i++) { View child = menuView.getChildAt(i); Animation anim = mAnimator.getOutAnimation(child, i); mAnimations.add(anim); if (anim != null) if (slowestAnimation == null || slowestAnimation.getStartOffset() + slowestAnimation.getDuration() < anim.getStartOffset() + anim.getDuration()) slowestAnimation = anim; } if (slowestAnimation == null) mOutAnimationEndListener.onAnimationEnd(null); else { slowestAnimation.setAnimationListener(mOutAnimationEndListener); for (int i = 0; i < count; i++) { Animation anim = mAnimations.get(i); if (anim != null) menuView.getChildAt(i).startAnimation(anim); } } mAnimations.clear(); }
From source file:net.bither.fragment.hot.AddAddressHotHDMFragment.java
private void finalAnimation() { final int fadeDuration = 400; final int zoomDuration = 500; AlphaAnimation fadeOut = new AlphaAnimation(1, 0); fadeOut.setDuration(fadeDuration);/*from www . ja va 2s . co m*/ fadeOut.setFillAfter(true); vBg.startAnimation(fadeOut); tvHot.startAnimation(fadeOut); tvCold.startAnimation(fadeOut); tvServer.startAnimation(fadeOut); if (llSingularRunning.getVisibility() == View.VISIBLE) { llSingularRunning.startAnimation(fadeOut); } flContainer.postDelayed(new Runnable() { @Override public void run() { vBg.setVisibility(View.GONE); tvHot.setVisibility(View.INVISIBLE); tvCold.setVisibility(View.INVISIBLE); tvServer.setVisibility(View.INVISIBLE); int[] size = getCompactContainerSize(); WrapLayoutParamsForAnimator animWrapper = new WrapLayoutParamsForAnimator(flContainer); ObjectAnimator animatorWidth = ObjectAnimator.ofInt(animWrapper, "width", size[0]) .setDuration(zoomDuration); ObjectAnimator animatorHeight = ObjectAnimator.ofInt(animWrapper, "height", size[1]) .setDuration(zoomDuration); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(animatorWidth, animatorHeight); animatorSet.start(); flContainer.postDelayed(new Runnable() { @Override public void run() { Animation anim = AnimationUtils.loadAnimation(getActivity(), R.anim.hdm_keychain_add_spin); anim.setFillAfter(true); flContainer.startAnimation(anim); ArrayList<String> addresses = getAddresses(); Intent intent = new Intent(); intent.putExtra(BitherSetting.INTENT_REF.ADDRESS_POSITION_PASS_VALUE_TAG, addresses); getActivity().setResult(Activity.RESULT_OK, intent); flContainer.postDelayed(new Runnable() { @Override public void run() { if (getActivity() != null) { ((AddPrivateKeyActivity) getActivity()).save(); } } }, anim.getDuration()); } }, zoomDuration); } }, fadeDuration); }
From source file:org.brandroid.openmanager.activities.OpenExplorer.java
private void onClipboardDropdown(View anchor) { ViewUtils.setViewsVisible(mStaticButtons, true, R.id.title_paste); if (anchor == null) anchor = ViewUtils.getFirstView(this, R.id.title_paste, R.id.title_icon, R.id.frag_holder); final BetterPopupWindow clipdrop = new BetterPopupWindow(this, anchor); View root = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.multiselect, null); GridView mGridCommands = (GridView) root.findViewById(R.id.multiselect_command_grid); final ListView mListClipboard = (ListView) root.findViewById(R.id.multiselect_item_list); mListClipboard.setAdapter(getClipboard()); mListClipboard.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> list, View view, final int pos, long id) { //OpenPath file = mClipboard.get(pos); //if(file.getParent().equals(mLastPath)) Animation anim = AnimationUtils.loadAnimation(OpenExplorer.this, R.anim.slide_out_left); //anim.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime)); list.getChildAt(pos).startAnimation(anim); new Handler().postDelayed(new Runnable() { public void run() { getClipboard().remove(pos); mListClipboard.invalidate(); if (getClipboard().getCount() == 0) clipdrop.dismiss(); }/*from w ww . j a v a 2 s .co m*/ }, anim.getDuration()); //else //getEventHandler().copyFile(file, mLastPath, OpenExplorer.this); } }); final Menu menu = IconContextMenu.newMenu(this, R.menu.multiselect); MenuUtils.setMenuChecked(menu, getClipboard().isMultiselect(), R.id.menu_multi); MenuUtils.setMenuEnabled(menu, getClipboard().hasPastable(), R.id.menu_multi_all_copy, R.id.menu_multi_all_copy, R.id.menu_multi_all_move); final IconContextMenuAdapter cmdAdapter = new IconContextMenuAdapter(this, menu); cmdAdapter.setTextLayout(R.layout.context_item); mGridCommands.setAdapter(cmdAdapter); mGridCommands.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> list, View view, int pos, long id) { MenuItem item = menu.getItem(pos); onClick(item.getItemId(), item, view); clipdrop.dismiss(); } }); float w = getResources().getDimension(R.dimen.popup_width) * (3 / 2); if (w > getWindowWidth()) w = getWindowWidth() - 20; clipdrop.setPopupWidth((int) w); clipdrop.setContentView(root); clipdrop.showLikePopDownMenu(); //dropdown.setAdapter(this, new IconContextMenuAdapter(context, menu)) //BetterPopupWindow win = new BetterPopupWindow(this, anchor); //ListView list = ((LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE)).inflate(R.layout.multiselect, null); //win.setContentView(root) }