/**
  * Adds load image task to execution pool. Image will be returned with {@link
  * ImageLoadingListener#onLoadingComplete(String, android.view.View, android.graphics.Bitmap)}
  * callback}. <br>
  * <b>NOTE:</b> {@link #init(ImageLoaderConfiguration)} method must be called before this method
  * call
  *
  * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
  * @param targetImageSize Minimal size for {@link Bitmap} which will be returned in {@linkplain
  *     ImageLoadingListener#onLoadingComplete(String, android.view.View, android.graphics.Bitmap)}
  *     callback}. Downloaded image will be decoded and scaled to {@link Bitmap} of the size which
  *     is <b>equal or larger</b> (usually a bit larger) than incoming targetImageSize.
  * @param options {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions Options}
  *     for image decoding and displaying. If <b>null</b> - default display image options
  *     {@linkplain
  *     ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions) from
  *     configuration} will be used.<br>
  * @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener
  *     fires events on UI thread if this method is called on UI thread.
  * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called
  *     before
  */
 public void loadImage(
     String uri,
     ImageSize targetImageSize,
     DisplayImageOptions options,
     ImageLoadingListener listener) {
   loadImage(uri, targetImageSize, options, listener, null);
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_profile_detail, container, false);

    // Initializes an imageView
    imgview = ((ImageView) rootView.findViewById(R.id.imageDetail));
    if (mItem.picurl != "") {

      // Fills the imageView with universalImageLoader
      ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getActivity()).build();
      imageLoader = ImageLoader.getInstance();
      imageLoader.init(config);
      imageLoader.loadImage(
          mItem.picurl,
          new SimpleImageLoadingListener() {
            @Override
            public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
              imgview.setImageBitmap(loadedImage);
            }
          });
    } else imgview.setImageResource(R.drawable.nopic);
    if (mItem != null) {
      ((TextView) rootView.findViewById(R.id.textUsername)).setText('[' + mItem.username + ']');
      ((TextView) rootView.findViewById(R.id.textMajor)).setText(mItem.dept);
      ((TextView) rootView.findViewById(R.id.textBoxNum)).setText(mItem.boxno);
      ((TextView) rootView.findViewById(R.id.textPhone)).setText(mItem.phonenum);
      ((TextView) rootView.findViewById(R.id.textAddress)).setText(mItem.campusaddress);
      ((TextView) rootView.findViewById(R.id.textName))
          .setText(mItem.lastName + " " + mItem.firstName);
      // ((TextView) rootView.findViewById(R.id.textAll)).setText(mItem.toString());
    }
    return rootView;
  }
예제 #3
0
 public static void loadImage(String path, ImageLoadingListener listener) {
   ImageLoader loader = ImageLoader.getInstance();
   try {
     loader.loadImage(path, DEFAULT_DISPLAY_IMAGE_OPTIONS, listener);
   } catch (OutOfMemoryError e) {
     e.printStackTrace();
   }
 }
  /**
   * Loads and decodes image synchronously.<br>
   * <b>NOTE:</b> {@link #init(ImageLoaderConfiguration)} method must be called before this method
   * call
   *
   * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
   * @param targetImageSize Minimal size for {@link Bitmap} which will be returned. Downloaded image
   *     will be decoded and scaled to {@link Bitmap} of the size which is <b>equal or larger</b>
   *     (usually a bit larger) than incoming targetImageSize.
   * @param options {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions Options}
   *     for image decoding and scaling. If <b>null</b> - default display image options {@linkplain
   *     ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions) from
   *     configuration} will be used.
   * @return Result image Bitmap. Can be <b>null</b> if image loading/decoding was failed or
   *     cancelled.
   * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called
   *     before
   */
  public Bitmap loadImageSync(String uri, ImageSize targetImageSize, DisplayImageOptions options) {
    if (options == null) {
      options = configuration.defaultDisplayImageOptions;
    }
    options = new DisplayImageOptions.Builder().cloneFrom(options).syncLoading(true).build();

    SyncImageLoadingListener listener = new SyncImageLoadingListener();
    loadImage(uri, targetImageSize, options, listener);
    return listener.getLoadedBitmap();
  }
예제 #5
0
  @Override
  public View instantiateItem(ViewGroup container, int position) {
    int index = position % picUrls.size();
    View view = picViews.get(index);
    final ImageView iv_image_browser = (ImageView) view.findViewById(R.id.iv_image_browser);
    PicUrls picUrl = picUrls.get(index);

    String url = picUrl.isShowOriImag() ? picUrl.getOriginal_pic() : picUrl.getBmiddle_pic();

    mImageLoader.loadImage(
        url,
        new ImageLoadingListener() {

          @Override
          public void onLoadingStarted(String imageUri, View view) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            float scale = (float) loadedImage.getHeight() / loadedImage.getWidth();

            int screenWidthPixels = DisplayUtils.getScreenWidthPixels(context);
            int screenHeightPixels = DisplayUtils.getScreenHeightPixels(context);
            int height = (int) (screenWidthPixels * scale);

            if (height < screenHeightPixels) {
              height = screenHeightPixels;
            }

            LayoutParams params = iv_image_browser.getLayoutParams();
            params.height = height;
            params.width = screenWidthPixels;

            iv_image_browser.setImageBitmap(loadedImage);
          }

          @Override
          public void onLoadingCancelled(String imageUri, View view) {
            // TODO Auto-generated method stub

          }
        });

    container.addView(view);
    return view;
  }
예제 #6
0
파일: Album.java 프로젝트: uxrp/Cross
    @Override
    public View instantiateItem(ViewGroup container, int position) {
      View item = LayoutInflater.from(mContext).inflate(R.layout.slider_item, null);
      container.addView(
          item, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
      PhotoView photoView = (PhotoView) item.findViewById(R.id.photoView);
      final ProgressBar progressBar = (ProgressBar) item.findViewById(R.id.loading);
      imageLoader.displayImage(
          images.get(position).getUrl(),
          photoView,
          new SimpleImageLoadingListener() {
            @Override
            public void onLoadingStarted(String imageUri, View view) {
              progressBar.setVisibility(View.VISIBLE);
            }

            @Override
            public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
              progressBar.setVisibility(View.GONE);
            }

            @Override
            public void onLoadingCancelled(String imageUri, View view) {
              progressBar.setVisibility(View.GONE);
            }

            @Override
            public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
              progressBar.setVisibility(View.GONE);
            }
          });
      // 牛逼的预加载
      if (position + 1 < images.size()) {
        imageLoader.loadImage(images.get(position + 1).getUrl(), null);
      }
      if (position > 0 && position - 1 < images.size()) {
        imageLoader.loadImage(images.get(position - 1).getUrl(), null);
      }

      return item;
    }
  private void changeBackgroundImage() {
    VideoContentInfo videoInfo = (VideoContentInfo) adapter.getSelectedItem();

    if (videoInfo.getBackgroundURL() == null) {
      return;
    }

    View fanArt = context.findViewById(R.id.fanArt);
    String transcodingURL = plexFactory.getImageURL(videoInfo.getBackgroundURL(), 1280, 720);
    imageLoader.loadImage(
        transcodingURL,
        new ImageSize(1280, 720),
        new SerenityBackgroundLoaderListener(fanArt, R.drawable.movies));
  }
 @Override
 public View instantiateItem(ViewGroup container, int position) {
   final TouchImageView img = new TouchImageView(container.getContext());
   loader.loadImage(
       imgs.get(position),
       ImageUtil.getImageOption(R.mipmap.icon_menu_4),
       new SimpleImageLoadingListener() {
         @Override
         public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
           img.setImageBitmap(loadedImage);
         }
       });
   container.addView(
       img, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
   return img;
 }
예제 #9
0
 /**
  * Adds load image task to execution pool. Image will be returned with {@link
  * ImageLoadingListener#onLoadingComplete(String, android.view.View, android.graphics.Bitmap)}
  * callback}.<br>
  * <b>NOTE:</b> {@link #init(ImageLoaderConfiguration)} method must be called before this method
  * call
  *
  * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
  * @param options {@linkplain DisplayImageOptions Display image options} for image displaying. If
  *     <b>null</b> - default display image options {@linkplain
  *     ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions) from
  *     configuration} will be used.<br>
  *     Incoming options should contain {@link FakeBitmapDisplayer} as displayer.
  * @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener
  *     fires events on UI thread.
  * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called
  *     before
  */
 public void loadImage(String uri, DisplayImageOptions options, ImageLoadingListener listener) {
   loadImage(uri, null, options, listener);
 }
예제 #10
0
 /**
  * Adds load image task to execution pool. Image will be returned with {@link
  * ImageLoadingListener#onLoadingComplete(String, android.view.View, android.graphics.Bitmap)}
  * callback}.<br>
  * <b>NOTE:</b> {@link #init(ImageLoaderConfiguration)} method must be called before this method
  * call
  *
  * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
  * @param minImageSize Minimal size for {@link Bitmap} which will be returned in {@linkplain
  *     ImageLoadingListener#onLoadingComplete(String, android.view.View, android.graphics.Bitmap)}
  *     callback}. Downloaded image will be decoded and scaled to {@link Bitmap} of the size which
  *     is <b>equal or larger</b> (usually a bit larger) than incoming minImageSize .
  * @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener
  *     fires events on UI thread.
  * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called
  *     before
  */
 public void loadImage(String uri, ImageSize minImageSize, ImageLoadingListener listener) {
   loadImage(uri, minImageSize, null, listener);
 }
예제 #11
0
 /**
  * Adds load image task to execution pool. Image will be returned with {@link
  * ImageLoadingListener#onLoadingComplete(String, android.view.View, android.graphics.Bitmap)}
  * callback}.<br>
  * <b>NOTE:</b> {@link #init(ImageLoaderConfiguration)} method must be called before this method
  * call
  *
  * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
  * @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener
  *     fires events on UI thread.
  * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called
  *     before
  */
 public void loadImage(String uri, ImageLoadingListener listener) {
   loadImage(uri, null, null, listener);
 }
  @Override
  public View getView(final int position, View v, ViewGroup parent) {
    // TODO Auto-generated method stub
    final LapakViewHolder holder;
    // final MessageLine message = (MessageLine) getItem(arg0);
    if (v == null) {
      LayoutInflater li =
          (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      v = li.inflate(R.layout.view_product_list_grid_item, parent, false);
      holder = new LapakViewHolder();
      holder.prodIcon = (ImageView) v.findViewById(R.id.item_image_lapak);
      holder.prodName = (TextView) v.findViewById(R.id.title);
      holder.prodPrice = (TextView) v.findViewById(R.id.price);
      holder.prodStock = (TextView) v.findViewById(R.id.stock);
      holder.check = (CheckBox) v.findViewById(R.id.checkBox1);

      v.setTag(holder);
    } else {
      holder = (LapakViewHolder) v.getTag();
    }

    final SoldProduct p = (SoldProduct) getItem(position);
    ImageLoader imageLoader = ImageLoader.getInstance();

    ImageSize targetSize = new ImageSize(200, 200); // result Bitmap will be
    // fit to this size
    imageLoader.loadImage(
        p.getImagesURL().get(0),
        targetSize,
        options,
        new SimpleImageLoadingListener() {
          @Override
          public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            holder.prodIcon.setImageBitmap(loadedImage);
          }
        });
    holder.prodName.setText(p.getName());
    holder.prodPrice.setText("Rp " + p.getPrice());
    holder.prodStock.setText(p.getStock() + " pcs");
    holder.check.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View arg0) {
            checked.put(p.getId(), ((CheckBox) arg0).isChecked());
          }
        });
    if (showCheckboxes) {
      holder.check.setVisibility(CheckBox.VISIBLE);
      if (checked.containsKey(p.getId())) {
        holder.check.setChecked(checked.get(p.getId()));
      } else {
        holder.check.setChecked(false);
      }
      v.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
              holder.check.setChecked(!holder.check.isChecked());
              checked.put(p.getId(), holder.check.isChecked());
            }
          });

      v.setOnLongClickListener(null);
    } else {
      holder.check.setVisibility(CheckBox.INVISIBLE);
      v.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              Intent i = new Intent(context, ProductDetail.class);
              i.putExtra("id", p.getId());
              context.startActivity(i);
            }
          });

      v.setOnLongClickListener(
          new OnLongClickListener() {

            @Override
            public boolean onLongClick(View v) {
              showCheckboxes();
              boolean isChecked = false;
              if (checked.containsKey(p.getId())) {
                isChecked = checked.get(p.getId());
              }
              holder.check.setChecked(isChecked);
              notifyDataSetChanged();
              ra.startActionMode(((LapakTidakDijualFragment) fragment).getCallback());
              return false;
            }
          });
    }

    return v;
  }
 /**
  * Adds load image task to execution pool. Image will be returned with {@link
  * ImageLoadingListener#onLoadingComplete(String, android.view.View, android.graphics.Bitmap)}
  * callback}. <br>
  * <b>NOTE:</b> {@link #init(ImageLoaderConfiguration)} method must be called before this method
  * call
  *
  * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
  * @param targetImageSize Minimal size for {@link Bitmap} which will be returned in {@linkplain
  *     ImageLoadingListener#onLoadingComplete(String, android.view.View, android.graphics.Bitmap)}
  *     callback}. Downloaded image will be decoded and scaled to {@link Bitmap} of the size which
  *     is <b>equal or larger</b> (usually a bit larger) than incoming targetImageSize.
  * @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener
  *     fires events on UI thread if this method is called on UI thread.
  * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called
  *     before
  */
 public void loadImage(String uri, ImageSize targetImageSize, ImageLoadingListener listener) {
   loadImage(uri, targetImageSize, null, listener, null);
 }
예제 #14
0
 public void loadImage(String url, int width, int height, SimpleImageLoadingListener listener) {
   imageLoader.loadImage(url, new ImageSize(width, height), listener);
 }
예제 #15
0
 public void loadImage(String url, SimpleImageLoadingListener listener) {
   imageLoader.loadImage(url, listener);
 }