@Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup rootView =
        (ViewGroup) inflater.inflate(R.layout.fragment_sale_skidkaonline, container, false);
    setHasOptionsMenu(true);
    setRetainInstance(true);

    sale = getArguments().getParcelable(CURRENT_SALE_TAG);

    progressBar = (CircularProgressView) rootView.findViewById(R.id.fragment_sale_progressbar);
    imageView = (SubsamplingScaleImageView) rootView.findViewById(R.id.fragment_sale_imageview);
    imageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CUSTOM);
    imageView.setMaxScale(getResources().getDimension(R.dimen.image_maximum_scale));

    File smallFile = ImageLoader.getInstance().getDiskCache().get(sale.getSmallImageUrl());
    if (smallFile != null) {
      imageView.setImage(ImageSource.uri(smallFile.getAbsolutePath()));
      loadBigImage();
    } else {
      ImageLoader.getInstance()
          .loadImage(
              sale.getSmallImageUrl(),
              null,
              UIL.getScaleImageOptions(),
              new ImageLoadingListener() {
                @Override
                public void onLoadingStarted(String s, View view) {
                  progressBar.setVisibility(View.VISIBLE);
                }

                @Override
                public void onLoadingFailed(String s, View view, FailReason failReason) {
                  progressBar.setVisibility(View.GONE);
                }

                @Override
                public void onLoadingComplete(String s, View view, Bitmap bitmap) {
                  File smallFile =
                      ImageLoader.getInstance().getDiskCache().get(sale.getSmallImageUrl());
                  if (smallFile != null) {
                    imageView.setImage(ImageSource.uri(smallFile.getAbsolutePath()));
                  }
                  bitmap.recycle();
                  loadBigImage();
                }

                @Override
                public void onLoadingCancelled(String s, View view) {}
              },
              new ImageLoadingProgressListener() {
                @Override
                public void onProgressUpdate(String s, View view, int progress, int size) {
                  progressBar.setProgress(progress * 500 / size);
                }
              });
    }
    return rootView;
  }
  private void loadBigImage() {
    ImageLoader.getInstance()
        .loadImage(
            sale.getImageUrl(),
            null,
            UIL.getScaleImageOptions(),
            new ImageLoadingListener() {
              @Override
              public void onLoadingStarted(String s, View view) {
                progressBar.setVisibility(View.VISIBLE);
              }

              @Override
              public void onLoadingFailed(String s, View view, FailReason failReason) {
                progressBar.setVisibility(View.GONE);
              }

              @Override
              public void onLoadingComplete(String s, View view, Bitmap bitmap) {
                File file = ImageLoader.getInstance().getDiskCache().get(sale.getImageUrl());
                if (file != null) {
                  imageView.setImage(ImageSource.uri(file.getAbsolutePath()));
                }
                progressBar.setVisibility(View.GONE);
              }

              @Override
              public void onLoadingCancelled(String s, View view) {}
            },
            new ImageLoadingProgressListener() {
              @Override
              public void onProgressUpdate(String s, View view, int progress, int size) {
                progressBar.setProgress(500 + progress * 500 / size);
              }
            });
  }