mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-13 09:48:47 +00:00
Restored list page code back to version ba8f249
This commit is contained in:
parent
5312bd3b8e
commit
433ad774f3
@ -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<List> lists;
|
||||
private LayoutInflater inflater;
|
||||
private TextView tvListName;
|
||||
private List curList;
|
||||
private Requestor requestor;
|
||||
|
||||
public ShoppingListsAdapter(Activity activity, ArrayList<List> 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() + " (shared)");
|
||||
}
|
||||
else {
|
||||
tvListName.setText(curList.getName() + " (" + sharee.getShareWithEmail() + ")");
|
||||
}
|
||||
|
||||
String listText = tvListName.getText().toString();
|
||||
|
||||
if(listText.length() > 25) {
|
||||
tvListName.setText(listText.substring(0, 25) + "...");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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<List> 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() + " (shared)");
|
||||
}
|
||||
else {
|
||||
holder.listName.setText(curList.getName() + " (" + 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 {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user