Skip to content

Commit

Permalink
Merge branch 'main' into select_delete_items
Browse files Browse the repository at this point in the history
  • Loading branch information
Sami-Jagirdar committed Nov 6, 2023
2 parents fcd53ae + 9db4dbe commit fe1747c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 11 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Android CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Cache Gradle dependencies
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: Build with Gradle
run: |
chmod +x gradlew
./gradlew test
continue-on-error: true
5 changes: 3 additions & 2 deletions app/src/main/java/com/example/househomey/HomeFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ public class HomeFragment extends Fragment implements DeleteItemsFragment.OnFrag
private CollectionReference itemRef;
private ListView itemListView;
private PopupMenu filterView;
private ArrayList<Item> itemList = new ArrayList<>();
private ItemAdapter itemAdapter;
private ArrayList<Item> itemList;
private ArrayAdapter<Item> itemAdapter;

/**
* This constructs a new HomeFragment with the appropriate list of items
* @param itemRef A reference to the firestore collection containing the items to display
*/
public HomeFragment(CollectionReference itemRef) {
this.itemRef = itemRef;
itemList = new ArrayList<>();
}

/**
Expand Down
13 changes: 5 additions & 8 deletions app/src/main/java/com/example/househomey/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
* @see ItemAdapter
*/
public class Item {

// TODO: We should make this private and only use the Getter to access the id
public String id;
private String id;
private String description;
private Date acquisitionDate;
private String make = "";
Expand All @@ -35,11 +33,11 @@ public class Item {
* @throws NullPointerException if a null required field is given
*/
public Item(String id, @NonNull Map<String, Object> data) {
// Required fields
// Required fields, will throw exceptions
this.id = Objects.requireNonNull(id);
this.description = (String) Objects.requireNonNull(data.get("description"));
this.acquisitionDate = ((Timestamp) Objects.requireNonNull(data.get("acquisitionDate"))).toDate();
this.cost = new BigDecimal((String) Objects.requireNonNull(data.get("cost"))).setScale(2, RoundingMode.HALF_DOWN);
this.cost = new BigDecimal((String) Objects.requireNonNull(data.get("cost"))).setScale(2, RoundingMode.HALF_UP);

// Optional fields
if (data.containsKey("make")) {
Expand All @@ -56,10 +54,9 @@ public Item(String id, @NonNull Map<String, Object> data) {
}
}


/**
* Getter for ID of the item
* @return Unique ID of the item
* Getter for id
* @return The id of this item in firestore
*/
public String getId() {
return id;
Expand Down
2 changes: 1 addition & 1 deletion app/src/test/java/com/example/househomey/ItemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void setUp() {
public void testRequiredConstructor() {
Item newItem = new Item(id, inputMap);

assertEquals(id, newItem.id);
assertEquals(id, newItem.getId());
assertEquals(inputMap.get("description"), newItem.getDescription());
assertEquals(((Timestamp)inputMap.get("acquisitionDate")).toDate(), newItem.getAcquisitionDate());
assertEquals(new BigDecimal((String) inputMap.get("cost")), newItem.getCost());
Expand Down

0 comments on commit fe1747c

Please sign in to comment.