Android 内存+文件+网络三级缓存

三级缓存实现图片异步加载实现流程 三级缓存实现图片异步加载、强引用、弱引用的使用,文件下载流程等 立即下载
package com.panpass.main;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

/* 
 * 图片管理 
 * 异步获取图片,直接调用loadImage()函数,该函数自己判断是从缓存还是网络加载 
 * 同步获取图片,直接调用getBitmap()函数,该函数自己判断是从缓存还是网络加载 
 * 仅从本地获取图片,调用getBitmapFromNative() 
 * 仅从网络加载图片,调用getBitmapFromHttp() 
 * 
 */
public class ImageManager {

	public static ImageManager im = null;
	private final static String TAG = "ImageManager";

	private ImageMemoryCache imageMemoryCache; // 内存缓存

	private ImageFileCache imageFileCache; // 文件缓存

	// 正在下载的image列表
	public static HashMap<String, Handler> ongoingTaskMap = new HashMap<String, Handler>();

	// 等待下载的image列表
	public static HashMap<String, Handler> waitingTaskMap = new HashMap<String, Handler>();

	// 同时下载图片的线程个数
	final static int MAX_DOWNLOAD_IMAGE_THREAD = 4;

	private final Handler downloadStatusHandler = new Handler() {
		public void handleMessage(Message msg) {
			startDownloadNext();
		}
	};

	public static ImageManager getInstance(Context mContext) {

		if (im == null) {

			synchronized (ImageManager.class) {

				if (im == null) {

					im = new ImageManager(mContext);
				}
			}
		}

		return im;

	}

	public ImageManager(Context mContext) {
		imageMemoryCache = new ImageMemoryCache();
		imageFileCache = new ImageFileCache(mContext);
	}

	/**
	 * 获取图片,多线程的入口
	 */
	public void loadBitmap(String urlStr, Handler handler) {
		String url = urlStr.hashCode() + "";

		// 先从内存缓存中获取,取到直接加载
		Bitmap bitmap = getBitmapFromNative(urlStr);
		if (bitmap != null) {
			Message msg = Message.obtain();
			Bundle bundle = new Bundle();
			bundle.putString("url", url);
			msg.obj = bitmap;
			msg.setData(bundle);
			handler.sendMessage(msg);
		} else {
			downloadBmpOnNewThread(urlStr, handler);
		}
	}

	/**
	 * 新起线程下载图片
	 */
	private void downloadBmpOnNewThread(final String urlStr,
			final Handler handler) {
		final String url = urlStr.hashCode() + "";
		if (ongoingTaskMap.size() >= MAX_DOWNLOAD_IMAGE_THREAD) {
			synchronized (waitingTaskMap) {
				waitingTaskMap.put(url, handler);
			}
		} else {
			synchronized (ongoingTaskMap) {
				ongoingTaskMap.put(url, handler);
			}
			new Thread() {
				public void run() {
					Bitmap bmp = getBitmapFromHttp(urlStr);
					// 不论下载是否成功,都从下载队列中移除,再由业务逻辑判断是否重新下载
					// 下载图片使用了httpClientRequest,本身已经带了重连机制
					synchronized (ongoingTaskMap) {
						ongoingTaskMap.remove(url);
					}

					if (downloadStatusHandler != null) {
						downloadStatusHandler.sendEmptyMessage(0);

					}
					Message msg = Message.obtain();
					msg.obj = bmp;
					Bundle bundle = new Bundle();
					bundle.putString("url", url);
					msg.setData(bundle);

					if (handler != null) {
						handler.sendMessage(msg);
					}
				}
			}.start();
		}
	}

	/**
	 * 依次从内存,缓存文件,网络上加载单个bitmap,不考虑线程的问题
	 */
	public Bitmap getBitmap(String urlStr) {

		String url = urlStr.hashCode() + "";
		// 从内存缓存中获取图片
		Bitmap bitmap = imageMemoryCache.getBitmapFromMemory(url);
		if (bitmap == null) {
			// 文件缓存中获取
			bitmap = imageFileCache.getImageFromFile(url);
			if (bitmap != null) {
				// 添加到内存缓存
				imageMemoryCache.addBitmapToMemory(url, bitmap);
			} else {
				// 从网络获取
				bitmap = getBitmapFromHttp(urlStr);
			}
		}
		return bitmap;
	}

	/**
	 * 从内存或者缓存文件中获取bitmap
	 */
	public Bitmap getBitmapFromNative(String urlStr) {

		String url = urlStr.hashCode() + "";
		Bitmap bitmap = null;
		bitmap = imageMemoryCache.getBitmapFromMemory(url);

		if (bitmap == null) {
			bitmap = imageFileCache.getImageFromFile(url);
			if (bitmap != null) {
				// 添加到内存缓存
				imageMemoryCache.addBitmapToMemory(url, bitmap);
			}
		}
		return bitmap;
	}

	/**
	 * 通过网络下载图片,与线程无关
	 */
	public Bitmap getBitmapFromHttp(String urlStr) {

		String url = urlStr.hashCode() + "";
		Bitmap bmp = null;

		try {
			byte[] tmpPicByte = getImageBytes(urlStr);

			if (tmpPicByte != null) {
				bmp = BitmapFactory.decodeByteArray(tmpPicByte, 0,
						tmpPicByte.length);
			}
			tmpPicByte = null;
		} catch (Exception e) {
			e.printStackTrace();
		}

		if (bmp != null) {
			// 添加到文件缓存
			imageFileCache.saveBitmapToFile(bmp, url);
			// 添加到内存缓存
			imageMemoryCache.addBitmapToMemory(url, bmp);
		}
		return bmp;
	}

	/**
	 * 下载链接的图片资源
	 * 
	 * @param url
	 * 
	 * @return 图片
	 */
	public byte[] getImageBytes(String urlStr) {
		if (urlStr != null && !"".equals(urlStr)) {
			HttpGet get = new HttpGet(urlStr);
			get.addHeader("Accept-Encoding", "indentity");
			HttpClient client = new DefaultHttpClient();
			HttpResponse response = null;
			try {
				response = client.execute(get);

				if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {

					InputStream is = response.getEntity().getContent();

					ByteArrayOutputStream baos = new ByteArrayOutputStream();
					byte[] buf = new byte[1024];
					int len = -1;
					while ((len = is.read(buf)) != -1) {
						baos.write(buf, 0, len);
					}

					return baos.toByteArray();

				}
			} catch (ClientProtocolException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}

		}
		return null;
	}

	/**
	 * 取出等待队列第一个任务,开始下载
	 */
	private void startDownloadNext() {
		synchronized (waitingTaskMap) {
			Iterator<Entry<String, Handler>> iter = waitingTaskMap.entrySet()
					.iterator();

			if (iter.hasNext()) {

				Map.Entry<String, Handler> entry = (Map.Entry<String, Handler>) iter
						.next();

				if (entry != null) {
					waitingTaskMap.remove(entry.getKey());
					downloadBmpOnNewThread((String) entry.getKey(),
							(Handler) entry.getValue());
				}
			}
		}
	}

	/**
	 * 图片变为圆角
	 * 
	 * @param bitmap
	 *            :传入的bitmap
	 * @param pixels
	 *            :圆角的度数,值越大,圆角越大
	 * @return bitmap:加入圆角的bitmap
	 */
	public static Bitmap toRoundCorner(Bitmap bitmap, int pixels) {
		if (bitmap == null)
			return null;
		Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
				bitmap.getHeight(), Config.ARGB_8888);
		Canvas canvas = new Canvas(output);
		final int color = 0xff424242;
		final Paint paint = new Paint();
		final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
		final RectF rectF = new RectF(rect);
		final float roundPx = pixels;
		paint.setAntiAlias(true);
		canvas.drawARGB(0, 0, 0, 0);
		paint.setColor(color);
		canvas.drawRoundRect(rectF, roundPx, roundPx, paint);

		// paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));

		canvas.drawBitmap(bitmap, rect, rect, paint);
		return output;
	}

}
package com.panpass.main;


import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;


import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;


public class ImageFileCache {




<span style="white-space:pre">	</span>private File cacheDir;


<span style="white-space:pre">	</span>public ImageFileCache(Context context) {
<span style="white-space:pre">		</span>// 如果有SD卡则在SD卡中建一个LazyList的目录存放缓存的图片
<span style="white-space:pre">		</span>// 没有SD卡就放在系统的缓存目录中
<span style="white-space:pre">		</span>if (android.os.Environment.getExternalStorageState().equals(
<span style="white-space:pre">				</span>android.os.Environment.MEDIA_MOUNTED))
<span style="white-space:pre">			</span>cacheDir = new File(
<span style="white-space:pre">					</span>android.os.Environment.getExternalStorageDirectory(),
<span style="white-space:pre">					</span>"LazyList");
<span style="white-space:pre">		</span>else
<span style="white-space:pre">			</span>cacheDir = context.getCacheDir();
<span style="white-space:pre">		</span>if (!cacheDir.exists())
<span style="white-space:pre">			</span>cacheDir.mkdirs();
<span style="white-space:pre">	</span>}


<span style="white-space:pre">	</span>public Bitmap getImageFromFile(String url) {
<span style="white-space:pre">		</span>// 将url的hashCode作为缓存的文件名
<span style="white-space:pre">		</span>// Another possible solution
<span style="white-space:pre">		</span>// String filename = URLEncoder.encode(url);
<span style="white-space:pre">		</span>File f = new File(cacheDir, url);
<span style="white-space:pre">		</span>if(f.exists()){
<span style="white-space:pre">			</span>return BitmapFactory.decodeFile(f.getAbsolutePath());
<span style="white-space:pre">		</span>}
<span style="white-space:pre">		</span>return null;


<span style="white-space:pre">	</span>}
<span style="white-space:pre">	</span>public void saveBitmapToFile(Bitmap bm ,String url) {


<span style="white-space:pre">		</span>File file=new File(cacheDir,url);//将要保存图片的路径
<span style="white-space:pre">		</span>try {
<span style="white-space:pre">			</span>BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
<span style="white-space:pre">			</span>bm.compress(Bitmap.CompressFormat.JPEG, 100, bos);
<span style="white-space:pre">			</span>bos.flush();
<span style="white-space:pre">			</span>bos.close();
<span style="white-space:pre">		</span>} catch (IOException e) {
<span style="white-space:pre">			</span>e.printStackTrace();
<span style="white-space:pre">		</span>}


<span style="white-space:pre">	</span>}






<span style="white-space:pre">	</span>public void clear() {
<span style="white-space:pre">		</span>File[] files = cacheDir.listFiles();
<span style="white-space:pre">		</span>if (files == null)
<span style="white-space:pre">			</span>return;
<span style="white-space:pre">		</span>for (File f : files)
<span style="white-space:pre">			</span>f.delete();
<span style="white-space:pre">	</span>}


}



package com.panpass.main;


import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;


import android.graphics.Bitmap;
import android.util.Log;


public class ImageMemoryCache {


<span style="white-space:pre">	</span>private static final String TAG = "MemoryCache";
<span style="white-space:pre">	</span>/**
<span style="white-space:pre">	</span> * 放入缓存时是个同步操作 LinkedHashMap构造方法的最后一个参数true代表这个map里的元素将按照最 近使用次数由少到多排列,
<span style="white-space:pre">	</span> * 即LRU。
<span style="white-space:pre">	</span> * 这样的好处是如果要将缓存中的元素替换,则先遍历出最近最少使用的元素来替换以提高效率
<span style="white-space:pre">	</span> */
<span style="white-space:pre">	</span>private Map<String, Bitmap> cache = Collections
<span style="white-space:pre">			</span>.synchronizedMap(new LinkedHashMap<String, Bitmap>(10, 1.5f, true));
<span style="white-space:pre">	</span>// 缓存中图片所占用的字节,初始0,将通过此变量严格控制缓存所占用的堆内存
<span style="white-space:pre">	</span>private long size = 0;// current allocated size
<span style="white-space:pre">	</span>// 缓存只能占用的最大堆内存
<span style="white-space:pre">	</span>private long limit = 1000000;// max memory in bytes


<span style="white-space:pre">	</span>public ImageMemoryCache() {
<span style="white-space:pre">		</span>// use 25% of available heap size
<span style="white-space:pre">		</span>setLimit(Runtime.getRuntime().maxMemory() / 4);
<span style="white-space:pre">	</span>}


<span style="white-space:pre">	</span>public void setLimit(long new_limit) {
<span style="white-space:pre">		</span>limit = new_limit;
<span style="white-space:pre">		</span>Log.i(TAG, "MemoryCache will use up to " + limit / 1024. / 1024. + "MB");
<span style="white-space:pre">	</span>}


<span style="white-space:pre">	</span>public Bitmap getBitmapFromMemory(String id) {
<span style="white-space:pre">		</span>try {
<span style="white-space:pre">			</span>if (!cache.containsKey(id))
<span style="white-space:pre">				</span>return null;
<span style="white-space:pre">			</span>return cache.get(id);
<span style="white-space:pre">		</span>} catch (NullPointerException ex) {
<span style="white-space:pre">			</span>return null;
<span style="white-space:pre">		</span>}
<span style="white-space:pre">	</span>}


<span style="white-space:pre">	</span>public void addBitmapToMemory(String id, Bitmap bitmap) {
<span style="white-space:pre">		</span>try {
<span style="white-space:pre">			</span>if (cache.containsKey(id))
<span style="white-space:pre">				</span>size -= getSizeInBytes(cache.get(id));
<span style="white-space:pre">			</span>cache.put(id, bitmap);
<span style="white-space:pre">			</span>size += getSizeInBytes(bitmap);
<span style="white-space:pre">			</span>checkSize();
<span style="white-space:pre">		</span>} catch (Throwable th) {
<span style="white-space:pre">			</span>th.printStackTrace();
<span style="white-space:pre">		</span>}
<span style="white-space:pre">	</span>}


<span style="white-space:pre">	</span>/**
<span style="white-space:pre">	</span> * 严格控制堆内存,如果超过将首先替换最近最少使用的那个图片缓存
<span style="white-space:pre">	</span> * 
<span style="white-space:pre">	</span> */
<span style="white-space:pre">	</span>private void checkSize() {
<span style="white-space:pre">		</span>Log.i(TAG, "cache size=" + size + " length=" + cache.size());
<span style="white-space:pre">		</span>if (size > limit) {
<span style="white-space:pre">			</span>// 先遍历最近最少使用的元素
<span style="white-space:pre">			</span>Iterator<Entry<String, Bitmap>> iter = cache.entrySet().iterator();
<span style="white-space:pre">			</span>while (iter.hasNext()) {
<span style="white-space:pre">				</span>Entry<String, Bitmap> entry = iter.next();
<span style="white-space:pre">				</span>size -= getSizeInBytes(entry.getValue());
<span style="white-space:pre">				</span>iter.remove();
<span style="white-space:pre">				</span>if (size <= limit)
<span style="white-space:pre">					</span>break;
<span style="white-space:pre">			</span>}
<span style="white-space:pre">			</span>Log.i(TAG, "Clean cache. New size " + cache.size());
<span style="white-space:pre">		</span>}
<span style="white-space:pre">	</span>}


<span style="white-space:pre">	</span>public void clear() {
<span style="white-space:pre">		</span>cache.clear();
<span style="white-space:pre">	</span>}


<span style="white-space:pre">	</span>/**
<span style="white-space:pre">	</span> * 图片占用的内存
<span style="white-space:pre">	</span> * 
<span style="white-space:pre">	</span> * @param bitmap
<span style="white-space:pre">	</span> * @return
<span style="white-space:pre">	</span> */
<span style="white-space:pre">	</span>long getSizeInBytes(Bitmap bitmap) {
<span style="white-space:pre">		</span>if (bitmap == null)
<span style="white-space:pre">			</span>return 0;
<span style="white-space:pre">		</span>return bitmap.getRowBytes() * bitmap.getHeight();
<span style="white-space:pre">	</span>}
}


package com.panpass.main;


import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Window;
import android.widget.ImageView;


import com.example.imgdemo.R;


public class MainActivity extends Activity {


<span style="white-space:pre">	</span>private Context mContext = this;


<span style="white-space:pre">	</span>private ImageView img1,img2,img3,img4,img5;
<span style="white-space:pre">	</span>@Override
<span style="white-space:pre">	</span>protected void onCreate(Bundle savedInstanceState) {
<span style="white-space:pre">		</span>super.onCreate(savedInstanceState);
<span style="white-space:pre">		</span>getWindow().requestFeature(Window.FEATURE_NO_TITLE);
<span style="white-space:pre">		</span>setContentView(R.layout.main_acticity);


<span style="white-space:pre">		</span>img1 = (ImageView) findViewById(R.id.img1);
<span style="white-space:pre">		</span>img2 = (ImageView) findViewById(R.id.img2);
<span style="white-space:pre">		</span>img3 = (ImageView) findViewById(R.id.img3);
<span style="white-space:pre">		</span>img4 = (ImageView) findViewById(R.id.img4);
<span style="white-space:pre">		</span>img5 = (ImageView) findViewById(R.id.img5);






<span style="white-space:pre">		</span>ImageManager.getInstance(mContext).loadBitmap("https://www.baidu.com/img/baidu_jgylogo3.gif?v=26599715.gif", new Handler(){


<span style="white-space:pre">			</span>@Override
<span style="white-space:pre">			</span>public void handleMessage(Message msg) {
<span style="white-space:pre">				</span>super.handleMessage(msg);


<span style="white-space:pre">				</span>img1.setImageBitmap((Bitmap)msg.obj);
<span style="white-space:pre">			</span>}
<span style="white-space:pre">		</span>});


<span style="white-space:pre">		</span>ImageManager.getInstance(mContext).loadBitmap("https://www.baidu.com/img/baidu_jgylogo3.gif?v=26599715.gif", new Handler(){


<span style="white-space:pre">			</span>@Override
<span style="white-space:pre">			</span>public void handleMessage(Message msg) {
<span style="white-space:pre">				</span>super.handleMessage(msg);


<span style="white-space:pre">				</span>img2.setImageBitmap((Bitmap)msg.obj);
<span style="white-space:pre">			</span>}
<span style="white-space:pre">		</span>});
<span style="white-space:pre">		</span>ImageManager.getInstance(mContext).loadBitmap("https://www.baidu.com/img/baidu_jgylogo3.gif?v=26599715.gif", new Handler(){


<span style="white-space:pre">			</span>@Override
<span style="white-space:pre">			</span>public void handleMessage(Message msg) {
<span style="white-space:pre">				</span>super.handleMessage(msg);


<span style="white-space:pre">				</span>img3.setImageBitmap((Bitmap)msg.obj);
<span style="white-space:pre">			</span>}
<span style="white-space:pre">		</span>});
<span style="white-space:pre">		</span>ImageManager.getInstance(mContext).loadBitmap("https://www.baidu.com/img/baidu_jgylogo3.gif?v=26599715.gif", new Handler(){


<span style="white-space:pre">			</span>@Override
<span style="white-space:pre">			</span>public void handleMessage(Message msg) {
<span style="white-space:pre">				</span>super.handleMessage(msg);


<span style="white-space:pre">				</span>img4.setImageBitmap((Bitmap)msg.obj);
<span style="white-space:pre">			</span>}
<span style="white-space:pre">		</span>});
<span style="white-space:pre">		</span>ImageManager.getInstance(mContext).loadBitmap("https://www.baidu.com/img/baidu_jgylogo3.gif?v=26599715.gif", new Handler(){


<span style="white-space:pre">			</span>@Override
<span style="white-space:pre">			</span>public void handleMessage(Message msg) {
<span style="white-space:pre">				</span>super.handleMessage(msg);


<span style="white-space:pre">				</span>img5.setImageBitmap((Bitmap)msg.obj);
<span style="white-space:pre">			</span>}
<span style="white-space:pre">		</span>});






<span style="white-space:pre">		</span>//<span style="white-space:pre">		</span>img2.setImageBitmap(ImageManager.getInstance(mContext).getBitmap("https://www.baidu.com/img/baidu_jgylogo3.gif?v=26599715.gif"));
<span style="white-space:pre">		</span>//
<span style="white-space:pre">		</span>//<span style="white-space:pre">		</span>img3.setImageBitmap(ImageManager.getInstance(mContext).getBitmap("https://www.baidu.com/img/baidu_jgylogo3.gif?v=26599715.gif"));
<span style="white-space:pre">		</span>//<span style="white-space:pre">		</span>img4.setImageBitmap(ImageManager.getInstance(mContext).getBitmap("https://www.baidu.com/img/baidu_jgylogo3.gif?v=26599715.gif"));
<span style="white-space:pre">		</span>//<span style="white-space:pre">		</span>img5.setImageBitmap(ImageManager.getInstance(mContext).getBitmap("https://www.baidu.com/img/baidu_jgylogo3.gif?v=26599715.gif"));
<span style="white-space:pre">	</span>}








}





Image Download(图片下载) 可以自动下载网页,论坛,相册,图集,缩略图所对应的图片,并自动跳入下一页. 用户也可以引导程序找到下一页. 程序还可以将整个小站的所有图片下载下来. 支持超链接,javascript,多帧等情况 it can download the images of website, forum, album, and jump to the next page automatically. and the user also can help the app to find the next button/page, so that it can automatically download images. it also can download some small websites' all images if you want. it can support the hyper link, javascript, multi-frames. it is based on .NET 2.0 the language is C# the core tech is webbrowser, multi-thread, 立即下载

相关推荐

Android使用缓存机制实现文件下载及异步请求图片加三级缓存

首先给大家介绍Android使用缓存机制实现文件下载 在下载文件或者在线浏览文件时,或者为了保证文件下载的正确性,需要使用缓存机制,常使用SoftReference来实现。 SoftReference的特点是它的一个实例保存对一个Java对象的软引用,该软引用的存在不妨碍垃圾收集线程对该Java对象的回收。也就是说,一旦SoftReference保存了对一个Java对象的软引用后,在垃圾线程对这个Java对象回收前,SoftReference类所提供的get()方法返回Java对象的强引用。另外,一旦垃圾线程回收该Java对象之后,get()方法将返回null。软引用可以和一个引用队列(Re

【Android -- 学习笔记】图片的三级缓存

Android 图片的三级缓存

Kevin Learn Android 668

restbed编译笔记

Restbed 可以构建出基于asio库的restfulAPI服务,Restbed 4.7版本使用了1.12.0版本的asio(其他版本编译不通过),可直接访问github下载:https://github.com/chriskohlhoff/asio/tree/asio-1-12-0。另外Restbed还依赖openssl库(可直接下载exe的安装包,安装后取出lib库及头文件放到到restbed\dependency\openssl中即可,https://slproweb.com/download/W.

mahong100的博客 2108

android中的三级缓存,自己动手实现Android中的三级缓存框架

前言2018年过去了,很久之前就希望自己可以潜心研究源码,研究技术,但是空闲时间不是看电影,就是玩游戏都没有认真看技术方面的东西感觉很内疚,2019年一定要好好的研究端正态度,认真学习技术。为什么要三级缓存有时候Android应用中要获取比较大的数据,比如说图片流,短视频流等,如果每次都从网络上去请求,那么响应速度很慢的,用户体验不好。 二级缓存 如果把服务器拉下来的数据保存在本地数据库中,在服务...

weixin_34279705的博客 469

ADS与MATLAB数据互通全指南:从Snp文件导入到TXT导出完整流程

本文详细介绍了在射频与微波工程中,实现ADS与MATLAB高效数据互通的完整流程。核心内容包括利用SPOutput控件、数据显示窗口及测量方程等多种方法,将ADS仿真数据(如S参数)导出为Touchstone或TXT格式,并导入MATLAB进行深度分析与可视化;同时指导如何将MATLAB处理后的数据回灌至ADS,用于模型验证与协同仿真,旨在构建自动化、无损的数据交换工作流,提升工程师的工作效率。

pluto的博客 394

交通小白首投TRB就中Oral?我的完整时间线与避坑指南(附Editorial Manager实操截图)

本文详细解析了交通领域新手如何高效完成TRB国际会议投稿的全流程,从选题策略到投稿系统实操,再到评审过程解析和常见误区避坑指南。特别针对初次投稿者提供了实用建议,包括时间规划、选题考量、Editorial Manager系统操作技巧,以及如何应对评审意见。文章还分享了从录用到会议参与的关键步骤,帮助研究者提升投稿成功率。

weixin_27303545的博客 389

android中图片的三级cache策略(内存 文件 网络)之二 内存缓存策略

android中图片的三级cache策略(内存 文件 网络)之二 内存缓存策略

qq_43661383的博客 324

Codex CLI 接入智谱 GLM-5.1 完整教程

Codex CLI 是 OpenAI 推出的命令行 AI 编程工具,支持自主读取文件、执行命令、编写代码等操作,是目前最火的终端 AI 编程工具之一。通过 CLIProxyAPI 代理,我们成功将 Codex CLI 与智谱 GLM-5.1 模型对接,核心在于解决 Responses API 与 Chat Completions API 的协议转换问题。✅成熟稳定:CLIProxyAPI 社区活跃(4.7k fork),持续维护✅完整兼容:支持流式/非流式、function calling✅低成本。

u011831527的博客 2584

Android中图片的三级缓存(内存、文件、网络)

最近项目中图片太多起初只做了二级缓存(其实就是做了一个文件缓存)但是总感觉不够好,于是就研究了一下三级缓存并用到项目中。下面就谈谈三级缓存吧。1、为什么要使用三级缓存 如今的 Android App 经常会需要网络交互,通过网络获取图片是再正常不过的事了 假如每次启动的时候都从网络拉取图片的话,势必会消耗很多流量。对于非wifi用户来说,流量还是很贵的,一个很耗流量的应用,其用户数量级肯定要受到影响

Army_Jun的博客 3918

在VINS-FUSION上处理KITTI数据集(双目+GPS)

VINS-Fusion 是一个开源的实时多传感器状态估计库,主要由香港科技大学的沈邵劼教授领导的研究团队开发。它是 VINS-Mono(单目视觉惯性系统)的扩展,支持多种传感器组合,如双目、立体相机和IMU。

如果想成为中心,那么就到中心去吧。 1206

数据处理和分析之数据聚类:层次聚类(Hierarchical Clustering):单链接层次聚类方法

单链接层次聚类(Single-Linkage Hierarchical Clustering)是凝聚型层次聚类的一种,它基于数据点之间的最小距离来定义聚类间的相似性。在单链接层次聚类中,两个聚类之间的距离定义为这两个聚类中任意两个数据点之间的最短距离。这种聚类方法倾向于形成链状或线性的聚类,因为聚类的边界是由最远的数据点决定的,而不是聚类的平均或中心位置。单链接层次聚类通过计算簇间最近点的距离来决定簇的合并,这种方法简单直观,但可能导致簇的形状不规则,尤其是在数据点分布不均匀的情况下。

2401_87715305的博客 1443

android中图片的三级cache策略(内存、文件、网络)之二:内存缓存策略

前言 记得很久之前我写了一篇banner的文章,好多朋友找我要代码,并要我开放banner中使用的图片管理工厂-ImageManager。如果想很好地理解下面的故事,请参看我半年前写的两篇博文:android中图片的三级cache策略(内存、文件、网络) 一 和 android中左右滑屏的实现(广告位banner组件)。当时没有发上来是由于如下几点原因:首先代码较多,其次当时写的时候也参考了

singwhatiwanna 1万+

2、MOSFET基本物理效应及其BSIM4模型解析

本文深入探讨了MOSFET的基本物理效应及其在BSIM4模型中的数学表述,涵盖门和沟道的几何结构、温度依赖性、材料模型选项、阈值电压计算、以及其他关键物理效应如LDD电阻、有限电荷厚度、有效迁移率等。同时解析了机械应力、邻近效应及布局依赖效应对MOSFET性能的影响,并通过参数表和建模流程提供了精确建模的指导,旨在帮助读者优化MOSFET器件性能与可靠性。

purple的博客 566

android中图片的三级cache策略(内存、文件、网络)之三:文件缓存策略

前言 如果想很好地理解下面的故事,请参看我半年前写的两篇博文:android中图片的三级cache策略(内存、文件、网络) 一 和 android中左右滑屏的实现(广告位banner组件),还有昨天晚上写的android中图片的三级cache策略(内存、文件、网络)之二:内存缓存策略。 文件缓存策略 当一张图片从网络下载成功以后,这个图片会被加入内存缓存和文件缓存,对于文件缓存来说,这张

singwhatiwanna 1万+

2026数学建模国赛D题:时频冲突检测与消解 论文解析

最终无需撤销任何计划,共调整110个计划,其中频移43个、时移48个、间隔调整19个,总调整幅度528。附件模板只要求填写新增计划的频段区间和首次时间区间,没有要求填写宽度、间隔和次数,因此本文按附件中C类装备的统一需求特征处理:每个新增计划占用3个连续频段,持续2个时间单位,间隔8,使用12次。本文针对有限频带内大量周期性用频计划的时频冲突检测、单参数消解、无冲突条件下新增C类计划装载,以及允许调整间隔时长后的再次消解问题,建立了由占用展开、冲突图、组合动作集、精确约束满足和二维资源装箱组成的统一模型。

YOLO 190

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

android中图片的三级cache策略(内存 文件 网络)之三 文件缓存策略

android中图片的三级cache策略(内存 文件 网络)之三 文件缓存策略

qq_43661383的博客 287

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

Android 三级缓存Cache(内存,文件,网络)图片缓存设计

Android 三级缓存Cache(内存,文件,网络)图片缓存设计

ZengTao 2017

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

安卓图片三级缓存策略与实现

前言: 这里说的三级缓存,分别指的是:内存缓存、文件缓存和网络这三个层面。 一般来说,我们首次加载图片,内存和文件是没有缓存的,这样我们需要从网络加载,加载完成后,我们会存到内存和文件中去;当再次加载图片的时候,我们会先查找内存有没有,如果有就直接显示内存中的图片,如果没有,我们会接着查找文件中是否有,如果文件中有,我们会显示文件中的图片,并且把它存到内存中去,这样下次我们在内存中就能找到它了

YanRu的专栏 6129

android中图片的三级缓存cache策略(内存/文件/网络)

实现图片缓存也不难,需要有相应的cache策略。这里我采用 内存-文件-网络 三层cache机制,其中内存缓存包括强引用缓存和软引用缓存(SoftReference),其实网络不算cache,这里姑且也把它划到缓存的层次结构中 1.简介现在android应用中不可避免的要使用图片,有些图片是可以变化的,需要每次启动时从网络拉取,这种场景在有广告位的应用以及纯图片应...

dcqxxx0916的博客 155
上一篇: ======AR======
下一篇: ======socket 通信======
SoulOfAndroid
博客等级 码龄12年 8粉丝 84原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值