2016-05-19 07:37:28 +02:00
|
|
|
package net.foucry.pilldroid;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
2020-02-19 10:49:16 +01:00
|
|
|
import android.content.Context;
|
2020-04-12 10:32:00 +02:00
|
|
|
import android.content.Intent;
|
2016-05-19 07:37:28 +02:00
|
|
|
import android.support.design.widget.CollapsingToolbarLayout;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.support.v4.app.Fragment;
|
2020-04-12 10:32:00 +02:00
|
|
|
import android.util.Log;
|
2016-05-19 07:37:28 +02:00
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.TextView;
|
2020-02-19 10:49:16 +01:00
|
|
|
import android.widget.Toast;
|
2016-05-19 07:37:28 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A fragment representing a single Medicament detail screen.
|
|
|
|
* This fragment is either contained in a {@link MedicamentListActivity}
|
|
|
|
* in two-pane mode (on tablets) or a {@link MedicamentDetailActivity}
|
|
|
|
* on handsets.
|
|
|
|
*/
|
|
|
|
public class MedicamentDetailFragment extends Fragment {
|
2020-04-12 10:32:00 +02:00
|
|
|
|
2016-05-19 07:37:28 +02:00
|
|
|
/**
|
|
|
|
* The fragment argument representing the item ID that this fragment
|
|
|
|
* represents.
|
|
|
|
*/
|
2016-05-22 16:05:35 +02:00
|
|
|
public static final String ARG_ITEM_ID = "medicament";
|
2020-04-12 10:32:00 +02:00
|
|
|
private static final String TAG = MedicamentListActivity.class.getName();
|
2016-05-19 07:37:28 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The dummy content this fragment is presenting.
|
|
|
|
*/
|
2016-05-22 16:05:35 +02:00
|
|
|
private Medicament medicament;
|
2016-05-19 07:37:28 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Mandatory empty constructor for the fragment manager to instantiate the
|
|
|
|
* fragment (e.g. upon screen orientation changes).
|
|
|
|
*/
|
|
|
|
public MedicamentDetailFragment() {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
if (getArguments().containsKey(ARG_ITEM_ID)) {
|
|
|
|
// Load the dummy content specified by the fragment
|
|
|
|
// arguments. In a real-world scenario, use a Loader
|
|
|
|
// to load content from a content provider.
|
2016-05-22 16:05:35 +02:00
|
|
|
medicament = (Medicament) getArguments().getSerializable(ARG_ITEM_ID);
|
2016-05-19 07:37:28 +02:00
|
|
|
|
|
|
|
Activity activity = this.getActivity();
|
|
|
|
CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout);
|
|
|
|
if (appBarLayout != null) {
|
2016-05-22 16:05:35 +02:00
|
|
|
appBarLayout.setTitle(medicament.getNom());
|
2016-05-19 07:37:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-04-12 10:32:00 +02:00
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
2016-05-22 16:05:35 +02:00
|
|
|
View detailView = inflater.inflate(R.layout.medicament_detail, container, false);
|
|
|
|
View nameView;
|
|
|
|
View adminModeView;
|
|
|
|
View presentationView;
|
|
|
|
View stockView;
|
|
|
|
View priseView;
|
|
|
|
View warningView;
|
|
|
|
View alertView;
|
2016-05-19 07:37:28 +02:00
|
|
|
|
|
|
|
// Show the dummy content as text in a TextView.
|
2016-05-22 16:05:35 +02:00
|
|
|
if (medicament != null) {
|
|
|
|
// Find each conponment of rootView
|
|
|
|
nameView = detailView.findViewById(R.id.name_cell);
|
2020-02-19 10:49:16 +01:00
|
|
|
TextView nameLabel = nameView.findViewById(R.id.label);
|
|
|
|
TextView nameValeur = nameView.findViewById(R.id.valeur);
|
2016-05-22 16:05:35 +02:00
|
|
|
nameLabel.setText("Nom");
|
|
|
|
nameValeur.setText(medicament.getNom());
|
|
|
|
|
|
|
|
presentationView = detailView.findViewById(R.id.presentation_cell);
|
2020-02-19 10:49:16 +01:00
|
|
|
TextView presentationLabel = presentationView.findViewById(R.id.label);
|
|
|
|
TextView presentationValeur = presentationView.findViewById(R.id.valeur);
|
2016-05-22 16:05:35 +02:00
|
|
|
presentationLabel.setText("Presentation");
|
|
|
|
presentationValeur.setText(medicament.getPresentation());
|
|
|
|
|
|
|
|
adminModeView = detailView.findViewById(R.id.administration_cell);
|
2020-02-19 10:49:16 +01:00
|
|
|
TextView adminModeLabel = adminModeView.findViewById(R.id.label);
|
|
|
|
TextView adminModeValeur = adminModeView.findViewById(R.id.valeur);
|
2016-05-22 16:05:35 +02:00
|
|
|
adminModeLabel.setText("Mode d'administration");
|
|
|
|
adminModeValeur.setText(medicament.getMode_administration());
|
|
|
|
|
|
|
|
stockView = detailView.findViewById(R.id.stock_cell);
|
2020-02-19 10:49:16 +01:00
|
|
|
TextView stockLibelle = (stockView.findViewById(R.id.libelle));
|
|
|
|
TextView stockValue = stockView.findViewById(R.id.valeur);
|
2016-05-22 16:05:35 +02:00
|
|
|
stockLibelle.setText("Stock courant");
|
|
|
|
stockValue.setText(Double.toString(medicament.getStock()));
|
|
|
|
|
|
|
|
priseView = detailView.findViewById(R.id.prise_cell);
|
2020-02-19 10:49:16 +01:00
|
|
|
TextView priseLibelle = priseView.findViewById(R.id.libelle);
|
|
|
|
TextView priseValue = (priseView.findViewById(R.id.valeur));
|
2016-05-22 16:05:35 +02:00
|
|
|
priseLibelle.setText("Prise");
|
|
|
|
priseValue.setText(Double.toString(medicament.getPrise()));
|
|
|
|
|
|
|
|
warningView = detailView.findViewById(R.id.warning_cell);
|
|
|
|
TextView warningLibelle = (TextView) warningView.findViewById(R.id.libelle);
|
|
|
|
TextView warningValue = (TextView) warningView.findViewById(R.id.valeur);
|
|
|
|
warningLibelle.setText("Seuil d'alerte");
|
|
|
|
warningValue.setText(Integer.toString(medicament.getWarnThreshold()));
|
|
|
|
|
|
|
|
alertView = detailView.findViewById(R.id.alert_cell);
|
2020-02-19 10:49:16 +01:00
|
|
|
TextView alertLibelle = alertView.findViewById(R.id.libelle);
|
|
|
|
TextView alertValue = alertView.findViewById(R.id.valeur);
|
2016-05-22 16:05:35 +02:00
|
|
|
alertLibelle.setText("Seuil critique");
|
|
|
|
alertValue.setText(Integer.toString(medicament.getAlertThreshold()));
|
2016-05-19 07:37:28 +02:00
|
|
|
}
|
|
|
|
|
2016-05-22 16:05:35 +02:00
|
|
|
return detailView;
|
2016-05-19 07:37:28 +02:00
|
|
|
}
|
2020-02-19 10:49:16 +01:00
|
|
|
@Override
|
|
|
|
public void onStop()
|
|
|
|
{
|
|
|
|
Context context = getContext();
|
|
|
|
Toast.makeText(context, "***PROUT***", Toast.LENGTH_SHORT).show();
|
2020-04-12 19:57:48 +02:00
|
|
|
View currentView = getView();
|
|
|
|
View nameView;
|
|
|
|
View adminModeView;
|
|
|
|
View presentationView;
|
|
|
|
View stockView;
|
|
|
|
View priseView;
|
|
|
|
View warningView;
|
|
|
|
View alertView;
|
2020-04-12 10:32:00 +02:00
|
|
|
|
2020-04-12 19:57:48 +02:00
|
|
|
stockView = currentView.findViewById(R.id.alert_cell);
|
|
|
|
TextView stockValue = stockView.findViewById(R.id.valeur);
|
2020-04-12 10:32:00 +02:00
|
|
|
|
2020-04-12 19:57:48 +02:00
|
|
|
Log.d(TAG, "StockValue == "+ stockValue);
|
|
|
|
Log.d(TAG, "medicamentID "+ medicament.getId());
|
2020-04-12 10:32:00 +02:00
|
|
|
|
2020-04-12 19:57:48 +02:00
|
|
|
Toast.makeText(context,"stock value "+ stockValue, Toast.LENGTH_SHORT).show();
|
2020-02-19 10:49:16 +01:00
|
|
|
super.onStop();
|
|
|
|
}
|
2016-05-19 07:37:28 +02:00
|
|
|
}
|