use of org.qii.weiciyuan.support.lib.AnimationRect in project weiciyuan by qii.
the class ContainerFragment method displayPicture.
private void displayPicture(String path, boolean animateIn) {
GalleryAnimationActivity activity = (GalleryAnimationActivity) getActivity();
AnimationRect rect = getArguments().getParcelable("rect");
boolean firstOpenPage = getArguments().getBoolean("firstOpenPage");
if (firstOpenPage) {
if (animateIn) {
ObjectAnimator animator = activity.showBackgroundAnimate();
animator.start();
} else {
activity.showBackgroundImmediately();
}
getArguments().putBoolean("firstOpenPage", false);
}
if (!ImageUtility.isThisBitmapTooLargeToRead(path)) {
Fragment fragment = null;
if (ImageUtility.isThisPictureGif(path)) {
fragment = GifPictureFragment.newInstance(path, rect, animateIn);
} else {
fragment = GeneralPictureFragment.newInstance(path, rect, animateIn);
}
getChildFragmentManager().beginTransaction().replace(R.id.child, fragment).commitAllowingStateLoss();
} else {
LargePictureFragment fragment = LargePictureFragment.newInstance(path, animateIn);
getChildFragmentManager().beginTransaction().replace(R.id.child, fragment).commitAllowingStateLoss();
}
}
use of org.qii.weiciyuan.support.lib.AnimationRect in project weiciyuan by qii.
the class AbstractAppListAdapter method buildMultiPic.
protected void buildMultiPic(final MessageBean msg, final GridLayout gridLayout) {
if (SettingUtility.isEnablePic()) {
gridLayout.setVisibility(View.VISIBLE);
final int count = msg.getPicCount();
for (int i = 0; i < count; i++) {
final IWeiciyuanDrawable pic = (IWeiciyuanDrawable) gridLayout.getChildAt(i);
pic.setVisibility(View.VISIBLE);
if (SettingUtility.getEnableBigPic()) {
TimeLineBitmapDownloader.getInstance().displayMultiPicture(pic, msg.getHighPicUrls().get(i), FileLocationMethod.picture_large, (AbstractTimeLineFragment) fragment);
} else {
TimeLineBitmapDownloader.getInstance().displayMultiPicture(pic, msg.getThumbnailPicUrls().get(i), FileLocationMethod.picture_thumbnail, (AbstractTimeLineFragment) fragment);
}
final int finalI = i;
pic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ArrayList<AnimationRect> animationRectArrayList = new ArrayList<AnimationRect>();
for (int i = 0; i < count; i++) {
final IWeiciyuanDrawable pic = (IWeiciyuanDrawable) gridLayout.getChildAt(i);
ImageView imageView = (ImageView) pic;
if (imageView.getVisibility() == View.VISIBLE) {
AnimationRect rect = AnimationRect.buildFromImageView(imageView);
animationRectArrayList.add(rect);
}
}
Intent intent = GalleryAnimationActivity.newIntent(msg, animationRectArrayList, finalI);
getActivity().startActivity(intent);
}
});
}
if (count < 9) {
ImageView pic;
switch(count) {
case 8:
pic = (ImageView) gridLayout.getChildAt(8);
pic.setVisibility(View.INVISIBLE);
break;
case 7:
for (int i = 8; i > 6; i--) {
pic = (ImageView) gridLayout.getChildAt(i);
pic.setVisibility(View.INVISIBLE);
}
break;
case 6:
for (int i = 8; i > 5; i--) {
pic = (ImageView) gridLayout.getChildAt(i);
pic.setVisibility(View.GONE);
}
break;
case 5:
for (int i = 8; i > 5; i--) {
pic = (ImageView) gridLayout.getChildAt(i);
pic.setVisibility(View.GONE);
}
pic = (ImageView) gridLayout.getChildAt(5);
pic.setVisibility(View.INVISIBLE);
break;
case 4:
for (int i = 8; i > 5; i--) {
pic = (ImageView) gridLayout.getChildAt(i);
pic.setVisibility(View.GONE);
}
pic = (ImageView) gridLayout.getChildAt(5);
pic.setVisibility(View.INVISIBLE);
pic = (ImageView) gridLayout.getChildAt(4);
pic.setVisibility(View.INVISIBLE);
break;
case 3:
for (int i = 8; i > 2; i--) {
pic = (ImageView) gridLayout.getChildAt(i);
pic.setVisibility(View.GONE);
}
break;
case 2:
for (int i = 8; i > 2; i--) {
pic = (ImageView) gridLayout.getChildAt(i);
pic.setVisibility(View.GONE);
}
pic = (ImageView) gridLayout.getChildAt(2);
pic.setVisibility(View.INVISIBLE);
break;
}
}
} else {
gridLayout.setVisibility(View.GONE);
}
}
use of org.qii.weiciyuan.support.lib.AnimationRect in project weiciyuan by qii.
the class BrowserWeiboMsgFragment method displayPictures.
private void displayPictures(final MessageBean msg, final GridLayout layout, WeiboDetailImageView view, boolean refreshPic) {
if (!msg.isMultiPics()) {
view.setVisibility(View.VISIBLE);
if (Utility.isTaskStopped(picTask) && refreshPic) {
picTask = new MsgDetailReadWorker(view, msg);
picTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
} else {
picTask.setView(view);
}
} else {
layout.setVisibility(View.VISIBLE);
final int count = msg.getPicCount();
for (int i = 0; i < count; i++) {
final IWeiciyuanDrawable pic = (IWeiciyuanDrawable) layout.getChildAt(i);
pic.setVisibility(View.VISIBLE);
if (SettingUtility.getEnableBigPic()) {
TimeLineBitmapDownloader.getInstance().displayMultiPicture(pic, msg.getHighPicUrls().get(i), FileLocationMethod.picture_large);
} else {
TimeLineBitmapDownloader.getInstance().displayMultiPicture(pic, msg.getMiddlePicUrls().get(i), FileLocationMethod.picture_bmiddle);
}
final int finalI = i;
pic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ArrayList<AnimationRect> animationRectArrayList = new ArrayList<AnimationRect>();
for (int i = 0; i < count; i++) {
final IWeiciyuanDrawable pic = (IWeiciyuanDrawable) layout.getChildAt(i);
ImageView imageView = (ImageView) pic;
if (imageView.getVisibility() == View.VISIBLE) {
AnimationRect rect = AnimationRect.buildFromImageView(imageView);
animationRectArrayList.add(rect);
}
}
Intent intent = GalleryAnimationActivity.newIntent(msg, animationRectArrayList, finalI);
getActivity().startActivity(intent);
}
});
}
if (count < 9) {
for (int i = count; i < 9; i++) {
ImageView pic = (ImageView) layout.getChildAt(i);
pic.setVisibility(View.GONE);
}
}
}
}
use of org.qii.weiciyuan.support.lib.AnimationRect in project weiciyuan by qii.
the class MsgDetailReadWorker method onPostExecute.
@Override
protected void onPostExecute(String path) {
retry.setVisibility(View.INVISIBLE);
pb.setIndeterminate(true);
if (!TextUtils.isEmpty(path)) {
if (!path.endsWith(".gif")) {
readNormalPic(path);
} else {
view.setGif(path);
}
pb.setVisibility(View.INVISIBLE);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AnimationRect rect = AnimationRect.buildFromImageView(view.getImageView());
ArrayList<AnimationRect> animationRectArrayList = new ArrayList<AnimationRect>();
animationRectArrayList.add(rect);
Intent intent = GalleryAnimationActivity.newIntent(msg, animationRectArrayList, 0);
GlobalContext.getInstance().getActivity().startActivity(intent);
}
});
} else {
pb.setVisibility(View.INVISIBLE);
view.setImageDrawable(new ColorDrawable(Color.TRANSPARENT));
retry.setVisibility(View.VISIBLE);
retry.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MsgDetailReadWorker picTask = new MsgDetailReadWorker(view, msg);
picTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
}
});
}
}
use of org.qii.weiciyuan.support.lib.AnimationRect in project weiciyuan by qii.
the class GeneralPictureFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.gallery_general_layout, container, false);
photoView = (PhotoView) view.findViewById(R.id.animation);
if (SettingUtility.allowClickToCloseGallery()) {
photoView.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
@Override
public void onViewTap(View view, float x, float y) {
getActivity().onBackPressed();
}
});
}
LongClickListener longClickListener = ((ContainerFragment) getParentFragment()).getLongClickListener();
photoView.setOnLongClickListener(longClickListener);
final String path = getArguments().getString("path");
boolean animateIn = getArguments().getBoolean("animationIn");
final AnimationRect rect = getArguments().getParcelable("rect");
if (!animateIn) {
new MyAsyncTask<Void, Bitmap, Bitmap>() {
@Override
protected Bitmap doInBackground(Void... params) {
Bitmap bitmap = ImageUtility.decodeBitmapFromSDCard(path, IMAGEVIEW_SOFT_LAYER_MAX_WIDTH, IMAGEVIEW_SOFT_LAYER_MAX_HEIGHT);
return bitmap;
}
@Override
protected void onPostExecute(Bitmap bitmap) {
super.onPostExecute(bitmap);
photoView.setImageBitmap(bitmap);
}
}.executeOnIO();
return view;
}
final Bitmap bitmap = ImageUtility.decodeBitmapFromSDCard(path, IMAGEVIEW_SOFT_LAYER_MAX_WIDTH, IMAGEVIEW_SOFT_LAYER_MAX_HEIGHT);
photoView.setImageBitmap(bitmap);
final Runnable endAction = new Runnable() {
@Override
public void run() {
Bundle bundle = getArguments();
bundle.putBoolean("animationIn", false);
}
};
photoView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
if (rect == null) {
photoView.getViewTreeObserver().removeOnPreDrawListener(this);
endAction.run();
return true;
}
final Rect startBounds = new Rect(rect.scaledBitmapRect);
final Rect finalBounds = AnimationUtility.getBitmapRectFromImageView(photoView);
if (finalBounds == null) {
photoView.getViewTreeObserver().removeOnPreDrawListener(this);
endAction.run();
return true;
}
float startScale = (float) finalBounds.width() / startBounds.width();
if (startScale * startBounds.height() > finalBounds.height()) {
startScale = (float) finalBounds.height() / startBounds.height();
}
int deltaTop = startBounds.top - finalBounds.top;
int deltaLeft = startBounds.left - finalBounds.left;
photoView.setPivotY((photoView.getHeight() - finalBounds.height()) / 2);
photoView.setPivotX((photoView.getWidth() - finalBounds.width()) / 2);
photoView.setScaleX(1 / startScale);
photoView.setScaleY(1 / startScale);
photoView.setTranslationX(deltaLeft);
photoView.setTranslationY(deltaTop);
photoView.animate().translationY(0).translationX(0).scaleY(1).scaleX(1).setDuration(ANIMATION_DURATION).setInterpolator(new AccelerateDecelerateInterpolator()).withEndAction(endAction);
AnimatorSet animationSet = new AnimatorSet();
animationSet.setDuration(ANIMATION_DURATION);
animationSet.setInterpolator(new AccelerateDecelerateInterpolator());
animationSet.playTogether(ObjectAnimator.ofFloat(photoView, "clipBottom", AnimationRect.getClipBottom(rect, finalBounds), 0));
animationSet.playTogether(ObjectAnimator.ofFloat(photoView, "clipRight", AnimationRect.getClipRight(rect, finalBounds), 0));
animationSet.playTogether(ObjectAnimator.ofFloat(photoView, "clipTop", AnimationRect.getClipTop(rect, finalBounds), 0));
animationSet.playTogether(ObjectAnimator.ofFloat(photoView, "clipLeft", AnimationRect.getClipLeft(rect, finalBounds), 0));
animationSet.start();
photoView.getViewTreeObserver().removeOnPreDrawListener(this);
return true;
}
});
return view;
}
Aggregations