From 8653b9a0352f63e87e8f872f6c15d1750519a417 Mon Sep 17 00:00:00 2001 From: NMerz Date: Sat, 14 Nov 2020 11:40:42 -0500 Subject: [PATCH 1/2] Try storing serialized search object Does not seem to be the best solution (https://stackoverflow.com/questions/17662236/java-write-object-to-mysql-each-field-or-serialized-byte-array) and does not entirely work, but saving it for posterity because there are some interesting changes here --- .../Lists/ItemSearch/src/ItemSearcher.java | 14 ++++- .../SearchHistory/src/SearchHistory.java | 39 +++++++++++++ .../SearchHistory/src/SearchHistoryGET.java | 11 ++++ .../src/SearchHistoryGetter.java | 31 ++++++++++ .../SearchHistory/src/SearchHistoryPUT.java | 11 ++++ .../src/SearchHistoryPutter.java | 34 +++++++++++ .../src/SearchHistoryUpdate.java | 56 +++++++++++++++++++ Lambdas/Lists/pom.xml | 5 ++ .../java/com/example/listify/Requestor.java | 21 ++++++- .../example/listify/data/SearchHistory.java | 23 ++++++++ 10 files changed, 243 insertions(+), 2 deletions(-) create mode 100644 Lambdas/Lists/SearchHistory/src/SearchHistory.java create mode 100644 Lambdas/Lists/SearchHistory/src/SearchHistoryGET.java create mode 100644 Lambdas/Lists/SearchHistory/src/SearchHistoryGetter.java create mode 100644 Lambdas/Lists/SearchHistory/src/SearchHistoryPUT.java create mode 100644 Lambdas/Lists/SearchHistory/src/SearchHistoryPutter.java create mode 100644 Lambdas/Lists/SearchHistory/src/SearchHistoryUpdate.java create mode 100644 Listify/app/src/main/java/com/example/listify/data/SearchHistory.java diff --git a/Lambdas/Lists/ItemSearch/src/ItemSearcher.java b/Lambdas/Lists/ItemSearch/src/ItemSearcher.java index a3a7381..eef6cc4 100644 --- a/Lambdas/Lists/ItemSearch/src/ItemSearcher.java +++ b/Lambdas/Lists/ItemSearch/src/ItemSearcher.java @@ -1,3 +1,6 @@ +import com.amazonaws.services.lambda.AWSLambdaClientBuilder; +import com.amazonaws.services.lambda.model.InvokeRequest; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -18,13 +21,22 @@ public class ItemSearcher implements CallHandler { } @Override - public Object conductAction(Map body, HashMap queryParams, String s) throws SQLException { + public Object conductAction(Map body, HashMap queryParams, String cognitoID) throws SQLException { PreparedStatement getItemMatches = connection.prepareStatement(GET_ITEM_MATCHES); getItemMatches.setString(1, "%" + queryParams.get("id") + "%"); System.out.println(getItemMatches); ResultSet searchResults = getItemMatches.executeQuery(); ItemSearch searchResultsObject = new ItemSearch(searchResults); System.out.println(searchResultsObject); + InvokeRequest invokeRequest = new InvokeRequest(); + invokeRequest.setFunctionName("SearchHistoryUpdate"); + invokeRequest.setPayload("{" + + " \"newSearch\": \"" + queryParams.get("id") + "\"," + + " \"cognitoID\": \""+ cognitoID + "\"" + + "}"); + invokeRequest.setInvocationType("Event"); + System.out.println(invokeRequest); + AWSLambdaClientBuilder.defaultClient().invoke(invokeRequest); return searchResultsObject; } } diff --git a/Lambdas/Lists/SearchHistory/src/SearchHistory.java b/Lambdas/Lists/SearchHistory/src/SearchHistory.java new file mode 100644 index 0000000..b29e10d --- /dev/null +++ b/Lambdas/Lists/SearchHistory/src/SearchHistory.java @@ -0,0 +1,39 @@ +import java.io.Serializable; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; + +public class SearchHistory implements Serializable { + ArrayList searches; + + public SearchHistory(ArrayList searches) { + this.searches = searches; + } + + public SearchHistory() { + this.searches = new ArrayList<>(); + } + + public SearchHistory(ResultSet row) throws SQLException { + this.searches = (ArrayList) row.getObject("historyObject"); + } + + public ArrayList getSearches() { + return searches; + } + + public void setSearches(ArrayList searches) { + this.searches = searches; + } + + public void addSearch(String newSearch) { + searches.add(newSearch); + } + + @Override + public String toString() { + return "SearchHistory{" + + "searches=" + searches + + '}'; + } +} diff --git a/Lambdas/Lists/SearchHistory/src/SearchHistoryGET.java b/Lambdas/Lists/SearchHistory/src/SearchHistoryGET.java new file mode 100644 index 0000000..4c696b3 --- /dev/null +++ b/Lambdas/Lists/SearchHistory/src/SearchHistoryGET.java @@ -0,0 +1,11 @@ +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; + +import java.util.Map; + +public class SearchHistoryGET implements RequestHandler, Object> { + + public Object handleRequest(Map inputMap, Context unfilled) { + return BasicHandler.handleRequest(inputMap, unfilled, SearchHistoryGetter.class); + } +} diff --git a/Lambdas/Lists/SearchHistory/src/SearchHistoryGetter.java b/Lambdas/Lists/SearchHistory/src/SearchHistoryGetter.java new file mode 100644 index 0000000..13319cd --- /dev/null +++ b/Lambdas/Lists/SearchHistory/src/SearchHistoryGetter.java @@ -0,0 +1,31 @@ +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; + +public class SearchHistoryGetter implements CallHandler { + + private Connection connection; + private String cognitoID; + + public SearchHistoryGetter(Connection connection, String cognitoID) { + this.connection = connection; + this.cognitoID = cognitoID; + } + + final private String SELECT_HISTORY = "SELECT * from SearchHistory WHERE userID = ?;"; + + public Object conductAction(Map bodyMap, HashMap queryString, String cognitoID) throws SQLException { + PreparedStatement select_history = connection.prepareStatement(SELECT_HISTORY); + select_history.setString(1, cognitoID); + System.out.println(select_history); + ResultSet searchHistory = select_history.executeQuery(); + if (!searchHistory.first()) { + return new SearchHistory(); + } + System.out.println(new SearchHistory(searchHistory)); + return new SearchHistory(searchHistory); + } +} \ No newline at end of file diff --git a/Lambdas/Lists/SearchHistory/src/SearchHistoryPUT.java b/Lambdas/Lists/SearchHistory/src/SearchHistoryPUT.java new file mode 100644 index 0000000..28d5019 --- /dev/null +++ b/Lambdas/Lists/SearchHistory/src/SearchHistoryPUT.java @@ -0,0 +1,11 @@ +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; + +import java.util.Map; + +public class SearchHistoryPUT implements RequestHandler, Object> { + + public Object handleRequest(Map inputMap, Context unfilled) { + return BasicHandler.handleRequest(inputMap, unfilled, SearchHistoryPutter.class); + } +} diff --git a/Lambdas/Lists/SearchHistory/src/SearchHistoryPutter.java b/Lambdas/Lists/SearchHistory/src/SearchHistoryPutter.java new file mode 100644 index 0000000..a18a2ff --- /dev/null +++ b/Lambdas/Lists/SearchHistory/src/SearchHistoryPutter.java @@ -0,0 +1,34 @@ +import com.google.gson.Gson; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; + +public class SearchHistoryPutter implements CallHandler { + + private Connection connection; + private String cognitoID; + + public SearchHistoryPutter(Connection connection, String cognitoID) { + this.connection = connection; + this.cognitoID = cognitoID; + } + + final private String STORE_HISTORY = "REPLACE INTO SearchHistory(userID, historyObject) VALUES(?, ?);"; + + public Object conductAction(Map bodyMap, HashMap queryString, String cognitoID) throws SQLException { + final String searchHistoryJson = new Gson().toJson(bodyMap); + System.out.println(searchHistoryJson); + SearchHistory toStore = new Gson().fromJson(searchHistoryJson, SearchHistory.class); + System.out.println(toStore); + PreparedStatement store_history = connection.prepareStatement(STORE_HISTORY); + store_history.setString(1, cognitoID); + store_history.setObject(2, toStore.searches); + System.out.println(store_history); + store_history.executeUpdate(); + connection.commit(); + return null; + } +} \ No newline at end of file diff --git a/Lambdas/Lists/SearchHistory/src/SearchHistoryUpdate.java b/Lambdas/Lists/SearchHistory/src/SearchHistoryUpdate.java new file mode 100644 index 0000000..70671aa --- /dev/null +++ b/Lambdas/Lists/SearchHistory/src/SearchHistoryUpdate.java @@ -0,0 +1,56 @@ +import com.amazonaws.services.lambda.AWSLambdaClientBuilder; +import com.amazonaws.services.lambda.model.InvokeRequest; +import com.amazonaws.services.lambda.model.InvokeResult; +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; +import com.google.gson.Gson; + +import java.util.InputMismatchException; +import java.util.Map; + +public class SearchHistoryUpdate implements RequestHandler, Object> { + + public Object handleRequest(Map inputMap, Context unfilled) { + String cognitoID = (String) inputMap.get("cognitoID"); + System.out.println(cognitoID); + String newSearch = (String) inputMap.get("newSearch"); + System.out.println(newSearch); + InvokeRequest invokeRequest = new InvokeRequest(); + invokeRequest.setFunctionName("SearchHistoryGET"); + invokeRequest.setPayload("{" + + " \"body\": {" + + " }," + + " \"params\": {" + + " \"querystring\": {" + + " }" + + " }," + + " \"context\": {" + + " \"sub\": \""+ cognitoID + "\"" + + " }" + + "}"); + System.out.println(invokeRequest); + InvokeResult searchHistoryResult = AWSLambdaClientBuilder.defaultClient().invoke(invokeRequest); + System.out.println(searchHistoryResult); + if (searchHistoryResult.getStatusCode() != 200) { + throw new InputMismatchException("Could not find a search history for the specified usr"); + } + System.out.println(new String(searchHistoryResult.getPayload().array())); + SearchHistory priorSearchHistory = new Gson().fromJson(new String(searchHistoryResult.getPayload().array()), SearchHistory.class); + priorSearchHistory.addSearch(newSearch); + invokeRequest.setFunctionName("SearchHistoryPUT"); + System.out.println("New search history: " + new Gson().toJson(priorSearchHistory)); + invokeRequest.setPayload("{" + + " \"body\":" + new Gson().toJson(priorSearchHistory) + "," + + " \"params\": {" + + " \"querystring\": {" + + " }" + + " }," + + " \"context\": {" + + " \"sub\": \""+ cognitoID + "\"" + + " }" + + "}"); + invokeRequest.setInvocationType("Event"); + System.out.println(invokeRequest); + AWSLambdaClientBuilder.defaultClient().invoke(invokeRequest); + return null; } +} diff --git a/Lambdas/Lists/pom.xml b/Lambdas/Lists/pom.xml index b148d2c..4725165 100644 --- a/Lambdas/Lists/pom.xml +++ b/Lambdas/Lists/pom.xml @@ -94,6 +94,11 @@ jackson-dataformat-xml 2.8.5 + + com.fasterxml.jackson.core + jackson-annotations + 2.11.3 + com.fasterxml.jackson.core jackson-databind diff --git a/Listify/app/src/main/java/com/example/listify/Requestor.java b/Listify/app/src/main/java/com/example/listify/Requestor.java index b2df019..ed149c3 100644 --- a/Listify/app/src/main/java/com/example/listify/Requestor.java +++ b/Listify/app/src/main/java/com/example/listify/Requestor.java @@ -60,6 +60,25 @@ public class Requestor { launchCall(deleteRequest, null, classType, failureHandler); } + public void putObject(Object toPost) throws JSONException { + putObject(toPost, (RequestErrorHandler) null); + } + + public void putObject(Object toPost, RequestErrorHandler failureHandler) throws JSONException { + putObject(toPost, null, failureHandler); + } + + public void putObject(Object toPost, Receiver idReceiver) throws JSONException { + putObject(toPost, idReceiver, null); + } + + public void putObject(Object toPut, Receiver idReceiver, RequestErrorHandler failureHandler) throws JSONException { + String putURL = DEV_BASEURL + "/" + toPut.getClass().getSimpleName(); + Request putRequest = buildBaseRequest(putURL, "PUT", new Gson().toJson(toPut)); + launchCall(putRequest, idReceiver, Integer.class, failureHandler); + } + + public void postObject(Object toPost) throws JSONException { postObject(toPost, (RequestErrorHandler) null); } @@ -85,7 +104,7 @@ public class Requestor { String responseString = response.body().string(); if (receiver != null) { if (classType == null) { - Log.e("Requestor Contract Error", "classType while receiver populated"); + Log.e("Requestor Contract Error", "no/null classType while receiver populated"); } try { receiver.acceptDelivery(new Gson().fromJson(responseString, classType)); diff --git a/Listify/app/src/main/java/com/example/listify/data/SearchHistory.java b/Listify/app/src/main/java/com/example/listify/data/SearchHistory.java new file mode 100644 index 0000000..dace88d --- /dev/null +++ b/Listify/app/src/main/java/com/example/listify/data/SearchHistory.java @@ -0,0 +1,23 @@ +package com.example.listify.data; + +import java.util.ArrayList; + +public class SearchHistory { + ArrayList searches; + + public SearchHistory(ArrayList searches) { + this.searches = searches; + } + + public ArrayList getSearches() { + return searches; + } + + public void setSearches(ArrayList searches) { + this.searches = searches; + } + + public void addSearch(String newSearch) { + searches.add(newSearch); + } +} From 3afaad89ea4e0874a98493fcc025fda746106756 Mon Sep 17 00:00:00 2001 From: NMerz Date: Sat, 14 Nov 2020 12:05:50 -0500 Subject: [PATCH 2/2] Use plain table search history This is easier, clearer, faster for inters, and ultimately not really much less space efficient than trying to store this in a serialized nor unreasonably slow for retrievals. Food for thought: Would this might be well-suited to a nosql database? --- .../Lists/ItemSearch/src/ItemSearcher.java | 14 ++++- .../SearchHistory/src/SearchHistory.java | 6 +- ...HistoryPUT.java => SearchHistoryPOST.java} | 4 +- .../src/SearchHistoryUpdate.java | 56 ------------------- ...yPutter.java => SearchHistoryUpdater.java} | 16 ++---- .../com/example/listify/MainActivity.java | 16 ++++-- .../example/listify/data/SearchHistory.java | 7 +++ 7 files changed, 40 insertions(+), 79 deletions(-) rename Lambdas/Lists/SearchHistory/src/{SearchHistoryPUT.java => SearchHistoryPOST.java} (72%) delete mode 100644 Lambdas/Lists/SearchHistory/src/SearchHistoryUpdate.java rename Lambdas/Lists/SearchHistory/src/{SearchHistoryPutter.java => SearchHistoryUpdater.java} (53%) diff --git a/Lambdas/Lists/ItemSearch/src/ItemSearcher.java b/Lambdas/Lists/ItemSearch/src/ItemSearcher.java index eef6cc4..e24ebdf 100644 --- a/Lambdas/Lists/ItemSearch/src/ItemSearcher.java +++ b/Lambdas/Lists/ItemSearch/src/ItemSearcher.java @@ -29,10 +29,18 @@ public class ItemSearcher implements CallHandler { ItemSearch searchResultsObject = new ItemSearch(searchResults); System.out.println(searchResultsObject); InvokeRequest invokeRequest = new InvokeRequest(); - invokeRequest.setFunctionName("SearchHistoryUpdate"); + invokeRequest.setFunctionName("SearchHistoryPOST"); invokeRequest.setPayload("{" + - " \"newSearch\": \"" + queryParams.get("id") + "\"," + - " \"cognitoID\": \""+ cognitoID + "\"" + + " \"body\": {" + + " \"searchTerm\": \"" + queryParams.get("id") + "\"" + + " }," + + " \"params\": {" + + " \"querystring\": {" + + " }" + + " }," + + " \"context\": {" + + " \"sub\": \"" + cognitoID + "\"" + + " }" + "}"); invokeRequest.setInvocationType("Event"); System.out.println(invokeRequest); diff --git a/Lambdas/Lists/SearchHistory/src/SearchHistory.java b/Lambdas/Lists/SearchHistory/src/SearchHistory.java index b29e10d..f319150 100644 --- a/Lambdas/Lists/SearchHistory/src/SearchHistory.java +++ b/Lambdas/Lists/SearchHistory/src/SearchHistory.java @@ -15,7 +15,11 @@ public class SearchHistory implements Serializable { } public SearchHistory(ResultSet row) throws SQLException { - this.searches = (ArrayList) row.getObject("historyObject"); + this.searches = new ArrayList<>(); + row.beforeFirst(); + while (row.next()) { + this.searches.add(row.getString("search")); + } } public ArrayList getSearches() { diff --git a/Lambdas/Lists/SearchHistory/src/SearchHistoryPUT.java b/Lambdas/Lists/SearchHistory/src/SearchHistoryPOST.java similarity index 72% rename from Lambdas/Lists/SearchHistory/src/SearchHistoryPUT.java rename to Lambdas/Lists/SearchHistory/src/SearchHistoryPOST.java index 28d5019..6b05141 100644 --- a/Lambdas/Lists/SearchHistory/src/SearchHistoryPUT.java +++ b/Lambdas/Lists/SearchHistory/src/SearchHistoryPOST.java @@ -3,9 +3,9 @@ import com.amazonaws.services.lambda.runtime.RequestHandler; import java.util.Map; -public class SearchHistoryPUT implements RequestHandler, Object> { +public class SearchHistoryPOST implements RequestHandler, Object> { public Object handleRequest(Map inputMap, Context unfilled) { - return BasicHandler.handleRequest(inputMap, unfilled, SearchHistoryPutter.class); + return BasicHandler.handleRequest(inputMap, unfilled, SearchHistoryUpdater.class); } } diff --git a/Lambdas/Lists/SearchHistory/src/SearchHistoryUpdate.java b/Lambdas/Lists/SearchHistory/src/SearchHistoryUpdate.java deleted file mode 100644 index 70671aa..0000000 --- a/Lambdas/Lists/SearchHistory/src/SearchHistoryUpdate.java +++ /dev/null @@ -1,56 +0,0 @@ -import com.amazonaws.services.lambda.AWSLambdaClientBuilder; -import com.amazonaws.services.lambda.model.InvokeRequest; -import com.amazonaws.services.lambda.model.InvokeResult; -import com.amazonaws.services.lambda.runtime.Context; -import com.amazonaws.services.lambda.runtime.RequestHandler; -import com.google.gson.Gson; - -import java.util.InputMismatchException; -import java.util.Map; - -public class SearchHistoryUpdate implements RequestHandler, Object> { - - public Object handleRequest(Map inputMap, Context unfilled) { - String cognitoID = (String) inputMap.get("cognitoID"); - System.out.println(cognitoID); - String newSearch = (String) inputMap.get("newSearch"); - System.out.println(newSearch); - InvokeRequest invokeRequest = new InvokeRequest(); - invokeRequest.setFunctionName("SearchHistoryGET"); - invokeRequest.setPayload("{" + - " \"body\": {" + - " }," + - " \"params\": {" + - " \"querystring\": {" + - " }" + - " }," + - " \"context\": {" + - " \"sub\": \""+ cognitoID + "\"" + - " }" + - "}"); - System.out.println(invokeRequest); - InvokeResult searchHistoryResult = AWSLambdaClientBuilder.defaultClient().invoke(invokeRequest); - System.out.println(searchHistoryResult); - if (searchHistoryResult.getStatusCode() != 200) { - throw new InputMismatchException("Could not find a search history for the specified usr"); - } - System.out.println(new String(searchHistoryResult.getPayload().array())); - SearchHistory priorSearchHistory = new Gson().fromJson(new String(searchHistoryResult.getPayload().array()), SearchHistory.class); - priorSearchHistory.addSearch(newSearch); - invokeRequest.setFunctionName("SearchHistoryPUT"); - System.out.println("New search history: " + new Gson().toJson(priorSearchHistory)); - invokeRequest.setPayload("{" + - " \"body\":" + new Gson().toJson(priorSearchHistory) + "," + - " \"params\": {" + - " \"querystring\": {" + - " }" + - " }," + - " \"context\": {" + - " \"sub\": \""+ cognitoID + "\"" + - " }" + - "}"); - invokeRequest.setInvocationType("Event"); - System.out.println(invokeRequest); - AWSLambdaClientBuilder.defaultClient().invoke(invokeRequest); - return null; } -} diff --git a/Lambdas/Lists/SearchHistory/src/SearchHistoryPutter.java b/Lambdas/Lists/SearchHistory/src/SearchHistoryUpdater.java similarity index 53% rename from Lambdas/Lists/SearchHistory/src/SearchHistoryPutter.java rename to Lambdas/Lists/SearchHistory/src/SearchHistoryUpdater.java index a18a2ff..625c6db 100644 --- a/Lambdas/Lists/SearchHistory/src/SearchHistoryPutter.java +++ b/Lambdas/Lists/SearchHistory/src/SearchHistoryUpdater.java @@ -1,31 +1,25 @@ -import com.google.gson.Gson; - import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.HashMap; import java.util.Map; -public class SearchHistoryPutter implements CallHandler { +public class SearchHistoryUpdater implements CallHandler { private Connection connection; private String cognitoID; - public SearchHistoryPutter(Connection connection, String cognitoID) { + public SearchHistoryUpdater(Connection connection, String cognitoID) { this.connection = connection; this.cognitoID = cognitoID; } - final private String STORE_HISTORY = "REPLACE INTO SearchHistory(userID, historyObject) VALUES(?, ?);"; + final private String UPDATE_HISTORY = "INSERT INTO SearchHistory(userID, search) VALUES(?, ?);"; public Object conductAction(Map bodyMap, HashMap queryString, String cognitoID) throws SQLException { - final String searchHistoryJson = new Gson().toJson(bodyMap); - System.out.println(searchHistoryJson); - SearchHistory toStore = new Gson().fromJson(searchHistoryJson, SearchHistory.class); - System.out.println(toStore); - PreparedStatement store_history = connection.prepareStatement(STORE_HISTORY); + PreparedStatement store_history = connection.prepareStatement(UPDATE_HISTORY); store_history.setString(1, cognitoID); - store_history.setObject(2, toStore.searches); + store_history.setObject(2, bodyMap.get("searchTerm")); System.out.println(store_history); store_history.executeUpdate(); connection.commit(); diff --git a/Listify/app/src/main/java/com/example/listify/MainActivity.java b/Listify/app/src/main/java/com/example/listify/MainActivity.java index 881ce02..ec0c89b 100644 --- a/Listify/app/src/main/java/com/example/listify/MainActivity.java +++ b/Listify/app/src/main/java/com/example/listify/MainActivity.java @@ -16,19 +16,15 @@ import androidx.navigation.Navigation; import androidx.navigation.ui.AppBarConfiguration; import androidx.navigation.ui.NavigationUI; import com.amplifyframework.auth.AuthException; -import com.example.listify.data.Item; -import com.example.listify.data.ItemSearch; import com.example.listify.data.List; -import com.example.listify.data.ListEntry; +import com.example.listify.data.SearchHistory; import com.example.listify.ui.LoginPage; import com.google.android.material.navigation.NavigationView; import org.json.JSONException; import java.io.IOException; import java.time.Instant; -import java.util.Arrays; import java.util.Properties; -import java.util.Random; import static com.example.listify.SplashActivity.showSplash; @@ -108,7 +104,14 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF } Requestor requestor = new Requestor(authManager, configs.getProperty("apiKey")); - + SynchronousReceiver historyReceiver = new SynchronousReceiver<>(); + requestor.getObject("N/A", SearchHistory.class, historyReceiver, historyReceiver); + try { + System.out.println(historyReceiver.await()); + } catch (Exception e) { + e.printStackTrace(); + } + /* List testList = new List(-1, "New List", "user filled by lambda", Instant.now().toEpochMilli()); ListEntry entry = new ListEntry(1, 4, Math.abs(new Random().nextInt()), Instant.now().toEpochMilli(),false); @@ -139,6 +142,7 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF } catch (Exception receiverError) { receiverError.printStackTrace(); } + */ } //------------------------------------------------------------------------------------------// diff --git a/Listify/app/src/main/java/com/example/listify/data/SearchHistory.java b/Listify/app/src/main/java/com/example/listify/data/SearchHistory.java index dace88d..1d29594 100644 --- a/Listify/app/src/main/java/com/example/listify/data/SearchHistory.java +++ b/Listify/app/src/main/java/com/example/listify/data/SearchHistory.java @@ -20,4 +20,11 @@ public class SearchHistory { public void addSearch(String newSearch) { searches.add(newSearch); } + + @Override + public String toString() { + return "SearchHistory{" + + "searches=" + searches + + '}'; + } }