use of com.mixiaoxiao.android.youdaofanyi.MxxYoudaoFanyiManager 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);
}
});
}
Aggregations