mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-17 18:41:37 +01:00
Merge
This commit is contained in:
commit
edd62d4b6b
2 changed files with 27 additions and 1 deletions
|
@ -25,6 +25,7 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.SimpleCursorAdapter;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -71,6 +72,10 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
Log.d(TAG, "Remove old notification");
|
||||
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
nm.cancelAll();
|
||||
|
||||
// ATTENTION: This was auto-generated to implement the App Indexing API.
|
||||
// See https://g.co/AppIndexing/AndroidStudio for more information.
|
||||
client.connect();
|
||||
|
@ -91,6 +96,27 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
public void onStop() {
|
||||
super.onStop();
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
Date now = calendar.getTime();
|
||||
|
||||
long dateSchedule;
|
||||
|
||||
Medicament firstMedicament = medicaments.get(0);
|
||||
|
||||
Date dateAlerte = UtilDate.removeDaysToDate(firstMedicament.getAlertThreshold(), firstMedicament.getDateEndOfStock());
|
||||
|
||||
if (dateAlerte.getTime() < now.getTime())
|
||||
{
|
||||
dateSchedule = 120000;
|
||||
} else {
|
||||
dateSchedule = dateAlerte.getTime() - now.getTime();
|
||||
}
|
||||
|
||||
// int between2DateInMillis = (int) (tomorrow.getTime() - now.getTime());
|
||||
scheduleNotification(getNotification("Vous devez passer à la pharmacie."), dateSchedule);
|
||||
|
||||
Log.d(TAG, "Notification scheduled for "+ UtilDate.convertDate(now.getTime() + dateSchedule));
|
||||
|
||||
// ATTENTION: This was auto-generated to implement the App Indexing API.
|
||||
// See https://g.co/AppIndexing/AndroidStudio for more information.
|
||||
Action viewAction = Action.newAction(
|
||||
|
|
|
@ -107,7 +107,7 @@ public class UtilDate {
|
|||
}
|
||||
|
||||
public static String convertDate(long dateInMilliseconds) {
|
||||
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||
DateFormat formatter = new SimpleDateFormat("dd/MM/yy hh:mm:ss");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(dateInMilliseconds);
|
||||
return formatter.format(calendar.getTime());
|
||||
|
|
Loading…
Reference in a new issue