android网络开源框架volley(四)——谈谈图片加载

安卓常用网络请求框架XUtils、OkHttp、Volley、Retrofit 1.xutils 此框架庞大而周全,这个框架可以网络请求,同时可以图片加载,又可以数据存储,又可以 View 注解,使用这种框架很方便,这样会使得你整个项目对它依赖性太强,万一以后这个库不维护了,或者中间某个模块出问题了,这个影响非常大,所以在项目开发时,一般会更喜欢选择专注某一领域的框架。 使用案例: RequestParams params = new RequestParams("http:... 阅读详情

过完年,心情状态好了很多,终于可以静下心来写点东西。之前关于volley用过的东西都写了,这次再整理下——关于volley加载图片的用法。


1、加载图片,然后显示

加载图片,这个几乎每个app都会有所涉及,然后就是如何流畅加载,如何管理好内存,避免OOM之类。这些东西,几乎是每个程序员必须面对的。使用volley加载网络图片,主要用到其中的ImageLoader类。关于这个类的主要说明如下:


它主要是帮我们载入和缓存从远程网络加载的图片。构造方法中我们需要传入请求队列和一个ImageCache接口的实现(这个地方谷歌并没有为我们做好图片的缓存,我们需要按照自己的思路去实现这些功能,比如LRU,LFU,FIFO等,下面的demo我用的就是support-v4中的Lru),可以做L1 Cache。另外,getImageListener(ImageView view, int defaultImageResId, int errorImageResId)为我们提供了默认的ImageLoader.ImageListener实现。还有一个注意事项:所有的请求都必须在主线程中发出。

ImageLoader提供了两个get方法,具体的实现可以查看源码,值得注意的地方是,get(java.lang.String requestUrl, ImageLoader.ImageListener imageListener, int maxWidth, int maxHeight)这个方法中,我们可以通过设置最大宽高来限制加载到内存中的图片的大小,减少OOM的发生,当加载一些大图片时,效果还是非常明显的。

下面贴一个通过GridView加载图片的代码,首先是adapter:

/**
 * GridView的adapter
 * 
 * @author ttdevs http://blog.youkuaiyun.com/ttdevs
 */
public class GridViewAdapter extends BaseAdapter implements OnScrollListener {

	private final int WITDH = 960, HEIGHT = 960; // 默认加载图片的size,如果不设置可能会出现OOM,设置了,就会好一些

	public final static String[] URLS = ImageURLs.imageThumbUrls;

	private Context mContext;
	private ImageGridView mIgvImage;
	private ImageLoader mImageLoader;

	public GridViewAdapter(Context context, ImageGridView igvImage) {
		mContext = context;
		mIgvImage = igvImage;
		mIgvImage.setOnScrollListener(this);

		mImageLoader = VolleyQueue.getImageLoader();
	}

	@Override
	public int getCount() {
		return URLS.length;
	}

	@Override
	public Object getItem(int position) {
		return URLS[position];
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = null;
		if (convertView == null) {
			view = LayoutInflater.from(mContext).inflate(R.layout.item_image, null);
		} else {
			view = convertView;
		}

		String imageUrl = URLS[position];
		ImageView ivImage = (ImageView) view.findViewById(R.id.ivImage);
		ivImage.setTag(imageUrl);// 给ImageView设置一个Tag,保证异步加载图片时不会乱序

		return view;
	}

	private int mFirstVisibleItem; // 第一张可见图片的下标
	private int mVisibleItemCount; // 一屏有多少张图片可见
	private boolean isFirstEnter = true; // 记录是否刚打开程序,用于解决进入程序不滚动屏幕,不会下载图片的问题。
	private List<ImageContainer> icList = new ArrayList<ImageContainer>();

	@Override
	public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
		mFirstVisibleItem = firstVisibleItem;
		mVisibleItemCount = visibleItemCount;

		if (isFirstEnter && visibleItemCount > 0) {
			loadBitmaps(firstVisibleItem, visibleItemCount);
			isFirstEnter = false;
		}
	}

	@Override
	public void onScrollStateChanged(AbsListView view, int scrollState) {
		// 仅当GridView静止时才去下载图片,GridView滑动时取消所有正在下载的任务
		if (scrollState == SCROLL_STATE_IDLE) {
			loadBitmaps(mFirstVisibleItem, mVisibleItemCount);
		} else {
			for (ImageContainer ic : icList) {
				ic.cancelRequest();
				System.err.println(">>>>> cancel loading:" + ic.getRequestUrl());
			}
			icList.clear();
		}
	}

	private void loadBitmaps(int firstVisibleItem, int visibleItemCount) {
		try {
			for (int i = firstVisibleItem; i < firstVisibleItem + visibleItemCount; i++) {
				final String imageUrl = URLS[i];

				// // 使用ImageLoader的默认实现
				final ImageView ivImage = (ImageView) mIgvImage.findViewWithTag(imageUrl);
				// ImageListener listener =
				// ImageLoader.getImageListener(ivImage,
				// R.drawable.ic_empty_photo, R.drawable.ic_empty_photo);
				// mImageLoader.get(imageUrl, listener);

				// 自己写的,可能写的不太好,但是这个更有利于理解ImageLoader执行过程
				ImageContainer ic = mImageLoader.get(imageUrl, new ImageListener() {

					@Override
					public void onResponse(ImageContainer response, boolean isImmediate) {
						String imageUrl = response.getRequestUrl();

						if (ivImage != null) {
							Bitmap tbm = response.getBitmap();
							if (tbm != null) {
								System.out.println("<<<<<loading finish:" + imageUrl);
								ivImage.setImageBitmap(response.getBitmap());
							} else {
								ivImage.setImageResource(R.drawable.ic_empty_photo);
							}
						}
					}

					@Override
					public void onErrorResponse(VolleyError error) {
						error.printStackTrace();
						ivImage.setImageResource(R.drawable.ic_empty_photo);
					}

				}, WITDH, HEIGHT); // 此处使用另外一个构造函数在加载的时候是加载原始图片
				System.out.println(">>>>><" + i + ">loading:" + imageUrl);
				icList.add(ic);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

另外需要关注的就是做为处理图片缓存的实现,这里使用LRU策略:

public class BitmapLruCache extends LruCache<String, Bitmap> implements ImageCache {
	
	public BitmapLruCache(int maxSize) {
		super(maxSize);
		initLocalFileManager();
	}

	private void initLocalFileManager() {
		
	}

	@Override
	protected int sizeOf(String key, Bitmap value) {
		// TODO value.getByteCount();
		return value.getRowBytes() * value.getHeight();
	}

	@Override
	public Bitmap getBitmap(String url) {
		Bitmap tbm = get(url);
		if(tbm != null){
			return tbm;
		}
		return null; //TODO local file
	}

	@Override
	public void putBitmap(String url, Bitmap bitmap) {
		put(url, bitmap);
	}
}

最后一个和之前文章中区别不大的VolleyQueue.java:

public class VolleyQueue {
	private static RequestQueue mRequestQueue;
	private static ImageLoader mImageLoader;

	private VolleyQueue() {

	}

	/**
	 * 初始话我们的请求队列。这个地方有一个BitmapLruCache,这个在后面做图片加载的时候会提到的图片缓存策略
	 * 
	 * @param context
	 */
	static void init(Context context) {
		mRequestQueue = Volley.newRequestQueue(context);

		int memClass = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
		// Use 1/8th of the available memory for this memory cache.
		int cacheSize = 1024 * 1024 * memClass / 8;
		mImageLoader = new ImageLoader(mRequestQueue, new BitmapLruCache(cacheSize));
	}
      ......
}

最后看一下运行效果图:


滑动还是非常之流畅的。


2、使用NetworkImageView

有了上面的分析,看这个就比较简单了,就是对ImageView的再封装,加入网络请求:

这个的缺点就是加载大量图片的时候可能更容易出现OOM问题,因为它没有处理图片的压缩,当然,你能保证你的图片很小或者你也可以重写NetworkImageView,给它添加一个设置加载尺寸的方法。


3、分析:ImageLoader和ImageRequest

下面来分析下这个ImageLoader和ImageRequest。首先是ImageLoader,它的关键方法是:
/**
     * Issues a bitmap request with the given URL if that image is not available
     * in the cache, and returns a bitmap container that contains all of the data
     * relating to the request (as well as the default image if the requested
     * image is not available).
     * @param requestUrl The url of the remote image
     * @param imageListener The listener to call when the remote image is loaded
     * @param maxWidth The maximum width of the returned image.
     * @param maxHeight The maximum height of the returned image.
     * @return A container object that contains all of the properties of the request, as well as
     *     the currently available image (default if remote is not loaded).
     */
    public ImageContainer get(String requestUrl, ImageListener imageListener,
            int maxWidth, int maxHeight) {
        // only fulfill requests that were initiated from the main thread.
        throwIfNotOnMainThread();

        final String cacheKey = getCacheKey(requestUrl, maxWidth, maxHeight);

        // Try to look up the request in the cache of remote images.
        Bitmap cachedBitmap = mCache.getBitmap(cacheKey);
        if (cachedBitmap != null) {
            // Return the cached bitmap.
            ImageContainer container = new ImageContainer(cachedBitmap, requestUrl, null, null);
            imageListener.onResponse(container, true);
            return container;
        }

        // The bitmap did not exist in the cache, fetch it!
        ImageContainer imageContainer =
                new ImageContainer(null, requestUrl, cacheKey, imageListener);

        // Update the caller to let them know that they should use the default bitmap.
        imageListener.onResponse(imageContainer, true);

        // Check to see if a request is already in-flight.
        BatchedImageRequest request = mInFlightRequests.get(cacheKey);
        if (request != null) {
            // If it is, add this request to the list of listeners.
            request.addContainer(imageContainer);
            return imageContainer;
        }

        // The request is not already in flight. Send the new request to the network and
        // track it.
        Request<?> newRequest =
            new ImageRequest(requestUrl, new Listener<Bitmap>() {
                @Override
                public void onResponse(Bitmap response) {
                    onGetImageSuccess(cacheKey, response);
                }
            }, maxWidth, maxHeight,
            Config.RGB_565, new ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    onGetImageError(cacheKey, error);
                }
            });

        mRequestQueue.add(newRequest);
        mInFlightRequests.put(cacheKey,
                new BatchedImageRequest(newRequest, imageContainer));
        return imageContainer;
    }
首先,检查当前是不是在主线程,接着检查当前请求的图片是不是在缓存中,如果是就直接返回,否则继续。缓存中不存在的话,先创建一个ImageContainer对象,这个时候就可以通知界面显示正式图片加载完成之前的默认图片了。在正式创建一个图片请求之前,再去检查一下这个请求是否已经存在,这个可以避免重复请求的发生。请求存在,则返回,不存在则正式创建一个图片请求对象——ImageRequest,最后返回。这个逻辑很简单。关键我们来看看这个ImageRequest的代码:
/**
 * A canned request for getting an image at a given URL and calling
 * back with a decoded Bitmap.
 */
public class ImageRequest extends Request<Bitmap> {
    /** Socket timeout in milliseconds for image requests */
    private static final int IMAGE_TIMEOUT_MS = 1000;

    /** Default number of retries for image requests */
    private static final int IMAGE_MAX_RETRIES = 2;

    /** Default backoff multiplier for image requests */
    private static final float IMAGE_BACKOFF_MULT = 2f;

    private final Response.Listener<Bitmap> mListener;
    private final Config mDecodeConfig;
    private final int mMaxWidth;
    private final int mMaxHeight;

    /** Decoding lock so that we don't decode more than one image at a time (to avoid OOM's) */
    private static final Object sDecodeLock = new Object();

    /**
     * Creates a new image request, decoding to a maximum specified width and
     * height. If both width and height are zero, the image will be decoded to
     * its natural size. If one of the two is nonzero, that dimension will be
     * clamped and the other one will be set to preserve the image's aspect
     * ratio. If both width and height are nonzero, the image will be decoded to
     * be fit in the rectangle of dimensions width x height while keeping its
     * aspect ratio.
     *
     * @param url URL of the image
     * @param listener Listener to receive the decoded bitmap
     * @param maxWidth Maximum width to decode this bitmap to, or zero for none
     * @param maxHeight Maximum height to decode this bitmap to, or zero for
     *            none
     * @param decodeConfig Format to decode the bitmap to
     * @param errorListener Error listener, or null to ignore errors
     */
    public ImageRequest(String url, Response.Listener<Bitmap> listener, int maxWidth, int maxHeight,
            Config decodeConfig, Response.ErrorListener errorListener) {
        super(Method.GET, url, errorListener);
        setRetryPolicy(
                new DefaultRetryPolicy(IMAGE_TIMEOUT_MS, IMAGE_MAX_RETRIES, IMAGE_BACKOFF_MULT));
        mListener = listener;
        mDecodeConfig = decodeConfig;
        mMaxWidth = maxWidth;
        mMaxHeight = maxHeight;
    }

    @Override
    public Priority getPriority() {
        return Priority.LOW;
    }

    /**
     * Scales one side of a rectangle to fit aspect ratio.
     *
     * @param maxPrimary Maximum size of the primary dimension (i.e. width for
     *        max width), or zero to maintain aspect ratio with secondary
     *        dimension
     * @param maxSecondary Maximum size of the secondary dimension, or zero to
     *        maintain aspect ratio with primary dimension
     * @param actualPrimary Actual size of the primary dimension
     * @param actualSecondary Actual size of the secondary dimension
     */
    private static int getResizedDimension(int maxPrimary, int maxSecondary, int actualPrimary,
            int actualSecondary) {
        // If no dominant value at all, just return the actual.
        if (maxPrimary == 0 && maxSecondary == 0) {
            return actualPrimary;
        }

        // If primary is unspecified, scale primary to match secondary's scaling ratio.
        if (maxPrimary == 0) {
            double ratio = (double) maxSecondary / (double) actualSecondary;
            return (int) (actualPrimary * ratio);
        }

        if (maxSecondary == 0) {
            return maxPrimary;
        }

        double ratio = (double) actualSecondary / (double) actualPrimary;
        int resized = maxPrimary;
        if (resized * ratio > maxSecondary) {
            resized = (int) (maxSecondary / ratio);
        }
        return resized;
    }

    @Override
    protected Response<Bitmap> parseNetworkResponse(NetworkResponse response) {
        // Serialize all decode on a global lock to reduce concurrent heap usage.
        synchronized (sDecodeLock) {
            try {
                return doParse(response);
            } catch (OutOfMemoryError e) {
                VolleyLog.e("Caught OOM for %d byte image, url=%s", response.data.length, getUrl());
                return Response.error(new ParseError(e));
            }
        }
    }

    /**
     * The real guts of parseNetworkResponse. Broken out for readability.
     */
    private Response<Bitmap> doParse(NetworkResponse response) {
        byte[] data = response.data;
        BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
        Bitmap bitmap = null;
        if (mMaxWidth == 0 && mMaxHeight == 0) {
            decodeOptions.inPreferredConfig = mDecodeConfig;
            bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, decodeOptions);
        } else {
            // If we have to resize this image, first get the natural bounds.
            decodeOptions.inJustDecodeBounds = true;
            BitmapFactory.decodeByteArray(data, 0, data.length, decodeOptions);
            int actualWidth = decodeOptions.outWidth;
            int actualHeight = decodeOptions.outHeight;

            // Then compute the dimensions we would ideally like to decode to.
            int desiredWidth = getResizedDimension(mMaxWidth, mMaxHeight,
                    actualWidth, actualHeight);
            int desiredHeight = getResizedDimension(mMaxHeight, mMaxWidth,
                    actualHeight, actualWidth);

            // Decode to the nearest power of two scaling factor.
            decodeOptions.inJustDecodeBounds = false;
            // TODO(ficus): Do we need this or is it okay since API 8 doesn't support it?
            // decodeOptions.inPreferQualityOverSpeed = PREFER_QUALITY_OVER_SPEED;
            decodeOptions.inSampleSize =
                findBestSampleSize(actualWidth, actualHeight, desiredWidth, desiredHeight);
            Bitmap tempBitmap =
                BitmapFactory.decodeByteArray(data, 0, data.length, decodeOptions);

            // If necessary, scale down to the maximal acceptable size.
            if (tempBitmap != null && (tempBitmap.getWidth() > desiredWidth ||
                    tempBitmap.getHeight() > desiredHeight)) {
                bitmap = Bitmap.createScaledBitmap(tempBitmap,
                        desiredWidth, desiredHeight, true);
                tempBitmap.recycle();
            } else {
                bitmap = tempBitmap;
            }
        }

        if (bitmap == null) {
            return Response.error(new ParseError(response));
        } else {
            return Response.success(bitmap, HttpHeaderParser.parseCacheHeaders(response));
        }
    }

    @Override
    protected void deliverResponse(Bitmap response) {
        mListener.onResponse(response);
    }

    /**
     * Returns the largest power-of-two divisor for use in downscaling a bitmap
     * that will not result in the scaling past the desired dimensions.
     *
     * @param actualWidth Actual width of the bitmap
     * @param actualHeight Actual height of the bitmap
     * @param desiredWidth Desired width of the bitmap
     * @param desiredHeight Desired height of the bitmap
     */
    // Visible for testing.
    static int findBestSampleSize(
            int actualWidth, int actualHeight, int desiredWidth, int desiredHeight) {
        double wr = (double) actualWidth / desiredWidth;
        double hr = (double) actualHeight / desiredHeight;
        double ratio = Math.min(wr, hr);
        float n = 1.0f;
        while ((n * 2) <= ratio) {
            n *= 2;
        }

        return (int) n;
    }
}
如果认认真真的看完这个类,相信你对图片的加载会有一个比较深入的理解,所以建议认认真真的看这个类。
首先是构造方法,比我们之前介绍的Requst多了三个参数,int maxWidth,int maxHeight,Config decodeConfig,decodeConfig这个暂时我们可以不用去关心,就是告诉如何去解码bitmap,默认给的是Config.RGB_565,长宽这个字面意思不用解释,最大宽高,不传默认为实际大小。
接着就是protected Response<Bitmap> parseNetworkResponse(NetworkResponse response),关键代码在Response<Bitmap> doParse(NetworkResponse response)中,在这里我们可以看到,如果我们不设置最大宽高,就会直接解码图片,这个加载的就是实际大小的图片,占用内存就不太好控制了。如果我们设置了就会按照一定的规则去重新创建一个原始图片的缩略图,这个可以使加载到内存中的图片更好,避免OOM,具体怎么加载,为什么这样加载,大家可以参考附录中的介绍,也就是android 文档中的加载大图说明,看完之后,相信你会对大图的处理有非常深刻的理解。


4、下一篇

如果有机会,下一篇再写点关于HTTPS的东西,在此Mark一下,免得啥时候忘记咯


5、附录

参考:http://blog.youkuaiyun.com/guolin_blog/article/details/9526203 

google关于图片加载(这个对于处理图片加载很有帮助):

http://developer.android.com/training/displaying-bitmaps/index.html ;

http://blog.youkuaiyun.com/guolin_blog/article/details/9316683


安卓学习笔记43:初试开源框架Volley 文章目录零、学习目标一、Volley概述(一)安卓HTTP网络编程两种方式(二)简化HTTP通信,推出Volley框架二、案例演示 - 利用Volley下载网页(一)运行效果(二)涉及知识点(三)实现步骤1、创建安卓应用【DownloadWebPageByVolley】2、将背景图片拷贝到drawable目录3、主布局资源文件activity_main.xml4、字符串资源文件strings.xml5、在模块构建文件里添加对Volley的依赖6、在项目清单文件里授权访问因特网7、主界面类 - MainAct 阅读详情

相关推荐

Volley:高效处理大量图片的Android图片加载库

Volley是一款由Google提供的强大网络通信库,特别适合于数据量不大的场景,如列表项、网格视图中的图片加载等。它能够减少网络请求的配置负担,并提供了一定程度上的请求优先级管理。Volley的异步机制使得网络操作不会阻塞UI线程,从而提升了用户体验。在Android开发中,LruCache默认情况下是通过对象的内存占用大小来计算容量的,但在某些情况下我们可能需要根据自己的需求来自定义容量的计算方式。例如,在处理图片缓存时,可能更关心图片的像素数量而不是它占用的内存大小。自定义容量计算可以通过重写。

weixin_35414484的博客 728

Android Volley完全解析(二),使用Volley加载网络图片

在上一篇文章中,我们了解了Volley到底是什么,以及它的基本用法。本篇文章中我们即将学习关于Volley更加高级的用法,如何你还没有看过我的上一篇文章的话,建议先去阅读Android Volley完全解析(一),初识Volley的基本用法。 在上篇文章中有提到过,Volley是将AsyncHttpClient和Universal-Image-Loader的优点集成于一身的一个框架。我们都知道,Universal-Image-Loader具备非常强大的加载网络图片的功能,而使用Volley,我们也可以实现基

郭霖的专栏 16万+

Volley加载网络图片

一个使用Volley解析网络图片的Demo

Android中关于Volley的使用(一)加载图片

在Android中,如果我们要展示的图片是存储在网络上的时候,我们就必须通过HttpClient或者HttpUrlConnection这两个类来进行关于网络方面的操作,比如下面中利用GridView来展示几个图片: 关于GridView如何来展示图片就不多讲了,这个其实是跟ListView利用BaseAdapter来展示的原理是一样的,大家有兴趣可以下面的文章看一下: Android中关于...

maozhuxigood 235

Android框架Volley使用:ImageRequest请求实现图片加载

主要介绍了Android框架Volley使用:ImageRequest请求实现图片加载的相关知识,非常不错,具有一定的参考借鉴价值 ,需要的朋友可以参考下

ETL第八章无人售货机零售项目实践

ETL实战项目——无人售货机

m0_52058217的博客 4419

Android 图片加载框架:Google开发的框架源码Volley 以及Picasso和Glide比较

首先了解一下,它是封装了HTTPConnection和HTTPClient类的一个框架, 适用于数据量少但是通信频繁的情况,如加载图片; 就拿StringRequest(用来请求字符串的)举例: Volley的顺序是 : Http请求-------再接受响应 只需三步 GET: 1.首先新建一个请求队列,用来存放一会要发出的Http消息: 2.构造一条HTTP请求: ...

emmmsuperdan的博客 576

小红书高时效推荐系统背后的技术升级

在小红书 APP 中,推荐系统的实效性对推荐效果有着特别重要的影响,特别是作为 UGC 平台,小红书的推荐系统如果能更快地捕捉用户与笔记之间的变化和联系,就能够给推荐带来更好的效果。在2021年上半年,首页推荐的召回、粗排、精排的主要模块都保持在天级更新的状态,我们通过持续迭代,将召回 CF 渠道、召回索引更新、召回模型/粗精排模型的训练都做到了分钟级更新,为首页推荐的分发效率带来飞跃式提升,并给业务侧带来非常显著的收益。 小红书站内“最近一天内发布的新笔记”在首页的曝光占比一直很高,这段时间更是快速

REDtech_1024的博客 3529

android 使用volley下载文件和加载gif图片

这个是我写的比较满意的,禁止一切转载,需要请联系博主。 大家都知道Volley是谷歌官方推出来的网络库,使用他进行数据交互,图片加载都非常方便,但是他不支持下载文件,网上很多人都说,他下载文件的性能非常不好,所以就没有提供下载的功能,这个是前提。在安卓上面,默认是不支持显示GIF图片的,如果你用ImageView,也只会显示GIF图的第一帧,这个我们可以用的开源的GifImageView 控件,gi

星雨晴空 6721

VisionMaster位置修正功能深度解析:如何让找圆工具自动跟随移动目标?

本文深度解析海康威视VisionMaster平台的位置修正功能,重点介绍如何通过模板匹配与找圆工具的智能联动实现移动目标的动态追踪。文章详细阐述了工业视觉检测中的坐标系同步原理、模板匹配配置技巧及异常处理策略,为工程师提供了一套完整的工业级解决方案。

uu89012的博客 289

解决linux 2.5G网卡驱动问题

解决linux 2.5G网卡驱动问题 关键词:2.5G网卡驱动,ubuntu,安装,2.5G Ethernet LINUX driver,Realtek网卡驱动 由于2.5G网卡较新,各linux发行版的通用驱动已不适用,新装的系统会出现无法上网问题,由于国内网络环境去Realtek官网很难下载到驱动文件,故本文提供github上的2.5G Ethernet LINUX driver r8125 for kernel up to 5.6的版本驱动文件r8125-9.003.05.tar.bz2各位可以自

poorguy_aos的博客 1万+

android网络开源框架volley(四)——谈谈图片加载续——九张图片相册的展示(微信微博等)

需要实现一个相册的展示,默认最多显示九张,超过了就显示前九张。很常见的功能,比如新浪微博、微信等

ttdevs 3503

数据产品需求文档(PRD)怎么写?阿里P8分享的模板+5个避坑点

作用:记录文档的版本、作者、评审信息,避免“文档混乱”。填写规范字段说明示例文档名称清晰反映产品名称,如“用户行为分析平台PRD”用户行为分析平台PRD_V1.0文档版本用“版本号+日期”,如V1.0_20240301编写人数据产品经理姓名+联系方式张三(138-XXXX-XXXX)评审人员业务负责人、开发经理、数据分析师、运维负责人李四(业务)、王五(开发)、赵六(数据)、周七(运维)评审时间评审日期2024-03-05评审意见。

架构师的AI之路,分享AI应用开发架构的学习与实践。 1578

Universal-Image-Loader,android-Volley,Picasso、Fresco和Glide五大Android开源组件加载网络图片的优缺点比较

在android中的加载网络图片是一件十分令人头疼的事情,在网上有着许多关于加载网络图片的开源库,可以让我们十分方便的加载网络图片。在这里我主要介绍一下我自己在使用Volley, Picasso, Universal-Imageloader的一些使用的感悟。以及最基本的用法介绍。 1.android-Volley 给ImageView设置图片源 // im

Keep Learning , Keep Improving ! 3万+

sid图像数据_遥感影像数据

影像数据基本概念影像数据是由卫星或飞机上的成像系统获得的影像,多为遥感影像数据。影像数据的每个像元都有一个值,表示传感器探测到像素对应地面面积上目标物的电磁辐射强度,也叫亮度值、灰度值。SuperMap支持的影像数据格式有:*.img、*.tif、*.tiff、*.bmp、*.jpg、*.png、*.gif、*.raw、*.sid等。计算机以二进制记录数据,所以其量化的等级以二进制来划分,即2n。...

weixin_39534395的博客 1627

ESP32系列之LVGL(四):输入设备(外部按键)对接

本文详细介绍了如何在ESP32上使用LVGL库对接外部按键作为输入设备,包括硬件连接、驱动层实现和LVGL输入设备移植。通过具体代码示例和实战案例,帮助开发者快速实现按键控制UI界面,解决常见问题如按键无反应和控件跳转不正常。

weixin_30907935的博客 243

Android项目框架之图片加载框架的选择

本文来自http://blog.youkuaiyun.com/liuxian13183/,引用必须注明出处! 从Android爆发以后,自定义的控件如EditTextWithDelete、ActionBar、PullToRresh逐步进入开发者的视野,想起11年的时候,基本项目中使用的UI还全都是Android提供的基础控件,少一点的动画+布局,下载和网络请求都是用HttpClient,图片加载当然也是下载

劝学 2846

手把手教你学Simulink--控制策略与算法的DC-DC变换器领域仿真领域建模实例:基于Simulink实现一个双闭环控制Buck变换器的仿真建模

目录主要步骤1. 前期准备2. 构建Buck变换器模型3. 定义双闭环控制器4. 设置参考电压和反馈回路5. 实现双闭环控制器逻辑6. 仿真参数设置7. 运行仿真与结果分析示例整合代码片段1. Simulink模型2. 双闭环控制器参数调节3. 仿真结果分析总结双闭环控制是一种常见的控制策略,广泛应用于电力电子系统(如DC-DC变换器)中。它通过内外两个环路的协同工作,分别控制系统的动态性能和稳态性能。对于Buck变换器,通常采用电流内环和电压外环的双闭环控制结构。以下是一个手把手教程,帮助你基于Simul

MHD0815的博客 327

Android Volley开源框架的使用

一、Android Volley 开源框架的使用 2013年Google I/O大会上推出了一个新的网络通信框架——Volley。它既可以像AsyncHttpClient一样非常简单地进行HTTP通信,也可以像Universal-Image-Loader一样轻松加载网络上的图片。 除了简单易用之外,Volley在性能方面也进行了大幅度的调整,它的设计目标就是非常适合去进行数据量不大,但通信频繁的网...

sunshine_a70的博客 335

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

android 三方开源库 网络库、图片加载库

一. ‌Cronet‌是一个基于‌Chromium‌网络组件的Android网络请求框架,它利用了Google Chrome浏览器的网络堆栈,提供了高效、低延迟的HTTP和TCP/IP通信能力。1. Volley是Google官方推出的一个Android网络库,它的主要优点在于对请求的自动调度和优先级处理,以及内存和性能的优化。- RxJava在Android中是一个处理异步操作和事件流的强大库,RxJava是一个在Java VM上使用可观测的序列来组成异步的、基于事件的程序的库。

lui0617的博客 1654

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

FaceBook开源图片加载框架Fresco简单介绍

一、Fresco编译和引入工程        Fresco是Facebook最新推出的一款用于Android应用中展示图片的强大图片库,可以从网络、本地存储和本地资源中加载图片。之前看大家在QQ群和各个社区都在讨论Fresco,都说性能非常好,心里禁不住诱惑,所以决定尝试一下。前途是光明的,道路是曲折的,Fresco的引入出现各种问题,折腾了我好些时间。        Fresco在git

small-dream的博客 6319

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

Android常用开源网络框架(一)—— Volley篇

Android常用开源网络框架 在Android开发中,网络请求是最重要的模块之一,Android中大部分网络请求使用的是HTTP连接,包括原生的HttpClient和HttpUrlConnection两种访问网络方式。需要注意的是,HttpClient方式在Android6.0以后,很多类已经不支持了。 目前主流的开源网络框架,主要有OkHttp,Volley,Retrofit三种,我本人在短暂...

步步小猫的博客 738

Universal-Image-Loader,android-Volley,Picasso、Fresco和Glide五大Android开源组件加载网络图片比较

目录(?)[-] 4Fresco关于 Fresco特性 内存管理图片的渐进式呈现Gif图和WebP格式 图像的呈现 图像的加载PS还有一个glide的框架总结 推荐:http://www.ithao123.cn/content-10792416.html    在Android中的加载网络图片是一件十分令人头疼的事情,在网上有着许多关于加载网络图片的开源

zyxNobita专栏 952

关于应用Volley框架 + Android 网络通信框架Volley简介(Google IO 2013)

在android中基于http请求的框架很多,自己如果比较了解http请求流程,自己也可以写一个不错的框架,由于一些原因,项目中我们自己开发的框架被要求用volley替换掉了,因此我不得不对volley这个开发包进行自己的研究,以希望能够熟悉整个流程,以及能够顺利的将这个开源包融入到项目中同时不会影响原有逻辑。(个人风格的原因吧,我不是很喜欢贴大段大段的代码在帖子里面,大家如果能对照volley源

moubenmao的专栏 3671

六款值得推荐的android(安卓)开源框架简介

同事整理的android(安卓)开源框架,个个都堪称经典 1、volley 项目地址 https://github.com/smanikandan14/Volley-demo  (1)  JSON,图像等的异步下载;  (2)  网络请求的排序(scheduling)  (3)  网络请求的优先级处理  (4)  缓存  (5)  多级别取消请求  (6)

郭风朴(guofengpu)的Android影音专栏 1197

Android 网络框架(Android-async-http,OKHttp,retrofit,volley,xUtils,Afinal)

目前常用的网络框架,当然呢,每种网络框架都会有其优点和缺点的,主要是根据我们自身的项目进行选择:1.Android-async-http Android-async-http 是一个强大的网络请求库,这个网络请求库是基于 Apache HttpClient 库之上的一个异步网络请求处理库,网络处理均基于 Android 的非 UI 线程,通过回调方法处理请求结果。 android-async-

qq_37278353的博客 1901
上一篇: RadioButton 左侧显示文字,右侧显示按钮时文字不靠边的问题解决
下一篇: android TCP 和 UDP总结
ttdevs
博客等级 码龄15年 388粉丝 91原创
评论 10
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值