diff --git a/Listify/app/src/main/java/com/example/listify/adapter/ShoppingListsAdapter.java b/Listify/app/src/main/java/com/example/listify/adapter/ShoppingListsAdapter.java index 75c13b3..6b1a0f0 100644 --- a/Listify/app/src/main/java/com/example/listify/adapter/ShoppingListsAdapter.java +++ b/Listify/app/src/main/java/com/example/listify/adapter/ShoppingListsAdapter.java @@ -22,13 +22,11 @@ import java.util.Properties; import static com.example.listify.MainActivity.am; -public class ShoppingListsAdapter extends BaseAdapter implements Requestor.Receiver { +public class ShoppingListsAdapter extends BaseAdapter { private Activity activity; private ArrayList lists; private LayoutInflater inflater; private TextView tvListName; - private List curList; - private Requestor requestor; public ShoppingListsAdapter(Activity activity, ArrayList lists){ this.activity = activity; @@ -59,54 +57,22 @@ public class ShoppingListsAdapter extends BaseAdapter implements Requestor.Recei convertView = inflater.inflate(R.layout.shopping_lists_name_item, null); } - curList = lists.get(position); + final List curList = lists.get(position); tvListName = (TextView) convertView.findViewById(R.id.shopping_list_name); tvListName.setText(curList.getName()); if(curList.isShared()) { - Properties configs = new Properties(); - try { - configs = AuthManager.loadProperties(activity, "android.resource://" + activity.getPackageName() + "/raw/auths.json"); - } catch (IOException | JSONException e) { - e.printStackTrace(); + tvListName.setText(curList.getName() + " (shared by User " + curList.getOwner() + ")"); + + String listText = tvListName.getText().toString(); + + if(listText.length() > 25) { + tvListName.setText(listText.substring(0, 25) + "..."); } - requestor = new Requestor(am, configs.getProperty("apiKey")); - requestor.getObject(Integer.toString(curList.getListID()), ListShare.class, this); - } - - String listText = tvListName.getText().toString(); - - if(listText.length() > 25) { - tvListName.setText(listText.substring(0, 25) + "..."); } return convertView; } - - @Override - public void acceptDelivery(Object delivered) { - ListShare sharee = (ListShare) delivered; - - if(sharee != null) { - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - if(sharee.getShareWithEmail().equals(am.getEmail(requestor))) { - tvListName.setText(curList.getName() + " (sh. by me)"); - } - else { - tvListName.setText(curList.getName() + " (sh. by " + sharee.getShareWithEmail() + ")"); - } - - String listText = tvListName.getText().toString(); - - if(listText.length() > 25) { - tvListName.setText(listText.substring(0, 25) + "..."); - } - } - }); - } - } } \ No newline at end of file diff --git a/Listify/app/src/main/java/com/example/listify/adapter/ShoppingListsSwipeableAdapter.java b/Listify/app/src/main/java/com/example/listify/adapter/ShoppingListsSwipeableAdapter.java index 0d4020e..28c4f43 100644 --- a/Listify/app/src/main/java/com/example/listify/adapter/ShoppingListsSwipeableAdapter.java +++ b/Listify/app/src/main/java/com/example/listify/adapter/ShoppingListsSwipeableAdapter.java @@ -22,11 +22,10 @@ import java.util.Properties; import static com.example.listify.MainActivity.am; -public class ShoppingListsSwipeableAdapter extends BaseAdapter implements Requestor.Receiver { +public class ShoppingListsSwipeableAdapter extends BaseAdapter { private Activity activity; private ArrayList lists; private LayoutInflater inflater; - private List curList; private ViewHolder holder; private Requestor requestor; private final ViewBinderHelper binderHelper; @@ -52,31 +51,6 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter implements Reques return position; } - @Override - public void acceptDelivery(Object delivered) { - ListShare sharee = (ListShare) delivered; - - if(sharee != null) { - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - if(sharee.getShareWithEmail().equals(am.getEmail(requestor))) { - holder.listName.setText(curList.getName() + " (sh. by me)"); - } - else { - holder.listName.setText(curList.getName() + " (sh. by " + sharee.getShareWithEmail() + ")"); - } - - String listText = holder.listName.getText().toString(); - - if(listText.length() > 25) { - holder.listName.setText(listText.substring(0, 25) + "..."); - } - } - }); - } - } - @Override public View getView(int position, View convertView, ViewGroup parent) { Properties configs = new Properties(); @@ -106,7 +80,7 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter implements Reques holder = (ViewHolder) convertView.getTag(); } - curList = lists.get(position); + final List curList = lists.get(position); // Bind the view to the unique list ID binderHelper.bind(holder.swipeLayout, Integer.toString(curList.getListID())); @@ -114,15 +88,17 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter implements Reques holder.listName.setText(curList.getName()); if(curList.isShared()) { - requestor.getObject(Integer.toString(curList.getListID()), ListShare.class, this); + holder.listName.setText(curList.getName() + " (shared by User " + curList.getOwner() + ")"); + + String listText = holder.listName.getText().toString(); + + if(listText.length() > 25) { + holder.listName.setText(listText.substring(0, 25) + "..."); + } } String listText = holder.listName.getText().toString(); - if(listText.length() > 25) { - holder.listName.setText(listText.substring(0, 25) + "..."); - } - if (curList.getEntries() != null) { holder.itemCount.setText(String.format("%d items", curList.getEntries().length)); } else {