mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-15 18:28:47 +00:00
Merge pull request #167 from ClaytonWWilson/aaron-branch-2
Aaron branch 2
This commit is contained in:
commit
eedb1a6895
@ -22,13 +22,11 @@ import java.util.Properties;
|
|||||||
|
|
||||||
import static com.example.listify.MainActivity.am;
|
import static com.example.listify.MainActivity.am;
|
||||||
|
|
||||||
public class ShoppingListsAdapter extends BaseAdapter implements Requestor.Receiver {
|
public class ShoppingListsAdapter extends BaseAdapter {
|
||||||
private Activity activity;
|
private Activity activity;
|
||||||
private ArrayList<List> lists;
|
private ArrayList<List> lists;
|
||||||
private LayoutInflater inflater;
|
private LayoutInflater inflater;
|
||||||
private TextView tvListName;
|
private TextView tvListName;
|
||||||
private List curList;
|
|
||||||
private Requestor requestor;
|
|
||||||
|
|
||||||
public ShoppingListsAdapter(Activity activity, ArrayList<List> lists){
|
public ShoppingListsAdapter(Activity activity, ArrayList<List> lists){
|
||||||
this.activity = activity;
|
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);
|
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 = (TextView) convertView.findViewById(R.id.shopping_list_name);
|
||||||
|
|
||||||
tvListName.setText(curList.getName());
|
tvListName.setText(curList.getName());
|
||||||
|
|
||||||
if(curList.isShared()) {
|
if(curList.isShared()) {
|
||||||
Properties configs = new Properties();
|
tvListName.setText(curList.getName() + " (shared by User " + curList.getOwner() + ")");
|
||||||
try {
|
|
||||||
configs = AuthManager.loadProperties(activity, "android.resource://" + activity.getPackageName() + "/raw/auths.json");
|
String listText = tvListName.getText().toString();
|
||||||
} catch (IOException | JSONException e) {
|
|
||||||
e.printStackTrace();
|
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;
|
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) + "...");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -22,11 +22,10 @@ import java.util.Properties;
|
|||||||
|
|
||||||
import static com.example.listify.MainActivity.am;
|
import static com.example.listify.MainActivity.am;
|
||||||
|
|
||||||
public class ShoppingListsSwipeableAdapter extends BaseAdapter implements Requestor.Receiver {
|
public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
||||||
private Activity activity;
|
private Activity activity;
|
||||||
private ArrayList<List> lists;
|
private ArrayList<List> lists;
|
||||||
private LayoutInflater inflater;
|
private LayoutInflater inflater;
|
||||||
private List curList;
|
|
||||||
private ViewHolder holder;
|
private ViewHolder holder;
|
||||||
private Requestor requestor;
|
private Requestor requestor;
|
||||||
private final ViewBinderHelper binderHelper;
|
private final ViewBinderHelper binderHelper;
|
||||||
@ -52,31 +51,6 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter implements Reques
|
|||||||
return position;
|
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
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
Properties configs = new Properties();
|
Properties configs = new Properties();
|
||||||
@ -106,7 +80,7 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter implements Reques
|
|||||||
holder = (ViewHolder) convertView.getTag();
|
holder = (ViewHolder) convertView.getTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
curList = lists.get(position);
|
final List curList = lists.get(position);
|
||||||
|
|
||||||
// Bind the view to the unique list ID
|
// Bind the view to the unique list ID
|
||||||
binderHelper.bind(holder.swipeLayout, Integer.toString(curList.getListID()));
|
binderHelper.bind(holder.swipeLayout, Integer.toString(curList.getListID()));
|
||||||
@ -114,15 +88,17 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter implements Reques
|
|||||||
holder.listName.setText(curList.getName());
|
holder.listName.setText(curList.getName());
|
||||||
|
|
||||||
if(curList.isShared()) {
|
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();
|
String listText = holder.listName.getText().toString();
|
||||||
|
|
||||||
if(listText.length() > 25) {
|
|
||||||
holder.listName.setText(listText.substring(0, 25) + "...");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (curList.getEntries() != null) {
|
if (curList.getEntries() != null) {
|
||||||
holder.itemCount.setText(String.format("%d items", curList.getEntries().length));
|
holder.itemCount.setText(String.format("%d items", curList.getEntries().length));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user