use of com.stickercamera.app.model.PhotoItem in project StickerCamera by Skykai521.
the class FileUtils method findPicsInDir.
//获取path路径下的图片
public ArrayList<PhotoItem> findPicsInDir(String path) {
ArrayList<PhotoItem> photos = new ArrayList<PhotoItem>();
File dir = new File(path);
if (dir.exists() && dir.isDirectory()) {
for (File file : dir.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
String filePath = pathname.getAbsolutePath();
return (filePath.endsWith(".png") || filePath.endsWith(".jpg") || filePath.endsWith(".jepg"));
}
})) {
photos.add(new PhotoItem(file.getAbsolutePath(), file.lastModified()));
}
}
Collections.sort(photos);
return photos;
}
use of com.stickercamera.app.model.PhotoItem 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;
}
use of com.stickercamera.app.model.PhotoItem in project StickerCamera by Skykai521.
the class AlbumFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View root = inflater.inflate(R.layout.fragment_album, null);
photos = (ArrayList<PhotoItem>) getArguments().getSerializable("photos");
albums = (GridView) root.findViewById(R.id.albums);
albums.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
PhotoItem photo = photos.get(arg2);
CameraManager.getInst().processPhotoItem(getActivity(), photo);
}
});
return root;
}
use of com.stickercamera.app.model.PhotoItem in project StickerCamera by Skykai521.
the class CameraActivity method addPhoto.
private void addPhoto(PhotoItem photoItem) {
ImageView photo = new ImageView(this);
if (StringUtils.isNotBlank(photoItem.getImageUri())) {
ImageLoaderUtils.displayLocalImage(photoItem.getImageUri(), photo, null);
} else {
photo.setImageResource(R.drawable.default_img);
}
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(photoWidth, photoWidth);
params.leftMargin = photoMargin;
params.rightMargin = photoMargin;
params.gravity = Gravity.CENTER;
photo.setScaleType(ImageView.ScaleType.CENTER_CROP);
photo.setTag(photoItem.getImageUri());
if (photoArea.getChildCount() >= photoNumber) {
photoArea.removeViewAt(photoArea.getChildCount() - 1);
photoArea.addView(photo, 0, params);
} else {
photoArea.addView(photo, 0, params);
}
photo.setOnClickListener(v -> {
if (v instanceof ImageView && v.getTag() instanceof String) {
CameraManager.getInst().processPhotoItem(CameraActivity.this, new PhotoItem((String) v.getTag(), System.currentTimeMillis()));
}
});
}
use of com.stickercamera.app.model.PhotoItem in project StickerCamera by Skykai521.
the class GalleryAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final GalleryHolder holder;
int width = DistanceUtil.getCameraAlbumWidth();
if (convertView == null) {
LayoutInflater layoutInflater = LayoutInflater.from(mContext);
convertView = layoutInflater.inflate(R.layout.item_gallery, null);
holder = new GalleryHolder();
holder.sample = (ImageView) convertView.findViewById(R.id.gallery_sample_image);
holder.sample.setLayoutParams(new AbsListView.LayoutParams(width, width));
convertView.setTag(holder);
} else {
holder = (GalleryHolder) convertView.getTag();
}
final PhotoItem gallery = (PhotoItem) getItem(position);
ImageLoaderUtils.displayLocalImage(gallery.getImageUri(), holder.sample, null);
return convertView;
}
Aggregations