packages/apps/SnapdragonGallery/src/com/android/gallery3d/app/
GalleryActivity.java
//打开显示view
//碰到过类似问题,如果从安全角度来看,这本不算gallery的一个bug, 它主要关系到是否允许用户通过滑动来查看其它照片的问题
startViewAction(){
Path itemPath = dm.findPathByUri(uri, contentType);
Path albumPath = dm.getDefaultSetOf(itemPath);
boolean singleItemOnly = (albumPath == null) || intent.getBooleanExtra("SingleItemOnly", false);
if (!singleItemOnly) {
data.putString(PhotoPage.KEY_MEDIA_SET_PATH, albumPath.toString());
}
getStateManager().startState(SinglePhotoPage.class, data);
}
DataManager.java
findPathByUri(){
for (MediaSource source : mSourceMap.values()) {//主要有两个LocalSource 和 UriSource
}
}
getDefaultSetOf(){
MediaSource source = mSourceMap.get(item.getPrefix());//Prefix 为local 和 uri
}
UriSource UriImage
LocalSource LocalAlbumSet LocalAlbum LocalImage LocalVideo
UriImage.java
//DrmHelper DRM:数字版权管理
@Override
public Job<Bitmap> requestImage(int type) {
return new BitmapJob(type);
}
@Override
public Job<BitmapRegionDecoder> requestLargeImage() {
return new RegionDecoderJob();
}
startViewAction. uri=content://media/external/images/media/215contentType=image/gif
GalleryActivity: startViewAction. (itemPath )=/local/image/item/215
GalleryActivity: startViewAction. (albumPath )=/local/all/540528482
startViewAction. uri=content://com.android.providers.media.documents/document/image%3A240contentType=image/gif
GalleryActivity: startViewAction. (itemPath )=/uri/content%3A%2F%2Fcom.android.providers.media.documents%2Fdocument%2Fimage%253A240/image%2Fgif
GalleryActivity: startViewAction. (albumPath == null)=true
PhotoPage.java
onCreate(){
mMenuExecutor = new MenuExecutor(mActivity, mSelectionManager);
mPhotoView = new PhotoView(mActivity);//显示的view
mPhotoView.setListener(this);
mSetPathString = data.getString(KEY_MEDIA_SET_PATH);
(mSetPathString != null){ //打开动态(原图) PhotoDataAdapter
PhotoDataAdapter pda = new PhotoDataAdapter(
mActivity, mPhotoView, mMediaSet, itemPath, mCurrentIndex,
mAppBridge == null ? -1 : 0,
mAppBridge == null ? false : mAppBridge.isPanorama(),
mAppBridge == null ? false : mAppBridge.isStaticCamera());
mModel = pda;
mPhotoView.setModel(mModel);
}else {// Get default media set by the URI //否则,就是缩列图 (只有一帧) SinglePhotoDataAdapter
Log.w(TAG, "Get default media set by the URI ");
MediaItem mediaItem = (MediaItem)
mActivity.getDataManager().getMediaObject(itemPath);
mModel = new SinglePhotoDataAdapter(mActivity, mPhotoView, mediaItem);
mPhotoView.setModel(mModel);
updateCurrentPhoto(mediaItem);
}
}
SinglePhotoDataAdapter.java
onDecodeLargeComplete();//原图显示
onDecodeThumbComplete();//缩列图显示