-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Mofazzal874/Mofazzal
Factory Design added on Category items , ViewAllActivity, Query
- Loading branch information
Showing
11 changed files
with
132 additions
and
65 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/example/projecto/queries/HealthQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.example.projecto.queries; | ||
|
||
import com.google.android.gms.tasks.Task; | ||
import com.google.firebase.firestore.FirebaseFirestore; | ||
import com.google.firebase.firestore.QuerySnapshot; | ||
|
||
public class HealthQuery implements ProductQuery { | ||
private FirebaseFirestore firestore; | ||
|
||
public HealthQuery(FirebaseFirestore firestore) { | ||
this.firestore = firestore; | ||
} | ||
|
||
@Override | ||
public Task<QuerySnapshot> fetchProducts() { | ||
return firestore.collection("Allproducts").whereEqualTo("type", "health").get(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/example/projecto/queries/MedicationQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.example.projecto.queries; | ||
|
||
import com.google.android.gms.tasks.Task; | ||
import com.google.firebase.firestore.FirebaseFirestore; | ||
import com.google.firebase.firestore.QuerySnapshot; | ||
|
||
public class MedicationQuery implements ProductQuery { | ||
private FirebaseFirestore firestore; | ||
|
||
public MedicationQuery(FirebaseFirestore firestore) { | ||
this.firestore = firestore; | ||
} | ||
|
||
@Override | ||
public Task<QuerySnapshot> fetchProducts() { | ||
return firestore.collection("Allproducts").whereEqualTo("type", "medication").get(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/example/projecto/queries/PersonalQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.example.projecto.queries; | ||
|
||
import com.google.android.gms.tasks.Task; | ||
import com.google.firebase.firestore.FirebaseFirestore; | ||
import com.google.firebase.firestore.QuerySnapshot; | ||
|
||
public class PersonalQuery implements ProductQuery { | ||
private FirebaseFirestore firestore; | ||
|
||
public PersonalQuery(FirebaseFirestore firestore) { | ||
this.firestore = firestore; | ||
} | ||
|
||
@Override | ||
public Task<QuerySnapshot> fetchProducts() { | ||
return firestore.collection("Allproducts").whereEqualTo("type", "personal").get(); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/example/projecto/queries/ProductQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.example.projecto.queries; | ||
|
||
import com.google.android.gms.tasks.Task; | ||
import com.google.firebase.firestore.QuerySnapshot; | ||
|
||
public interface ProductQuery { | ||
Task<QuerySnapshot> fetchProducts(); | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/example/projecto/queries/ProductQueryFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.example.projecto.queries; | ||
|
||
import com.google.firebase.firestore.FirebaseFirestore; | ||
|
||
public class ProductQueryFactory { | ||
public static ProductQuery createQuery(String type, FirebaseFirestore firestore) { | ||
switch (type.toLowerCase()) { | ||
case "medication": | ||
return new MedicationQuery(firestore); | ||
case "health": | ||
return new HealthQuery(firestore); | ||
case "personal": | ||
return new PersonalQuery(firestore); | ||
default: | ||
throw new IllegalArgumentException("Unknown type: " + type); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/test/java/com/example/projecto/activities/ViewAllActivityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.example.projecto.activities; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
|
||
import com.example.projecto.models.ViewAllModel; | ||
|
||
|
||
public class ViewAllActivityTest { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters