mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 10:48:46 +00:00
Removed hardcoded db interaction
This commit is contained in:
parent
73639b50e2
commit
2c9eaee1be
@ -24,6 +24,8 @@ import java.time.Instant;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import static com.example.listify.MainActivity.am;
|
||||||
|
|
||||||
public class ItemDetails extends AppCompatActivity implements ListPickerDialogFragment.OnListPickListener, CreateListAddDialogFragment.OnNewListAddListener {
|
public class ItemDetails extends AppCompatActivity implements ListPickerDialogFragment.OnListPickListener, CreateListAddDialogFragment.OnNewListAddListener {
|
||||||
private Product curProduct;
|
private Product curProduct;
|
||||||
private LinearLayout linAddItem;
|
private LinearLayout linAddItem;
|
||||||
@ -71,12 +73,6 @@ public class ItemDetails extends AppCompatActivity implements ListPickerDialogFr
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
closeFABMenu();
|
closeFABMenu();
|
||||||
|
|
||||||
AuthManager authManager = new AuthManager();
|
|
||||||
try {
|
|
||||||
authManager.signIn("merzn@purdue.edu", "Password123");
|
|
||||||
} catch (AuthException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
Properties configs = new Properties();
|
Properties configs = new Properties();
|
||||||
try {
|
try {
|
||||||
configs = AuthManager.loadProperties(ItemDetails.this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
configs = AuthManager.loadProperties(ItemDetails.this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
||||||
@ -84,7 +80,7 @@ public class ItemDetails extends AppCompatActivity implements ListPickerDialogFr
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
Requestor requestor = new Requestor(authManager, configs.getProperty("apiKey"));
|
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||||
SynchronousReceiver<Integer[]> listIdsReceiver = new SynchronousReceiver<>();
|
SynchronousReceiver<Integer[]> listIdsReceiver = new SynchronousReceiver<>();
|
||||||
SynchronousReceiver<List> listReceiver = new SynchronousReceiver<>();
|
SynchronousReceiver<List> listReceiver = new SynchronousReceiver<>();
|
||||||
|
|
||||||
@ -166,19 +162,13 @@ public class ItemDetails extends AppCompatActivity implements ListPickerDialogFr
|
|||||||
@Override
|
@Override
|
||||||
public void sendListSelection(int selectedListIndex, int quantity) {
|
public void sendListSelection(int selectedListIndex, int quantity) {
|
||||||
|
|
||||||
AuthManager authManager = new AuthManager();
|
|
||||||
try {
|
|
||||||
authManager.signIn("merzn@purdue.edu", "Password123");
|
|
||||||
} catch (AuthException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
Properties configs = new Properties();
|
Properties configs = new Properties();
|
||||||
try {
|
try {
|
||||||
configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
||||||
} catch (IOException | JSONException e) {
|
} catch (IOException | JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Requestor requestor = new Requestor(authManager, configs.getProperty("apiKey"));
|
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||||
SynchronousReceiver<Integer> idReceiver = new SynchronousReceiver<>();
|
SynchronousReceiver<Integer> idReceiver = new SynchronousReceiver<>();
|
||||||
|
|
||||||
|
|
||||||
@ -196,19 +186,13 @@ public class ItemDetails extends AppCompatActivity implements ListPickerDialogFr
|
|||||||
@Override
|
@Override
|
||||||
public void sendNewListName(String name, int quantity) {
|
public void sendNewListName(String name, int quantity) {
|
||||||
|
|
||||||
AuthManager authManager = new AuthManager();
|
|
||||||
try {
|
|
||||||
authManager.signIn("merzn@purdue.edu", "Password123");
|
|
||||||
} catch (AuthException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
Properties configs = new Properties();
|
Properties configs = new Properties();
|
||||||
try {
|
try {
|
||||||
configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
||||||
} catch (IOException | JSONException e) {
|
} catch (IOException | JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Requestor requestor = new Requestor(authManager, configs.getProperty("apiKey"));
|
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||||
SynchronousReceiver<Integer> idReceiver = new SynchronousReceiver<>();
|
SynchronousReceiver<Integer> idReceiver = new SynchronousReceiver<>();
|
||||||
|
|
||||||
com.example.listify.data.List newList = new List(-1, name, "user filled by lambda", Instant.now().toEpochMilli());
|
com.example.listify.data.List newList = new List(-1, name, "user filled by lambda", Instant.now().toEpochMilli());
|
||||||
|
|||||||
@ -180,19 +180,13 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendNewListName(String name) {
|
public void sendNewListName(String name) {
|
||||||
AuthManager authManager = new AuthManager();
|
|
||||||
try {
|
|
||||||
authManager.signIn("merzn@purdue.edu", "Password123");
|
|
||||||
} catch (AuthException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
Properties configs = new Properties();
|
Properties configs = new Properties();
|
||||||
try {
|
try {
|
||||||
configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
||||||
} catch (IOException | JSONException e) {
|
} catch (IOException | JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Requestor requestor = new Requestor(authManager, configs.getProperty("apiKey"));
|
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||||
SynchronousReceiver<Integer> idReceiver = new SynchronousReceiver<>();
|
SynchronousReceiver<Integer> idReceiver = new SynchronousReceiver<>();
|
||||||
|
|
||||||
List newList = new List(-1, name, "user filled by lambda", Instant.now().toEpochMilli());
|
List newList = new List(-1, name, "user filled by lambda", Instant.now().toEpochMilli());
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import android.widget.ImageButton;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.SearchView;
|
import android.widget.SearchView;
|
||||||
import com.amplifyframework.auth.AuthException;
|
|
||||||
import com.example.listify.adapter.SearchResultsListAdapter;
|
import com.example.listify.adapter.SearchResultsListAdapter;
|
||||||
import com.example.listify.data.ItemSearch;
|
import com.example.listify.data.ItemSearch;
|
||||||
import com.example.listify.model.Product;
|
import com.example.listify.model.Product;
|
||||||
@ -21,6 +20,8 @@ import java.util.Comparator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import static com.example.listify.MainActivity.am;
|
||||||
|
|
||||||
public class SearchResults extends AppCompatActivity implements SortDialogFragment.OnSortingListener {
|
public class SearchResults extends AppCompatActivity implements SortDialogFragment.OnSortingListener {
|
||||||
private ListView listView;
|
private ListView listView;
|
||||||
private SearchResultsListAdapter searchResultsListAdapter;
|
private SearchResultsListAdapter searchResultsListAdapter;
|
||||||
@ -139,12 +140,6 @@ public class SearchResults extends AppCompatActivity implements SortDialogFragme
|
|||||||
// Clear the old search results
|
// Clear the old search results
|
||||||
resultsProductList.clear();
|
resultsProductList.clear();
|
||||||
|
|
||||||
AuthManager authManager = new AuthManager();
|
|
||||||
try {
|
|
||||||
authManager.signIn("merzn@purdue.edu", "Password123");
|
|
||||||
} catch (AuthException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
Properties configs = new Properties();
|
Properties configs = new Properties();
|
||||||
try {
|
try {
|
||||||
configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
configs = AuthManager.loadProperties(this, "android.resource://" + getPackageName() + "/raw/auths.json");
|
||||||
@ -152,7 +147,7 @@ public class SearchResults extends AppCompatActivity implements SortDialogFragme
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
Requestor requestor = new Requestor(authManager, configs.getProperty("apiKey"));
|
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||||
|
|
||||||
SynchronousReceiver<ItemSearch> itemReceiver = new SynchronousReceiver<>();
|
SynchronousReceiver<ItemSearch> itemReceiver = new SynchronousReceiver<>();
|
||||||
requestor.getObject(query, ItemSearch.class, itemReceiver, itemReceiver);
|
requestor.getObject(query, ItemSearch.class, itemReceiver, itemReceiver);
|
||||||
|
|||||||
@ -32,6 +32,8 @@ import java.time.Instant;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import static com.example.listify.MainActivity.am;
|
||||||
|
|
||||||
public class ListsFragment extends Fragment implements CreateListDialogFragment.OnNewListListener {
|
public class ListsFragment extends Fragment implements CreateListDialogFragment.OnNewListListener {
|
||||||
ArrayList<List> shoppingLists = new ArrayList<>();
|
ArrayList<List> shoppingLists = new ArrayList<>();
|
||||||
ListView shoppingListsView;
|
ListView shoppingListsView;
|
||||||
@ -41,12 +43,6 @@ public class ListsFragment extends Fragment implements CreateListDialogFragment.
|
|||||||
shoppingListsView = root.findViewById(R.id.shopping_lists);
|
shoppingListsView = root.findViewById(R.id.shopping_lists);
|
||||||
|
|
||||||
// TODO: Switch this to async
|
// TODO: Switch this to async
|
||||||
AuthManager authManager = new AuthManager();
|
|
||||||
try {
|
|
||||||
authManager.signIn("merzn@purdue.edu", "Password123");
|
|
||||||
} catch (AuthException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
Properties configs = new Properties();
|
Properties configs = new Properties();
|
||||||
try {
|
try {
|
||||||
configs = AuthManager.loadProperties(getContext(), "android.resource://" + getActivity().getPackageName() + "/raw/auths.json");
|
configs = AuthManager.loadProperties(getContext(), "android.resource://" + getActivity().getPackageName() + "/raw/auths.json");
|
||||||
@ -54,7 +50,7 @@ public class ListsFragment extends Fragment implements CreateListDialogFragment.
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
Requestor requestor = new Requestor(authManager, configs.getProperty("apiKey"));
|
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||||
SynchronousReceiver<Integer[]> listIdsReceiver = new SynchronousReceiver<>();
|
SynchronousReceiver<Integer[]> listIdsReceiver = new SynchronousReceiver<>();
|
||||||
SynchronousReceiver<List> listReceiver = new SynchronousReceiver<>();
|
SynchronousReceiver<List> listReceiver = new SynchronousReceiver<>();
|
||||||
|
|
||||||
@ -98,19 +94,14 @@ public class ListsFragment extends Fragment implements CreateListDialogFragment.
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendNewListName(String name) {
|
public void sendNewListName(String name) {
|
||||||
AuthManager authManager = new AuthManager();
|
|
||||||
try {
|
|
||||||
authManager.signIn("merzn@purdue.edu", "Password123");
|
|
||||||
} catch (AuthException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
Properties configs = new Properties();
|
Properties configs = new Properties();
|
||||||
try {
|
try {
|
||||||
configs = AuthManager.loadProperties(getContext(), "android.resource://" + getActivity().getPackageName() + "/raw/auths.json");
|
configs = AuthManager.loadProperties(getContext(), "android.resource://" + getActivity().getPackageName() + "/raw/auths.json");
|
||||||
} catch (IOException | JSONException e) {
|
} catch (IOException | JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Requestor requestor = new Requestor(authManager, configs.getProperty("apiKey"));
|
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||||
SynchronousReceiver<Integer> idReceiver = new SynchronousReceiver<>();
|
SynchronousReceiver<Integer> idReceiver = new SynchronousReceiver<>();
|
||||||
|
|
||||||
List newList = new List(-1, name, "user filled by lambda", Instant.now().toEpochMilli());
|
List newList = new List(-1, name, "user filled by lambda", Instant.now().toEpochMilli());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user