Search in sources :

Example 1 with YoudaoFanyiListener

use of com.mixiaoxiao.android.youdaofanyi.MxxYoudaoFanyiManager.YoudaoFanyiListener in project 9GAG by Mixiaoxiao.

the class ImageFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onActivityCreated(savedInstanceState);
    isClose = false;
    // mTranslateManager = new MxxTranslateManager(getActivity());
    mYoudaoFanyiManager = new MxxYoudaoFanyiManager(getActivity());
    mImageTitleTextView.setTypeface(Typeface.createFromAsset(getActivity().getAssets(), "Roboto-Light.ttf"));
    // LayoutTransition transition =new LayoutTransition();
    fadeInAnimator = ObjectAnimator.ofFloat(((View) mImageTitleTextView.getParent()), "alpha", 0f, 1f);
    // fadeInAnimator=ObjectAnimator.ofFloat(mImageTitleTextView, "translationY", -mImageTitleTextView.getHeight(), 0f);
    fadeInAnimator.setDuration(MxxScaleImageView.anim_duration / 2);
    fadeInAnimator.setStartDelay(MxxScaleImageView.anim_duration / 2);
    fadeInAnimator.addListener(new AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
            // mTranslateManager.translateNoDialog(mCurrentFeedItem.getCaption(), new MxxTranslateManager.TranslateListener() {
            // 
            // @Override
            // public void onSuccess(String content, String result) {
            // mImageTitleTextView.setText(content + "\n" + result);
            // }
            // 
            // @Override
            // public void onError() {
            // MxxToastUtil.showToast(getActivity(), "Translate error.");
            // }
            // });
            mYoudaoFanyiManager.fanyi(mCurrentFeedItem.getCaption(), new YoudaoFanyiListener() {

                @Override
                public void onSuccess(YoudaoFanyiItem fanyiItem) {
                    mImageTitleTextView.setText(fanyiItem.getTranslationContent(false));
                }

                @Override
                public void onError(String errMsg) {
                // TODO Auto-generated method stub
                }
            }, null);
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }
    });
    fadeOutAnimator = ObjectAnimator.ofFloat(((View) mImageTitleTextView.getParent()), "alpha", 1f, 0f);
    fadeOutAnimator.setDuration(MxxScaleImageView.anim_duration / 2);
    // fadeOutAnimator.addListener(new AnimatorListener() {
    // 
    // @Override
    // public void onAnimationStart(Animator animation) {}
    // @Override
    // public void onAnimationRepeat(Animator animation) {}
    // 
    // @Override
    // public void onAnimationEnd(Animator animation) {
    // mImageTitleTextView.setVisibility(View.GONE);
    // }
    // 
    // @Override
    // public void onAnimationCancel(Animator animation) {}
    // });
    // transition.setAnimator(LayoutTransition.APPEARING, fadeInAnimator );
    // transition.setAnimator(LayoutTransition.DISAPPEARING, fadeOutAnimator);
    // ((ViewGroup)mImageTitleTextView.getParent()).setLayoutTransition(transition);
    mScaleImageView.setImageViewListener(new ImageViewListener() {

        @Override
        public void onSingleTap() {
            // TODO Auto-generated method stub
            // mScaleImageView.resetScale();
            isClose = true;
            mScaleImageView.startCloseScaleAnimation();
            fadeOutAnimator.start();
        }

        @Override
        public void onScaleEnd() {
            // TODO Auto-generated method stub
            if (isClose) {
                mScaleImageView.setImageDrawable(null);
                rootView.setVisibility(View.GONE);
                ((MainActivity) getActivity()).showImageFragment(null, false, null);
                getActivity().supportInvalidateOptionsMenu();
                isClose = false;
            } else {
                mScaleImageView.setTopCrop(false);
                mScaleImageView.initAttacher();
            // checkGif();
            }
        }
    });
    // mImageTitleTextView.setOnLongClickListener(new View.OnLongClickListener() {
    // 
    // @Override
    // public boolean onLongClick(View v) {
    // // TODO Auto-generated method stub
    // showTitleTextViewTranslate();
    // return true;
    // }
    // });
    mImageTitleTextView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            // showTitleTextViewTranslate(getActivity(), mCurrentFeedItem.getCaption(),mTranslateManager);
            showTitleTextViewTranslate(getActivity(), mCurrentFeedItem.getCaption(), mYoudaoFanyiManager);
        }
    });
}
Also used : AnimatorListener(android.animation.Animator.AnimatorListener) YoudaoFanyiItem(com.mixiaoxiao.android.youdaofanyi.YoudaoFanyiItem) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ImageViewListener(com.mixiaoxiao.android.view.MxxScaleImageView.ImageViewListener) MxxYoudaoFanyiManager(com.mixiaoxiao.android.youdaofanyi.MxxYoudaoFanyiManager) YoudaoFanyiListener(com.mixiaoxiao.android.youdaofanyi.MxxYoudaoFanyiManager.YoudaoFanyiListener) MxxScaleImageView(com.mixiaoxiao.android.view.MxxScaleImageView) ImageView(android.widget.ImageView) MxxBlurView(com.mixiaoxiao.android.blur.MxxBlurView) View(android.view.View) TextView(android.widget.TextView)

Aggregations

Animator (android.animation.Animator)1 AnimatorListener (android.animation.Animator.AnimatorListener)1 ObjectAnimator (android.animation.ObjectAnimator)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 MxxBlurView (com.mixiaoxiao.android.blur.MxxBlurView)1 MxxScaleImageView (com.mixiaoxiao.android.view.MxxScaleImageView)1 ImageViewListener (com.mixiaoxiao.android.view.MxxScaleImageView.ImageViewListener)1 MxxYoudaoFanyiManager (com.mixiaoxiao.android.youdaofanyi.MxxYoudaoFanyiManager)1 YoudaoFanyiListener (com.mixiaoxiao.android.youdaofanyi.MxxYoudaoFanyiManager.YoudaoFanyiListener)1 YoudaoFanyiItem (com.mixiaoxiao.android.youdaofanyi.YoudaoFanyiItem)1