com.nostra13.universalimageloader.core.ImageLoader Java Examples

The following examples show how to use com.nostra13.universalimageloader.core.ImageLoader. 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 File: AboutAdapter.java    From wallpaperboard with 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 #2
Source File: ShareUtil.java    From JianDan with 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 #3
Source File: ImageLoaderUtils.java    From DevUtils with 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 #4
Source File: ClientApplication.java    From android-tv-launcher with 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 #5
Source File: App.java    From VideoMeeting with 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 #6
Source File: PostItemView.java    From ChipHellClient with 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 #7
Source File: MainApplication.java    From snowdream-books-android with 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 #8
Source File: WallpaperPropertiesLoaderTask.java    From candybar with 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 #9
Source File: MomentListActivity.java    From hayoou-wechat-export with GNU General Public License v3.0 6 votes vote down vote up
@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 #10
Source File: ItemsDetailActivity.java    From tup.dota2recipe with 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 #11
Source File: ImagesDetailActivity.java    From SimplifyReader with 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 #12
Source File: AndroidUniversalImageLoaderSampleApplication.java    From android-opensource-library-56 with Apache License 2.0 6 votes vote down vote up
@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 #13
Source File: MyAccountActivity.java    From sealtalk-android with 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 #14
Source File: ShareUtil.java    From JianDan_OkHttp with 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 #15
Source File: SegmentBitmapViewHolder.java    From ml with 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 #16
Source File: MyApp.java    From ImageLoadingView with 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 #17
Source File: MainActivity.java    From ml with 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 #18
Source File: ClearCacheDialog.java    From WliveTV with 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 #19
Source File: LocationFragment.java    From foodie-app with 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 #20
Source File: MomentListActivity.java    From WeChatMomentStat-Android with GNU General Public License v3.0 6 votes vote down vote up
@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 #21
Source File: ImageLoaderTools.java    From Social with 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 #22
Source File: ContactFragment.java    From sctalk with 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 #23
Source File: MainActivity.java    From JsonParsingDemo with 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 #24
Source File: GradViewAdapter.java    From android-open-project-demo with 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 #25
Source File: FragmentSlidingMenu.java    From BigApp_WordPress_Android with Apache License 2.0 6 votes vote down vote up
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 #26
Source File: HeroImagesAdapter.java    From tup.dota2recipe with 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 #27
Source File: MainActivity.java    From MultipleImagePicker with Apache License 2.0 5 votes vote down vote up
private void initImageLoader() {
       // for universal image loader
	DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
			.cacheOnDisc().imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
			.bitmapConfig(Bitmap.Config.RGB_565).build();
	ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(
			this).defaultDisplayImageOptions(defaultOptions).memoryCache(
			new WeakMemoryCache());

	ImageLoaderConfiguration config = builder.build();
	imageLoader = ImageLoader.getInstance();
	imageLoader.init(config);
}
 
Example #28
Source File: UserListAdapter.java    From VideoMeeting with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(SimpleViewHolder holder, int position) {
    final ChooseUserItem item = getItem(position);
    User user = item.getUser();
    boolean isChoose = item.isChoose();
    String nickName = user.getNickName();
    String avatar = user.getAvatar();

    CircleImageView imgAvatar = holder.find(R.id.img_item_user_avatar);
    TextView tvNickName = holder.find(R.id.tv_item_user_nickname);
    CheckBox checkBox = holder.find(R.id.cb_item_user_choose);

    checkBox.setChecked(isChoose);
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            item.setIsChoose(isChecked);
        }
    });

    if (!TextUtils.isEmpty(avatar)) {
        ImageLoader.getInstance().displayImage(App.getInstance().getString(R.string.file_base_url) + avatar, imgAvatar);
    } else {
        imgAvatar.setImageResource(R.mipmap.ic_launcher);
    }
    tvNickName.setText(nickName);
}
 
Example #29
Source File: BaseFragment.java    From Android-Universal-Image-Loader-Modify with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
	switch (item.getItemId()) {
		case R.id.item_clear_memory_cache:
			ImageLoader.getInstance().clearMemoryCache();
			return true;
		case R.id.item_clear_disc_cache:
			ImageLoader.getInstance().clearDiskCache();
			return true;
		default:
			return false;
	}
}
 
Example #30
Source File: ThumbViewActivity.java    From PinchImageView with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_thumb_view);

    final DisplayImageOptions thumbOptions = new DisplayImageOptions.Builder().cacheInMemory(true).build();
    final ImageLoader imageLoader = Global.getImageLoader(getApplicationContext());

    final ViewGroup root = (ViewGroup) findViewById(R.id.root);
    int l = root.getChildCount();
    for (int i = 0; i < l; i++) {
        final int fi = i;
        final ImageView thumb = (ImageView) ((ViewGroup) root.getChildAt(i)).getChildAt(0);
        final ImageViewAware thumbAware = new ImageViewAware(thumb);
        final String url = Global.getTestImage(i).getThumb(100, 100).url;
        imageLoader.displayImage(url, thumbAware, thumbOptions);
        thumb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ThumbViewActivity.this, PicViewActivity.class);
                intent.putExtra("image", Global.getTestImage(fi));
                ImageSize targetSize = new ImageSize(thumbAware.getWidth(), thumbAware.getHeight());
                String memoryCacheKey = MemoryCacheUtils.generateKey(url, targetSize);
                intent.putExtra("cache_key", memoryCacheKey);
                Rect rect = new Rect();
                thumb.getGlobalVisibleRect(rect);
                intent.putExtra("rect", rect);
                intent.putExtra("scaleType", thumb.getScaleType());
                startActivity(intent);
            }
        });
    }
}