Ajout et correction des DBHelper, Medicament et Utils*

This commit is contained in:
Jacques Foucry 2016-05-19 14:20:52 +02:00
parent 5dc6c3d51f
commit 95e3a5b842
6 changed files with 23 additions and 39 deletions

View file

@ -3,8 +3,9 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.10" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />

View file

@ -1,4 +1,4 @@
package net.foucry.medicament;
package net.foucry.pilldroid;
import android.content.ContentValues;
import android.content.Context;
@ -76,7 +76,7 @@ public class DBHelper extends SQLiteOpenHelper {
public void dropDrug() {
SQLiteDatabase db = this.getWritableDatabase();
Log.d(CustomizedListView.Constants.TAG, "Drop drug table");
Log.d(MedicamentListActivity.Constants.TAG, "Drop drug table");
db.execSQL("DROP TABLE IF EXISTS drug");
this.onCreate(db);
@ -84,7 +84,7 @@ public class DBHelper extends SQLiteOpenHelper {
public void addDrug(Medicament medicament) {
// Logging
Log.d(CustomizedListView.Constants.TAG, medicament.toString());
Log.d(MedicamentListActivity.Constants.TAG, medicament.toString());
// Get reference to writable DB
SQLiteDatabase db = this.getWritableDatabase();
@ -144,7 +144,7 @@ public class DBHelper extends SQLiteOpenHelper {
medicament.setAlertThreshold(Integer.parseInt(cursor.getString(9)));
// Log
Log.d(CustomizedListView.Constants.TAG, "getDrug("+id+")" + medicament.toString());
Log.d(MedicamentListActivity.Constants.TAG, "getDrug("+id+")" + medicament.toString());
// Return medicament
@ -183,7 +183,7 @@ public class DBHelper extends SQLiteOpenHelper {
medicament.setAlertThreshold(Integer.parseInt(cursor.getString(9)));
// Log
Log.d(CustomizedListView.Constants.TAG, "getDrug("+cip13+")" + medicament.toString());
Log.d(MedicamentListActivity.Constants.TAG, "getDrug("+cip13+")" + medicament.toString());
// Return medicament
@ -225,7 +225,7 @@ public class DBHelper extends SQLiteOpenHelper {
}
cursor.close();
Log.d(CustomizedListView.Constants.TAG, "getAllDrugs " + medicaments.toString());
Log.d(MedicamentListActivity.Constants.TAG, "getAllDrugs " + medicaments.toString());
// return
return medicaments;
@ -269,7 +269,7 @@ public class DBHelper extends SQLiteOpenHelper {
db.close();
// log
Log.d(CustomizedListView.Constants.TAG, "delete drug "+medicament.toString());
Log.d(MedicamentListActivity.Constants.TAG, "delete drug "+medicament.toString());
}
public int getCount() {

View file

@ -1,4 +1,4 @@
package net.foucry.medicament;
package net.foucry.pilldroid;
import java.io.Serializable;
import java.lang.String;
@ -6,8 +6,7 @@ import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import static net.foucry.medicament.UtilDate.*;
import static net.foucry.pilldroid.UtilDate.*;
/**
* Created by jacques on 26/11/15.
@ -183,27 +182,4 @@ public class Medicament implements Serializable {
return currentStock - takeDuringPeriod;
}
// public static Medicament getMedicamentByCIP13(String cip13) {
// Log.e(CustomizedListView.Constants.TAG, "getMedicamentByCIP13 called");
//
// Context context = null;
// DBHelper db = new DBHelper(context);
// SQLiteDatabase myDatabase = DBHelper.getInstance(context).getWritableDatabase();
//
// Medicament medicament = null;
//
// Cursor cur = myDatabase.query("medicaments", COLUMN_LIST, "cip13 = ?", new String[]{cip13}, null, null,null);
// if (cur != null) {
// cur.moveToFirst();
// int count = cur.getCount();
// Log.d(CustomizedListView.Constants.TAG, "Number of item in cursor " + String.valueOf(count));
// medicament = new Medicament(cur);
// }
// cur.close();
// myDatabase.close();
// return medicament;
// }
}

View file

@ -19,6 +19,7 @@ import android.widget.TextView;
import net.foucry.pilldroid.dummy.DummyContent;
import java.util.List;
import java.util.Random;
/**
* An activity representing a list of Medicaments. This activity
@ -35,6 +36,12 @@ public class MedicamentListActivity extends AppCompatActivity {
* device.
*/
private boolean mTwoPane;
final static Boolean DEMO = true;
final static Random random = new Random();
// Log TAG String
public interface Constants {
String TAG = "nef.foucry.pilldroid";
}
@Override
protected void onCreate(Bundle savedInstanceState) {

View file

@ -1,4 +1,4 @@
package net.foucry.medicament;
package net.foucry.pilldroid;
import android.util.Log;
@ -21,7 +21,7 @@ public class UtilDate {
*/
public static Date dateAtNoon(Date aDate) {
Log.d(CustomizedListView.Constants.TAG, "dateAtNoon " + aDate);
Log.d(MedicamentListActivity.Constants.TAG, "dateAtNoon " + aDate);
Calendar calendar = Calendar.getInstance();
calendar.setTime(aDate);
@ -57,7 +57,7 @@ public class UtilDate {
*/
public static String date2String(Date date, DateFormat dateFormat) {
Log.d(CustomizedListView.Constants.TAG, "date == " + date);
Log.d(MedicamentListActivity.Constants.TAG, "date == " + date);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);

View file

@ -1,4 +1,4 @@
package net.foucry.medicament;
package net.foucry.pilldroid;
import java.io.InputStream;
import java.io.OutputStream;
@ -25,7 +25,7 @@ public class Utils {
}
public static final double doubleRandomInclusive(int min, int max) {
double value = Math.floor(min + (max - min) * CustomizedListView.random.nextDouble() *4)/4;
double value = Math.floor(min + (max - min) * MedicamentListActivity.random.nextDouble() *4)/4;
return value;
}