Fin du reloockage du modèle - Il est temps de réintégrer develop

This commit is contained in:
Jacques Foucry 2016-05-23 18:45:12 +02:00
commit 4c0cb9d3cd
23 changed files with 471 additions and 122 deletions

View file

@ -3,8 +3,9 @@
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" /> <option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.10" />
<option name="modules"> <option name="modules">
<set> <set>
<option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$" />

View file

@ -6,8 +6,8 @@ android {
defaultConfig { defaultConfig {
applicationId "net.foucry.pilldroid" applicationId "net.foucry.pilldroid"
minSdkVersion 22 minSdkVersion 21
targetSdkVersion 23 targetSdkVersion 21
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
} }

View file

@ -1,4 +1,4 @@
package net.foucry.medicament; package net.foucry.pilldroid;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Context; import android.content.Context;
@ -76,7 +76,7 @@ public class DBHelper extends SQLiteOpenHelper {
public void dropDrug() { public void dropDrug() {
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
Log.d(CustomizedListView.Constants.TAG, "Drop drug table"); Log.d(MedicamentListActivity.Constants.TAG, "Drop drug table");
db.execSQL("DROP TABLE IF EXISTS drug"); db.execSQL("DROP TABLE IF EXISTS drug");
this.onCreate(db); this.onCreate(db);
@ -84,7 +84,7 @@ public class DBHelper extends SQLiteOpenHelper {
public void addDrug(Medicament medicament) { public void addDrug(Medicament medicament) {
// Logging // Logging
Log.d(CustomizedListView.Constants.TAG, medicament.toString()); Log.d(MedicamentListActivity.Constants.TAG, medicament.toString());
// Get reference to writable DB // Get reference to writable DB
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
@ -144,7 +144,7 @@ public class DBHelper extends SQLiteOpenHelper {
medicament.setAlertThreshold(Integer.parseInt(cursor.getString(9))); medicament.setAlertThreshold(Integer.parseInt(cursor.getString(9)));
// Log // Log
Log.d(CustomizedListView.Constants.TAG, "getDrug("+id+")" + medicament.toString()); Log.d(MedicamentListActivity.Constants.TAG, "getDrug("+id+")" + medicament.toString());
// Return medicament // Return medicament
@ -183,7 +183,7 @@ public class DBHelper extends SQLiteOpenHelper {
medicament.setAlertThreshold(Integer.parseInt(cursor.getString(9))); medicament.setAlertThreshold(Integer.parseInt(cursor.getString(9)));
// Log // Log
Log.d(CustomizedListView.Constants.TAG, "getDrug("+cip13+")" + medicament.toString()); Log.d(MedicamentListActivity.Constants.TAG, "getDrug("+cip13+")" + medicament.toString());
// Return medicament // Return medicament
@ -225,7 +225,7 @@ public class DBHelper extends SQLiteOpenHelper {
} }
cursor.close(); cursor.close();
Log.d(CustomizedListView.Constants.TAG, "getAllDrugs " + medicaments.toString()); Log.d(MedicamentListActivity.Constants.TAG, "getAllDrugs " + medicaments.toString());
// return // return
return medicaments; return medicaments;
@ -269,7 +269,7 @@ public class DBHelper extends SQLiteOpenHelper {
db.close(); db.close();
// log // log
Log.d(CustomizedListView.Constants.TAG, "delete drug "+medicament.toString()); Log.d(MedicamentListActivity.Constants.TAG, "delete drug "+medicament.toString());
} }
public int getCount() { public int getCount() {

View file

@ -1,4 +1,4 @@
package net.foucry.medicament; package net.foucry.pilldroid;
import java.io.Serializable; import java.io.Serializable;
import java.lang.String; import java.lang.String;
@ -6,8 +6,7 @@ import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import static net.foucry.medicament.UtilDate.*; import static net.foucry.pilldroid.UtilDate.*;
/** /**
* Created by jacques on 26/11/15. * Created by jacques on 26/11/15.
@ -50,19 +49,6 @@ public class Medicament implements Serializable {
this.alertThreshold = alert; this.alertThreshold = alert;
} }
// private Medicament(Cursor cursor) {
// if (cursor == null) throw new AssertionError();
//
// this.setCis(cursor.getString(0));
// this.setCip13(cursor.getString(1));
// this.setNom(cursor.getString(2));
// this.setMode_administration(cursor.getString(3));
// this.setPresentation(cursor.getString(4));
// this.setStock(cursor.getFloat(5));
// this.setPrise(cursor.getFloat(6));
// }
public int getId() { public int getId() {
return id; return id;
@ -183,27 +169,4 @@ public class Medicament implements Serializable {
return currentStock - takeDuringPeriod; return currentStock - takeDuringPeriod;
} }
// public static Medicament getMedicamentByCIP13(String cip13) {
// Log.e(CustomizedListView.Constants.TAG, "getMedicamentByCIP13 called");
//
// Context context = null;
// DBHelper db = new DBHelper(context);
// SQLiteDatabase myDatabase = DBHelper.getInstance(context).getWritableDatabase();
//
// Medicament medicament = null;
//
// Cursor cur = myDatabase.query("medicaments", COLUMN_LIST, "cip13 = ?", new String[]{cip13}, null, null,null);
// if (cur != null) {
// cur.moveToFirst();
// int count = cur.getCount();
// Log.d(CustomizedListView.Constants.TAG, "Number of item in cursor " + String.valueOf(count));
// medicament = new Medicament(cur);
// }
// cur.close();
// myDatabase.close();
// return medicament;
// }
} }

View file

@ -23,13 +23,17 @@ public class MedicamentDetailActivity extends AppCompatActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_medicament_detail); setContentView(R.layout.activity_medicament_detail);
Toolbar toolbar = (Toolbar) findViewById(R.id.detail_toolbar); Toolbar toolbar = (Toolbar) findViewById(R.id.detail_toolbar);
setSupportActionBar(toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
toolbar.setTitle(getTitle());
}
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() { fab.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Snackbar.make(view, "Replace with your own detail action", Snackbar.LENGTH_LONG) Snackbar.make(view, "Will be use to save changes in a drug", Snackbar.LENGTH_LONG)
.setAction("Action", null).show(); .setAction("Action", null).show();
} }
}); });
@ -53,8 +57,8 @@ public class MedicamentDetailActivity extends AppCompatActivity {
// Create the detail fragment and add it to the activity // Create the detail fragment and add it to the activity
// using a fragment transaction. // using a fragment transaction.
Bundle arguments = new Bundle(); Bundle arguments = new Bundle();
arguments.putString(MedicamentDetailFragment.ARG_ITEM_ID, arguments.putSerializable("medicament",
getIntent().getStringExtra(MedicamentDetailFragment.ARG_ITEM_ID)); getIntent().getSerializableExtra("medicament"));
MedicamentDetailFragment fragment = new MedicamentDetailFragment(); MedicamentDetailFragment fragment = new MedicamentDetailFragment();
fragment.setArguments(arguments); fragment.setArguments(arguments);
getSupportFragmentManager().beginTransaction() getSupportFragmentManager().beginTransaction()

View file

@ -4,6 +4,7 @@ import android.app.Activity;
import android.support.design.widget.CollapsingToolbarLayout; import android.support.design.widget.CollapsingToolbarLayout;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -22,12 +23,12 @@ public class MedicamentDetailFragment extends Fragment {
* The fragment argument representing the item ID that this fragment * The fragment argument representing the item ID that this fragment
* represents. * represents.
*/ */
public static final String ARG_ITEM_ID = "item_id"; public static final String ARG_ITEM_ID = "medicament";
/** /**
* The dummy content this fragment is presenting. * The dummy content this fragment is presenting.
*/ */
private DummyContent.DummyItem mItem; private Medicament medicament;
/** /**
* Mandatory empty constructor for the fragment manager to instantiate the * Mandatory empty constructor for the fragment manager to instantiate the
@ -44,12 +45,12 @@ public class MedicamentDetailFragment extends Fragment {
// Load the dummy content specified by the fragment // Load the dummy content specified by the fragment
// arguments. In a real-world scenario, use a Loader // arguments. In a real-world scenario, use a Loader
// to load content from a content provider. // to load content from a content provider.
mItem = DummyContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID)); medicament = (Medicament) getArguments().getSerializable(ARG_ITEM_ID);
Activity activity = this.getActivity(); Activity activity = this.getActivity();
CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout); CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout);
if (appBarLayout != null) { if (appBarLayout != null) {
appBarLayout.setTitle(mItem.content); appBarLayout.setTitle(medicament.getNom());
} }
} }
} }
@ -57,13 +58,61 @@ public class MedicamentDetailFragment extends Fragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.medicament_detail, container, false); View detailView = inflater.inflate(R.layout.medicament_detail, container, false);
View nameView;
View adminModeView;
View presentationView;
View stockView;
View priseView;
View warningView;
View alertView;
// Show the dummy content as text in a TextView. // Show the dummy content as text in a TextView.
if (mItem != null) { if (medicament != null) {
((TextView) rootView.findViewById(R.id.medicament_detail)).setText(mItem.details); // Find each conponment of rootView
nameView = detailView.findViewById(R.id.name_cell);
TextView nameLabel = (TextView) nameView.findViewById(R.id.label);
TextView nameValeur = (TextView) nameView.findViewById(R.id.valeur);
nameLabel.setText("Nom");
nameValeur.setText(medicament.getNom());
presentationView = detailView.findViewById(R.id.presentation_cell);
TextView presentationLabel = (TextView) presentationView.findViewById(R.id.label);
TextView presentationValeur = (TextView) presentationView.findViewById(R.id.valeur);
presentationLabel.setText("Presentation");
presentationValeur.setText(medicament.getPresentation());
adminModeView = detailView.findViewById(R.id.administration_cell);
TextView adminModeLabel = (TextView) adminModeView.findViewById(R.id.label);
TextView adminModeValeur = (TextView) adminModeView.findViewById(R.id.valeur);
adminModeLabel.setText("Mode d'administration");
adminModeValeur.setText(medicament.getMode_administration());
stockView = detailView.findViewById(R.id.stock_cell);
TextView stockLibelle = (TextView) stockView.findViewById(R.id.libelle);
TextView stockValue = (TextView) stockView.findViewById(R.id.valeur);
stockLibelle.setText("Stock courant");
stockValue.setText(Double.toString(medicament.getStock()));
priseView = detailView.findViewById(R.id.prise_cell);
TextView priseLibelle = (TextView) priseView.findViewById(R.id.libelle);
TextView priseValue = (TextView) priseView.findViewById(R.id.valeur);
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);
TextView alertLibelle = (TextView) alertView.findViewById(R.id.libelle);
TextView alertValue = (TextView) alertView.findViewById(R.id.valeur);
alertLibelle.setText("Seuil critique");
alertValue.setText(Integer.toString(medicament.getAlertThreshold()));
} }
return rootView; return detailView;
} }
} }

View file

@ -10,15 +10,25 @@ import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView; import android.widget.TextView;
import net.foucry.pilldroid.Medicament;
import net.foucry.pilldroid.dummy.DummyContent; import net.foucry.pilldroid.dummy.DummyContent;
import static net.foucry.pilldroid.UtilDate.*;
import static net.foucry.pilldroid.Utils.*;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Random;
/** /**
* An activity representing a list of Medicaments. This activity * An activity representing a list of Medicaments. This activity
@ -35,25 +45,90 @@ public class MedicamentListActivity extends AppCompatActivity {
* device. * device.
*/ */
private boolean mTwoPane; private boolean mTwoPane;
final static Boolean DEMO = true;
final static Random random = new Random();
// Log TAG String
public interface Constants {
String TAG = "nef.foucry.pilldroid";
}
private static DBHelper dbHelper;
private SimpleCursorAdapter drugAdapter;
private List<Medicament> medicaments;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_medicament_list); setContentView(R.layout.activity_medicament_list);
dbHelper = new DBHelper(this);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setTitle(getTitle()); if (toolbar != null) {
setSupportActionBar(toolbar);
toolbar.setTitle(getTitle());
}
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() { fab.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) Snackbar.make(view, "Will be used to add a drug to the list", Snackbar.LENGTH_LONG)
.setAction("Action", null).show(); .setAction("Action", null).show();
} }
}); });
if (DEMO) {
if (dbHelper.getCount() == 0) {
// String cis, String cip13, String nom, String mode_administration,
// String presentation,double stock, double prise, int warn, int alert
dbHelper.addDrug(new Medicament("60000011", "3400930000011", "Médicament test 01", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
doubleRandomInclusive(0, 100), doubleRandomInclusive(0, 10), 14, 7));
dbHelper.addDrug(new Medicament("60000012", "3400930000012", "Médicament test 02", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
doubleRandomInclusive(0, 100), doubleRandomInclusive(0, 10), 14, 7));
dbHelper.addDrug(new Medicament("60000013", "3400930000013", "Médicament test 03", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
doubleRandomInclusive(0, 100), doubleRandomInclusive(0, 10), 14, 7));
dbHelper.addDrug(new Medicament("60000014", "3400930000014", "Médicament test 04", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
doubleRandomInclusive(0, 100), doubleRandomInclusive(0, 10), 14, 7));
dbHelper.addDrug(new Medicament("60000015", "3400930000015", "Médicament test 05", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
doubleRandomInclusive(0, 100), doubleRandomInclusive(0, 10), 14, 7));
dbHelper.addDrug(new Medicament("60000016", "3400930000016", "Médicament test 06", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
doubleRandomInclusive(0, 100), doubleRandomInclusive(0, 10), 14, 7));
dbHelper.addDrug(new Medicament("60000017", "3400930000017", "Médicament test 07", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
doubleRandomInclusive(0, 100), doubleRandomInclusive(0, 10), 14, 7));
dbHelper.addDrug(new Medicament("60000018", "3400930000018", "Médicament test 08", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
doubleRandomInclusive(0, 100), doubleRandomInclusive(0, 10), 14, 7));
dbHelper.addDrug(new Medicament("60000019", "3400930000019", "Médicament test 09", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
doubleRandomInclusive(0, 100), doubleRandomInclusive(0, 10), 14, 7));
dbHelper.addDrug(new Medicament("60000010", "3400930000010", "Médicament test 10", "orale",
"plaquette(s) thermoformée(s) PVC PVDC aluminium de 10 comprimé(s)",
doubleRandomInclusive(0, 100), doubleRandomInclusive(0, 10), 14, 7));
}
}
if (this.medicaments == null) {
this.medicaments = dbHelper.getAllDrugs();
Collections.sort(this.medicaments, new Comparator<Medicament>() {
@Override
public int compare(Medicament lhs, Medicament rhs) {
return lhs.getDateEndOfStock().compareTo(rhs.getDateEndOfStock());
}
});
}
View recyclerView = findViewById(R.id.medicament_list); View recyclerView = findViewById(R.id.medicament_list);
assert recyclerView != null; assert recyclerView != null;
setupRecyclerView((RecyclerView) recyclerView); setupRecyclerView((RecyclerView) recyclerView);
@ -68,15 +143,16 @@ public class MedicamentListActivity extends AppCompatActivity {
} }
private void setupRecyclerView(@NonNull RecyclerView recyclerView) { private void setupRecyclerView(@NonNull RecyclerView recyclerView) {
recyclerView.setAdapter(new SimpleItemRecyclerViewAdapter(DummyContent.ITEMS)); recyclerView.addItemDecoration(new SimpleDividerItemDecoration(getApplicationContext()));
recyclerView.setAdapter(new SimpleItemRecyclerViewAdapter(medicaments));
} }
public class SimpleItemRecyclerViewAdapter public class SimpleItemRecyclerViewAdapter
extends RecyclerView.Adapter<SimpleItemRecyclerViewAdapter.ViewHolder> { extends RecyclerView.Adapter<SimpleItemRecyclerViewAdapter.ViewHolder> {
private final List<DummyContent.DummyItem> mValues; private final List<Medicament> mValues;
public SimpleItemRecyclerViewAdapter(List<DummyContent.DummyItem> items) { public SimpleItemRecyclerViewAdapter(List<Medicament> items) {
mValues = items; mValues = items;
} }
@ -88,17 +164,45 @@ public class MedicamentListActivity extends AppCompatActivity {
} }
@Override @Override
public void onBindViewHolder(final ViewHolder holder, int position) { public void onBindViewHolder(final ViewHolder holder, final int position) {
SimpleDateFormat dateFormat = new SimpleDateFormat("EEEE d MMMM yyyy", Locale.getDefault());
String dateEndOfStock = date2String(mValues.get(position).getDateEndOfStock(), dateFormat);
Log.d(Constants.TAG, "dateEndOfStock == " + dateEndOfStock);
Log.d(Constants.TAG, "stock == " + mValues.get(position).getStock());
Log.d(Constants.TAG, "prise == " + mValues.get(position).getPrise());
Log.d(Constants.TAG, "warn == " + mValues.get(position).getWarnThreshold());
Log.d(Constants.TAG, "alert == " + mValues.get(position).getAlertThreshold());
holder.mItem = mValues.get(position); holder.mItem = mValues.get(position);
holder.mIdView.setText(mValues.get(position).id); holder.mIDView.setText(mValues.get(position).getCip13());
holder.mContentView.setText(mValues.get(position).content); holder.mContentView.setText(mValues.get(position).getNom());
holder.mEndOfStock.setText(dateEndOfStock);
// Test to change background programmaticaly
if (mValues.get(position).getPrise() == 0) {
holder.mView.setBackgroundResource(R.drawable.gradient_bg);
} else {
if (mValues.get(position).getStock() <= mValues.get(position).getAlertThreshold()) {
holder.mView.setBackgroundResource(R.drawable.gradient_bg_alert);
holder.mIconView.setImageResource(R.drawable.stock_alert);
} else if ((mValues.get(position).getStock() > mValues.get(position).getAlertThreshold()) &&
(mValues.get(position).getStock() <= (mValues.get(position).getWarnThreshold() * mValues.get(position).getPrise()))) {
holder.mView.setBackgroundResource(R.drawable.gradient_bg_warning);
holder.mIconView.setImageResource(R.drawable.stock_warn);
} else {
holder.mView.setBackgroundResource(R.drawable.gradient_bg_ok);
holder.mIconView.setImageResource(R.drawable.stock_ok);
}
}
holder.mView.setOnClickListener(new View.OnClickListener() { holder.mView.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Medicament medicamentCourant = (Medicament) mValues.get(position);
if (mTwoPane) { if (mTwoPane) {
Bundle arguments = new Bundle(); Bundle arguments = new Bundle();
arguments.putString(MedicamentDetailFragment.ARG_ITEM_ID, holder.mItem.id); arguments.putSerializable("medicament", medicamentCourant);
MedicamentDetailFragment fragment = new MedicamentDetailFragment(); MedicamentDetailFragment fragment = new MedicamentDetailFragment();
fragment.setArguments(arguments); fragment.setArguments(arguments);
getSupportFragmentManager().beginTransaction() getSupportFragmentManager().beginTransaction()
@ -107,7 +211,7 @@ public class MedicamentListActivity extends AppCompatActivity {
} else { } else {
Context context = v.getContext(); Context context = v.getContext();
Intent intent = new Intent(context, MedicamentDetailActivity.class); Intent intent = new Intent(context, MedicamentDetailActivity.class);
intent.putExtra(MedicamentDetailFragment.ARG_ITEM_ID, holder.mItem.id); intent.putExtra("medicament", medicamentCourant);
context.startActivity(intent); context.startActivity(intent);
} }
@ -122,15 +226,20 @@ public class MedicamentListActivity extends AppCompatActivity {
public class ViewHolder extends RecyclerView.ViewHolder { public class ViewHolder extends RecyclerView.ViewHolder {
public final View mView; public final View mView;
public final TextView mIdView; public final TextView mIDView;
public final TextView mContentView; public final TextView mContentView;
public DummyContent.DummyItem mItem; public final TextView mEndOfStock;
public final ImageView mIconView;
public Medicament mItem;
public ViewHolder(View view) { public ViewHolder(View view) {
super(view); super(view);
mView = view; mView = view;
mIdView = (TextView) view.findViewById(R.id.id); mIDView = (TextView) view.findViewById(R.id.cip13);
mContentView = (TextView) view.findViewById(R.id.content); mContentView = (TextView) view.findViewById(R.id.valeur);
mEndOfStock = (TextView) view.findViewById(R.id.endOfStock);
mIconView = (ImageView) view.findViewById(R.id.list_image);
} }
@Override @Override

View file

@ -0,0 +1,37 @@
package net.foucry.pilldroid;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
/**
* Created by jacques on 10/05/16.
*/
public class SimpleDividerItemDecoration extends RecyclerView.ItemDecoration {
private Drawable mDivider;
public SimpleDividerItemDecoration(Context context) {
mDivider = context.getResources().getDrawable(R.drawable.line_divider);
}
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
int left = parent.getPaddingLeft();
int right = parent.getWidth() - parent.getPaddingRight();
int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
View child = parent.getChildAt(i);
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
int top = child.getBottom() + params.bottomMargin;
int bottom = top + mDivider.getIntrinsicHeight();
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}
}

View file

@ -1,4 +1,4 @@
package net.foucry.medicament; package net.foucry.pilldroid;
import android.util.Log; import android.util.Log;
@ -21,7 +21,7 @@ public class UtilDate {
*/ */
public static Date dateAtNoon(Date aDate) { public static Date dateAtNoon(Date aDate) {
Log.d(CustomizedListView.Constants.TAG, "dateAtNoon " + aDate); Log.d(MedicamentListActivity.Constants.TAG, "dateAtNoon " + aDate);
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(aDate); calendar.setTime(aDate);
@ -57,7 +57,7 @@ public class UtilDate {
*/ */
public static String date2String(Date date, DateFormat dateFormat) { public static String date2String(Date date, DateFormat dateFormat) {
Log.d(CustomizedListView.Constants.TAG, "date == " + date); Log.d(MedicamentListActivity.Constants.TAG, "date == " + date);
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(date); calendar.setTime(date);

View file

@ -1,4 +1,4 @@
package net.foucry.medicament; package net.foucry.pilldroid;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -25,7 +25,7 @@ public class Utils {
} }
public static final double doubleRandomInclusive(int min, int max) { public static final double doubleRandomInclusive(int min, int max) {
double value = Math.floor(min + (max - min) * CustomizedListView.random.nextDouble() *4)/4; double value = Math.floor(min + (max - min) * MedicamentListActivity.random.nextDouble() *4)/4;
return value; return value;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- Gradient Bg for listrow -->
<gradient
android:startColor="#f1f1f2"
android:centerColor="#e7e7e8"
android:endColor="#cfcfcf"
android:angle="270" />
</shape>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- Gradient BgColor for listrow Selected -->
<gradient
android:startColor="#18d7e5"
android:centerColor="#16cedb"
android:endColor="#09adb9"
android:angle="270" />
</shape>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Selector style for listrow -->
<item android:state_pressed="false" android:state_selected="false" android:drawable="@drawable/gradient_bg" />
<item android:state_pressed="true" android:drawable="@drawable/gradient_bg_hover" />
<item android:state_pressed="false" android:state_selected="true" android:drawable="@drawable/gradient_bg_hover" />
</selector>

View file

@ -17,11 +17,11 @@
<android.support.design.widget.CollapsingToolbarLayout <android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout" android:id="@+id/toolbar_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="25dp"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary" app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed" app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="@+id/toolbar"> app:toolbarId="@+id/toolbar"/>
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
android:id="@+id/detail_toolbar" android:id="@+id/detail_toolbar"
@ -30,24 +30,24 @@
app:layout_collapseMode="pin" app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout> </android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView <android.support.v4.widget.NestedScrollView
android:id="@+id/medicament_detail_container" android:id="@+id/medicament_detail_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.FloatingActionButton <android.support.design.widget.FloatingActionButton
android:id="@+id/fab" android:id="@+id/fab"
android:layout_width="wrap_content" android:layout_width="60dp"
android:layout_height="wrap_content" android:layout_height="60dp"
android:layout_gravity="center_vertical|start" android:layout_gravity="center_vertical|start"
android:layout_margin="@dimen/fab_margin" android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/stat_notify_chat" android:src="@android:drawable/ic_menu_save"
app:layout_anchor="@+id/medicament_detail_container" app:layout_anchor="@+id/medicament_detail_container"
app:layout_anchorGravity="top|end" /> app:layout_anchorGravity="top|end" />
</android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout>

View file

@ -32,11 +32,14 @@
<android.support.design.widget.FloatingActionButton <android.support.design.widget.FloatingActionButton
android:id="@+id/fab" android:id="@+id/fab"
android:layout_width="wrap_content" android:layout_width="60dp"
android:layout_height="wrap_content" android:layout_height="60dp"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin" android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email" /> android:src="@android:drawable/ic_input_add"
android:adjustViewBounds="true"
android:clickable="false"
android:baselineAlignBottom="false"/>
</android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout>

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/list_selector">
<TextView
android:id="@+id/valeur"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Valeur"
android:textSize="16dp"
android:textColor="#040404"
android:textStyle="bold"
android:paddingLeft="10dp"
android:paddingTop="5dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Label"
android:layout_below="@+id/valeur"
android:layout_alignParentLeft="true"
android:textStyle="italic"
android:textColor="#0c4758"
android:background="@android:color/transparent"
android:id="@+id/label"
android:paddingLeft="10sp"
android:paddingTop="5dp"/>
</RelativeLayout>

View file

@ -1,9 +1,61 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/medicament_detail" android:id="@+id/medicament_detail"
style="?android:attr/textAppearanceLarge" android:layout_width="wrap_content"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="match_parent" android:orientation="vertical"
android:padding="16dp" android:background="@drawable/list_selector"
android:textIsSelectable="true" tools:context="net.foucry.pilldroid.MedicamentDetailFragment">
tools:context="net.foucry.pilldroid.MedicamentDetailFragment" />
<include
android:id="@+id/name_cell"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5sp"
layout="@layout/info_cell" />
<include
android:id="@+id/presentation_cell"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/info_cell"
android:layout_marginTop="5sp" />
<include
android:id="@+id/administration_cell"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/info_cell"
android:layout_marginTop="5sp" />
<include
android:id="@+id/stock_cell"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/value_input"
android:layout_marginTop="30sp" />
<include
android:id="@+id/prise_cell"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/value_input"
android:layout_marginTop="30sp" />
<include
android:id="@+id/warning_cell"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/value_input"
android:layout_marginTop="15sp" />
<include
android:id="@+id/alert_cell"
layout="@layout/value_input"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5sp" />
</LinearLayout>

View file

@ -6,8 +6,7 @@
android:name="net.foucry.pilldroid.MedicamentListFragment" android:name="net.foucry.pilldroid.MedicamentListFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
app:layoutManager="LinearLayoutManager" app:layoutManager="LinearLayoutManager"
android:background="@drawable/list_selector"
tools:context="net.foucry.pilldroid.MedicamentListActivity" tools:context="net.foucry.pilldroid.MedicamentListActivity"
tools:listitem="@layout/medicament_list_content" /> tools:listitem="@layout/medicament_list_content" />

View file

@ -1,20 +1,69 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="60dp"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <LinearLayout android:id="@+id/thumbnail"
android:id="@+id/id"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin" android:padding="3dip"
android:textAppearance="?attr/textAppearanceListItem" /> android:layout_alignParentLeft="true"
android:background="@android:color/transparent"
android:layout_marginRight="0sp">
<ImageView
android:id="@+id/list_image"
android:layout_width="50sp"
android:layout_height="50sp"
android:layout_marginLeft="5dp"
android:layout_marginTop="2dp"
android:src="@drawable/stock_ok" />
</LinearLayout>
<!-- Drug's name-->
<TextView <TextView
android:id="@+id/content" android:id="@+id/valeur"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin" android:layout_alignTop="@+id/thumbnail"
android:textAppearance="?attr/textAppearanceListItem" /> android:layout_toRightOf="@+id/thumbnail"
</LinearLayout> android:text="Nom Médicament"
android:textColor="#040404"
android:typeface="sans"
android:textSize="16sp"
android:textStyle="bold"/>
<!-- CIP 13 (should change) -->
<TextView
android:id="@+id/cip13"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/valeur"
android:textColor="#343434"
android:textSize="14sp"
android:layout_marginTop="1sp"
android:layout_toRightOf="@+id/thumbnail"
android:text="cip13 goes here" />
<!-- dateEndOfStock -->
<TextView
android:id="@+id/endOfStock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@id/valeur"
android:gravity="right"
android:text="lundi 1 janvier 2001"
android:layout_marginRight="15dp"
android:textSize="14sp"
android:textColor="#212121"
android:textStyle="bold"/>
<!-- Rightend Arrow -->
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/arrow"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10sp"/>
</RelativeLayout>

View file

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="@+id/libelle"
android:background="@drawable/list_selector"
android:textStyle="bold"
android:textColor="#040404"
android:paddingLeft="5dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:gravity="center_vertical"
android:layout_toLeftOf="@+id/valeur"
android:layout_alignBottom="@+id/valeur" />
<EditText
android:layout_width="wrap_content"
android:layout_height="50dp"
android:inputType="numberDecimal"
android:ems="10"
android:id="@+id/valeur"
android:paddingRight="25dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:textAlignment="gravity"
android:background="@drawable/list_selector"
android:text="0"
android:gravity="right|fill_vertical"
android:numeric="decimal" />
</RelativeLayout>

View file

@ -1,9 +0,0 @@
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<dimen name="fab_margin">16dp</dimen> <dimen name="fab_margin">16dp</dimen>
<dimen name="app_bar_height">200dp</dimen> <dimen name="app_bar_height">75dp</dimen>
<dimen name="item_width">200dp</dimen> <dimen name="item_width">200dp</dimen>
<dimen name="text_margin">16dp</dimen> <dimen name="text_margin">16dp</dimen>
</resources> </resources>