use of com.yydcdut.note.entity.PhotoNote in project PhotoNoter by yydcdut.
the class SandBoxServicePresenterImpl method makePhoto.
/**
* 做图
*
* @param sandPhoto
*/
private void makePhoto(SandPhoto sandPhoto) {
byte[] rowData = getDataFromFile(sandPhoto.getFileName(), sandPhoto.getSize());
if (rowData == null) {
return;
}
byte[] data;
if (sandPhoto.getImageFormat() == ImageFormat.JPEG) {
data = rowData;
} else {
data = decodeNV21(rowData, sandPhoto.getSandExif().getImageWidth(), sandPhoto.getSandExif().getImageLength());
}
if (data == null) {
return;
}
Bitmap bitmap = null;
try {
bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
} catch (OutOfMemoryError e) {
YLog.e(e);
}
String fileName = sandPhoto.getTime() + ".jpg";
if (FilePathUtils.savePhoto(fileName, bitmap)) {
FilePathUtils.saveSmallPhoto(fileName, bitmap);
}
PhotoNote photoNote = new PhotoNote(fileName, sandPhoto.getTime(), sandPhoto.getTime(), "", "", sandPhoto.getTime(), sandPhoto.getTime(), sandPhoto.getCategoryId());
photoNote.setPaletteColor(Utils.getPaletteColor(bitmap));
mRxPhotoNote.savePhotoNote(photoNote).subscribe(photoNote1 -> {
}, (throwable -> YLog.e(throwable)));
try {
setExif(photoNote, sandPhoto.getSandExif(), sandPhoto.getCameraId(), sandPhoto.isMirror());
} catch (IOException e) {
YLog.e(e);
}
deleteFromDBAndSDCard(sandPhoto);
// bitmap.recycle();
System.gc();
}
use of com.yydcdut.note.entity.PhotoNote in project PhotoNoter by yydcdut.
the class AlbumPresenterImpl method changePhotosCategory.
@Override
public void changePhotosCategory(int toCategoryId) {
if (mCategoryId != toCategoryId) {
mRxPhotoNote.findByCategoryId(mCategoryId, mAlbumSortKind).observeOn(AndroidSchedulers.mainThread()).map(photoNoteList -> {
TreeMap<Integer, PhotoNote> map = getTreeMap();
for (int i = 0; i < photoNoteList.size(); i++) {
PhotoNote photoNote = photoNoteList.get(i);
if (photoNote.isSelected()) {
photoNote.setSelected(false);
photoNote.setCategoryId(toCategoryId);
map.put(i, photoNote);
}
}
int times = 0;
for (Map.Entry<Integer, PhotoNote> entry : map.entrySet()) {
photoNoteList.remove(entry.getValue());
// todo 这个在这里合适吗?觉得严重的不合适
mAlbumView.notifyItemRemoved(entry.getKey() - times);
mRxPhotoNote.updatePhotoNote(entry.getValue()).subscribe((photoNotes -> {
}), (throwable -> YLog.e(throwable)));
times++;
}
return map.size();
}).subscribe(integer -> {
mRxCategory.updateChangeCategory(mCategoryId, toCategoryId, integer).subscribe(categories -> {
mRxPhotoNote.refreshByCategoryId(mCategoryId, ComparatorFactory.FACTORY_NOT_SORT).subscribe((photoNoteList) -> mAlbumView.updateDataNoChange(photoNoteList), (throwable -> YLog.e(throwable)));
mRxPhotoNote.refreshByCategoryId(toCategoryId, ComparatorFactory.FACTORY_NOT_SORT).subscribe(photoNotes -> {
}, (throwable -> YLog.e(throwable)));
EventBus.getDefault().post(new CategoryMoveEvent());
}, (throwable -> YLog.e(throwable)));
}, (throwable -> YLog.e(throwable)));
}
}
use of com.yydcdut.note.entity.PhotoNote in project PhotoNoter by yydcdut.
the class PhotoNoteDB method findByCategoryId.
public synchronized List<PhotoNote> findByCategoryId(int categoryId) {
List<PhotoNote> list = new ArrayList<>();
SQLiteDatabase db = mNotesSQLite.getReadableDatabase();
Cursor cursor = db.query(NotesSQLite.TABLE_PHOTONOTE, null, "categoryId = ?", new String[] { categoryId + "" }, null, null, null);
while (cursor.moveToNext()) {
int id = cursor.getInt(cursor.getColumnIndex("_id"));
String photoName = cursor.getString(cursor.getColumnIndex("photoName"));
long createdPhotoTime = cursor.getLong(cursor.getColumnIndex("createdPhotoTime"));
long editedPhotoTime = cursor.getLong(cursor.getColumnIndex("editedPhotoTime"));
String title = cursor.getString(cursor.getColumnIndex("title"));
String content = cursor.getString(cursor.getColumnIndex("content"));
long createdNoteTime = cursor.getLong(cursor.getColumnIndex("createdNoteTime"));
long editedNoteTime = cursor.getLong(cursor.getColumnIndex("editedNoteTime"));
int color = cursor.getInt(cursor.getColumnIndex("palette"));
int tag = cursor.getInt(cursor.getColumnIndex("tag"));
int categoryId_ = cursor.getInt(cursor.getColumnIndex("categoryId"));
PhotoNote photoNote = new PhotoNote(id, photoName, createdPhotoTime, editedPhotoTime, title, content, createdNoteTime, editedNoteTime, categoryId_);
photoNote.setPaletteColor(color);
list.add(photoNote);
}
cursor.close();
db.close();
return list;
}
use of com.yydcdut.note.entity.PhotoNote in project PhotoNoter by yydcdut.
the class PhotoNoteDB method delete.
public synchronized int delete(PhotoNote... photoNotes) {
SQLiteDatabase db = mNotesSQLite.getWritableDatabase();
db.beginTransaction();
int rows = 0;
try {
for (PhotoNote photoNote : photoNotes) {
rows = db.delete(NotesSQLite.TABLE_PHOTONOTE, "_id = ?", new String[] { photoNote.getId() + "" });
}
db.setTransactionSuccessful();
} catch (Exception e) {
YLog.e(e);
return -1;
} finally {
// 处理完成
db.endTransaction();
db.close();
}
return rows;
}
use of com.yydcdut.note.entity.PhotoNote in project PhotoNoter by yydcdut.
the class AlbumAdapter method cancelSelectPhotos.
/**
* 取消选择所有照片
*/
public void cancelSelectPhotos() {
for (PhotoNote photoNote : mPhotoNoteList) {
photoNote.setSelected(false);
int index = mPhotoNoteList.indexOf(photoNote);
notifyItemChanged(index);
}
}
Aggregations