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