use of com.mixiaoxiao.android.youdaofanyi.YoudaoFanyiItem in project 9GAG by Mixiaoxiao.
the class ImageFragment method showTitleTextViewTranslate.
public static void showTitleTextViewTranslate(final Context context, String content, final MxxYoudaoFanyiManager fanyiManager) {
String[] words = content.split(" ");
// ArrayList<String> strings = (ArrayList<String>) Arrays.asList(words);
ArrayList<String> strings = new ArrayList<String>(words.length + 1);
strings.add(content);
for (String str : words) {
strings.add(str.replaceAll(",", ""));
}
Dialog dialog = MxxDialogUtil.creatListViewDialog(context, MxxTextUtil.getTypefaceSpannableString(context, "Select a text to translate", MxxTextUtil.Roboto_Light), strings, "Cancle", new MxxDialogUtil.MxxDialogListener() {
@Override
public void onRightBtnClick() {
}
@Override
public void onListItemClick(int position, String string) {
fanyiManager.fanyi(string, new MxxYoudaoFanyiManager.YoudaoFanyiListener() {
@Override
public void onSuccess(YoudaoFanyiItem fanyiItem) {
MxxDialogUtil.creatConfirmDialog(context, MxxTextUtil.getTypefaceSpannableString(context, "Translation", MxxTextUtil.Roboto_Light), fanyiItem.getTranslationContent(true), "OK", null, true, true, null).show();
}
@Override
public void onError(String errMsg) {
MxxToastUtil.showToast(context, "Translate error. \n" + errMsg);
}
}, MxxDialogUtil.creatPorgressDialog(context, null, MxxTextUtil.getTypefaceSpannableString(context, "Translating...", MxxTextUtil.Roboto_Light, false), false, true, null));
}
@Override
public void onLeftBtnClick() {
}
@Override
public void onCancel() {
}
@Override
public void onListItemLongClick(int position, String string) {
MxxTextUtil.copyString(context, string);
}
});
dialog.show();
}
use of com.mixiaoxiao.android.youdaofanyi.YoudaoFanyiItem 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