mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-21 20:19:23 +01:00
Ajout toolbar et ajustement des tailles des cellules
Manque le retour et le bouton de sauvegarde
This commit is contained in:
parent
0e84ec6ab6
commit
003f577288
13 changed files with 166 additions and 49 deletions
|
@ -6,8 +6,8 @@ android {
|
|||
|
||||
defaultConfig {
|
||||
applicationId "net.foucry.pilldroid"
|
||||
minSdkVersion 22
|
||||
targetSdkVersion 23
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 21
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
|
|
|
@ -53,8 +53,8 @@ public class MedicamentDetailActivity extends AppCompatActivity {
|
|||
// Create the detail fragment and add it to the activity
|
||||
// using a fragment transaction.
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putString(MedicamentDetailFragment.ARG_ITEM_ID,
|
||||
getIntent().getStringExtra(MedicamentDetailFragment.ARG_ITEM_ID));
|
||||
arguments.putSerializable("medicament",
|
||||
getIntent().getSerializableExtra("medicament"));
|
||||
MedicamentDetailFragment fragment = new MedicamentDetailFragment();
|
||||
fragment.setArguments(arguments);
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
|
|
|
@ -22,12 +22,12 @@ public class MedicamentDetailFragment extends Fragment {
|
|||
* The fragment argument representing the item ID that this fragment
|
||||
* 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.
|
||||
*/
|
||||
private DummyContent.DummyItem mItem;
|
||||
private Medicament medicament;
|
||||
|
||||
/**
|
||||
* Mandatory empty constructor for the fragment manager to instantiate the
|
||||
|
@ -44,12 +44,12 @@ public class MedicamentDetailFragment 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.
|
||||
mItem = DummyContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
|
||||
medicament = (Medicament) getArguments().getSerializable(ARG_ITEM_ID);
|
||||
|
||||
Activity activity = this.getActivity();
|
||||
CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout);
|
||||
if (appBarLayout != null) {
|
||||
appBarLayout.setTitle(mItem.content);
|
||||
appBarLayout.setTitle(medicament.getNom());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,13 +57,61 @@ public class MedicamentDetailFragment extends Fragment {
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
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.
|
||||
if (mItem != null) {
|
||||
((TextView) rootView.findViewById(R.id.medicament_detail)).setText(mItem.details);
|
||||
if (medicament != null) {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.support.v7.widget.RecyclerView;
|
|||
import android.support.v7.widget.Toolbar;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -17,14 +18,16 @@ import android.widget.ImageView;
|
|||
import android.widget.SimpleCursorAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
import net.foucry.pilldroid.Medicament;
|
||||
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.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
|
@ -128,6 +131,7 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
private void setupRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||
recyclerView.addItemDecoration(new SimpleDividerItemDecoration(getApplicationContext()));
|
||||
recyclerView.setAdapter(new SimpleItemRecyclerViewAdapter(medicaments));
|
||||
}
|
||||
|
||||
|
@ -148,17 +152,45 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
@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.mIDView.setText(mValues.get(position).getCip13());
|
||||
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() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Medicament medicamentCourant = (Medicament) mValues.get(position);
|
||||
if (mTwoPane) {
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putString(MedicamentDetailFragment.ARG_ITEM_ID, holder.mItem.getCip13());
|
||||
arguments.putSerializable("medicament", medicamentCourant);
|
||||
MedicamentDetailFragment fragment = new MedicamentDetailFragment();
|
||||
fragment.setArguments(arguments);
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
|
@ -167,7 +199,7 @@ public class MedicamentListActivity extends AppCompatActivity {
|
|||
} else {
|
||||
Context context = v.getContext();
|
||||
Intent intent = new Intent(context, MedicamentDetailActivity.class);
|
||||
intent.putExtra(MedicamentDetailFragment.ARG_ITEM_ID, holder.mItem.getCip13());
|
||||
intent.putExtra("medicament", medicamentCourant);
|
||||
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,8 +17,10 @@
|
|||
<android.support.design.widget.CollapsingToolbarLayout
|
||||
android:id="@+id/toolbar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:fitsSystemWindows="true"
|
||||
android:title="Prout"
|
||||
android:titleTextColor="@android:color/black"
|
||||
app:contentScrim="?attr/colorPrimary"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed"
|
||||
app:toolbarId="@+id/toolbar"/>
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?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="match_parent">
|
||||
android:layout_height="50dp"
|
||||
android:background="@drawable/list_selector">
|
||||
<TextView
|
||||
android:id="@+id/valeur"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -10,7 +11,8 @@
|
|||
android:textSize="16dp"
|
||||
android:textColor="#040404"
|
||||
android:textStyle="bold"
|
||||
android:paddingLeft="10dp" />
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingTop="5dp"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -21,6 +23,7 @@
|
|||
android:textColor="#57C1DE"
|
||||
android:background="@android:color/transparent"
|
||||
android:id="@+id/label"
|
||||
android:paddingLeft="10sp" />
|
||||
android:paddingLeft="10sp"
|
||||
android:paddingTop="5dp"/>
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,18 +1,10 @@
|
|||
<!--<TextView xmlns:android="http://schemas.android.com/apk/res/android"-->
|
||||
<!--xmlns:tools="http://schemas.android.com/tools"-->
|
||||
<!--android:id="@+id/medicament_detail"-->
|
||||
<!--style="?android:attr/textAppearanceLarge"-->
|
||||
<!--android:layout_width="match_parent"-->
|
||||
<!--android:layout_height="match_parent"-->
|
||||
<!--android:padding="16dp"-->
|
||||
<!--android:textIsSelectable="true"-->
|
||||
<!--android:text="rput"-->
|
||||
<!--tools:context="net.foucry.pilldroid.MedicamentDetailFragment" />-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/medicament_detail"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/list_selector"
|
||||
tools:context="net.foucry.pilldroid.MedicamentDetailFragment">
|
||||
|
||||
<include
|
||||
|
@ -43,6 +35,13 @@
|
|||
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"
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
android:name="net.foucry.pilldroid.MedicamentListFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
app:layoutManager="LinearLayoutManager"
|
||||
android:background="@drawable/list_selector"
|
||||
tools:context="net.foucry.pilldroid.MedicamentListActivity"
|
||||
tools:listitem="@layout/medicament_list_content" />
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="60dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout android:id="@+id/thumbnail"
|
||||
|
@ -10,12 +10,14 @@
|
|||
android:padding="3dip"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="@android:color/transparent"
|
||||
android:layout_marginRight="5sp">
|
||||
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="5dp"
|
||||
android:src="@drawable/stock_ok" />
|
||||
</LinearLayout>
|
||||
<!-- Drug's name-->
|
||||
|
@ -28,7 +30,7 @@
|
|||
android:text="Nom Médicament"
|
||||
android:textColor="#040404"
|
||||
android:typeface="sans"
|
||||
android:textSize="14sp"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<!-- CIP 13 (should change) -->
|
||||
|
@ -38,7 +40,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/valeur"
|
||||
android:textColor="#343434"
|
||||
android:textSize="13sp"
|
||||
android:textSize="14sp"
|
||||
android:layout_marginTop="1sp"
|
||||
android:layout_toRightOf="@+id/thumbnail"
|
||||
android:text="cip13 goes here" />
|
||||
|
@ -52,8 +54,8 @@
|
|||
android:layout_alignTop="@id/valeur"
|
||||
android:gravity="right"
|
||||
android:text="lundi 1 janvier 2001"
|
||||
android:layout_marginRight="5dip"
|
||||
android:textSize="12sp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#212121"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
|
|
|
@ -11,20 +11,24 @@
|
|||
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="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:inputType="numberDecimal"
|
||||
android:ems="10"
|
||||
android:id="@+id/valeur"
|
||||
android:paddingRight="10dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:textAlignment="gravity"
|
||||
android:background="@drawable/list_selector"
|
||||
android:text="0" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -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>
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="fab_margin">16dp</dimen>
|
||||
<dimen name="app_bar_height">200dp</dimen>
|
||||
<dimen name="app_bar_height">100dp</dimen>
|
||||
<dimen name="item_width">200dp</dimen>
|
||||
<dimen name="text_margin">16dp</dimen>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue