List of usage examples for android.view.animation TranslateAnimation TranslateAnimation
public TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta)
From source file:net.bither.fragment.hot.MarketFragment.java
public void showPriceAlertAnimTo(int fromX, int fromY, Market toMarket) { int[] containerOffset = new int[2]; v.getLocationInWindow(containerOffset); containerOffset[0] += v.getPaddingLeft(); containerOffset[1] += v.getPaddingTop(); ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) ivMarketPriceAnimIcon.getLayoutParams(); lp.topMargin = fromY - containerOffset[1]; lp.leftMargin = fromX - containerOffset[0]; int marketIndex = markets.indexOf(toMarket); if (marketIndex < lv.getFirstVisiblePosition() || marketIndex > lv.getLastVisiblePosition()) { lv.setSelection(marketIndex);//from w w w. j ava 2 s .c o m } View marketView = lv.getChildAt(marketIndex - lv.getFirstVisiblePosition()); View toIconView = marketView.findViewById(R.id.iv_price_alert); int[] toLocation = new int[2]; toIconView.getLocationInWindow(toLocation); TranslateAnimation anim = new TranslateAnimation(0, toLocation[0] - fromX, 0, toLocation[1] - fromY); anim.setDuration(300); anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { doRefresh(); ivMarketPriceAnimIcon.setVisibility(View.INVISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); ivMarketPriceAnimIcon.setVisibility(View.VISIBLE); ivMarketPriceAnimIcon.startAnimation(anim); }
From source file:org.glucosio.android.fragment.AssistantFragment.java
@OnClick(R.id.fragment_assistant_archived) void archivedButtonClicked() { populateWithArchivedTips();//from w w w .j a v a2 s . c om adapter.notifyDataSetChanged(); tipsRecycler.swapAdapter(adapter, false); archivedDismissButton.setVisibility(View.VISIBLE); final Animation slide = new TranslateAnimation(0, 0, 0, 200); slide.setDuration(500); archivedButton.startAnimation(slide); archivedButton.setVisibility(View.GONE); }
From source file:org.bcsphere.activity.BCPage.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.btnManager: mActivity.managerPopupWindow.showAsDropDown(view, 0, 0); TranslateAnimation animation = new TranslateAnimation(0, 0, 0, (float) (getScreenHeight(mActivity) * (430.0 / 1920.0))); animation.setDuration(200);// www . j a v a 2 s . com animation.setFillAfter(true); parentView.startAnimation(animation); break; case R.id.btnMenu: if (menuPopupWindow == null) { menuPopupWindow = new MenuPopupWindow(mActivity); } if (menuPopupWindow.isShowing()) { menuPopupWindow.dismiss(); return; } menuPopupWindow.showAsDropDown(btnMenu, 0, 20); break; case R.id.btnBack: mWebView.goBack(); break; case R.id.btnClose: Intent intent = new Intent(); intent.setAction("removeApp"); intent.putExtra("removeAppURL", PageManager.getCurrentPager().url); mActivity.sendBroadcast(intent); PageManager.setDeleteUrl(PageManager.getCurrentPager().url); break; case R.id.hintOpenBluetooth: startActivity(new Intent(Settings.ACTION_BLUETOOTH_SETTINGS)); break; case R.id.hintOpenNetwork: startActivity(new Intent(Settings.ACTION_SETTINGS)); break; } }
From source file:com.cleanwiz.applock.ui.activity.LockMainActivity.java
private void initAnim() { long duration = 300; long durationS = 160; float alpha = 0.3f; AccelerateInterpolator accInterpolator = new AccelerateInterpolator(); tab_left = new TranslateAnimation(tabW, 0, 0, 0); tab_right = new TranslateAnimation(0, tabW, 0, 0); tab_alpha_1 = new AlphaAnimation(1.0f, alpha); tab_alpha_2 = new AlphaAnimation(alpha, 1.0f); pop_in = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0); pop_out = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0); pop_in.setDuration(durationS);//w w w .j a v a 2 s. c om pop_in.setInterpolator(accInterpolator); pop_in.setAnimationListener(new PopListener(popView, PopListener.TYPE_IN)); pop_out.setDuration(durationS); pop_out.setInterpolator(accInterpolator); pop_out.setAnimationListener(new PopListener(popView, PopListener.TYPE_OUT)); tab_left.setFillAfter(true); tab_left.setFillEnabled(true); tab_left.setDuration(duration); tab_left.setInterpolator(accInterpolator); tab_right.setFillAfter(true); tab_right.setFillEnabled(true); tab_right.setDuration(duration); tab_right.setInterpolator(accInterpolator); tab_alpha_1.setFillAfter(true); tab_alpha_1.setFillEnabled(true); tab_alpha_1.setDuration(duration); tab_alpha_1.setInterpolator(accInterpolator); tab_alpha_2.setFillAfter(true); tab_alpha_2.setFillEnabled(true); tab_alpha_2.setDuration(duration); tab_alpha_2.setInterpolator(accInterpolator); AlphaAnimation alphaInit = new AlphaAnimation(alpha, alpha); alphaInit.setFillAfter(true); alphaInit.setFillEnabled(true); tv_tab_box.startAnimation(alphaInit); }
From source file:fragments.InfoListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setListAdapter();/*from w w w . j av a2s.com*/ mListView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { mQuickReturnHeight = mQuickReturnView.getHeight(); mListView.computeScrollY(); } }); mListView.setOnScrollListener(new OnScrollListener() { @SuppressLint("NewApi") @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { mScrollY = 0; int translationY = 0; try { if (mListView.scrollYIsComputed()) { mScrollY = mListView.getComputedScrollY(); } } catch (NullPointerException ex) { Log.e(InfoListFragment.class.getSimpleName(), ex.toString()); } int rawY = mScrollY; switch (mState) { case Constants.STATE_OFFSCREEN: if (rawY >= mMinRawY) { mMinRawY = rawY; } else { mState = Constants.STATE_RETURNING; } translationY = rawY; break; case Constants.STATE_ONSCREEN: if (rawY > mQuickReturnHeight) { mState = Constants.STATE_OFFSCREEN; mMinRawY = rawY; } translationY = rawY; break; case Constants.STATE_RETURNING: translationY = (rawY - mMinRawY) + mQuickReturnHeight; System.out.println(translationY); if (translationY < 0) { translationY = 0; mMinRawY = rawY + mQuickReturnHeight; } if (rawY == 0) { mState = Constants.STATE_ONSCREEN; translationY = 0; } if (translationY > mQuickReturnHeight) { mState = Constants.STATE_OFFSCREEN; mMinRawY = rawY; } break; } /** this can be used if the build is below honeycomb **/ if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) { anim = new TranslateAnimation(0, 0, translationY, translationY); anim.setFillAfter(true); anim.setDuration(0); mQuickReturnView.startAnimation(anim); } else { mQuickReturnView.setTranslationY(translationY); } } @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } }); }
From source file:com.spoiledmilk.ibikecph.controls.SortableListView.java
void translate(View v, float deltaY, final boolean finalAnim) { float newY = posY + deltaY; if (animation != null && animation.isInitialized()) animation.cancel();/* w ww . ja v a2s . com*/ animation = new TranslateAnimation(0, 0, posY, newY); animation.setDuration(finalAnim ? 0 : 100); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (!finalAnim) { animation.setFillEnabled(true); animation.setFillAfter(true); } else { view.clearAnimation(); posY = 0; } } }); posY = newY; v.startAnimation(animation); }
From source file:com.linkbubble.ui.BubbleFlowView.java
public void add(View view, boolean insertNextToCenterItem) { //view.setBackgroundColor(mViews.size() % 2 == 0 ? 0xff660066 : 0xff666600); view.setOnClickListener(mViewOnClickListener); view.setOnTouchListener(mViewOnTouchListener); int centerIndex = getCenterIndex(); int insertAtIndex = insertNextToCenterItem ? centerIndex + 1 : mViews.size(); if (view.getParent() != null) { ((ViewGroup) view.getParent()).removeView(view); }//ww w . j ava 2 s.com FrameLayout.LayoutParams lp = new LayoutParams(mItemWidth, mItemHeight, Gravity.TOP | Gravity.LEFT); lp.leftMargin = mEdgeMargin + insertAtIndex * mItemWidth; mContent.addView(view, lp); mContent.invalidate(); if (insertNextToCenterItem) { mViews.add(centerIndex + 1, view); } else { mViews.add(view); } updatePositions(); updateScales(getScrollX()); if (insertNextToCenterItem) { TranslateAnimation slideOnAnim = new TranslateAnimation(0, 0, -mItemHeight, 0); slideOnAnim.setDuration(Constant.BUBBLE_FLOW_ANIM_TIME); slideOnAnim.setFillAfter(true); view.startAnimation(slideOnAnim); for (int i = centerIndex + 2; i < mViews.size(); i++) { View viewToShift = mViews.get(i); TranslateAnimation slideRightAnim = new TranslateAnimation(-mItemWidth, 0, 0, 0); slideRightAnim.setDuration(Constant.BUBBLE_FLOW_ANIM_TIME); slideRightAnim.setFillAfter(true); viewToShift.startAnimation(slideRightAnim); } } ViewGroup.LayoutParams contentLP = mContent.getLayoutParams(); contentLP.width = (mViews.size() * mItemWidth) + mItemWidth + (2 * mEdgeMargin); mContent.setLayoutParams(contentLP); }
From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java
/** * Create dynamically an android animation for a coin or a bill droping into * the moneybox.// w ww .j a va 2s .c o m * * @param img * ImageView to receive the animation * @param layout * Layout that paint the image * @param curr * Currency value of the image * @return Set of animations to apply to the image */ private AnimationSet createDropAnimation(ImageView img, View layout, CurrencyValueDef curr) { AnimationSet result; result = new AnimationSet(false); result.setFillAfter(true); // Fade in AlphaAnimation fadeIn; fadeIn = new AlphaAnimation(0.0f, 1.0f); fadeIn.setDuration(300); result.addAnimation(fadeIn); // drop TranslateAnimation drop; int bottom; bottom = Math.abs(layout.getHeight() - img.getLayoutParams().height); drop = new TranslateAnimation(1.0f, 1.0f, 1.0f, bottom); drop.setStartOffset(300); drop.setDuration(1500); if (curr.getType() == CurrencyValueDef.MoneyType.COIN) { drop.setInterpolator(new BounceInterpolator()); } else { // drop.setInterpolator(new DecelerateInterpolator(0.7f)); drop.setInterpolator(new AnticipateOvershootInterpolator()); } result.addAnimation(drop); return result; }
From source file:passenger.view.activity.SmsLoginActivity.java
@Override public void onClick(View v) { Intent intent = new Intent(); switch (v.getId()) { case R.id.textView_frogetPassword: intent.setClass(SmsLoginActivity.this, UpdatePasswordActivity.class); startActivity(intent);/*from ww w. j ava 2 s. c om*/ break; case R.id.textView_register: intent.setClass(SmsLoginActivity.this, RegisterActivity.class); startActivity(intent); break; case R.id.textView_quickLogin: isQuickLogin = true; mTextView_quickLogin.setTextColor(basicColor); mTextView_accountLogin.setTextColor(mSystem_gray); Animation animation = new TranslateAnimation(offset, 0, 0, 0); animation.setFillAfter(true);// True:??? animation.setDuration(300); mImageView_tiao01.startAnimation(animation); mLogin.setVisibility(View.GONE); mLinear_quickLogin.setVisibility(View.VISIBLE); mLinear_accountLogin.setVisibility(View.INVISIBLE); break; case R.id.textView_accountLogin: isQuickLogin = false; mTextView_accountLogin.setTextColor(basicColor); mTextView_quickLogin.setTextColor(mSystem_gray); Animation animation02 = new TranslateAnimation(0, offset, 0, 0); animation02.setFillAfter(true);// True:??? animation02.setDuration(300); mImageView_tiao01.startAnimation(animation02); mLogin.setVisibility(View.VISIBLE); mLinear_quickLogin.setVisibility(View.INVISIBLE); mLinear_accountLogin.setVisibility(View.VISIBLE); break; case R.id.login: if (isQuickLogin) { if (mSuijiMath.equals(mSms.getText().toString().trim())) { //? final String DeviceId = Installation.id(SmsLoginActivity.this); //??????????----start----// Map<String, String> params = new HashMap<String, String>(); params.put("phone", mPhoneNum); params.put("login_id", DeviceId); ApiClient.smsLogingSuccess(SmsLoginActivity.this, params, new VolleyListener() { public void onErrorResponse(VolleyError volleyError) { } public void onResponse(String s) { Log.e("SmsLoginActivity", "onResponse: --??????->>" + s); mUser = GsonUtils.parseJSON(s, UserZhuChe.class); if (mUser.isSuccess()) { Log.e("SmsLoginActivity", "onResponse: --????->>" + mLoginState.isLogin()); toast("??"); //???????? mLoginState.login(SmsLoginActivity.this); Log.e("SmsLoginActivity", "onResponse: --?????->>" + mLoginState.isLogin()); //???id?? UserLoginInfo userLoginInfo = new UserLoginInfo(mPhoneNum, "" + mUser.getContains().getId(), DeviceId, mUser.getContains().getImage(), mUser.getContains().getIdCardImage(), mUser.getContains().getIdCardImage_back(), mUser.getContains().getDrivingLicenseImage(), mUser.getContains().getDrivingLicenseImage_back()); mLoginState.setLoginInfo(userLoginInfo); Log.e("SmsLoginActivity", "onResponse: --?->>" + mLoginState.getLoginInfo().toString()); //? MobclickAgent.onProfileSignIn(mPhoneNum); finish(); } else { toast(mUser.getMessage()); } } }); //??????????----end----// } else { toast("?"); } } else { mPhoneNum = mEditText_phoneNum.getText().toString().trim(); String password = mEditText_password.getText().toString().trim(); //? final String DeviceId = Installation.id(SmsLoginActivity.this); Map<String, String> map = new HashMap<String, String>(); map.put("phone", mPhoneNum); map.put("login_id", DeviceId); map.put("password", password); ApiClient.passWordLoginSuccess(SmsLoginActivity.this, map, new VolleyListener() { @Override public void onErrorResponse(VolleyError volleyError) { } @Override public void onResponse(String s) { mUser = GsonUtils.parseJSON(s, UserZhuChe.class); if (mUser.isSuccess()) { Log.e("SmsLoginActivity", "onResponse: --????->>" + mLoginState.isLogin()); //???????? mLoginState.login(SmsLoginActivity.this); Log.e("SmsLoginActivity", "onResponse: --?????->>" + mLoginState.isLogin()); //???id?? UserLoginInfo userLoginInfo = new UserLoginInfo(mPhoneNum, "" + mUser.getContains().getId(), DeviceId, mUser.getContains().getImage(), mUser.getContains().getIdCardImage(), mUser.getContains().getIdCardImage_back(), mUser.getContains().getDrivingLicenseImage(), mUser.getContains().getDrivingLicenseImage_back()); mLoginState.setLoginInfo(userLoginInfo); toast("?"); //? MobclickAgent.onProfileSignIn(mPhoneNum); finish(); // Intent intent = new Intent(); // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // intent.setClass(SmsLoginActivity.this, MainActivity.class); // startActivity(intent); } else { toast("???"); } } }); } break; case R.id.iv_org_detailback: finish(); AnimFromRightToLeft(); break; case R.id.phone_num_cancle: mPhone_num.setText(""); break; case R.id.sms_cancle: mSms.setText(""); break; case R.id.sendSms: // if (ContextCompat.checkSelfPermission(SmsLoginActivity.this, Manifest.permission.READ_SMS) // != PackageManager.PERMISSION_GRANTED) // { // //WRITE_EXTERNAL_STORAGE?? // ActivityCompat.requestPermissions(SmsLoginActivity.this, new String[]{Manifest.permission.READ_SMS}, Constant.PermissionRequestAndResultCode.PERMISSION_READ_SMS); // } else // { sendSMS(); // } break; } }
From source file:com.breadwallet.tools.animation.BRAnimator.java
/** * Animate the transition on burgerButton/MenuButton pressed *///from w w w.ja v a 2s . c o m public static void pressMenuButton(final MainActivity context) { try { if (context == null) return; ((BreadWalletApp) context.getApplication()).cancelToast(); final FragmentManager fragmentManager = context.getFragmentManager(); if (level == 0) { if (PLATFORM_ON) new Thread(new Runnable() { @Override public void run() { HTTPServer.startServer(); } }).start(); level++; CustomPagerAdapter.adapter.showFragments(false, context); context.setBurgerButtonImage(BRConstants.CLOSE); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); FragmentSettingsAll to = (FragmentSettingsAll) fragmentManager .findFragmentByTag(FragmentSettingsAll.class.getName()); if (to == null) to = new FragmentSettingsAll(); fragmentTransaction.add(R.id.main_layout, to, FragmentSettingsAll.class.getName()); fragmentTransaction.commit(); final FragmentSettingsAll finalTo = to; new Handler().postDelayed(new Runnable() { @Override public void run() { TranslateAnimation trans = new TranslateAnimation(0, 0, 1920, 0); trans.setDuration(500); trans.setInterpolator(new DecelerateOvershootInterpolator(3f, 0.5f)); View view = finalTo.getView(); if (view != null) view.startAnimation(trans); } }, 1); InputMethodManager keyboard = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); if (keyboard != null) keyboard.hideSoftInputFromWindow( CustomPagerAdapter.adapter.mainFragment.addressEditText.getWindowToken(), 0); } else if (level == 1) { if (PLATFORM_ON) new Thread(new Runnable() { @Override public void run() { HTTPServer.stopServer(); } }).start(); level--; context.setBurgerButtonImage(BRConstants.BURGER); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.setCustomAnimations(R.animator.from_top, R.animator.to_bottom); FragmentSettingsAll fragmentSettingsAll = (FragmentSettingsAll) fragmentManager .findFragmentByTag(FragmentSettingsAll.class.getName()); fragmentTransaction.remove(fragmentSettingsAll); fragmentTransaction.commit(); CustomPagerAdapter.adapter.showFragments(true, context); } } catch (Exception e) { e.printStackTrace(); } }