mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-22 04:29:22 +01:00
Use Medic instead of Drug
This commit is contained in:
parent
426092bbad
commit
8257f5477a
2 changed files with 30 additions and 29 deletions
|
@ -13,6 +13,7 @@ import androidx.appcompat.app.ActionBar;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import static net.foucry.pilldroid.R.id.detail_toolbar;
|
||||
|
@ -37,17 +38,10 @@ public class DrugDetailActivity extends AppCompatActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
|
||||
/* fetching the string passed with intent using ‘extras’*/
|
||||
|
||||
assert bundle != null;
|
||||
aMedic = (Medic) bundle.getSerializable("medic");
|
||||
|
||||
assert aMedic != null;
|
||||
aMedic = (Medic) bundle.get("medic");
|
||||
Log.d(TAG, "aMedic == " + aMedic);
|
||||
|
||||
/* fetching the string passed with intent using ‘bundle’*/
|
||||
|
||||
setContentView(R.layout.activity_drug_detail);
|
||||
Toolbar toolbar = findViewById(detail_toolbar);
|
||||
|
||||
|
@ -87,9 +81,11 @@ public class DrugDetailActivity extends AppCompatActivity {
|
|||
if (savedInstanceState == null) {
|
||||
// Create the detail fragment and add it to the activity
|
||||
// using a fragment transaction.
|
||||
/*Bundle arguments = new Bundle();
|
||||
arguments.putSerializable("medic",
|
||||
getIntent().getExtras());*/
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putSerializable("drug",
|
||||
getIntent().getSerializableExtra("drug"));
|
||||
arguments.putSerializable("medic", aMedic);
|
||||
DrugDetailFragment fragment = new DrugDetailFragment();
|
||||
fragment.setArguments(arguments);
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
|
@ -145,8 +141,8 @@ public class DrugDetailActivity extends AppCompatActivity {
|
|||
TextView warningTextView = warningView.findViewById(R.id.value);
|
||||
String warningValue = warningTextView.getText().toString();
|
||||
|
||||
newMedic.setStock(Double.parseDouble(stockValue));
|
||||
newMedic.setTake(Double.parseDouble(takeValue));
|
||||
newMedic.setStock(Float.parseFloat(stockValue));
|
||||
newMedic.setTake(Float.parseFloat(takeValue));
|
||||
newMedic.setWarning(Integer.parseInt(warningValue));
|
||||
newMedic.setAlert(Integer.parseInt(alertValue));
|
||||
newMedic.getDateEndOfStock();
|
||||
|
|
|
@ -11,6 +11,8 @@ import androidx.fragment.app.Fragment;
|
|||
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
|
||||
import net.foucry.pilldroid.models.Medic;
|
||||
|
||||
/**
|
||||
* A fragment representing a single Drug detail screen.
|
||||
* This fragment is either contained in a {@link DrugListActivity}
|
||||
|
@ -23,12 +25,12 @@ public class DrugDetailFragment extends Fragment {
|
|||
* The fragment argument representing the item ID that this fragment
|
||||
* represents.
|
||||
*/
|
||||
public static final String ARG_ITEM_ID = "drug";
|
||||
public static final String ARG_ITEM_ID = "medic";
|
||||
|
||||
/**
|
||||
* The dummy content this fragment is presenting.
|
||||
*/
|
||||
private Drug drug;
|
||||
private Medic medic;
|
||||
|
||||
/**
|
||||
* Mandatory empty constructor for the fragment manager to instantiate the
|
||||
|
@ -46,13 +48,13 @@ public class DrugDetailFragment extends Fragment {
|
|||
// Load the dummy content specified by the fragment
|
||||
// arguments. In a real-world scenario, use a Loader
|
||||
// to load content from a content provider.
|
||||
drug = (Drug) getArguments().getSerializable(ARG_ITEM_ID);
|
||||
medic = (Medic) getArguments().getSerializable(ARG_ITEM_ID);
|
||||
|
||||
Activity activity = this.getActivity();
|
||||
assert activity != null;
|
||||
CollapsingToolbarLayout appBarLayout = activity.findViewById(R.id.toolbar_layout);
|
||||
if (appBarLayout != null) {
|
||||
appBarLayout.setTitle(drug.getName());
|
||||
appBarLayout.setTitle(medic.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,47 +71,49 @@ public class DrugDetailFragment extends Fragment {
|
|||
View alertView;
|
||||
|
||||
// Show the dummy content as text in a TextView.
|
||||
if (drug != null) {
|
||||
if (medic != null) {
|
||||
// Find each component of rootView
|
||||
nameView = detailView.findViewById(R.id.name_cell);
|
||||
TextView nameLabel = nameView.findViewById(R.id.label);
|
||||
TextView nameValue = nameView.findViewById(R.id.value);
|
||||
nameLabel.setText(R.string.drug_name_label);
|
||||
nameValue.setText(drug.getName());
|
||||
nameValue.setText(medic.getName());
|
||||
|
||||
presentationView = detailView.findViewById(R.id.presentation_cell);
|
||||
TextView presentationLabel = presentationView.findViewById(R.id.label);
|
||||
TextView presentationValue = presentationView.findViewById(R.id.value);
|
||||
presentationLabel.setText(R.string.drug_presentation_label);
|
||||
presentationValue.setText(drug.getPresentation());
|
||||
presentationValue.setText(medic.getPresentation());
|
||||
|
||||
adminModeView = detailView.findViewById(R.id.administration_cell);
|
||||
TextView adminModeLabel = adminModeView.findViewById(R.id.label);
|
||||
TextView adminModeValue = adminModeView.findViewById(R.id.value);
|
||||
adminModeLabel.setText(R.string.drug_administrationMode_label);
|
||||
adminModeValue.setText(drug.getAdministration_mode());
|
||||
adminModeValue.setText(medic.getAdministration_mode());
|
||||
|
||||
stockView = detailView.findViewById(R.id.stock_cell);
|
||||
TextView stockLibelle = (stockView.findViewById(R.id.label));
|
||||
TextView stockValue = stockView.findViewById(R.id.value);
|
||||
stockLibelle.setText(R.string.drug_current_stock_label);
|
||||
stockValue.setText(Double.toString(drug.getStock()));
|
||||
stockValue.setText(Utils.fmt(medic.getStock()));
|
||||
stockValue.setHint(R.string.drug_current_stock_label);
|
||||
stockValue.setSelectAllOnFocus(true);
|
||||
|
||||
takeView = detailView.findViewById(R.id.take_cell);
|
||||
TextView priseLabel = takeView.findViewById(R.id.label);
|
||||
TextView priseValue = (takeView.findViewById(R.id.value));
|
||||
priseLabel.setText(R.string.drug_take_label);
|
||||
priseValue.setText(Double.toString(drug.getTake()));
|
||||
priseValue.setHint(R.string.drug_take_label);
|
||||
priseValue.setSelectAllOnFocus(true);
|
||||
TextView takeLabel = takeView.findViewById(R.id.label);
|
||||
TextView takeValue = (takeView.findViewById(R.id.value));
|
||||
takeLabel.setText(R.string.drug_take_label);
|
||||
//takeValue.setText(Double.toString(medic.getTake()));
|
||||
takeValue.setText(Utils.fmt(medic.getTake()));
|
||||
takeValue.setHint(R.string.drug_take_label);
|
||||
takeValue.setSelectAllOnFocus(true);
|
||||
|
||||
warningView = detailView.findViewById(R.id.warning_cell);
|
||||
TextView warningLibelle = warningView.findViewById(R.id.label);
|
||||
TextView warningValue = warningView.findViewById(R.id.value);
|
||||
warningLibelle.setText(R.string.drug_warningThreshold_label);
|
||||
warningValue.setText(Integer.toString(drug.getWarnThreshold()));
|
||||
//warningValue.setText(Integer.toString(medic.getWarnThreshold()));
|
||||
warningValue.setText(Utils.fmt(medic.getWarning()));
|
||||
warningValue.setHint(R.string.drug_warningThreshold_label);
|
||||
warningValue.setSelectAllOnFocus(true);
|
||||
|
||||
|
@ -117,7 +121,8 @@ public class DrugDetailFragment extends Fragment {
|
|||
TextView alertLibelle = alertView.findViewById(R.id.label);
|
||||
TextView alertValue = alertView.findViewById(R.id.value);
|
||||
alertLibelle.setText(R.string.drug_alertThreshold_label);
|
||||
alertValue.setText(Integer.toString(drug.getAlertThreshold()));
|
||||
//alertValue.setText(Integer.toString(medic.getAlertThreshold()));
|
||||
alertValue.setText(Utils.fmt(medic.getAlert()));
|
||||
alertValue.setHint(R.string.drug_alertThreshold_label);
|
||||
alertValue.setSelectAllOnFocus(true);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue