items) {
mValues = items;
}
- public void addItem(Medicament scannedMedoc) {
+ void addItem(Medicament scannedMedoc) {
mValues.add(scannedMedoc);
notifyDataSetChanged();
dbHelper.addDrug(scannedMedoc);
@@ -478,16 +483,16 @@ public class MedicamentListActivity extends AppCompatActivity {
return mValues.size();
}
- public class ViewHolder extends RecyclerView.ViewHolder {
- public final View mView;
- public final TextView mIDView;
- public final TextView mContentView;
- public final TextView mEndOfStock;
- public final ImageView mIconView;
+ class ViewHolder extends RecyclerView.ViewHolder {
+ final View mView;
+ final TextView mIDView;
+ final TextView mContentView;
+ final TextView mEndOfStock;
+ final ImageView mIconView;
- public Medicament mItem;
+ Medicament mItem;
- public ViewHolder(View view) {
+ ViewHolder(View view) {
super(view);
mView = view;
mIDView = (TextView) view.findViewById(R.id.cip13);
diff --git a/app/src/main/java/net/foucry/pilldroid/NotificationPublisher.java b/app/src/main/java/net/foucry/pilldroid/NotificationPublisher.java
index a908fb0..770c6e4 100644
--- a/app/src/main/java/net/foucry/pilldroid/NotificationPublisher.java
+++ b/app/src/main/java/net/foucry/pilldroid/NotificationPublisher.java
@@ -6,22 +6,28 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Vibrator;
+import android.util.Log;
+
+import static android.support.v7.widget.StaggeredGridLayoutManager.TAG;
/**
* Created by jfoucry on 6/23/16.
*/
public class NotificationPublisher extends BroadcastReceiver {
+ private static String TAG = Thread.currentThread().getStackTrace()[1].getMethodName();
public static String NOTIFICATION_ID = "notification-id";
public static String NOTIFICATION = "notification";
public void onReceive(Context context, Intent intent) {
+ Log.i(TAG, "");
+
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = intent.getParcelableExtra(NOTIFICATION);
int id = intent.getIntExtra(NOTIFICATION_ID,0);
notificationManager.notify(id, notification);
- Vibrator vibrator = (Vibrator) context.getSystemService(context.VIBRATOR_SERVICE);
+ Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(400);
}
diff --git a/app/src/main/java/net/foucry/pilldroid/PillDroidJobService.java b/app/src/main/java/net/foucry/pilldroid/PillDroidJobService.java
new file mode 100644
index 0000000..c913ac6
--- /dev/null
+++ b/app/src/main/java/net/foucry/pilldroid/PillDroidJobService.java
@@ -0,0 +1,43 @@
+package net.foucry.pilldroid;
+
+import android.app.job.JobParameters;
+import android.app.job.JobService;
+import android.os.Message;
+import android.os.Handler;
+import android.util.Log;
+import android.widget.Toast;
+
+
+/**
+ * Created by jacques on 17/09/16.
+ */
+public class PillDroidJobService extends JobService {
+ private static final String TAG = "JobService";
+
+ private Handler mJobHandler = new Handler(new Handler.Callback() {
+ @Override
+ public boolean handleMessage(Message msg) {
+// Toast.makeText( getApplicationContext(), "PillDroid - Calcul nouveau stocks", Toast.LENGTH_SHORT).show();
+// MedicamentListActivity.newStockCalculation(getApplicationContext());
+
+ jobFinished( (JobParameters) msg.obj,false);
+ return true;
+ }
+ });
+
+ @Override
+ public boolean onStartJob (JobParameters params) {
+ Log.i(TAG, "on Start Job: " + params.getJobId());
+ mJobHandler.sendMessage(Message.obtain(mJobHandler, 1,params));
+ return false;
+ }
+
+ @Override
+ public boolean onStopJob(JobParameters params) {
+ mJobHandler.removeMessages(1);
+ return false;
+ }
+
+
+}
+
diff --git a/app/src/main/java/net/foucry/pilldroid/TimeService.java b/app/src/main/java/net/foucry/pilldroid/TimeService.java
deleted file mode 100644
index 2aed6e6..0000000
--- a/app/src/main/java/net/foucry/pilldroid/TimeService.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package net.foucry.pilldroid;
-
-import android.app.Service;
-import android.content.Intent;
-import android.os.Handler;
-import android.os.IBinder;
-import android.widget.Toast;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Timer;
-import java.util.TimerTask;
-
-/**
- * Created by jacques on 22/08/16.
- */
-public class TimeService extends Service {
- //public static final long NOTIFY_INTERVAL = 10 *1000;
-
- private Handler mHandler = new Handler();
- private Timer mTimer = null;
-
- @Override
- public IBinder onBind(Intent intent) {
- return null;
- }
-
- @Override
- public void onCreate() {
- if(mTimer != null) {
- mTimer.cancel();
- } else {
- mTimer = new Timer();
- }
-
- mTimer.scheduleAtFixedRate(new TimeDisplayTimerTask(),0, UtilDate.tomorrowAtNoonInMillis());
- }
-
- class TimeDisplayTimerTask extends TimerTask {
- @Override
- public void run() {
- mHandler.post(new Runnable() {
-
- @Override
- public void run() {
- Toast.makeText(getApplicationContext(),getDateTime(), Toast.LENGTH_SHORT).show();
- }
- });
- }
-
- private String getDateTime() {
- SimpleDateFormat sdf = new SimpleDateFormat("[yyyy/MM/dd - HH:mm:ss]");
- return sdf.format(new Date());
- }
- }
-}
diff --git a/app/src/main/java/net/foucry/pilldroid/UtilDate.java b/app/src/main/java/net/foucry/pilldroid/UtilDate.java
index 6fd503c..e513ae8 100644
--- a/app/src/main/java/net/foucry/pilldroid/UtilDate.java
+++ b/app/src/main/java/net/foucry/pilldroid/UtilDate.java
@@ -7,22 +7,24 @@ import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
+import java.util.Locale;
+
/**
* Created by jacques on 05/05/16.
*/
-public class UtilDate {
+class UtilDate {
private static final String TAG = UtilDate.class.getName();
/**
*
- * @param aDate
- * @return date
+ * @param aDate anydate
+ * @return date the same date as input but at noon (12:00:00)
*
* set date time at Noon
*/
- public static Date dateAtNoon(Date aDate) {
+ static Date dateAtNoon(Date aDate) {
- Log.d(TAG, "dateAtNoon " + aDate);
+// Log.d(TAG, "dateAtNoon " + aDate);
Calendar calendar = Calendar.getInstance();
calendar.setTime(aDate);
@@ -34,13 +36,13 @@ public class UtilDate {
}
/**
*
- * @param days
- * @param date
+ * @param days number of days to remove to the ate
+ * @param date date before day removing
* @return date
*
* Substract days to date and return a new date
*/
- public static Date removeDaysToDate(int days, Date date) {
+ static Date removeDaysToDate(int days, Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_YEAR, -days);
@@ -50,12 +52,12 @@ public class UtilDate {
/**
*
- * @param date
- * @return String
+ * @param date Date to be converted
+ * @return String of the converted date
*
* Convert a date to a String using a SimpleDateFormat
*/
- public static String date2String(Date date, DateFormat dateFormat) {
+ static String date2String(Date date, DateFormat dateFormat) {
Log.d(TAG, "date == " + date);
@@ -67,25 +69,25 @@ public class UtilDate {
/**
*
- * @param dateString
- * @return date
+ * @param dateString string representing a Date to be conveted
+ * @return date Date after convertion
*
* Convert String date into Date
*/
- public static Date string2Date(String dateString) {
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ static Date string2Date(String dateString) {
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.FRANCE);
ParsePosition pos = new ParsePosition(0);
return dateFormat.parse(dateString,pos);
}
/**
*
- * @param date
- * @return int
+ * @param date start date
+ * @return int numbers of days between date and today
*
* Number of days between date (older than today) and today
*/
- public static int nbOfDaysBetweenDateAndToday(Date date) {
+ static int nbOfDaysBetweenDateAndToday(Date date) {
Date oldDate = dateAtNoon(date); // Be sure that the old date is at Noon
Date todayDate = dateAtNoon(new Date()); // Be sure that we use today at Noon
@@ -97,7 +99,7 @@ public class UtilDate {
* return int
*/
- public static long tomorrowAtNoonInMillis() {
+ static long tomorrowAtNoonInMillis() {
Date now = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(now);
@@ -108,8 +110,8 @@ public class UtilDate {
return (tomorrowAtNoon.getTime() - now.getTime());
}
- public static String convertDate(long dateInMilliseconds) {
- DateFormat formatter = new SimpleDateFormat("dd/MM/yy hh:mm:ss");
+ static String convertDate(long dateInMilliseconds) {
+ DateFormat formatter = new SimpleDateFormat("dd/MM/yy HH:mm:ss", Locale.FRANCE);
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(dateInMilliseconds);
return formatter.format(calendar.getTime());
diff --git a/app/src/main/java/net/foucry/pilldroid/Utils.java b/app/src/main/java/net/foucry/pilldroid/Utils.java
index 6b79c60..11a5d19 100644
--- a/app/src/main/java/net/foucry/pilldroid/Utils.java
+++ b/app/src/main/java/net/foucry/pilldroid/Utils.java
@@ -22,12 +22,17 @@ public class Utils {
os.write(bytes, 0, count);
}
}
- catch(Exception ex){}
+ catch(Exception ignored){}
}
- public static final double doubleRandomInclusive(int min, int max) {
- double value = Math.floor(min + (max - min) * MedicamentListActivity.random.nextDouble() *4)/4;
-
- return value;
+ /**
+ * Return a random number between twovalues - use to gənerat a false demo DB
+ * @param min minimal value accepted
+ * @param max maximum value accepted
+ * @return
+ */
+ static final int intRandomExclusive(int min, int max) {
+ Random r = new Random();
+ return r.nextInt(max - min) +max;
}
}
\ No newline at end of file
diff --git a/app/src/main/java/net/foucry/pilldroid/dummy/DummyContent.java b/app/src/main/java/net/foucry/pilldroid/dummy/DummyContent.java
deleted file mode 100644
index 8a110fc..0000000
--- a/app/src/main/java/net/foucry/pilldroid/dummy/DummyContent.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package net.foucry.pilldroid.dummy;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Helper class for providing sample content for user interfaces created by
- * Android template wizards.
- *
- * TODO: Replace all uses of this class before publishing your app.
- */
-public class DummyContent {
-
- /**
- * An array of sample (dummy) items.
- */
- public static final List ITEMS = new ArrayList();
-
- /**
- * A map of sample (dummy) items, by ID.
- */
- public static final Map ITEM_MAP = new HashMap();
-
- private static final int COUNT = 25;
-
- static {
- // Add some sample items.
- for (int i = 1; i <= COUNT; i++) {
- addItem(createDummyItem(i));
- }
- }
-
- private static void addItem(DummyItem item) {
- ITEMS.add(item);
- ITEM_MAP.put(item.id, item);
- }
-
- private static DummyItem createDummyItem(int position) {
- return new DummyItem(String.valueOf(position), "Item " + position, makeDetails(position));
- }
-
- private static String makeDetails(int position) {
- StringBuilder builder = new StringBuilder();
- builder.append("Details about Item: ").append(position);
- for (int i = 0; i < position; i++) {
- builder.append("\nMore details information here.");
- }
- return builder.toString();
- }
-
- /**
- * A dummy item representing a piece of content.
- */
- public static class DummyItem {
- public final String id;
- public final String content;
- public final String details;
-
- public DummyItem(String id, String content, String details) {
- this.id = id;
- this.content = content;
- this.details = details;
- }
-
- @Override
- public String toString() {
- return content;
- }
- }
-}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f38692b..fd9f3dc 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -129,4 +129,5 @@
trouvé dans la base de données
À propos
Aide
+ Vous devez passer à la pharmarcie -POUET
diff --git a/build.gradle b/build.gradle
index 77ce66e..c20bca1 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.1.3'
+ classpath 'com.android.tools.build:gradle:2.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files