Java Code Examples for com.nostra13.universalimageloader.core.ImageLoader

The following examples show how to use com.nostra13.universalimageloader.core.ImageLoader. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: SimplifyReader   Source File: ImagesDetailActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void initViewsAndEvents() {
    mSmoothImageView.setOriginalInfo(mWidth, mHeight, mLocationX, mLocationY);
    mSmoothImageView.transformIn();

    ImageLoader.getInstance().displayImage(mImageUrl, mSmoothImageView);

    mSmoothImageView.setOnTransformListener(new SmoothImageView.TransformListener() {
        @Override
        public void onTransformComplete(int mode) {
            if (mode == 2) {
                finish();
            }
        }
    });

    mSmoothImageView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
        @Override
        public void onPhotoTap(View view, float v, float v2) {
            mSmoothImageView.transformOut();
        }
    });
}
 
Example 2
Source Project: tup.dota2recipe   Source File: ItemsDetailActivity.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 绑定视图-物品简单数据信息
 * 
 * @param v
 * @param cItem
 * @param cImageLoadOptions
 */
public static void bindItemsItemSimpleView(final View v, final ItemsItem cItem,
        final DisplayImageOptions cImageLoadOptions) {
    if (v == null || cItem == null || cImageLoadOptions == null) {
        return;
    }

    ImageLoader.getInstance().displayImage(
            Utils.getItemsImageUri(cItem.keyName),
            ((ImageView) v.findViewById(R.id.image_items)),
            cImageLoadOptions);

    ((TextView) v.findViewById(R.id.text_items_dname)).setText(cItem.dname);
    ((TextView) v.findViewById(R.id.text_items_dname_l)).setText(cItem.dname_l);
    ((TextView) v.findViewById(R.id.text_items_cost)).setText(String.valueOf(cItem.cost));
}
 
Example 3
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_moment_list);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
            .cacheInMemory(true)
            .cacheOnDisk(true)
            .build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
            .defaultDisplayImageOptions(defaultOptions)
            .build();
    ImageLoader.getInstance().init(config);

    updateSnsList();
}
 
Example 4
Source Project: candybar   Source File: WallpaperPropertiesLoaderTask.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onPostExecute(Boolean aBoolean) {
    super.onPostExecute(aBoolean);
    if (aBoolean && mContext.get() != null && !((AppCompatActivity) mContext.get()).isFinishing()) {
        if (mWallpaper.getSize() <= 0) {
            File target = ImageLoader.getInstance().getDiskCache().get(mWallpaper.getURL());
            if (target.exists()) {
                mWallpaper.setSize((int) target.length());
            }
        }
    }

    if (mCallback != null && mCallback.get() != null) {
        mCallback.get().onPropertiesReceived(mWallpaper);
    }
}
 
Example 5
Source Project: snowdream-books-android   Source File: MainApplication.java    License: Apache License 2.0 6 votes vote down vote up
private void initImageLoader(){
        Context context = getApplicationContext();
        File cacheDir = StorageUtils.getCacheDirectory(context);
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
                .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
                .diskCacheExtraOptions(480, 800, null)
                .threadPriority(Thread.NORM_PRIORITY - 2) // default
                .tasksProcessingOrder(QueueProcessingType.FIFO) // default
                .denyCacheImageMultipleSizesInMemory()
                .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
                .memoryCacheSize(2 * 1024 * 1024)
                .memoryCacheSizePercentage(13) // default
                .diskCache(new UnlimitedDiscCache(cacheDir)) // default
                .diskCacheSize(50 * 1024 * 1024)
                .diskCacheFileCount(100)
                .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
                .imageDownloader(new BaseImageDownloader(context)) // default
                .imageDecoder(new BaseImageDecoder(false)) // default
                .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
//                .writeDebugLogs()
                .build();

        ImageLoader.getInstance().init(config);
    }
 
Example 6
Source Project: sealtalk-android   Source File: MyAccountActivity.java    License: MIT License 6 votes vote down vote up
private void initView() {
    mPhone = (TextView) findViewById(R.id.tv_my_phone);
    portraitItem = (RelativeLayout) findViewById(R.id.rl_my_portrait);
    nameItem = (RelativeLayout) findViewById(R.id.rl_my_username);
    passwordItem = (RelativeLayout) findViewById(R.id.rl_my_password);
    mImageView = (SelectableRoundedImageView) findViewById(R.id.img_my_portrait);
    mName = (TextView) findViewById(R.id.tv_my_username);
    portraitItem.setOnClickListener(this);
    nameItem.setOnClickListener(this);
    passwordItem.setOnClickListener(this);
    String cacheName = sp.getString("loginnickname", "");
    String cachePortrait = sp.getString("loginPortrait", "");
    String cachePhone = sp.getString("loginphone","");
    if (!TextUtils.isEmpty(cachePhone)) {
        mPhone.setText("+86 "+cachePhone);
    }
    if (!TextUtils.isEmpty(cacheName)) {
        mName.setText(cacheName);
        if (TextUtils.isEmpty(cachePortrait)) {
            ImageLoader.getInstance().displayImage(RongGenerate.generateDefaultAvatar(cacheName, sp.getString("loginid", "a")), mImageView, App.getOptions());
        }else {
            ImageLoader.getInstance().displayImage(cachePortrait, mImageView, App.getOptions());
        }
    }
    setPortraitChangeListener();
}
 
Example 7
Source Project: ChipHellClient   Source File: PostItemView.java    License: Apache License 2.0 6 votes vote down vote up
public void bindValue(Post post) {
    ImageLoader.getInstance().displayImage(post.getAvatarUrl(), imageViewAvatar, Constants.avatarDisplayOption, animateFirstListener);
    textViewAuthi.setText(Html.fromHtml(post.getAuthi()));
    String content = post.getContent();
    if (post.getImgList() != null) {
        content += post.getImgList();
    }
    textViewContent.setText(Html.fromHtml(content, new ImageGetter() {

        @Override
        public Drawable getDrawable(String source) {
            if (!source.startsWith("http:")) {
                source = Constants.BASE_URL + source;
            }
            LogMessage.i("PostItemView", source);
            return new UrlDrawable(source, textViewContent);
        }
    }, null));
}
 
Example 8
Source Project: Social   Source File: ImageLoaderTools.java    License: Apache License 2.0 6 votes vote down vote up
private static ImageLoader initImageLoader(Context context) {
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
            .cacheInMemory(true)
            .cacheOnDisc(true)
            .showStubImage(R.drawable.image_holder)
            .showImageForEmptyUri(R.drawable.image_holder)
            .showImageOnFail(R.drawable.image_holder)
            .build();

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
            .defaultDisplayImageOptions(defaultOptions)//
            .discCacheSize(DISK_CACHE_SIZE_BYTES)
            .memoryCacheSize(MEMORY_CACHE_SIZE_BYTES)
            .build();

    ImageLoader tmpIL = ImageLoader.getInstance();
    tmpIL.init(config);
    return tmpIL;

}
 
Example 9
Source Project: sctalk   Source File: ContactFragment.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @Description 初始化界面资源
 */
private void initRes() {
    // 设置顶部标题栏
    showContactTopBar();
    hideTopBar();

    super.init(curView);
    showProgressBar();

    sortSideBar = (SortSideBar) curView.findViewById(R.id.sidrbar);
    dialog = (TextView) curView.findViewById(R.id.dialog);
    sortSideBar.setTextView(dialog);
    sortSideBar.setOnTouchingLetterChangedListener(this);

    allContactListView = (ListView) curView.findViewById(R.id.all_contact_list);
    departmentContactListView = (ListView) curView.findViewById(R.id.department_contact_list);

    //this is critical, disable loading when finger sliding, otherwise you'll find sliding is not very smooth
    allContactListView.setOnScrollListener(new PauseOnScrollListener(ImageLoader.getInstance(), true, true));
    departmentContactListView.setOnScrollListener(new PauseOnScrollListener(ImageLoader.getInstance(), true, true));
    // todo eric
    // showLoadingProgressBar(true);
}
 
Example 10
Source Project: android-open-project-demo   Source File: GradViewAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder viewHolder;
    if (convertView == null) {
        convertView = layoutInflater.inflate(R.layout.grid_view_item, parent, false);
        viewHolder = new ViewHolder();
        viewHolder.ivCar = (ImageView) convertView.findViewById(R.id.iv_car);
        convertView.setTag(viewHolder);

    } else {
        viewHolder = (ViewHolder) convertView.getTag();
    }


    ImageLoader.getInstance().displayImage(imageUrls[position], viewHolder.ivCar, options);

    return convertView;
}
 
Example 11
Source Project: ImageLoadingView   Source File: MyApp.java    License: Apache License 2.0 6 votes vote down vote up
private void initImageLoader(Context context) {
    ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context);
    config.denyCacheImageMultipleSizesInMemory();
    config.diskCacheSize(50 * 1024 * 1024);
    config.tasksProcessingOrder(QueueProcessingType.LIFO);
    ImageLoader.getInstance().init(config.build());

    defaultOptions = new DisplayImageOptions.Builder()
            .cacheInMemory(false)
            .cacheOnDisk(true)
            .imageScaleType(ImageScaleType.IN_SAMPLE_INT)//设置图片以如何的编码方式显示
            .showImageOnLoading(R.mipmap.loading)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .showImageOnFail(R.mipmap.loading)
            .showImageForEmptyUri(R.mipmap.loading)
            .build();

    ImageLoader.getInstance().clearDiskCache();
    ImageLoader.getInstance().clearMemoryCache();
}
 
Example 12
Source Project: android-tv-launcher   Source File: ClientApplication.java    License: MIT License 6 votes vote down vote up
/**
 * init UIL ImageLoader
 */
public static void initImageLoader(Context context) {
    // This configuration tuning is custom. You can tune every option, you
    // may tune some of them,
    // or you can create default configuration by
    // ImageLoaderConfiguration.createDefault(this);
    // method.
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
            context).threadPriority(Thread.NORM_PRIORITY - 2)
            .denyCacheImageMultipleSizesInMemory()
            .discCacheFileNameGenerator(new Md5FileNameGenerator())
            .tasksProcessingOrder(QueueProcessingType.LIFO)
            .writeDebugLogs() // Remove for release app
            .build();
    // Initialize ImageLoader with configuration.
    ImageLoader.getInstance().init(config);
}
 
Example 13
Source Project: VideoMeeting   Source File: App.java    License: Apache License 2.0 6 votes vote down vote up
private void initLib() {
    // 初始化日志功能, 开启/关闭 日志输出
    L.setLogOpen(AppConstant.LOG_OPEN);

    // 初始化自定义异常捕获
    CrashHandler.getInstance().init(this);

    // 初始化ImageLoader
    // 设置图片显示选项
    DisplayImageOptions displayOp = new DisplayImageOptions.Builder()
            .showImageOnLoading(0)// 图片正在加载时显示的背景
            .cacheInMemory(true)// 缓存在内存中
            .cacheOnDisk(true)// 缓存在磁盘中
            .displayer(new FadeInBitmapDisplayer(300))// 显示渐变动画
            .bitmapConfig(Bitmap.Config.RGB_565) // 设置图片的解码类型
            .considerExifParams(true)// 考虑旋转角
            .build();

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
            getApplicationContext()).defaultDisplayImageOptions(displayOp)
            .denyCacheImageMultipleSizesInMemory()// 不解析多种尺寸
            .build();

    ImageLoader.getInstance().init(config);
}
 
Example 14
Source Project: DevUtils   Source File: ImageLoaderUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 初始化 ImageLoader 加载配置
 * @param context {@link Context}
 */
public static void init(final Context context) {
    DisplayImageOptions options = DF_OPTIONS;
    // 针对图片缓存的全局加载配置 ( 主要有线程类、缓存大小、磁盘大小、图片下载与解析、日志方面的配置 )
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
            .defaultDisplayImageOptions(options) // 加载 DisplayImageOptions 参数
            .threadPriority(Thread.NORM_PRIORITY - 2) // 线程池内加载的数量
            .denyCacheImageMultipleSizesInMemory() // 加载同一 URL 图片时 imageView 从小变大时从内存缓存中加载
            //.memoryCache(new UsingFreqLimitedMemoryCache(1024 * 1024)) // 通过自己的内存缓存实现
            .memoryCacheSize(2 * 1024 * 1024) // 内存缓存最大值
            .memoryCacheSizePercentage(13)
            //.diskCacheSize(50 * 1024 * 1024) // SDCard 缓存最大值 50mb
            //.discCacheFileNameGenerator(new Md5FileNameGenerator()) // 将保存的时候的 URI 名称用 MD5 加密
            //.diskCacheFileCount(100) // 缓存的文件数量
            //.memoryCache(new WeakMemoryCache()).diskCacheFileNameGenerator(new HashCodeFileNameGenerator())
            .imageDownloader(new BaseImageDownloader(context)) // default
            .tasksProcessingOrder(QueueProcessingType.LIFO).build();
    ImageLoader.getInstance().init(config);
}
 
Example 15
Source Project: JianDan   Source File: ShareUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static void sharePicture(Activity activity, String url) {

        String[] urlSplits = url.split("\\.");

        File cacheFile = ImageLoader.getInstance().getDiskCache().get(url);

        //如果不存在,则使用缩略图进行分享
        if (!cacheFile.exists()) {
            String picUrl = url;
            picUrl = picUrl.replace("mw600", "small").replace("mw1200", "small").replace
                    ("large", "small");
            cacheFile = ImageLoader.getInstance().getDiskCache().get(picUrl);
        }

        File newFile = new File(CacheUtil.getSharePicName
                (cacheFile, urlSplits));

        if (FileUtil.copyTo(cacheFile, newFile)) {
            ShareUtil.sharePicture(activity, newFile.getAbsolutePath(),
                    "分享自煎蛋 " + url);
        } else {
            ShowToast.Short(ConstantString.LOAD_SHARE);
        }
    }
 
Example 16
Source Project: wallpaperboard   Source File: AboutAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder.getItemViewType() == TYPE_HEADER) {
        HeaderViewHolder headerViewHolder = (HeaderViewHolder) holder;
        String imageUri = mContext.getString(R.string.about_image);

        if (ColorHelper.isValidColor(imageUri)) {
            headerViewHolder.image.setBackgroundColor(Color.parseColor(imageUri));
        } else if (!URLUtil.isValidUrl(imageUri)) {
            imageUri = "drawable://" + DrawableHelper.getResourceId(mContext, imageUri);
            ImageLoader.getInstance().displayImage(imageUri, headerViewHolder.image,
                    ImageConfig.getDefaultImageOptions());
        } else {
            ImageLoader.getInstance().displayImage(imageUri, headerViewHolder.image,
                    ImageConfig.getDefaultImageOptions());
        }

        String profileUri = mContext.getResources().getString(R.string.about_profile_image);
        if (!URLUtil.isValidUrl(profileUri)) {
            profileUri = "drawable://" + DrawableHelper.getResourceId(mContext, profileUri);
        }

        ImageLoader.getInstance().displayImage(profileUri, headerViewHolder.profile,
                ImageConfig.getDefaultImageOptions());
    }
}
 
Example 17
private void freshLoginStatus(String userName) {
    ImageLoader mImageLoader = ImageLoader.getInstance();
    DisplayImageOptions options = ImageLoaderOptions.getOptionsCachedDisk(true);
    if (userName == null) {
        userName = new SpTool(getActivity(), SpTool.SP_USER).getString("userName", null);
    }
    if (userName == null) {
        v_line_bottom.setVisibility(View.GONE);
        tv_logout.setVisibility(View.GONE);
        mTv_username.setText(getString(R.string.v_left_menu_login));
        return;
    }
    mImageLoader.displayImage(new SpTool(getActivity(), SpTool.SP_USER).getString("avatar", null), mIv_user, options);
    v_line_bottom.setVisibility(View.VISIBLE);
    tv_logout.setVisibility(View.VISIBLE);
    mTv_username.setText(userName);
}
 
Example 18
Source Project: JsonParsingDemo   Source File: MainActivity.java    License: MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    dialog = new ProgressDialog(this);
    dialog.setIndeterminate(true);
    dialog.setCancelable(false);
    dialog.setMessage("Loading. Please wait..."); // showing a dialog for loading the data
    // Create default options which will be used for every
    //  displayImage(...) call if no options will be passed to this method
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
            .cacheInMemory(true)
            .cacheOnDisk(true)
    .build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
    .defaultDisplayImageOptions(defaultOptions)
    .build();
    ImageLoader.getInstance().init(config); // Do it on Application start

    lvMovies = (ListView)findViewById(R.id.lvMovies);


    // To start fetching the data when app start, uncomment below line to start the async task.
            new JSONTask().execute(URL_TO_HIT);
}
 
Example 19
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_moment_list);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
            .cacheInMemory(true)
            .cacheOnDisk(true)
            .build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
            .defaultDisplayImageOptions(defaultOptions)
            .build();
    ImageLoader.getInstance().init(config);

    updateSnsList();
}
 
Example 20
Source Project: foodie-app   Source File: LocationFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    if (position == 0) {
        holder.headerView.setText(mLocation);
        return;
    }
    position = position - 1;
    RestaurantInfo resaurantInfo=restaurantList.get(position);

    DisplayImageOptions RestaurantImageOptions = new DisplayImageOptions.Builder()
            .showImageOnLoading(R.drawable.loading_large)
            .showImageOnFail(R.drawable.recipe)
            .cacheInMemory(true)
            .cacheOnDisk(true)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .build();
    ImageLoader.getInstance().displayImage(resaurantInfo.getPictureSmall(), holder.mRestaurantImageView, RestaurantImageOptions);
   
    holder.mDistanceView.setText("1.1km");
    holder.mAddressVview.setText(resaurantInfo.getAddress());
    holder.mKeywordView.setText(resaurantInfo.getKeyWord());
    holder.mAveragePriceView.setText(resaurantInfo.getAveragePrice());
    holder.mCommentCountView.setText("212");
    holder.mRestaurantNameView.setText(resaurantInfo.getRestaurantName());
    holder.mScoreView.setRating(4);
}
 
Example 21
Source Project: WliveTV   Source File: ClearCacheDialog.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	super.onCreate(savedInstanceState);
	setContentView(R.layout.dialog_clearcache);
	btn = (Button) findViewById(R.id.btn_download);
	tvUpdateMsg = (TextView) findViewById(R.id.tv_update_msg);
	btn.setOnClickListener( new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			ImageLoader.getInstance().clearMemoryCache();
			ImageLoader.getInstance().clearDiskCache();
			dismiss();
		}
	});
}
 
Example 22
Source Project: ml   Source File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Subscribe(threadMode = ThreadMode.MAIN)
public void onImageSelectedEvent(ImageSelectedEvent event) {
    Fragment fragment = findFragment(R.id.fragment_detected_images);

    if (fragment instanceof DetectedImagesFragment == false) {
        return;
    }

    DetectedImage styledImage = ((DetectedImagesFragment)fragment).getImageOnPosition(
            event.selectedPosition);

    Logger.debug("selected image: %s", styledImage);
    if (mSelectedImagePreview != null
            && styledImage != null) {
        ImageLoader.getInstance().displayImage(
                "file://" + styledImage.getDetectedPath(),
                mSelectedImagePreview,
                Constants.PREVIEW_IMAGE_LOADER_OPTIONS);
    }
}
 
Example 23
Source Project: ml   Source File: SegmentBitmapViewHolder.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void bindItem(final Context context, SegmentBitmap segmentBitmap) {
    if (mImageView != null) {
        if (segmentBitmap.bitmapUri != null) {
                ImageLoader.getInstance().displayImage(
                        segmentBitmap.bitmapUri.toString(),
                        mImageView,
                        DEFAULT_IMAGE_LOADER_OPTIONS);
        } else {
            mImageView.setImageBitmap(segmentBitmap.bitmap);
        }
    }

    if (mLabelView != null) {
        mLabelView.setText(segmentBitmap.labelResId);
    }
}
 
Example 24
Source Project: JianDan_OkHttp   Source File: ShareUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static void sharePicture(Activity activity, String url) {

        String[] urlSplits = url.split("\\.");

        File cacheFile = ImageLoader.getInstance().getDiskCache().get(url);

        //如果不存在,则使用缩略图进行分享
        if (!cacheFile.exists()) {
            String picUrl = url;
            picUrl = picUrl.replace("mw600", "small").replace("mw1200", "small").replace
                    ("large", "small");
            cacheFile = ImageLoader.getInstance().getDiskCache().get(picUrl);
        }

        File newFile = new File(CacheUtil.getSharePicName
                (cacheFile, urlSplits));

        if (FileUtil.copyTo(cacheFile, newFile)) {
            ShareUtil.sharePicture(activity, newFile.getAbsolutePath(),
                    "分享自煎蛋 " + url);
        } else {
            ShowToast.Short(ConstantString.LOAD_SHARE);
        }
    }
 
Example 25
Source Project: tup.dota2recipe   Source File: HeroImagesAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View view = convertView;

    final ViewHolder holder;
    if (convertView == null) {
        view = mInflater.inflate(R.layout.fragment_itemsdetail_hero_grid_item, parent, false);

        holder = new ViewHolder();
        holder.text = (TextView) view.findViewById(R.id.text_hero_name);
        holder.image = (ImageView) view.findViewById(R.id.image_hero);

        view.setTag(holder);
    } else {
        holder = (ViewHolder) view.getTag();
    }

    final HeroItem item = (HeroItem) getItem(position);
    ImageLoader.getInstance().displayImage(Utils.getHeroImageUri(item.keyName),
            holder.image, mImageLoadOptions);
    holder.text.setText(item.name_l);

    return view;
}
 
Example 26
@Override
public void onCreate() {
    super.onCreate();

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
            getApplicationContext())
            .threadPoolSize(3)
            .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
            .memoryCacheSize(2 * 1024 * 1024)
            .discCache(
                    new UnlimitedDiscCache(StorageUtils
                            .getCacheDirectory(getApplicationContext())))
            .build();

    ImageLoader.getInstance().init(config);
}
 
Example 27
Source Project: letv   Source File: LetvCacheMannager.java    License: Apache License 2.0 5 votes vote down vote up
public synchronized void loadImage(String url, ImageView imageView, DisplayImageOptions options) {
    if (ImageLoader.getInstance().isInited()) {
        if (!(TextUtils.isEmpty(url) || imageView == null)) {
            ImageLoader.getInstance().displayImage(url, imageView, options);
        }
    }
}
 
Example 28
Source Project: smartcoins-wallet   Source File: Helper.java    License: MIT License 5 votes vote down vote up
public static void initImageLoader(Context context) {

        ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context);
        config.threadPriority(Thread.NORM_PRIORITY - 2);
        config.denyCacheImageMultipleSizesInMemory();
        config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
        config.diskCacheSize(50 * 1024 * 1024); // 50 MiB
        config.tasksProcessingOrder(QueueProcessingType.LIFO);
        config.writeDebugLogs(); // Remove for release app

        // Initialize ImageLoader with configuration.
        ImageLoader.getInstance().init(config.build());


    }
 
Example 29
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    Person person = dataList.get(position);
    if (person == null) return;
    holder.usernameTv.setText(person.getUsername());
    holder.ageTv.setText(person.getAge() + "岁");
    holder.descTv.setText(person.getDesc());
    ImageLoader.getInstance().displayImage(person.getAvatar(), holder.avatarIv);
}
 
Example 30
Source Project: GalleryFinal   Source File: ChoosePhotoListAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    DisplayImageOptions options = new DisplayImageOptions.Builder()
            .showImageOnFail(R.drawable.ic_gf_default_photo)
            .showImageForEmptyUri(R.drawable.ic_gf_default_photo)
            .showImageOnLoading(R.drawable.ic_gf_default_photo).build();

    ImageView ivPhoto = (ImageView) mInflater.inflate(R.layout.adapter_photo_list_item, null);
    setHeight(ivPhoto);

    PhotoInfo photoInfo = mList.get(position);
    ImageLoader.getInstance().displayImage("file:/" + photoInfo.getPhotoPath(), ivPhoto, options);
    return ivPhoto;
}