Merge pull request #174 from ClaytonWWilson/master

Merge from master
This commit is contained in:
Aaron Sun 2020-12-04 10:01:53 -08:00 committed by GitHub
commit a25c435985
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 155 additions and 84 deletions

View File

@ -0,0 +1,16 @@
# Chain Module
Deals with information concerning store chains supported by the product populating and product serving Lambdas.
### ChainGET
#### Expected request body:
N/A
#### Expected query parameters:
- id
- Used for specifying which chain to retrieve
- Valid values: -1,1<n<{num_chains}
#### Inputs and outputs:
- id = -1: Returns an array if chainIDs (Integers)
- id = 1<n<{num_chains}: Returns a [Chain object](https://github.com/ClaytonWWilson/Listify/blob/master/Lambdas/Lists/Chain/src/Chain.java) for the chain with chainID=id

View File

@ -18,7 +18,7 @@ public class ChainGetter implements CallHandler {
@Override @Override
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryMap, String cognitoID) throws SQLException { public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryMap, String cognitoID) throws SQLException {
Integer id = Integer.parseInt(queryMap.get("id")); Integer id = (Integer) bodyMap.get("id");
if (id == -1) { if (id == -1) {
PreparedStatement getChains = connection.prepareStatement(GET_CHAINS); PreparedStatement getChains = connection.prepareStatement(GET_CHAINS);
System.out.println(getChains); System.out.println(getChains);

View File

@ -1,4 +1,4 @@
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import java.sql.SQLException; import java.sql.SQLException;
@ -9,12 +9,12 @@ public class TestChainGetter {
@Test @Test
public void testChainGetterValid() { public void testChainGetterValid() {
testChainGetter(false); testChainGetter(true);
} }
@Test @Test
public void testChainGetterError() { public void testChainGetterError() {
testChainGetter(true); testChainGetter(false);
} }
public void testChainGetter(boolean shouldThrow) { public void testChainGetter(boolean shouldThrow) {
@ -29,7 +29,7 @@ public class TestChainGetter {
ChainGetter chainGetter = Mockito.spy(new ChainGetter(injector, "cognitoID")); ChainGetter chainGetter = Mockito.spy(new ChainGetter(injector, "cognitoID"));
Map<String, Object> ignore = new HashMap<>(); Map<String, Object> ignore = new HashMap<>();
Map<String, Object> body = TestInputUtils.addBody(ignore); Map<String, Object> body = TestInputUtils.addBody(ignore);
ignore.put("id", 1); //in ChainGetter.java uses ignore map for id parameter body.put("id", 1);
try { try {
Object rawIDReturn = chainGetter.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID"); Object rawIDReturn = chainGetter.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
@ -38,6 +38,12 @@ public class TestChainGetter {
} catch (SQLException throwables) { } catch (SQLException throwables) {
assert shouldThrow; assert shouldThrow;
throwables.printStackTrace(); throwables.printStackTrace();
} catch (NumberFormatException throwables) {
assert shouldThrow;
throwables.printStackTrace();
} catch (ClassCastException throwables) {
assert shouldThrow;
throwables.printStackTrace();
} }
} }
} }

View File

@ -1,4 +1,4 @@
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import java.math.BigDecimal; import java.math.BigDecimal;

View File

@ -1,4 +1,4 @@
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import java.sql.SQLException; import java.sql.SQLException;

View File

@ -0,0 +1,16 @@
# Chain Module
Deals with information concerning store chains supported by the product populating and product serving Lambdas.
### ChainGET
#### Expected request body:
N/A
#### Expected query parameters:
- id
- Used for specifying which chain to retrieve
- Valid values: -1,1<n<{num_chains}
#### Inputs and outputs:
- id = -1: Returns an array if chainIDs (Integers)
- id = 1<n<{num_chains}: Returns a [Chain object](https://github.com/ClaytonWWilson/Listify/blob/master/Lambdas/Lists/Chain/src/Chain.java) for the chain with chainID=id

View File

@ -12,14 +12,10 @@ import java.util.Map;
public class TestListAdder { public class TestListAdder {
@Test @Test
public void testListAdderValid() throws SQLException { public void testListAdderValid() throws SQLException { testListAdderCoreMock(true); }
testListAdderCoreMock(false);
}
@Test @Test
public void testListAdderError() throws SQLException { public void testListAdderError() throws SQLException { testListAdderCoreMock(false); }
testListAdderCoreMock(true);
}
public void testListAdderCoreMock(boolean shouldThrow) throws SQLException { public void testListAdderCoreMock(boolean shouldThrow) throws SQLException {
StatementInjector injector; StatementInjector injector;
@ -52,6 +48,6 @@ public class TestListAdder {
return; return;
} }
when(injector.getStatementString().contains("INSERT INTO List (name, owner, lastUpdated) VALUES (?, ?, ?);INSERT INTO ListSharee(listID, userID) VALUES(?, ?);[1, cognitoID]")).thenReturn(true); when(injector.getStatementString().contains("INSERT INTO List (name, owner, lastUpdated) VALUES (?, ?, ?);INSERT INTO ListSharee(listID, userID) VALUES(?, ?);[1, cognitoID]")).thenReturn(true);
assert (injector.getStatementString().contains("INSERT INTO List (name, owner, lastUpdated) VALUES (?, ?, ?);INSERT INTO ListSharee(listID, userID) VALUES(?, ?);[1, cognitoID]")); assert !(injector.getStatementString().contains("INSERT INTO List (name, owner, lastUpdated) VALUES (?, ?, ?);INSERT INTO ListSharee(listID, userID) VALUES(?, ?);[1, cognitoID]"));
} }
} }

View File

@ -11,20 +11,18 @@ import java.util.Map;
public class TestListGetter { public class TestListGetter {
@Test @Test
public void testListGetterValid() { conductListGetterTestMock(false); } public void testListGetterValid() { conductListGetterTestMock(true); }
@Test @Test
public void testListIDGetterValid() { public void testListIDGetterValid() {
conductListIDGetterTestMock(false); conductListIDGetterTestMock(true);
} }
@Test @Test
public void testListIDGetterError() { public void testListIDGetterError() { conductListIDGetterTestMock(false); }
conductListIDGetterTestMock(false);
}
@Test @Test
public void testListGetterError() { conductListGetterTestMock(true); } public void testListGetterError() { conductListGetterTestMock(false); }
public void conductListGetterTestMock(boolean shouldThrow) { public void conductListGetterTestMock(boolean shouldThrow) {
Integer listID = 1; Integer listID = 1;
@ -63,8 +61,11 @@ public class TestListGetter {
List listReturn = (List) conductReturn; List listReturn = (List) conductReturn;
assert (listReturn.toString().equals("List{itemID=1, name='aname', owner='anowner', lastUpdated=1602192528688, entries=[ItemEntry{listID=1, productID=2, quantity=3, addedDate=1602192528689, purchased=false}]}")); assert (listReturn.toString().equals("List{itemID=1, name='aname', owner='anowner', lastUpdated=1602192528688, entries=[ItemEntry{listID=1, productID=2, quantity=3, addedDate=1602192528689, purchased=false}]}"));
} catch (SQLException throwables) { } catch (SQLException throwables) {
throwables.printStackTrace();
assert shouldThrow; assert shouldThrow;
throwables.printStackTrace();
} catch (ClassCastException throwables) {
assert !shouldThrow;
throwables.printStackTrace();
} }
} }
@ -81,11 +82,10 @@ public class TestListGetter {
} catch (SQLException throwables) { } catch (SQLException throwables) {
throwables.printStackTrace(); throwables.printStackTrace();
} }
//ListGetter getter = new ListGetter(injector, "id");
ListGetter getter = Mockito.spy(new ListGetter(injector, "id")); ListGetter getter = Mockito.spy(new ListGetter(injector, "id"));
Map<String, Object> ignore = new HashMap<>(); Map<String, Object> ignore = new HashMap<>();
HashMap<String, String> queryParams = TestInputUtils.addQueryParams(ignore); HashMap<String, String> queryParams = TestInputUtils.addQueryParams(ignore);
queryParams.put("id", "-1"); queryParams.put("id", "1");
try { try {
Object conductReturn = getter.conductAction(TestInputUtils.addBody(ignore), queryParams, "cognitoID"); Object conductReturn = getter.conductAction(TestInputUtils.addBody(ignore), queryParams, "cognitoID");
assert !shouldThrow; assert !shouldThrow;
@ -96,6 +96,9 @@ public class TestListGetter {
} catch (SQLException throwables) { } catch (SQLException throwables) {
throwables.printStackTrace(); throwables.printStackTrace();
assert shouldThrow; assert shouldThrow;
} catch (ClassCastException throwables) {
throwables.printStackTrace();
assert !shouldThrow;
} }
} }
} }

View File

@ -1,6 +1,7 @@
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import java.security.AccessControlException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -9,12 +10,12 @@ public class TestListDuplicate {
@Test @Test
public void testListDuplicateValid() { public void testListDuplicateValid() {
testListDuplicaterMock(false); testListDuplicaterMock(true);
} }
@Test @Test
public void testListDuplicateError() { public void testListDuplicateError() {
testListDuplicaterMock(true); testListDuplicaterMock(false);
} }
public void testListDuplicaterMock(boolean shouldThrow) { public void testListDuplicaterMock(boolean shouldThrow) {
@ -38,6 +39,9 @@ public class TestListDuplicate {
} catch (SQLException throwables) { } catch (SQLException throwables) {
assert shouldThrow; assert shouldThrow;
throwables.printStackTrace(); throwables.printStackTrace();
} catch(AccessControlException throwables) {
assert !shouldThrow;
throwables.printStackTrace();
} }
} }
} }

View File

@ -1,6 +1,7 @@
import org.junit.Test; import org.junit.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import java.security.AccessControlException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -9,12 +10,12 @@ public class TestListEntryAdder {
@Test @Test
public void testListEntryAdderValid() { public void testListEntryAdderValid() {
testListEntryAdderCoreMock(false); testListEntryAdderCoreMock(true);
} }
@Test @Test
public void testListEntryAdderError() { public void testListEntryAdderError() {
testListEntryAdderCoreMock(true); testListEntryAdderCoreMock(false);
} }
public void testListEntryAdderCoreMock(boolean shouldThrow) { public void testListEntryAdderCoreMock(boolean shouldThrow) {
@ -43,6 +44,9 @@ public class TestListEntryAdder {
} catch (SQLException throwables) { } catch (SQLException throwables) {
assert shouldThrow; assert shouldThrow;
throwables.printStackTrace(); throwables.printStackTrace();
} catch (AccessControlException throwables) {
assert !shouldThrow;
throwables.printStackTrace();
} }
} }
} }

View File

@ -2,6 +2,7 @@ import org.junit.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.mockito.Mockito.*; import org.mockito.Mockito.*;
import java.security.AccessControlException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -9,11 +10,11 @@ import java.util.Map;
public class TestListEntryDeleter { public class TestListEntryDeleter {
@Test @Test
public void testListEntryDeleterValid() { testListEntryDeleterCoreMock(false); } public void testListEntryDeleterValid() { testListEntryDeleterCoreMock(true); }
@Test @Test
public void testListEntryDeleterError() { public void testListEntryDeleterError() {
testListEntryDeleterCoreMock(true); testListEntryDeleterCoreMock(false);
} }
public void testListEntryDeleterCoreMock(boolean shouldThrow) { public void testListEntryDeleterCoreMock(boolean shouldThrow) {
@ -39,6 +40,9 @@ public class TestListEntryDeleter {
} catch (SQLException throwables) { } catch (SQLException throwables) {
assert shouldThrow; assert shouldThrow;
throwables.printStackTrace(); throwables.printStackTrace();
} catch (AccessControlException throwables) {
assert !shouldThrow;
throwables.printStackTrace();
} }
} }
} }

View File

@ -1,4 +1,4 @@
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import java.sql.SQLException; import java.sql.SQLException;
@ -38,6 +38,9 @@ public class TestListReposition {
} catch (SQLException throwables) { } catch (SQLException throwables) {
assert shouldThrow; assert shouldThrow;
throwables.printStackTrace(); throwables.printStackTrace();
} catch (IllegalArgumentException throwables) {
assert !shouldThrow;
throwables.printStackTrace();
} }
} }
} }

View File

@ -18,9 +18,9 @@ public class PicturePutter implements CallHandler {
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryString, String cognitoID) throws SQLException { public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryString, String cognitoID) throws SQLException {
PreparedStatement storePicture = connection.prepareStatement(STORE_PICTURE_SQL); PreparedStatement storePicture = connection.prepareStatement(STORE_PICTURE_SQL);
if(!bodyMap.containsKey("base64EncodedImage")) { // if(!bodyMap.containsKey("base64EncodedImage")) {
throw new IllegalArgumentException("Base64EncodedImage not found"); // throw new IllegalArgumentException("Base64EncodedImage not found");
} // }
storePicture.setString(1, cognitoID); storePicture.setString(1, cognitoID);
storePicture.setString(2, bodyMap.get("base64EncodedImage").toString()); storePicture.setString(2, bodyMap.get("base64EncodedImage").toString());
System.out.println(storePicture); System.out.println(storePicture);

View File

@ -1,4 +1,4 @@
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import java.sql.SQLException; import java.sql.SQLException;
@ -9,7 +9,7 @@ public class TestPictureGetter {
@Test @Test
public void testPictureGetterValid() { public void testPictureGetterValid() {
testPictureGetter(false); testPictureGetter(true);
} }
@Test @Test
@ -35,7 +35,7 @@ public class TestPictureGetter {
try { try {
Object rawIDReturn = pictureGetter.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID"); Object rawIDReturn = pictureGetter.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
assert (rawIDReturn != null); assert (rawIDReturn != null);
} catch (SQLException throwables) { } catch (SQLException | IllegalArgumentException throwables) {
assert shouldThrow; assert shouldThrow;
throwables.printStackTrace(); throwables.printStackTrace();
} }

View File

@ -1,4 +1,4 @@
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import java.sql.SQLException; import java.sql.SQLException;
@ -9,12 +9,12 @@ public class TestPicturePutter {
@Test @Test
public void testPicturePutterValid() { public void testPicturePutterValid() {
testPicturePutter(false); testPicturePutter(true);
} }
@Test @Test
public void testPicturePutterError() { public void testPicturePutterError() {
testPicturePutter(true); testPicturePutter(false);
} }
public void testPicturePutter(boolean shouldThrow) { public void testPicturePutter(boolean shouldThrow) {
@ -29,12 +29,20 @@ public class TestPicturePutter {
PicturePutter picturePutter = Mockito.spy(new PicturePutter(injector, "cognitoID")); PicturePutter picturePutter = Mockito.spy(new PicturePutter(injector, "cognitoID"));
Map<String, Object> ignore = new HashMap<>(); Map<String, Object> ignore = new HashMap<>();
Map<String, Object> body = TestInputUtils.addBody(ignore); Map<String, Object> body = TestInputUtils.addBody(ignore);
body.put("base64EncodedImage", "testingimage");
try { try {
Object rawIDReturn = picturePutter.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID"); Object rawIDReturn = picturePutter.conductAction(body, TestInputUtils.addQueryParams(ignore), "cognitoID");
assert (rawIDReturn == null); assert (rawIDReturn == null);
} catch (SQLException throwables) { } catch (SQLException throwables) {
assert shouldThrow; assert shouldThrow;
throwables.printStackTrace(); throwables.printStackTrace();
} catch (IllegalArgumentException throwables) {
assert shouldThrow;
throwables.printStackTrace();
} catch(NullPointerException throwables) {
assert shouldThrow;
throwables.printStackTrace();
} }
} }
} }

View File

@ -1,4 +1,4 @@
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import java.sql.SQLException; import java.sql.SQLException;

View File

@ -1,4 +1,4 @@
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import java.sql.SQLException; import java.sql.SQLException;

View File

@ -40,7 +40,7 @@ public class UserDeleter implements CallHandler {
private final String DELETE_LISTS = "DELETE FROM List WHERE (owner = ?);"; private final String DELETE_LISTS = "DELETE FROM List WHERE (owner = ?);";
private final String DELETE_LIST_SHARES = "DELETE FROM ListSharee WHERE (listID = ?);"; private final String DELETE_LIST_SHARES = "DELETE FROM ListSharee WHERE (listID = ?);";
private final String DELETE_LIST_ACCESS = "DELETE FROM ListSharee WHERE (userID = ?);"; private final String DELETE_LIST_ACCESS = "DELETE FROM ListSharee WHERE (userID = ?);";
private final String DELETE_PROFILE_PICTURE = "DELETE FROM Pictures WHERE (userID = ?);"; private final String DELETE_PROFILE_PICTURE = "DELETE FROM Pictures WHERE (cognitoID = ?);";
public UserDeleter(Connection connection, String cognitoID) { public UserDeleter(Connection connection, String cognitoID) {
this.connection = connection; this.connection = connection;

View File

@ -43,6 +43,10 @@ public class ConfirmShareView extends AppCompatActivity {
try { try {
requestor.getObject(shareeEmail, User.class, userReceiver); requestor.getObject(shareeEmail, User.class, userReceiver);
String shareeID = userReceiver.await().getCognitoID(); String shareeID = userReceiver.await().getCognitoID();
if (shareeID == null) {
setResult(RESULT_CANCELED,null);
finish();
}
requestor.getObject(shareeID, Picture.class, profilePictureReceiver); requestor.getObject(shareeID, Picture.class, profilePictureReceiver);
profilePictureView.setImageURI(Uri.fromFile(saveImage(profilePictureReceiver.await().getBase64EncodedImage(), "shareeProfilePicture"))); profilePictureView.setImageURI(Uri.fromFile(saveImage(profilePictureReceiver.await().getBase64EncodedImage(), "shareeProfilePicture")));
} catch (Exception e) { } catch (Exception e) {

View File

@ -1,13 +1,9 @@
package com.example.listify; package com.example.listify;
import android.Manifest;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor; import android.database.Cursor;
import android.location.Location;
import android.location.LocationManager;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
@ -24,7 +20,6 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.FileProvider; import androidx.core.content.FileProvider;
import androidx.drawerlayout.widget.DrawerLayout; import androidx.drawerlayout.widget.DrawerLayout;
import androidx.navigation.NavController; import androidx.navigation.NavController;
@ -84,31 +79,31 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
startActivity(intent); startActivity(intent);
} }
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if(checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { // if(checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
Log.d("CHECKING", "WORKS"); // Log.d("CHECKING", "WORKS");
} else { // } else {
ActivityCompat.requestPermissions( // ActivityCompat.requestPermissions(
this, // this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, // new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
0 // 0
); // );
} // }
Location location; // Location location;
//
while(true) { // while(true) {
try { // try {
location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); // location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
break; // break;
} catch(java.lang.SecurityException e) { // } catch(java.lang.SecurityException e) {
//User clicked delete // //User clicked delete
} // }
} // }
//
if(location != null) { // if(location != null) {
double longitude = location.getLongitude(); // double longitude = location.getLongitude();
double latitude = location.getLatitude(); // double latitude = location.getLatitude();
} // }
//------------------------------Auth Testing---------------------------------------------// //------------------------------Auth Testing---------------------------------------------//

View File

@ -13,7 +13,7 @@ import com.chauthai.swipereveallayout.SwipeRevealLayout;
import com.chauthai.swipereveallayout.ViewBinderHelper; import com.chauthai.swipereveallayout.ViewBinderHelper;
import com.example.listify.*; import com.example.listify.*;
import com.example.listify.data.List; import com.example.listify.data.List;
import com.example.listify.data.ListShare; import com.example.listify.data.User;
import org.json.JSONException; import org.json.JSONException;
import java.io.IOException; import java.io.IOException;
@ -25,6 +25,7 @@ import static com.example.listify.MainActivity.am;
public class ShoppingListsSwipeableAdapter extends BaseAdapter { public class ShoppingListsSwipeableAdapter extends BaseAdapter {
private Activity activity; private Activity activity;
private ArrayList<List> lists; private ArrayList<List> lists;
private ArrayList<String> emails;
private LayoutInflater inflater; private LayoutInflater inflater;
private ViewHolder holder; private ViewHolder holder;
private Requestor requestor; private Requestor requestor;
@ -34,6 +35,23 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
binderHelper = new ViewBinderHelper(); binderHelper = new ViewBinderHelper();
this.activity = activity; this.activity = activity;
this.lists = lists; this.lists = lists;
this.emails = new ArrayList<>();
Properties configs = new Properties();
try {
configs = AuthManager.loadProperties(activity, "android.resource://" + activity.getPackageName() + "/raw/auths.json");
} catch (IOException | JSONException e) {
e.printStackTrace();
}
requestor = new Requestor(am, configs.getProperty("apiKey"));
SynchronousReceiver<User> emailReceiver = new SynchronousReceiver();
for (List list : lists) {
requestor.getObject(list.getOwner(), User.class, emailReceiver);
try {
emails.add(emailReceiver.await().getEmail());
} catch (Exception e) {
e.printStackTrace();
}
}
} }
@Override @Override
@ -53,13 +71,6 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
@Override @Override
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {
Properties configs = new Properties();
try {
configs = AuthManager.loadProperties(activity, "android.resource://" + activity.getPackageName() + "/raw/auths.json");
} catch (IOException | JSONException e) {
e.printStackTrace();
}
requestor = new Requestor(am, configs.getProperty("apiKey"));
if (inflater == null) { if (inflater == null) {
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@ -88,12 +99,12 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
holder.listName.setText(curList.getName()); holder.listName.setText(curList.getName());
if(curList.isShared()) { if(curList.isShared()) {
holder.listName.setText(curList.getName() + " (shared by User " + curList.getOwner() + ")"); holder.listName.setText(curList.getName() + " (shared by " + emails.get(position) + ")");
String listText = holder.listName.getText().toString(); String listText = holder.listName.getText().toString();
if(listText.length() > 25) { if(listText.length() > 27) {
holder.listName.setText(listText.substring(0, 25) + "..."); holder.listName.setText(listText.substring(0, 27) + "...");
} }
} }
@ -117,6 +128,7 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
Toast.makeText(activity, String.format("%s deleted", curList.getName()), Toast.LENGTH_SHORT).show(); Toast.makeText(activity, String.format("%s deleted", curList.getName()), Toast.LENGTH_SHORT).show();
lists.remove(position); lists.remove(position);
emails.remove(position);
// Update listView // Update listView
notifyDataSetChanged(); notifyDataSetChanged();