mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 02:38:47 +00:00
Added back old list display adapter as ShoppingListsAdapter
This commit is contained in:
parent
cce114e4d5
commit
f559a3298f
@ -13,7 +13,7 @@ import android.widget.ListView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import com.example.listify.adapter.ShoppingListsSwipeableAdapter;
|
||||
import com.example.listify.adapter.ShoppingListsAdapter;
|
||||
import com.example.listify.data.List;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -28,7 +28,7 @@ public class ListPickerDialogFragment extends DialogFragment {
|
||||
public OnListPickListener onListPickListener;
|
||||
|
||||
ListView userListsView;
|
||||
ShoppingListsSwipeableAdapter shoppingListsSwipeableAdapter;
|
||||
ShoppingListsAdapter shoppingListsAdapter;
|
||||
Button btnMinus;
|
||||
Button btnPlus;
|
||||
EditText etQuantity;
|
||||
@ -66,8 +66,8 @@ public class ListPickerDialogFragment extends DialogFragment {
|
||||
|
||||
// Display user's shopping lists
|
||||
userListsView = (ListView) root.findViewById(R.id.user_lists);
|
||||
shoppingListsSwipeableAdapter = new ShoppingListsSwipeableAdapter(getActivity(), userLists);
|
||||
userListsView.setAdapter(shoppingListsSwipeableAdapter);
|
||||
shoppingListsAdapter = new ShoppingListsAdapter(getActivity(), userLists);
|
||||
userListsView.setAdapter(shoppingListsAdapter);
|
||||
|
||||
// TODO: fix highlighting error
|
||||
userListsView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
|
||||
@ -0,0 +1,55 @@
|
||||
package com.example.listify.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
import com.example.listify.R;
|
||||
import com.example.listify.data.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ShoppingListsAdapter extends BaseAdapter {
|
||||
private Activity activity;
|
||||
private ArrayList<List> lists;
|
||||
private LayoutInflater inflater;
|
||||
|
||||
public ShoppingListsAdapter(Activity activity, ArrayList<List> lists){
|
||||
this.activity = activity;
|
||||
this.lists = lists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return lists.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return lists.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
if (inflater == null) {
|
||||
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
}
|
||||
if (convertView == null) {
|
||||
convertView = inflater.inflate(R.layout.shopping_lists_name_item, null);
|
||||
}
|
||||
|
||||
List curList = lists.get(position);
|
||||
|
||||
TextView tvListName = (TextView) convertView.findViewById(R.id.shopping_list_name);
|
||||
tvListName.setText(curList.getName());
|
||||
|
||||
return convertView;
|
||||
}
|
||||
}
|
||||
@ -53,7 +53,7 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
||||
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
}
|
||||
if (convertView == null) {
|
||||
convertView = inflater.inflate(R.layout.display_shopping_lists_item, null);
|
||||
convertView = inflater.inflate(R.layout.shopping_lists_swipeable_name_item, null);
|
||||
|
||||
holder = new ViewHolder();
|
||||
holder.swipeLayout = (SwipeRevealLayout)convertView.findViewById(R.id.swipe_layout);
|
||||
|
||||
20
Listify/app/src/main/res/layout/shopping_lists_name_item.xml
Normal file
20
Listify/app/src/main/res/layout/shopping_lists_name_item.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?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"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<TextView
|
||||
android:id="@+id/shopping_list_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</RelativeLayout>
|
||||
Loading…
Reference in New Issue
Block a user