From 957a9b09ac816b697f232cfa264d8388d25bf16a Mon Sep 17 00:00:00 2001 From: Jacques Foucry Date: Tue, 30 Aug 2016 23:54:23 +0200 Subject: [PATCH] =?UTF-8?q?Corrections=20apr=C3=A8s=20merge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/net/foucry/pilldroid/DBMedoc.java | 26 +++++-------------- .../java/net/foucry/pilldroid/UtilDate.java | 8 ++++++ 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/net/foucry/pilldroid/DBMedoc.java b/app/src/main/java/net/foucry/pilldroid/DBMedoc.java index 11f910f..b5fd309 100644 --- a/app/src/main/java/net/foucry/pilldroid/DBMedoc.java +++ b/app/src/main/java/net/foucry/pilldroid/DBMedoc.java @@ -21,15 +21,14 @@ public class DBMedoc extends SQLiteOpenHelper{ private static final int DATABASE_VERSION = 1; private static String DATABASE_PATH = "/data/data/net.foucry.pilldroid/databases/"; - private static String DATABASE_NAME = "medicaments.db"; + private static String dbName = "medicaments.db"; private SQLiteDatabase myDataBase; private final Context myContext; + File dbFile = new File(DATABASE_PATH + dbName); private static final String TABLE_NAME = "medicaments"; -// private static final String MEDOC_ID = "id"; private static final String MEDOC_CIS = "cis"; private static final String MEDOC_CIP13 = "cip13"; -// private static final String MEDOC_CIP7 = "cip7"; private static final String MEDOC_ADMIN = "mode_administration"; private static final String MEDOC_NOM = "nom"; private static final String MEDOC_PRES = "presentation"; @@ -70,30 +69,26 @@ public class DBMedoc extends SQLiteOpenHelper{ private void copyDatabase(String dbPath) { try { - InputStream assestDB = myContext.getAssets().open(dbName); + InputStream assetDB = myContext.getAssets().open(dbName); OutputStream appDB = new FileOutputStream(dbPath, false); byte[] buffer = new byte[1024]; int length; - while ((length = assestDB.read(buffer)) > 0) { + while ((length = assetDB.read(buffer)) > 0) { appDB.write(buffer,0, length); } appDB.flush(); appDB.close(); - assestDB.close(); + assetDB.close(); } catch (IOException e) { e.printStackTrace(); } - - myOutput.flush(); - myOutput.close(); - myInput.close(); } public void openDatabase() throws SQLiteException { Log.e(TAG, "openDatabase called"); - String myPath = DATABASE_PATH + DATABASE_NAME; + String myPath = DATABASE_PATH + dbName; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } @@ -104,15 +99,6 @@ public class DBMedoc extends SQLiteOpenHelper{ myDataBase.close(); } } - @Override - public void onCreate(SQLiteDatabase db) { - - } - - @Override - public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - - } private DBMedoc dbMedoc; diff --git a/app/src/main/java/net/foucry/pilldroid/UtilDate.java b/app/src/main/java/net/foucry/pilldroid/UtilDate.java index 8ad4b92..c8284e8 100644 --- a/app/src/main/java/net/foucry/pilldroid/UtilDate.java +++ b/app/src/main/java/net/foucry/pilldroid/UtilDate.java @@ -113,6 +113,14 @@ public class UtilDate { public static long tomorrowAtNoon() { Date now = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(now); + calendar.add(Calendar.DAY_OF_YEAR,1); + + Date tomorrowAtNoon = dateAtNoon(calendar.getTime()); + + return (tomorrowAtNoon.getTime() - now.getTime()); + } public static String convertDate(long dateInMilliseconds) { DateFormat formatter = new SimpleDateFormat("dd/MM/yy hh:mm:ss");