Add log facilities

This commit is contained in:
jacques 2020-05-03 15:14:56 +02:00
parent 8e21fbe39e
commit f90438ab37
4 changed files with 26 additions and 5 deletions

View file

@ -261,6 +261,9 @@ class DBHelper extends SQLiteOpenHelper {
* @param medicament object to be updated in DB
*/
public void updateDrug(Medicament medicament) {
Log.d(TAG, "Update Drug == " + medicament.toString());
// Get reference to writable DB
SQLiteDatabase db = this.getWritableDatabase();
@ -279,6 +282,7 @@ class DBHelper extends SQLiteOpenHelper {
KEY_ID+" = ?", // selections
new String[] {String.valueOf(medicament.getId()) } ); // selections args
Log.d(TAG, "Return update = " + i);
// Close DB
db.close();

View file

@ -5,11 +5,14 @@ import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.app.ActionBar;
import android.view.MenuItem;
import net.foucry.pilldroid.Medicament;
/**
* An activity representing a single Medicament detail screen. This
* activity is only used narrow width devices. On tablet-size devices,
@ -18,12 +21,23 @@ import android.view.MenuItem;
*/
public class MedicamentDetailActivity extends AppCompatActivity {
private static final String TAG = MedicamentDetailActivity.class.getName();
Medicament medicament;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle extras = getIntent().getExtras();
/* fetching the string passed with intent using extras*/
medicament = (Medicament) extras.getSerializable("medicament");
setContentView(R.layout.activity_medicament_detail);
Toolbar toolbar = findViewById(R.id.detail_toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
toolbar.setTitle(getTitle());
@ -35,6 +49,10 @@ public class MedicamentDetailActivity extends AppCompatActivity {
public void onClick(View view) {
Snackbar.make(view, "Will be use to save changes in a drug", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
Log.d(TAG, "Click on save icone + medicament ");
// TODO: récupérer les infos de la vue (cf onStop du Fragment)
setResult(1);
finish();

View file

@ -26,7 +26,7 @@ public class MedicamentDetailFragment extends Fragment {
* represents.
*/
public static final String ARG_ITEM_ID = "medicament";
private static final String TAG = MedicamentListActivity.class.getName();
private static final String TAG = MedicamentDetailFragment.class.getName();
/**
* The dummy content this fragment is presenting.
@ -125,9 +125,6 @@ public class MedicamentDetailFragment extends Fragment {
dbHelper = new DBHelper(context);
View currentView = getView();
// View nameView;
// View adminModeView;
// View presentationView;
View stockView;
View priseView;
View warningView;
@ -161,6 +158,8 @@ public class MedicamentDetailFragment extends Fragment {
medicament.setPrise(Double.parseDouble(priseValue));
medicament.setWarnThreshold(Integer.parseInt(warningValue));
medicament.setAlertThreshold(Integer.parseInt(alertValue));
medicament.setDateLastUpdate();
medicament.setDateEndOfStock();
dbHelper.updateDrug(medicament);
super.onStop();

View file

@ -232,7 +232,7 @@ public class MedicamentListActivity extends AppCompatActivity {
public void newStockCalculation() {
Medicament currentMedicament;
//DBHelper DBHelper dbHelper;
dbHelper = new DBHelper(this);
for (int position = 0 ; position < this. getCount() ; position++ ) {
currentMedicament = this.getItem(position);