From 0e7b23ac5764591a513aa809d1f548a9ab11dc42 Mon Sep 17 00:00:00 2001 From: Mary Tran Date: Wed, 31 Oct 2018 12:55:15 -0400 Subject: [PATCH] Changing gridview text colour to white --- .../olympus/olympusservices/Service.java | 19 +++++++++++++++++++ .../olympusservices/ServiceProvider.java | 19 +++++++++++++++++++ .../olympus/olympusservices/ServicesList.java | 2 +- .../olympus/olympusservices/UsersList.java | 2 +- .../layout/simple_list_item_1_customized.xml | 15 +++++++++++++++ 5 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 OlympusServices/app/src/main/res/layout/simple_list_item_1_customized.xml diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Service.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Service.java index d3b7c03..266115a 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Service.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Service.java @@ -1,12 +1,17 @@ package com.uottawa.olympus.olympusservices; +import java.util.ArrayList; +import java.util.List; + public class Service { private String name; private double rate; + private List serviceProviders; Service(String name, double rate) { this.name = name; this.rate = rate; + serviceProviders = new ArrayList(); } public String getName() { @@ -24,4 +29,18 @@ public class Service { public void setRate(double rate) { this.rate = rate; } + + public boolean addServiceProvider(ServiceProvider user){ + for (ServiceProvider listUser : serviceProviders){ + if (user.getUsername().equals(listUser.getUsername())){ + return false; + } + } + serviceProviders.add(user); + return true; + } + + public List getServiceProviders(){ + return serviceProviders; + } } diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProvider.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProvider.java index 086ccf0..15bfde4 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProvider.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProvider.java @@ -1,12 +1,31 @@ package com.uottawa.olympus.olympusservices; +import java.util.ArrayList; +import java.util.List; + public class ServiceProvider extends UserType { + private List services; + ServiceProvider(String username, String password, String firstname, String lastname){ super(username, password, firstname, lastname); + services = new ArrayList<>(); } public String getRole(){ return "ServiceProvider"; } + public boolean addService(Service service){ + for (Service listService : services){ + if (service.getName().equals(listService.getName())){ + return false; + } + } + services.add(service); + return true; + } + + public List getServices(){ + return services; + } } diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java index e070cb1..8f29a44 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java @@ -29,7 +29,7 @@ public class ServicesList extends AppCompatActivity implements NewServiceDialogF services[(i+1)*2] = current[0]; services[(i+1)*2+1] = current[1]; } - ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, services); + ArrayAdapter adapter = new ArrayAdapter(this, R.layout.simple_list_item_1_customized, services); GridView gridView = findViewById(R.id.Services); gridView.setAdapter(adapter); gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UsersList.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UsersList.java index e7bbff4..4cb5afb 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UsersList.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UsersList.java @@ -26,7 +26,7 @@ public class UsersList extends AppCompatActivity { usernames[(i+1)*2] = current[0]; usernames[(i+1)*2+1] = current[3]; } - ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, usernames); + ArrayAdapter adapter = new ArrayAdapter(this, R.layout.simple_list_item_1_customized, usernames); GridView gridView = findViewById(R.id.Users); gridView.setAdapter(adapter); } diff --git a/OlympusServices/app/src/main/res/layout/simple_list_item_1_customized.xml b/OlympusServices/app/src/main/res/layout/simple_list_item_1_customized.xml new file mode 100644 index 0000000..9847704 --- /dev/null +++ b/OlympusServices/app/src/main/res/layout/simple_list_item_1_customized.xml @@ -0,0 +1,15 @@ + + + + \ No newline at end of file