A class used to store cache data into theSD card, or read cache from it.
Fields |
private LongSparseArray<Record> mIndexMap; |
privatefinal LongSparseArray<RandomAccessFile> mChunkFiles |
LongSparseArray: SparseArrays map longs to Objects. Unlike a normal array of Objects,there can be gaps in the indices. It is intended to be more efficient thanusing a HashMap to map Longs to Objects.
mIndexMap: a map from (long) keyto a record which indiactes the offset / size of the data stored in the chunkfile.
private static final class Record {
…
public final long timestamp;
public final int chunk;
public final int offset;
public final int size;
public final int sizeOnDisk;
}
mChunkFiles: a map from (Record.) chunkto the random access chunk files.
Methods |
publicbyte[] get(long key, long timestamp) |
publicvoid put(long key, byte[] data, long timestamp) |
get:
put:
extends IntentService
IntentService is a base class for Service
sthat handle asynchronous requests (expressedas Intent
s) on demand. Clients send requests through startService(Intent)
calls; the service is started as needed, handles each Intent inturn using a worker thread, and stops itself when it runs out of work. To use it, extend IntentService andimplement onHandleIntent
(Intent)
.IntentService will receive the Intents, launch a worker thread, and stop theservice as appropriate.
All requests are handled on a singleworker thread -- they may take as long as necessary (and will not block theapplication's main loop), but only one request will be processed at a time.
A class used to store cache data into the SD card, or read cachefrom it.
Fields |
publicstaticfinal DiskCache sAlbumCache = new DiskCache("local-album-cache"); |
publicstaticfinal DiskCache sMetaAlbumCache = new DiskCache("local-meta-cache"); |
publicstaticfinal DiskCache sSkipThumbnailIds = new DiskCache("local-skip-cache"); |
|
privatestatic ImageList sList = null; |
|
|
|
|
|
|
LongSparseArray: SparseArrays map longs to Objects. Unlike a normal array of Objects,there can be gaps
Gallery.java is the mainand launcher activity.
App.java hooks up other activity classes to App,including Gallery.
ImageManager.java is usedto retrieve and store images in the media content provider.
MediaFeed, MediaSets负责相册集的加载
RenderView.java extendsGLSurfaceView
SDK 中的 android.opengl.GLSurfaceView 类提供如下功能:
· 在 OpenGL ES 和 View 系统之间建立联系;
·得 OpenGL ES 可以工作在 Activity 生命周期中;
·可选择合适的 frame buffer 像素格式;
·创建并管理一个单独的渲染线程,可以实现平滑的动画;
·提供 debugging 工具和 API。
GLSurfaceView.Render 接口负责调用OpenGL来渲染一帧画面,有三个方法:
· onSurfaceCreated(): 该方法在渲染开始前调用,OpenGL ES 的绘制上下文被重建时也会被调用。当 activity 暂停时绘制上下文会丢失,当 activity 继续时,绘制上下文会被重建。另外,创建长期存在的 OpenGL 资源(如 texture)往往也在这里进行。
· onSurfaceChanged(): 当 surface 的尺寸发生改变时该方法被调用。往往在这里设置 viewport。若你的 camera 是固定的,也可以在这里设置 camera。
· onDrawFrame(): 每帧都通过该方法进行绘制。绘制时通常先调用 glClear 函数来清空 framebuffer,然后在调用 OpenGL ES 的起它的接口进行绘制。