본문 바로가기
프로그래밍/Android

Android getRoundedBitmapFromServer

by CaffeLatte 2015. 2. 25.

public static void getRoundedBitmapFromServer(final ImageView targetIcon, String downloadUrl, final int iconWidth, final int iconHeight)

    {

        ImageLoader imageLoader = ImageLoader.getInstance();


        DisplayImageOptions options = new DisplayImageOptions.Builder()

                .cacheInMemory(true)

                .resetViewBeforeLoading(true)

                .build();


        SimpleImageLoadingListener imageDownloadListener = new SimpleImageLoadingListener()

        {

            @Override

            public void onLoadingStarted(String imageUri, View view)

            {

            }


            @Override

            public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage)

            {

                ((ImageView) view).setImageBitmap(BeehiveUtils.getRoundedBitmap(loadedImage, iconWidth, iconHeight));

//                targetIcon.setImageBitmap(BeehiveUtils.getRoundedBitmap(loadedImage, iconWidth, iconHeight));

                /**

                 * following show the difference between original image and cropped image

                 **/

//                ((ImageView) view).setBackgroundDrawable(new BitmapDrawable(activity.getResources(), loadedImage));

            }


            @Override

            public void onLoadingFailed(String imageUri, View view, FailReason failReason)

            {

            }


            @Override

            public void onLoadingCancelled(String imageUri, View view)

            {


            }

        };


        imageLoader.displayImage(downloadUrl, targetIcon, options, imageDownloadListener);

//        imageLoader.loadImage(downloadUrl, options, imageDownloadListener);

    }

댓글