Example usage for android.view.animation TranslateAnimation TranslateAnimation

List of usage examples for android.view.animation TranslateAnimation TranslateAnimation

Introduction

In this page you can find the example usage for android.view.animation TranslateAnimation TranslateAnimation.

Prototype

public TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta) 

Source Link

Document

Constructor to use when building a TranslateAnimation from code

Usage

From source file:bmcx.aiton.com.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  www  .  j  a va  2  s. c  o m
        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<>();
                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, User.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<>();
            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, User.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:io.development.tymo.adapters.FeedZoomMoreAdapter.java

public FeedZoomMoreAdapter(Context context, int itemCount) {
    SharedPreferences mSharedPreferences = context.getSharedPreferences(Constants.USER_CREDENTIALS,
            MODE_PRIVATE);/*from  w  w  w.  ja  v  a2  s. c o  m*/
    email = mSharedPreferences.getString(Constants.EMAIL, "");

    dateFormat = new DateFormat(context);

    mContext = context;
    mItems = new ArrayList<>(itemCount);
    for (int i = 0; i < itemCount; i++) {
        addItem(i);
    }

    animation = new TranslateAnimation(0.0f, 0.0f, -Utilities.convertDpToPixel(3, context),
            Utilities.convertDpToPixel(4, context));
    animation.setDuration(1400);
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.REVERSE);

    animation2 = new TranslateAnimation(0.0f, 0.0f, Utilities.convertDpToPixel(3, context),
            -Utilities.convertDpToPixel(4, context));
    animation2.setDuration(1000);
    animation2.setRepeatCount(Animation.INFINITE);
    animation2.setRepeatMode(Animation.REVERSE);

    rotation = new RotateAnimation(-3, 3, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    rotation.setDuration(1200);
    rotation.setRepeatCount(Animation.INFINITE);
    rotation.setRepeatMode(Animation.REVERSE);
}

From source file:com.juick.android.MainActivity.java

public void openNavigationMenu(boolean animate) {
    if (isNavigationMenuShown())
        return;//w  ww.  ja v  a  2  s. co  m
    navigationMenuShown = true;
    final ViewGroup navigationPanel = (ViewGroup) findViewById(R.id.navigation_panel);
    navigationPanel.setVisibility(View.VISIBLE);
    final View frag = (ViewGroup) findViewById(R.id.messagesfragment);
    if (animate) {
        AnimationSet set = new AnimationSet(true);
        TranslateAnimation translate = new TranslateAnimation(0, navigationPanel.getWidth(), 0, 0);
        translate.setFillAfter(false);
        translate.setFillEnabled(true);
        translate.setDuration(400);
        set.addAnimation(translate);
        set.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                frag.clearAnimation();
                layoutNavigationPane();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                //To change body of implemented methods use File | Settings | File Templates.
            }
        });
        frag.startAnimation(set);
    } else {
        layoutNavigationPane();
    }
}

From source file:com.rareventure.gps2.reviewer.map.OsmMapGpsTrailerReviewerMapActivity.java

protected void initWithWorkingGetWidth() {
    slideSasFullToTab = new TranslateAnimation(0, sasPanelButton.getWidth() - sasPanel.getWidth(), 0, 0);
    slideSasTabToFull = new TranslateAnimation(sasPanelButton.getWidth() - sasPanel.getWidth(), 0, 0, 0);
    slideSasTabToNone = new TranslateAnimation(sasPanelButton.getWidth() - sasPanel.getWidth(),
            -sasPanel.getWidth(), 0, 0);
    slideSasFullToNone = new TranslateAnimation(0, -sasPanel.getWidth(), 0, 0);
    slideSasNoneToFull = new TranslateAnimation(-sasPanel.getWidth(), 0, 0, 0);
    slideSasNoneToTab = new TranslateAnimation(-sasPanel.getWidth(),
            sasPanelButton.getWidth() - sasPanel.getWidth(), 0, 0);

    slideSasFullToTab.setDuration(500);/* w  ww .jav  a2  s.com*/
    slideSasTabToFull.setDuration(500);
    slideSasTabToNone.setDuration(200);
    slideSasFullToNone.setDuration(500);
    slideSasNoneToFull.setDuration(500);
    slideSasNoneToTab.setDuration(200);

    osmMapView.setZoomCenter(osmMapView.getWidth() / 2, findViewById(R.id.timeview_layout).getTop() / 2);
}

From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java

/**
 * Create dynamically an android animation for a coin or a bill getting from
 * the moneybox./*from   www  .  j a  v  a2s .c  o  m*/
 * 
 * @param img
 *            ImageView to receive the animation
 * @param layout
 *            Layout that paint the image
 * @return Set of animations to apply to the image
 */
private AnimationSet createGetAnimation(ImageView img, View layout) {
    AnimationSet result;

    result = new AnimationSet(false);
    result.setFillAfter(true);

    // get
    TranslateAnimation get;
    int bottom;

    bottom = Math.abs(layout.getHeight() - img.getLayoutParams().height);
    get = new TranslateAnimation(1.0f, 1.0f, bottom, 1.0f);
    get.setDuration(1500);
    result.addAnimation(get);

    // Fade out
    AlphaAnimation fadeOut;

    fadeOut = new AlphaAnimation(1.0f, 0.0f);
    fadeOut.setDuration(300);
    fadeOut.setStartOffset(1500);

    result.addAnimation(fadeOut);

    return result;
}

From source file:com.plusub.lib.example.view.TabView.java

/**
 * ?/* w w w.j  a v  a 2s  .  com*/
 * @param arg0
 */
private void moveCursor(int arg0) {
    TranslateAnimation animation = new TranslateAnimation(mCursorCurPosition, arg0 * mScreenWidth / tabCount,
            Animation.RELATIVE_TO_SELF, Animation.RELATIVE_TO_SELF);
    mCursorCurPosition = arg0 * mScreenWidth / tabCount;
    animation.setDuration(200);
    animation.setInterpolator(new LinearInterpolator());
    animation.setFillAfter(true);
    mIvCursor.startAnimation(animation);
}

From source file:com.tr4android.support.extension.widget.LabelView.java

private static Animation createAnimationSet(float fromAlpha, float toAlpha, int fromXDelta, int toXDelta) {
    AnimationSet anim = new AnimationSet(true);
    anim.addAnimation(new AlphaAnimation(fromAlpha, toAlpha));
    anim.addAnimation(new TranslateAnimation(fromXDelta, toXDelta, 0, 0));
    return anim;// ww  w . j  a v  a  2s . c o m
}

From source file:com.linkbubble.ui.BubbleFlowView.java

protected void remove(final int index, boolean animateOff, boolean removeFromList,
        final OnRemovedListener onRemovedListener) {
    if (index < 0 || index >= mViews.size()) {
        return;/*w w w  .  ja  v  a  2 s.c o m*/
    }
    final View view = mViews.get(index);

    if (animateOff) {
        if (removeFromList == false) {
            throw new RuntimeException("removeFromList must be true if animating off");
        }
        TranslateAnimation slideOffAnim = new TranslateAnimation(0, 0, 0, -mItemHeight);
        slideOffAnim.setDuration(Constant.BUBBLE_FLOW_ANIM_TIME);
        slideOffAnim.setFillAfter(true);
        slideOffAnim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                mContent.removeView(view);

                // Cancel the current animation on the views so the offset no longer applies
                for (int i = 0; i < mViews.size(); i++) {
                    View view = mViews.get(i);
                    Animation viewAnimation = view.getAnimation();
                    if (viewAnimation != null) {
                        viewAnimation.cancel();
                        view.setAnimation(null);
                    }
                }
                updatePositions();
                updateScales(getScrollX());
                mSlideOffAnimationPlaying = false;

                if (onRemovedListener != null) {
                    onRemovedListener.onRemoved(view);
                }
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        invalidate(); // This fixes #284 - it's a hack, but it will do for now.
        view.startAnimation(slideOffAnim);
        mSlideOffAnimationPlaying = true;

        mViews.remove(view);

        int viewsSize = mViews.size();
        if (index < viewsSize) {
            for (int i = index; i < viewsSize; i++) {
                final View viewToShift = mViews.get(i);
                TranslateAnimationEx slideAnim = new TranslateAnimationEx(0, -mItemWidth, 0, 0,
                        new TranslateAnimationEx.TransformationListener() {
                            @Override
                            public void onApplyTransform(float interpolatedTime, Transformation t, float dx,
                                    float dy) {
                                float centerX = getScrollX() + (mWidth / 2) - (mItemWidth / 2);
                                updateScaleForView(viewToShift, centerX, viewToShift.getX() + dx);
                            }
                        });
                slideAnim.setDuration(Constant.BUBBLE_FLOW_ANIM_TIME);
                slideAnim.setFillAfter(true);
                viewToShift.startAnimation(slideAnim);
            }
        } else if (viewsSize > 0) {
            for (int i = 0; i < index; i++) {
                final View viewToShift = mViews.get(i);
                TranslateAnimationEx slideAnim = new TranslateAnimationEx(0, mItemWidth, 0, 0,
                        new TranslateAnimationEx.TransformationListener() {
                            @Override
                            public void onApplyTransform(float interpolatedTime, Transformation t, float dx,
                                    float dy) {
                                float centerX = getScrollX() + (mWidth / 2) - (mItemWidth / 2);
                                updateScaleForView(viewToShift, centerX, viewToShift.getX() + dx);
                            }
                        });
                slideAnim.setDuration(Constant.BUBBLE_FLOW_ANIM_TIME);
                slideAnim.setFillAfter(true);
                viewToShift.startAnimation(slideAnim);
            }
        }
    } else {
        mContent.removeView(view);
        if (removeFromList) {
            mViews.remove(view);
            updatePositions();
            updateScales(getScrollX());
            mContent.invalidate();
        }
        if (onRemovedListener != null) {
            onRemovedListener.onRemoved(view);
        }
    }
}

From source file:com.example.haber.ui.activity.TabbedActivity.java

private void switchStatus() {
    if (currentStatus == COMMON_STATUS) {
        if (sensorManager != null)
            sensorManager.unregisterListener(sensorListener, sensor);
        if (tbDial.isChecked())
            tbDial.setChecked(false);/*from  w w w.j  av a2 s.c  o  m*/
        if (tbConsoleControl.isChecked())
            tbConsoleControl.setChecked(false);
        if (layoutDial.getVisibility() != View.GONE) {
            Animation animation = new TranslateAnimation(0, 0, 0,
                    200 * metrics.density + 0.5f + displayHeight * 0.32f);
            animation.setDuration(200);
            layoutDial.startAnimation(animation);
            layoutDial.setVisibility(View.GONE);
        }
        if (containConsoleControl.getVisibility() != View.GONE)
            containConsoleControl.setVisibility(View.GONE);
        if (containViewPager.getVisibility() == View.GONE)
            containViewPager.setVisibility(View.VISIBLE);
    } else if (currentStatus == DIAL_STATUS) {

        if (!tbDial.isChecked())
            tbDial.setChecked(true);
        if (tbConsoleControl.isChecked())
            tbConsoleControl.setChecked(false);
        if (containConsoleControl.getVisibility() != View.GONE)
            containConsoleControl.setVisibility(View.GONE);
        if (containViewPager.getVisibility() != View.VISIBLE)
            containViewPager.setVisibility(View.VISIBLE);
        if (layoutDial.getVisibility() == View.GONE) {
            layoutDial.setVisibility(View.VISIBLE);
            Animation animation = new TranslateAnimation(0, 0,
                    200 * metrics.density + 0.5f + displayHeight * 0.32f, 0);
            animation.setDuration(300);
            layoutDial.startAnimation(animation);
        }
        sensorManager.unregisterListener(sensorListener, sensor);

    } else {
        sensorManager.registerListener(sensorListener, sensor, SensorManager.SENSOR_DELAY_UI);
        if (tbDial.isChecked())
            tbDial.setChecked(false);
        if (!tbConsoleControl.isChecked())
            tbConsoleControl.setChecked(true);
        if (layoutDial.getVisibility() != View.GONE) {
            Animation animation = new TranslateAnimation(0, 0, 0,
                    200 * metrics.density + 0.5f + displayHeight * 0.32f);
            animation.setDuration(200);
            layoutDial.startAnimation(animation);
            layoutDial.setVisibility(View.GONE);
        }
        if (containViewPager.getVisibility() != View.GONE)
            containViewPager.setVisibility(View.GONE);
        if (containConsoleControl.getVisibility() == View.GONE)
            containConsoleControl.setVisibility(View.VISIBLE);
    }
}

From source file:com.juick.android.MainActivity.java

public void closeNavigationMenu(boolean animate, boolean immediate) {
    if (!isNavigationMenuShown())
        return;/*from w  ww.ja v a 2  s.c  o m*/
    final ViewGroup navigationPanel = (ViewGroup) findViewById(R.id.navigation_panel);
    final View frag = findViewById(R.id.messagesfragment);
    final DragSortListView navigationList = (DragSortListView) findViewById(R.id.navigation_list);
    if (navigationList.isDragEnabled()) {
        navigationList.setDragEnabled(false);
        updateNavigation();
    }
    if (animate) {
        final AnimationSet set = new AnimationSet(true);
        TranslateAnimation translate = new TranslateAnimation(0, -navigationPanel.getWidth(), 0, 0);
        translate.setFillAfter(false);
        translate.setFillEnabled(true);
        translate.setDuration(400);
        set.addAnimation(translate);
        set.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                navigationMenuShown = false;
                frag.clearAnimation();
                layoutNavigationPane();
                //navigationPanel.setVisibility(View.INVISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                //To change body of implemented methods use File | Settings | File Templates.
            }
        });
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                frag.startAnimation(set);
                getActivity().findViewById(R.id.layout_container).invalidate();
            }
        }, immediate ? 1 : 200); // to smooth the slide

    } else {
        navigationMenuShown = false;
        layoutNavigationPane();
    }
}