List renaming

Added list reanming through a ListPUT lambda. Potentially could be used to alter other List aspects in the future.

Also renamed itemID to listID for semantic unity
This commit is contained in:
NMerz
2020-11-15 17:55:25 -05:00
parent 06d834eb01
commit 616caa1e10
8 changed files with 80 additions and 30 deletions

View File

@@ -1,11 +1,7 @@
package com.example.listify;
import android.app.Dialog;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import com.amplifyframework.auth.AuthException;
import com.bumptech.glide.Glide;
import com.example.listify.data.List;
import com.example.listify.data.ListEntry;
@@ -14,8 +10,6 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -215,7 +209,7 @@ public class ItemDetails extends AppCompatActivity implements ListPickerDialogFr
try {
ListEntry entry = new ListEntry(shoppingLists.get(selectedListIndex).getItemID(), curProduct.getItemId(), quantity, Instant.now().toEpochMilli(),false);
ListEntry entry = new ListEntry(shoppingLists.get(selectedListIndex).getListID(), curProduct.getItemId(), quantity, Instant.now().toEpochMilli(),false);
requestor.postObject(entry);
Toast.makeText(this, String.format("%d of Item added to %s", quantity, shoppingLists.get(selectedListIndex).getName()), Toast.LENGTH_LONG).show();
} catch (Exception e) {

View File

@@ -107,6 +107,7 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
SynchronousReceiver<SearchHistory> historyReceiver = new SynchronousReceiver<>();
requestor.getObject("N/A", SearchHistory.class, historyReceiver, historyReceiver);
try {
requestor.putObject(new List(293, "Java.py", "me!", 1));
System.out.println(historyReceiver.await());
} catch (Exception e) {
e.printStackTrace();

View File

@@ -90,7 +90,7 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
final List curList = lists.get(position);
// Bind the view to the unique list ID
binderHelper.bind(holder.swipeLayout, Integer.toString(curList.getItemID()));
binderHelper.bind(holder.swipeLayout, Integer.toString(curList.getListID()));
if(curList.isShared()) {
holder.textView.setText(curList.getName() + " (shared)");
@@ -102,7 +102,7 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
@Override
public void onClick(View v) {
try {
requestor.deleteObject(Integer.toString(curList.getItemID()), List.class);
requestor.deleteObject(Integer.toString(curList.getListID()), List.class);
}
catch(Exception e) {
e.printStackTrace();
@@ -129,7 +129,7 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
public void onClick(DialogInterface dialog, int which) {
EditText sharedEmailText = (EditText) codeView.findViewById(R.id.editTextTextSharedEmail);
String sharedEmail = sharedEmailText.getText().toString();
ListShare listShare = new ListShare(curList.getItemID(), sharedEmail, "Read, Write, Delete, Share");
ListShare listShare = new ListShare(curList.getListID(), sharedEmail, "Read, Write, Delete, Share");
try {
requestor.putObject(listShare);
}
@@ -148,7 +148,7 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
Toast.makeText(activity, String.format("Share %s", curList.getName()), Toast.LENGTH_SHORT).show();
// Close the layout
binderHelper.closeLayout(Integer.toString(curList.getItemID()));
binderHelper.closeLayout(Integer.toString(curList.getListID()));
}
});
@@ -158,7 +158,7 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
Intent listPage = new Intent(activity, ListPage.class);
// Send the list ID
listPage.putExtra("listID", curList.getItemID());
listPage.putExtra("listID", curList.getListID());
activity.startActivity(listPage);
}
});

View File

@@ -3,15 +3,15 @@ package com.example.listify.data;
import java.util.Arrays;
public class List {
Integer itemID;
Integer listID;
String name;
String owner;
long lastUpdated;
final ListEntry[] entries;
boolean shared;
public List(Integer itemID, String name, String owner, long lastUpdated, ListEntry[] entries, boolean shared) {
this.itemID = itemID;
public List(Integer listID, String name, String owner, long lastUpdated, ListEntry[] entries, boolean shared) {
this.listID = listID;
this.name = name;
this.owner = owner;
this.lastUpdated = lastUpdated;
@@ -19,14 +19,14 @@ public class List {
this.shared = false;
}
public List(Integer itemID, String name, String owner, long lastUpdated) {
this(itemID, name, owner, lastUpdated, null, false);
public List(Integer listID, String name, String owner, long lastUpdated) {
this(listID, name, owner, lastUpdated, null, false);
}
@Override
public String toString() {
return "List{" +
"itemID=" + itemID +
"listID=" + listID +
", name='" + name + '\'' +
", owner='" + owner + '\'' +
", lastUpdated=" + lastUpdated +
@@ -35,12 +35,12 @@ public class List {
'}';
}
public Integer getItemID() {
return itemID;
public Integer getListID() {
return listID;
}
public void setItemID(Integer itemID) {
this.itemID = itemID;
public void setListID(Integer listID) {
this.listID = listID;
}
public String getName() {

View File

@@ -101,7 +101,7 @@ public class HomeFragment extends Fragment implements CreateListDialogFragment.O
@Override
public void run() {
try {
newList.setItemID(idReceiver.await());
newList.setListID(idReceiver.await());
} catch (Exception e) {
getActivity().runOnUiThread(new Runnable() {
@Override