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.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
import net.foucry.pilldroid.Medicament;
import net.foucry.pilldroid.dummy.DummyContent;
import java.util.List;
@ -43,11 +45,16 @@ public class MedicamentListActivity extends AppCompatActivity {
String TAG = "nef.foucry.pilldroid";
}
private static DBHelper dbHelper;
private SimpleCursorAdapter drugAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_medicament_list);
dbHelper = new DBHelper(this);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setTitle(getTitle());
@ -97,7 +104,7 @@ public class MedicamentListActivity extends AppCompatActivity {
@Override
public void onBindViewHolder(final ViewHolder holder, int 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.mView.setOnClickListener(new View.OnClickListener() {
@ -105,7 +112,7 @@ public class MedicamentListActivity extends AppCompatActivity {
public void onClick(View v) {
if (mTwoPane) {
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();
fragment.setArguments(arguments);
getSupportFragmentManager().beginTransaction()
@ -114,7 +121,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.id);
intent.putExtra(MedicamentDetailFragment.ARG_ITEM_ID, holder.mItem.getCip13());
context.startActivity(intent);
}
@ -129,15 +136,20 @@ public class MedicamentListActivity extends AppCompatActivity {
public class ViewHolder extends RecyclerView.ViewHolder {
public final View mView;
public final TextView mIdView;
public final TextView mIDView;
public final TextView mContentView;
public DummyContent.DummyItem mItem;
public final TextView mEndOfStock;
public final ImageView mIconView;
public Medicament mItem;
public ViewHolder(View view) {
super(view);
mView = view;
mIdView = (TextView) view.findViewById(R.id.id);
mContentView = (TextView) view.findViewById(R.id.content);
mIDView = (TextView) view.findViewById(R.id.cip13);
mContentView = (TextView) view.findViewById(R.id.valeur);
mEndOfStock = (TextView) view.findViewById(R.id.endOfStock);
mIconView = (ImageView) view.findViewById(R.id.list_image);
}
@Override

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

View file

@ -1,20 +1,67 @@
<?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_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/id"
<LinearLayout android:id="@+id/thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:textAppearance="?attr/textAppearanceListItem" />
android:padding="3dip"
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
android:id="@+id/content"
android:id="@+id/valeur"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/text_margin"
android:textAppearance="?attr/textAppearanceListItem" />
</LinearLayout>
android:layout_alignTop="@+id/thumbnail"
android:layout_toRightOf="@+id/thumbnail"
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>