Search in sources :

Example 1 with SandExif

use of com.yydcdut.note.entity.SandExif in project PhotoNoter by yydcdut.

the class SandBoxDB method save.

/**
 * 保存
 *
 * @param sandPhoto
 * @return
 */
public synchronized long save(SandPhoto sandPhoto) {
    SQLiteDatabase db = mSandSQLite.getWritableDatabase();
    ContentValues contentValues = new ContentValues();
    contentValues.put("data", new byte[] { 'a' });
    contentValues.put("time", sandPhoto.getTime());
    contentValues.put("cameraId", sandPhoto.getCameraId());
    contentValues.put("category", sandPhoto.getCategoryId() + "");
    contentValues.put("mirror", sandPhoto.isMirror());
    contentValues.put("ratio", sandPhoto.getRatio());
    contentValues.put("fileName", sandPhoto.getFileName());
    contentValues.put("size", sandPhoto.getSize());
    contentValues.put("imageFormat_", sandPhoto.getImageFormat());
    SandExif sandExif = sandPhoto.getSandExif();
    contentValues.put("orientation_", sandExif.getOrientation());
    contentValues.put("latitude_", sandExif.getLatitude());
    contentValues.put("lontitude_", sandExif.getLongitude());
    contentValues.put("whiteBalance_", sandExif.getWhiteBalance());
    contentValues.put("flash_", sandExif.getFlash());
    contentValues.put("imageLength_", sandExif.getImageLength());
    contentValues.put("imageWidth_", sandExif.getImageWidth());
    contentValues.put("make_", sandExif.getMake());
    contentValues.put("model_", sandExif.getModel());
    long id = db.insert(SandSQLite.TABLE, null, contentValues);
    db.close();
    return id;
}
Also used : ContentValues(android.content.ContentValues) SandExif(com.yydcdut.note.entity.SandExif) SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

Example 2 with SandExif

use of com.yydcdut.note.entity.SandExif in project PhotoNoter by yydcdut.

the class SandBoxDB method findById.

public synchronized SandPhoto findById(long _id) {
    SandPhoto sandPhoto = null;
    SQLiteDatabase db = mSandSQLite.getReadableDatabase();
    Cursor cursor = db.query(SandSQLite.TABLE, null, "_id = ?", new String[] { _id + "" }, null, null, null, null);
    while (cursor.moveToNext()) {
        long id = cursor.getLong(cursor.getColumnIndex("_id"));
        long time = cursor.getLong(cursor.getColumnIndex("time"));
        String cameraId = cursor.getString(cursor.getColumnIndex("cameraId"));
        String categoryIdString = cursor.getString(cursor.getColumnIndex("category"));
        int categoryId;
        try {
            categoryId = Integer.parseInt(categoryIdString);
        } catch (Exception e) {
            YLog.e(e);
            categoryId = -1;
        }
        String isMirrorString = cursor.getString(cursor.getColumnIndex("mirror"));
        boolean isMirror = isMirrorString.equals("0") ? false : true;
        int ratio = cursor.getInt(cursor.getColumnIndex("ratio"));
        String fileName = cursor.getString(cursor.getColumnIndex("fileName"));
        int size = cursor.getInt(cursor.getColumnIndex("size"));
        int orientation1 = cursor.getInt(cursor.getColumnIndex("orientation_"));
        String latitude = cursor.getString(cursor.getColumnIndex("latitude_"));
        String lontitude = cursor.getString(cursor.getColumnIndex("lontitude_"));
        int whiteBalance = cursor.getInt(cursor.getColumnIndex("whiteBalance_"));
        int flash = cursor.getInt(cursor.getColumnIndex("flash_"));
        int imageLength = cursor.getInt(cursor.getColumnIndex("imageLength_"));
        int imageWidth = cursor.getInt(cursor.getColumnIndex("imageWidth_"));
        String make = cursor.getString(cursor.getColumnIndex("make_"));
        String model = cursor.getString(cursor.getColumnIndex("model_"));
        int imageFormat = cursor.getInt(cursor.getColumnIndex("imageFormat_"));
        SandExif sandExif = new SandExif(orientation1, latitude, lontitude, whiteBalance, flash, imageLength, imageWidth, make, model);
        sandPhoto = new SandPhoto(id, time, cameraId, categoryId, isMirror, ratio, fileName, size, imageFormat, sandExif);
    }
    cursor.close();
    db.close();
    return sandPhoto;
}
Also used : SandExif(com.yydcdut.note.entity.SandExif) SandPhoto(com.yydcdut.note.entity.SandPhoto) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor)

Example 3 with SandExif

use of com.yydcdut.note.entity.SandExif in project PhotoNoter by yydcdut.

the class SandBoxDB method finaAll.

public synchronized List<SandPhoto> finaAll() {
    List<SandPhoto> sandPhotoList = new ArrayList<>();
    SQLiteDatabase db = mSandSQLite.getReadableDatabase();
    Cursor cursor = db.query(SandSQLite.TABLE, null, null, null, null, null, null, null);
    while (cursor.moveToNext()) {
        long id = cursor.getLong(cursor.getColumnIndex("_id"));
        long time = cursor.getLong(cursor.getColumnIndex("time"));
        String cameraId = cursor.getString(cursor.getColumnIndex("cameraId"));
        String categoryIdString = cursor.getString(cursor.getColumnIndex("category"));
        int categoryId;
        try {
            categoryId = Integer.parseInt(categoryIdString);
        } catch (Exception e) {
            YLog.e(e);
            categoryId = -1;
        }
        String isMirrorString = cursor.getString(cursor.getColumnIndex("mirror"));
        boolean isMirror = isMirrorString.equals("0") ? false : true;
        int ratio = cursor.getInt(cursor.getColumnIndex("ratio"));
        String fileName = cursor.getString(cursor.getColumnIndex("fileName"));
        int size = cursor.getInt(cursor.getColumnIndex("size"));
        int orientation1 = cursor.getInt(cursor.getColumnIndex("orientation_"));
        String latitude = cursor.getString(cursor.getColumnIndex("latitude_"));
        String lontitude = cursor.getString(cursor.getColumnIndex("lontitude_"));
        int whiteBalance = cursor.getInt(cursor.getColumnIndex("whiteBalance_"));
        int flash = cursor.getInt(cursor.getColumnIndex("flash_"));
        int imageLength = cursor.getInt(cursor.getColumnIndex("imageLength_"));
        int imageWidth = cursor.getInt(cursor.getColumnIndex("imageWidth_"));
        String make = cursor.getString(cursor.getColumnIndex("make_"));
        String model = cursor.getString(cursor.getColumnIndex("model_"));
        int imageFormat = cursor.getInt(cursor.getColumnIndex("imageFormat_"));
        SandExif sandExif = new SandExif(orientation1, latitude, lontitude, whiteBalance, flash, imageLength, imageWidth, make, model);
        SandPhoto sandPhoto = new SandPhoto(id, time, cameraId, categoryId, isMirror, ratio, fileName, size, imageFormat, sandExif);
        sandPhotoList.add(sandPhoto);
    }
    cursor.close();
    db.close();
    return sandPhotoList;
}
Also used : SandExif(com.yydcdut.note.entity.SandExif) SandPhoto(com.yydcdut.note.entity.SandPhoto) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor)

Example 4 with SandExif

use of com.yydcdut.note.entity.SandExif in project PhotoNoter by yydcdut.

the class SandBoxDB method findFirstOne.

public synchronized SandPhoto findFirstOne() {
    SandPhoto sandPhoto = null;
    SQLiteDatabase db = mSandSQLite.getReadableDatabase();
    Cursor cursor = db.query(SandSQLite.TABLE, null, null, null, null, null, null, "0,1");
    while (cursor.moveToNext()) {
        long id = cursor.getLong(cursor.getColumnIndex("_id"));
        long time = cursor.getLong(cursor.getColumnIndex("time"));
        String cameraId = cursor.getString(cursor.getColumnIndex("cameraId"));
        String categoryIdString = cursor.getString(cursor.getColumnIndex("category"));
        int categoryId;
        try {
            categoryId = Integer.parseInt(categoryIdString);
        } catch (Exception e) {
            YLog.e(e);
            categoryId = -1;
        }
        String isMirrorString = cursor.getString(cursor.getColumnIndex("mirror"));
        boolean isMirror = isMirrorString.equals("0") ? false : true;
        int ratio = cursor.getInt(cursor.getColumnIndex("ratio"));
        String fileName = cursor.getString(cursor.getColumnIndex("fileName"));
        int size = cursor.getInt(cursor.getColumnIndex("size"));
        int orientation1 = cursor.getInt(cursor.getColumnIndex("orientation_"));
        String latitude = cursor.getString(cursor.getColumnIndex("latitude_"));
        String lontitude = cursor.getString(cursor.getColumnIndex("lontitude_"));
        int whiteBalance = cursor.getInt(cursor.getColumnIndex("whiteBalance_"));
        int flash = cursor.getInt(cursor.getColumnIndex("flash_"));
        int imageLength = cursor.getInt(cursor.getColumnIndex("imageLength_"));
        int imageWidth = cursor.getInt(cursor.getColumnIndex("imageWidth_"));
        String make = cursor.getString(cursor.getColumnIndex("make_"));
        String model = cursor.getString(cursor.getColumnIndex("model_"));
        int imageFormat = cursor.getInt(cursor.getColumnIndex("imageFormat_"));
        SandExif sandExif = new SandExif(orientation1, latitude, lontitude, whiteBalance, flash, imageLength, imageWidth, make, model);
        sandPhoto = new SandPhoto(id, time, cameraId, categoryId, isMirror, ratio, fileName, size, imageFormat, sandExif);
    }
    cursor.close();
    db.close();
    return sandPhoto;
}
Also used : SandExif(com.yydcdut.note.entity.SandExif) SandPhoto(com.yydcdut.note.entity.SandPhoto) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor)

Example 5 with SandExif

use of com.yydcdut.note.entity.SandExif in project PhotoNoter by yydcdut.

the class CameraServicePresenterImpl method add2DB.

@Override
public void add2DB(String fileName, int size, String cameraId, long time, int categoryId, boolean isMirror, int ratio, int orientation, String latitude, String longitude, int whiteBalance, int flash, int imageLength, int imageWidth, String make, String model, int imageFormat) {
    SandExif sandExif = new SandExif(orientation, latitude, longitude, whiteBalance, flash, imageLength, imageWidth, make, model);
    SandPhoto sandPhoto = new SandPhoto(SandPhoto.ID_NULL, time, cameraId, categoryId, isMirror, ratio, fileName, size, imageFormat, sandExif);
    mRxSandBox.saveOne(sandPhoto).subscribe(sandPhoto1 -> {
        synchronized (mObject) {
            long id = sandPhoto1.getId();
            sandPhoto.setId(id);
            mQueue.offer(sandPhoto);
            mObject.notifyAll();
        }
    }, (throwable -> YLog.e(throwable)));
}
Also used : Rect(android.graphics.Rect) RxPhotoNote(com.yydcdut.note.model.rx.RxPhotoNote) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SandPhoto(com.yydcdut.note.entity.SandPhoto) BitmapFactory(android.graphics.BitmapFactory) ExifInterface(android.media.ExifInterface) Inject(javax.inject.Inject) Const(com.yydcdut.note.utils.Const) RxSandBox(com.yydcdut.note.model.rx.RxSandBox) FilePathUtils(com.yydcdut.note.utils.FilePathUtils) Utils(com.yydcdut.note.utils.Utils) ICameraServiceView(com.yydcdut.note.views.service.ICameraServiceView) ImageFormat(android.graphics.ImageFormat) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) SandExif(com.yydcdut.note.entity.SandExif) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) Bitmap(android.graphics.Bitmap) YuvImage(android.graphics.YuvImage) ICameraServicePresenter(com.yydcdut.note.presenters.service.ICameraServicePresenter) PhotoNote(com.yydcdut.note.entity.PhotoNote) Queue(java.util.Queue) YLog(com.yydcdut.note.utils.YLog) IView(com.yydcdut.note.views.IView) InputStream(java.io.InputStream) SandExif(com.yydcdut.note.entity.SandExif) SandPhoto(com.yydcdut.note.entity.SandPhoto)

Aggregations

SandExif (com.yydcdut.note.entity.SandExif)6 SandPhoto (com.yydcdut.note.entity.SandPhoto)5 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)4 Cursor (android.database.Cursor)3 ContentValues (android.content.ContentValues)1 Bitmap (android.graphics.Bitmap)1 BitmapFactory (android.graphics.BitmapFactory)1 ImageFormat (android.graphics.ImageFormat)1 Rect (android.graphics.Rect)1 YuvImage (android.graphics.YuvImage)1 ExifInterface (android.media.ExifInterface)1 PhotoNote (com.yydcdut.note.entity.PhotoNote)1 RxPhotoNote (com.yydcdut.note.model.rx.RxPhotoNote)1 RxSandBox (com.yydcdut.note.model.rx.RxSandBox)1 ICameraServicePresenter (com.yydcdut.note.presenters.service.ICameraServicePresenter)1 Const (com.yydcdut.note.utils.Const)1 FilePathUtils (com.yydcdut.note.utils.FilePathUtils)1 Utils (com.yydcdut.note.utils.Utils)1 YLog (com.yydcdut.note.utils.YLog)1 IView (com.yydcdut.note.views.IView)1