Lists activity displays item count on each list

This commit is contained in:
Clayton Wilson 2020-11-14 19:35:11 -05:00
parent 680c545d76
commit 07733caed7
2 changed files with 18 additions and 6 deletions

View File

@ -80,7 +80,8 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
holder.frontView = convertView.findViewById(R.id.front_layout); holder.frontView = convertView.findViewById(R.id.front_layout);
holder.deleteList = convertView.findViewById(R.id.delete_list); holder.deleteList = convertView.findViewById(R.id.delete_list);
holder.shareList = convertView.findViewById(R.id.share_list); holder.shareList = convertView.findViewById(R.id.share_list);
holder.textView = (TextView) convertView.findViewById(R.id.shopping_list_name); holder.listName = (TextView) convertView.findViewById(R.id.shopping_list_name);
holder.itemCount = (TextView) convertView.findViewById(R.id.shopping_list_item_count);
convertView.setTag(holder); convertView.setTag(holder);
} else { } else {
@ -93,11 +94,14 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
binderHelper.bind(holder.swipeLayout, Integer.toString(curList.getItemID())); binderHelper.bind(holder.swipeLayout, Integer.toString(curList.getItemID()));
if(curList.isShared()) { if(curList.isShared()) {
holder.textView.setText(curList.getName() + " (shared)"); holder.listName.setText(curList.getName() + " (shared)");
} }
else { else {
holder.textView.setText(curList.getName()); holder.listName.setText(curList.getName());
} }
holder.itemCount.setText(String.format("%d items", curList.getEntries().length));
holder.deleteList.setOnClickListener(new View.OnClickListener() { holder.deleteList.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -172,6 +176,7 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
View frontView; View frontView;
View deleteList; View deleteList;
View shareList; View shareList;
TextView textView; TextView listName;
TextView itemCount;
} }
} }

View File

@ -40,11 +40,18 @@
android:layout_height="50dp"> android:layout_height="50dp">
<TextView <TextView
android:id="@+id/shopping_list_name" android:id="@+id/shopping_list_name"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="20sp" android:textSize="20sp"
android:textStyle="bold" android:textStyle="bold"
android:layout_gravity="center"/> android:layout_gravity="center_vertical"/>
<TextView
android:id="@+id/shopping_list_item_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:layout_gravity="center_vertical|end"/>
</FrameLayout> </FrameLayout>
</com.chauthai.swipereveallayout.SwipeRevealLayout> </com.chauthai.swipereveallayout.SwipeRevealLayout>