Mise en place du look PillStock

This commit is contained in:
Jacques Foucry 2016-05-19 17:14:58 +02:00
parent 95e3a5b842
commit 55d3e8b903
3 changed files with 76 additions and 17 deletions

View file

@ -13,9 +13,11 @@ import android.support.design.widget.Snackbar;
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 java.util.List; import java.util.List;
@ -43,11 +45,16 @@ public class MedicamentListActivity extends AppCompatActivity {
String TAG = "nef.foucry.pilldroid"; String TAG = "nef.foucry.pilldroid";
} }
private static DBHelper dbHelper;
private SimpleCursorAdapter drugAdapter;
@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); setSupportActionBar(toolbar);
toolbar.setTitle(getTitle()); toolbar.setTitle(getTitle());
@ -97,7 +104,7 @@ public class MedicamentListActivity extends AppCompatActivity {
@Override @Override
public void onBindViewHolder(final ViewHolder holder, int position) { public void onBindViewHolder(final ViewHolder holder, int position) {
holder.mItem = mValues.get(position); holder.mItem = mValues.get(position);
holder.mIdView.setText(mValues.get(position).id); holder.mIDView.setText(mValues.get(position).id);
holder.mContentView.setText(mValues.get(position).content); holder.mContentView.setText(mValues.get(position).content);
holder.mView.setOnClickListener(new View.OnClickListener() { holder.mView.setOnClickListener(new View.OnClickListener() {
@ -105,7 +112,7 @@ public class MedicamentListActivity extends AppCompatActivity {
public void onClick(View v) { public void onClick(View v) {
if (mTwoPane) { if (mTwoPane) {
Bundle arguments = new Bundle(); Bundle arguments = new Bundle();
arguments.putString(MedicamentDetailFragment.ARG_ITEM_ID, holder.mItem.id); arguments.putString(MedicamentDetailFragment.ARG_ITEM_ID, holder.mItem.getCip13());
MedicamentDetailFragment fragment = new MedicamentDetailFragment(); MedicamentDetailFragment fragment = new MedicamentDetailFragment();
fragment.setArguments(arguments); fragment.setArguments(arguments);
getSupportFragmentManager().beginTransaction() getSupportFragmentManager().beginTransaction()
@ -114,7 +121,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(MedicamentDetailFragment.ARG_ITEM_ID, holder.mItem.getCip13());
context.startActivity(intent); context.startActivity(intent);
} }
@ -129,15 +136,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

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

View file

@ -1,20 +1,67 @@
<?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="wrap_content"
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="5sp">
<ImageView
android:id="@+id/list_image"
android:layout_width="50sp"
android:layout_height="50sp"
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="14sp"
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="13sp"
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="5dip"
android:textSize="12sp"
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>