Search in sources :

Example 1 with TopNewsDesPresenterImpl

use of com.looklook.xinghongfei.looklook.presenter.implPresenter.TopNewsDesPresenterImpl in project LookLook by xinghongfei.

the class TopNewsDescribeActivity method initData.

protected void initData() {
    id = getIntent().getStringExtra("docid");
    title = getIntent().getStringExtra("title");
    mTextView.setText(title);
    mImageUrl = getIntent().getStringExtra("image");
    scrollListener = new NestedScrollView.OnScrollChangeListener() {

        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            if (oldScrollY < 168) {
                mShot.setOffset(-oldScrollY);
                mTextView.setOffset(-oldScrollY);
            }
        }
    };
    Glide.with(this).load(mImageUrl).override(width, heigh).listener(glideLoadListener).centerCrop().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(mShot);
    mTopNewsDesPresenter = new TopNewsDesPresenterImpl(this);
    mNest.setOnScrollChangeListener(scrollListener);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        postponeEnterTransition();
        mShot.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

            @Override
            public boolean onPreDraw() {
                mShot.getViewTreeObserver().removeOnPreDrawListener(this);
                startPostponedEnterTransition();
                return true;
            }
        });
    }
    mReturnHomeListener = new AnimUtils.TransitionListenerAdapter() {

        @Override
        public void onTransitionStart(Transition transition) {
            super.onTransitionStart(transition);
            // hide the fab as for some reason it jumps position??  TODO work out why
            mToolbar.animate().alpha(0f).setDuration(100).setInterpolator(new AccelerateInterpolator());
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                mShot.setElevation(1f);
                mToolbar.setElevation(0f);
            }
            mNest.animate().alpha(0f).setDuration(50).setInterpolator(new AccelerateInterpolator());
        }
    };
    mEnterTrasitionListener = new AnimUtils.TransitionListenerAdapter() {

        @Override
        public void onTransitionEnd(Transition transition) {
            super.onTransitionEnd(transition);
            //                    解决5.0 shara element bug
            ValueAnimator valueAnimator = ValueAnimator.ofInt(0, 100).setDuration(100);
            valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    //                            mShot.setOffset((Integer) valueAnimator.getAnimatedValue() * 10);
                    mNest.smoothScrollTo((Integer) valueAnimator.getAnimatedValue() / 10, 0);
                }
            });
            valueAnimator.start();
        //                    mShot.setAlpha(0.5f);
        //                    mShot.animate().alpha(1f).setDuration(800L).start();
        }

        @Override
        public void onTransitionResume(Transition transition) {
            super.onTransitionResume(transition);
        }
    };
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ValueAnimator(android.animation.ValueAnimator) AnimUtils(com.looklook.xinghongfei.looklook.util.AnimUtils) Transition(android.transition.Transition) NestedScrollView(android.support.v4.widget.NestedScrollView) TopNewsDesPresenterImpl(com.looklook.xinghongfei.looklook.presenter.implPresenter.TopNewsDesPresenterImpl) ViewTreeObserver(android.view.ViewTreeObserver)

Aggregations

ValueAnimator (android.animation.ValueAnimator)1 NestedScrollView (android.support.v4.widget.NestedScrollView)1 Transition (android.transition.Transition)1 ViewTreeObserver (android.view.ViewTreeObserver)1 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)1 TopNewsDesPresenterImpl (com.looklook.xinghongfei.looklook.presenter.implPresenter.TopNewsDesPresenterImpl)1 AnimUtils (com.looklook.xinghongfei.looklook.util.AnimUtils)1