use of com.stickercamera.app.model.Album in project StickerCamera by Skykai521.
the class ImageUtils method findGalleries.
public static Map<String, Album> findGalleries(Context mContext, List<String> paths, long babyId) {
paths.clear();
paths.add(FileUtils.getInst().getSystemPhotoPath());
String[] projection = { MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA, //FIXME 拍照时间为新增照片时间
MediaStore.Images.Media.DATE_ADDED };
Cursor cursor = mContext.getContentResolver().query(//指定所要查询的字段
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, //指定所要查询的字段
projection, //查询条件
MediaStore.Images.Media.SIZE + ">?", //查询条件中问号对应的值
new String[] { "100000" }, MediaStore.Images.Media.DATE_ADDED + " desc");
cursor.moveToFirst();
//文件夹照片
Map<String, Album> galleries = new HashMap<String, Album>();
while (cursor.moveToNext()) {
String data = cursor.getString(1);
if (data.lastIndexOf("/") < 1) {
continue;
}
String sub = data.substring(0, data.lastIndexOf("/"));
if (!galleries.keySet().contains(sub)) {
String name = sub.substring(sub.lastIndexOf("/") + 1, sub.length());
if (!paths.contains(sub)) {
paths.add(sub);
}
galleries.put(sub, new Album(name, sub, new ArrayList<PhotoItem>()));
}
galleries.get(sub).getPhotos().add(new PhotoItem(data, (long) (cursor.getInt(2)) * 1000));
}
//系统相机照片
ArrayList<PhotoItem> sysPhotos = FileUtils.getInst().findPicsInDir(FileUtils.getInst().getSystemPhotoPath());
if (!sysPhotos.isEmpty()) {
galleries.put(FileUtils.getInst().getSystemPhotoPath(), new Album("胶卷相册", FileUtils.getInst().getSystemPhotoPath(), sysPhotos));
} else {
galleries.remove(FileUtils.getInst().getSystemPhotoPath());
paths.remove(FileUtils.getInst().getSystemPhotoPath());
}
return galleries;
}