diff --git a/OlympusServices/.idea/assetWizardSettings.xml b/OlympusServices/.idea/assetWizardSettings.xml
new file mode 100644
index 0000000..6b96cf0
--- /dev/null
+++ b/OlympusServices/.idea/assetWizardSettings.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OlympusServices/.idea/caches/build_file_checksums.ser b/OlympusServices/.idea/caches/build_file_checksums.ser
index 38a3339..6f6e6b3 100644
Binary files a/OlympusServices/.idea/caches/build_file_checksums.ser and b/OlympusServices/.idea/caches/build_file_checksums.ser differ
diff --git a/OlympusServices/app/build.gradle b/OlympusServices/app/build.gradle
index b9ba7b2..de13111 100644
--- a/OlympusServices/app/build.gradle
+++ b/OlympusServices/app/build.gradle
@@ -39,6 +39,7 @@ dependencies {
implementation 'com.jaredrummler:material-spinner:1.2.5'
implementation 'com.android.support:design:28.0.0-alpha3'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
+ implementation 'com.android.support:recyclerview-v7:28.0.0'
}
repositories {
diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditServiceDialogFragment.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditServiceDialogFragment.java
index ecdd495..3998964 100644
--- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditServiceDialogFragment.java
+++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditServiceDialogFragment.java
@@ -45,7 +45,7 @@ public interface NoticeDialogListener {
public void onClick(DialogInterface dialog, int id) {
Bundle args = new Bundle();
//@anshu: get the name and rate to come from the dialog_service_new dialog
- args.putString("name", "hey");
+ args.putString("name", (String)getArguments().get("name"));
args.putDouble("rate", 2.5);
//
EditServiceDialogFragment.this.setArguments(args);
@@ -56,12 +56,13 @@ public interface NoticeDialogListener {
public void onClick(DialogInterface dialog, int id) {
Bundle args = new Bundle();
//@anshu: get the name and rate to come from the dialog_service_new dialog
- args.putString("name", "hey");
+ args.putString("name", (String)getArguments().get("name"));
//
EditServiceDialogFragment.this.setArguments(args);
mListener.onDialogDelete(EditServiceDialogFragment.this);
}
- });
+ })
+ .setTitle((String)getArguments().get("name"));
return builder.create();
}
}
diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/MyAdapter.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/MyAdapter.java
new file mode 100644
index 0000000..2855872
--- /dev/null
+++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/MyAdapter.java
@@ -0,0 +1,10 @@
+package com.uottawa.olympus.olympusservices;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java
index 2e35941..7f0496e 100644
--- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java
+++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java
@@ -45,7 +45,7 @@ public class NewServiceDialogFragment extends DialogFragment {
public void onClick(DialogInterface dialog, int id) {
Bundle args = new Bundle();
//@anshu: get the name and rate to come from the dialog_service_new dialog
- args.putString("name", "hey");
+ args.putString("name", "test2");
args.putDouble("rate", 2.5);
///
NewServiceDialogFragment.this.setArguments(args);
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 8f29a44..db0cd9e 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
@@ -1,9 +1,15 @@
package com.uottawa.olympus.olympusservices;
+import android.content.Context;
+import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.GridView;
@@ -14,39 +20,45 @@ import java.util.List;
public class ServicesList extends AppCompatActivity implements NewServiceDialogFragment.NoticeDialogListener, EditServiceDialogFragment.NoticeDialogListener{
+ private RecyclerView mRecyclerView;
+ private RecyclerView.Adapter mAdapter;
+ private RecyclerView.LayoutManager mLayoutManager;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_services_list);
DBHelper dbHelper = new DBHelper(this);
- List users = dbHelper.getAllServices();
- String[] services = new String[(users.size()+1)*2];
- services[0] = "Name";
- services[1] = "Rate";
- Iterator iter = users.iterator();
- for (int i=0; i serviceslist = dbHelper.getAllServices();
+ Service[] services = new Service[(serviceslist.size())];
+ Iterator iter = serviceslist.iterator();
+ for (int i=0; i(this, R.layout.simple_list_item_1_customized, services);
- GridView gridView = findViewById(R.id.Services);
- gridView.setAdapter(adapter);
- gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> parent, View view,
- int position, long id) {
- editService(view);
- }
- });
+
+ mRecyclerView = (RecyclerView) findViewById(R.id.Services);
+
+
+ mLayoutManager = new LinearLayoutManager(this);
+ mRecyclerView.setLayoutManager(mLayoutManager);
+
+ mAdapter = new MyAdapter(services, this);
+ mRecyclerView.setAdapter(mAdapter);
+
+
+
}
public void addService(View view) {
DialogFragment newFragment = new NewServiceDialogFragment();
newFragment.show(getSupportFragmentManager(), "addService");
}
- public void editService(View view) {
+ public void editService(View view, String name) {
DialogFragment newFragment = new EditServiceDialogFragment();
newFragment.show(getSupportFragmentManager(), "editService");
+ Bundle args = new Bundle();
+ args.putString("name", name);
+ newFragment.setArguments(args);
}
//add new service
@Override
@@ -83,4 +95,70 @@ public class ServicesList extends AppCompatActivity implements NewServiceDialogF
this.recreate();
}
+ public class MyAdapter extends RecyclerView.Adapter {
+
+ private Service[] services;
+ private Context context;
+
+ // Provide a reference to the views for each data item
+ // Complex data items may need more than one view per item, and
+ // you provide access to all the views for a data item in a view holder
+
+ // Provide a suitable constructor (depends on the kind of dataset)
+ public MyAdapter(Service[] services, Context context) {
+ this.services = services;
+ }
+
+ // Create new views (invoked by the layout manager)
+ @NonNull
+ @Override
+ public ServicesHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ View v = LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.list_item, parent, false);
+ ServicesHolder vh = new ServicesHolder(v);
+ return vh;
+ }
+
+ // Replace the contents of a view (invoked by the layout manager)
+ @Override
+ public void onBindViewHolder(ServicesHolder holder, int position) {
+ Service service = services[position];
+ holder.name.setText(service.getName());
+ holder.rate.setText(""+service.getRate());
+
+
+
+ }
+
+ // Return the size of your dataset (invoked by the layout manager)
+ @Override
+ public int getItemCount() {
+ return services.length;
+ }
+
+ class ServicesHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
+
+ TextView name;
+ TextView rate;
+
+ public ServicesHolder(View row){
+ super(row);
+ name = row.findViewById(R.id.Name);
+ rate = row.findViewById(R.id.Rate);
+ row.setOnClickListener(this);
+ }
+ @Override
+ public void onClick(View view) {
+ TextView nameview = (TextView)view.findViewById(R.id.Name);
+ String name = nameview.getText().toString();
+ editService(view, name);
+
+ }
+
+
+ }
+
+
+ }
+
}
\ No newline at end of file
diff --git a/OlympusServices/app/src/main/res/layout/activity_services_list.xml b/OlympusServices/app/src/main/res/layout/activity_services_list.xml
index a899d83..03bbcf4 100644
--- a/OlympusServices/app/src/main/res/layout/activity_services_list.xml
+++ b/OlympusServices/app/src/main/res/layout/activity_services_list.xml
@@ -15,7 +15,7 @@
+
+ android:orientation="horizontal"
+ android:paddingBottom="10dp">
-
+
+
+
+
+
+
+