Search in sources :

Example 1 with IWeiciyuanDrawable

use of org.qii.weiciyuan.support.asyncdrawable.IWeiciyuanDrawable 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);
    }
}
Also used : AnimationRect(org.qii.weiciyuan.support.lib.AnimationRect) ArrayList(java.util.ArrayList) Intent(android.content.Intent) ImageView(android.widget.ImageView) TimeLineAvatarImageView(org.qii.weiciyuan.support.lib.TimeLineAvatarImageView) ImageView(android.widget.ImageView) View(android.view.View) ListViewMiddleMsgLoadingView(org.qii.weiciyuan.support.lib.ListViewMiddleMsgLoadingView) AbsListView(android.widget.AbsListView) TimeLineAvatarImageView(org.qii.weiciyuan.support.lib.TimeLineAvatarImageView) TextView(android.widget.TextView) TimeTextView(org.qii.weiciyuan.support.lib.TimeTextView) ListView(android.widget.ListView) TextPaint(android.text.TextPaint) IWeiciyuanDrawable(org.qii.weiciyuan.support.asyncdrawable.IWeiciyuanDrawable)

Example 2 with IWeiciyuanDrawable

use of org.qii.weiciyuan.support.asyncdrawable.IWeiciyuanDrawable 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);
            }
        }
    }
}
Also used : AnimationRect(org.qii.weiciyuan.support.lib.AnimationRect) ArrayList(java.util.ArrayList) Intent(android.content.Intent) ImageView(android.widget.ImageView) WeiboDetailImageView(org.qii.weiciyuan.support.lib.WeiboDetailImageView) ProfileTopAvatarImageView(org.qii.weiciyuan.support.lib.ProfileTopAvatarImageView) MsgDetailReadWorker(org.qii.weiciyuan.support.asyncdrawable.MsgDetailReadWorker) ImageView(android.widget.ImageView) WeiboDetailImageView(org.qii.weiciyuan.support.lib.WeiboDetailImageView) View(android.view.View) AdapterView(android.widget.AdapterView) PullToRefreshListView(org.qii.weiciyuan.support.lib.pulltorefresh.PullToRefreshListView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) ProfileTopAvatarImageView(org.qii.weiciyuan.support.lib.ProfileTopAvatarImageView) IWeiciyuanDrawable(org.qii.weiciyuan.support.asyncdrawable.IWeiciyuanDrawable)

Example 3 with IWeiciyuanDrawable

use of org.qii.weiciyuan.support.asyncdrawable.IWeiciyuanDrawable in project weiciyuan by qii.

the class DMConversationAdapter method buildAvatar.

protected void buildAvatar(TimeLineAvatarImageView view, int position, final UserBean user) {
    ((IWeiciyuanDrawable) view).checkVerified(user);
    String image_url = user.getProfile_image_url();
    if (!TextUtils.isEmpty(image_url)) {
        view.setVisibility(View.VISIBLE);
        commander.downloadAvatar(view.getImageView(), user, (AbstractTimeLineFragment) fragment);
        view.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), UserInfoActivity.class);
                intent.putExtra("token", GlobalContext.getInstance().getSpecialToken());
                intent.putExtra("user", user);
                getActivity().startActivity(intent);
            }
        });
    } else {
        view.setVisibility(View.GONE);
    }
}
Also used : UserInfoActivity(org.qii.weiciyuan.ui.userinfo.UserInfoActivity) Intent(android.content.Intent) TimeLineAvatarImageView(org.qii.weiciyuan.support.lib.TimeLineAvatarImageView) TextView(android.widget.TextView) View(android.view.View) ListView(android.widget.ListView) IWeiciyuanDrawable(org.qii.weiciyuan.support.asyncdrawable.IWeiciyuanDrawable)

Example 4 with IWeiciyuanDrawable

use of org.qii.weiciyuan.support.asyncdrawable.IWeiciyuanDrawable in project weiciyuan by qii.

the class DMUserListAdapter method buildAvatar.

protected void buildAvatar(ImageView view, int position, final UserBean user) {
    ((IWeiciyuanDrawable) view).checkVerified(user);
    String image_url = user.getProfile_image_url();
    if (!TextUtils.isEmpty(image_url)) {
        view.setVisibility(View.VISIBLE);
        commander.downloadAvatar(view, user, (AbstractTimeLineFragment) fragment);
        view.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), UserInfoActivity.class);
                intent.putExtra("token", GlobalContext.getInstance().getSpecialToken());
                intent.putExtra("user", user);
                getActivity().startActivity(intent);
            }
        });
    } else {
        view.setVisibility(View.GONE);
    }
}
Also used : UserInfoActivity(org.qii.weiciyuan.ui.userinfo.UserInfoActivity) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TimeLineAvatarImageView(org.qii.weiciyuan.support.lib.TimeLineAvatarImageView) TextView(android.widget.TextView) ListView(android.widget.ListView) IWeiciyuanDrawable(org.qii.weiciyuan.support.asyncdrawable.IWeiciyuanDrawable)

Example 5 with IWeiciyuanDrawable

use of org.qii.weiciyuan.support.asyncdrawable.IWeiciyuanDrawable in project weiciyuan by qii.

the class AbstractAppListAdapter method interruptPicDownload.

protected void interruptPicDownload(IWeiciyuanDrawable view) {
    Drawable drawable = view.getImageView().getDrawable();
    if (drawable instanceof PictureBitmapDrawable) {
        PictureBitmapDrawable downloadedDrawable = (PictureBitmapDrawable) drawable;
        IPictureWorker worker = downloadedDrawable.getBitmapDownloaderTask();
        if (worker != null) {
            ((MyAsyncTask) worker).cancel(true);
        }
    }
    view.getImageView().setImageDrawable(null);
}
Also used : PictureBitmapDrawable(org.qii.weiciyuan.support.asyncdrawable.PictureBitmapDrawable) PictureBitmapDrawable(org.qii.weiciyuan.support.asyncdrawable.PictureBitmapDrawable) IWeiciyuanDrawable(org.qii.weiciyuan.support.asyncdrawable.IWeiciyuanDrawable) Drawable(android.graphics.drawable.Drawable) IPictureWorker(org.qii.weiciyuan.support.asyncdrawable.IPictureWorker) MyAsyncTask(org.qii.weiciyuan.support.lib.MyAsyncTask)

Aggregations

IWeiciyuanDrawable (org.qii.weiciyuan.support.asyncdrawable.IWeiciyuanDrawable)5 Intent (android.content.Intent)4 View (android.view.View)4 ListView (android.widget.ListView)4 TextView (android.widget.TextView)4 ImageView (android.widget.ImageView)3 TimeLineAvatarImageView (org.qii.weiciyuan.support.lib.TimeLineAvatarImageView)3 AbsListView (android.widget.AbsListView)2 ArrayList (java.util.ArrayList)2 AnimationRect (org.qii.weiciyuan.support.lib.AnimationRect)2 UserInfoActivity (org.qii.weiciyuan.ui.userinfo.UserInfoActivity)2 Drawable (android.graphics.drawable.Drawable)1 TextPaint (android.text.TextPaint)1 AdapterView (android.widget.AdapterView)1 IPictureWorker (org.qii.weiciyuan.support.asyncdrawable.IPictureWorker)1 MsgDetailReadWorker (org.qii.weiciyuan.support.asyncdrawable.MsgDetailReadWorker)1 PictureBitmapDrawable (org.qii.weiciyuan.support.asyncdrawable.PictureBitmapDrawable)1 ListViewMiddleMsgLoadingView (org.qii.weiciyuan.support.lib.ListViewMiddleMsgLoadingView)1 MyAsyncTask (org.qii.weiciyuan.support.lib.MyAsyncTask)1 ProfileTopAvatarImageView (org.qii.weiciyuan.support.lib.ProfileTopAvatarImageView)1