diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index f96e9d3..47056e3 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -16,12 +16,6 @@
-
-
-
-
();
+
inputParameter = (EditText) findViewById(R.id.input_parameter);
}
@@ -43,6 +54,7 @@ public void button_getBook_onClick(View view) {
String isbn = inputParameter.getText().toString();
// TODO Display book information for the book with the given ISBN.
+
}
public void button_getCheckedOut_onClick(View view) {
@@ -53,4 +65,32 @@ public void button_getCheckedOut_onClick(View view) {
// earliest due first.
}
+ private static ContentValues getContentValues(Books book) {
+ ContentValues values = new ContentValues();
+
+ values.put(BooksTable.Cols.ID, book.getId().toString());
+ values.put(BooksTable.Cols.TITLE, book.getTitle());
+ values.put(BooksTable.Cols.AUTHOR, book.getAuthor());
+ values.put(BooksTable.Cols.ISBN, book.getIsbn());
+ values.put(BooksTable.Cols.ISBN13, book.getIsbn13());
+ values.put(BooksTable.Cols.PUBLISHER, book.getPublisher());
+ values.put(BooksTable.Cols.PUBLISHYEAR, book.getPublishyear());
+ values.put(BooksTable.Cols.CHECKEDOUT, book.getCheckedout());
+ values.put(BooksTable.Cols.CHECKEDOUTBY, book.getCheckedoutby());
+ values.put(BooksTable.Cols.CHECKOUTDATEYEAR, book.getCheckoutdateyear());
+ values.put(BooksTable.Cols.CHECKOUTDATEMONTH, book.getCheckoutdatemonth());
+ values.put(BooksTable.Cols.CHECKOUTDATEDAY, book.getCheckoutdateday());
+ values.put(BooksTable.Cols.DUEDATEYEAR, book.getDuedateyear());
+ values.put(BooksTable.Cols.DUEDATEMONTH, book.getDuedatemonth());
+ values.put(BooksTable.Cols.DUEDATEDAY, book.getDuedateday());
+
+ return values;
+ }
+
+ public void addBook(Books b) {
+ ContentValues values = getContentValues(b);
+ mDatabase.insert(BooksTable.name, null, values);
+ }
+
+
}
diff --git a/src/main/java/nyc/c4q/ListActivity.java b/src/main/java/nyc/c4q/ListActivity.java
index 08894ac..efe9a67 100644
--- a/src/main/java/nyc/c4q/ListActivity.java
+++ b/src/main/java/nyc/c4q/ListActivity.java
@@ -1,45 +1,56 @@
package nyc.c4q;
import android.app.Activity;
+import android.content.Context;
+import android.graphics.Color;
import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
import android.widget.ListView;
+import android.widget.TextView;
+import java.util.ArrayList;
-public class ListActivity extends Activity {
+
+public class ListActivity extends Activity implements View.OnClickListener {
public ListView list;
+ public Button btnName;
+ public Button btnColor;
+
public static final Person[] PEOPLE = {
- new Person("Hannah", "Abbott", House.Hufflepuff),
- new Person("Katie", "Bell", House.Gryffindor),
- new Person("Susan", "Bones", House.Hufflepuff),
- new Person("Terry", "Boot", House.Ravenclaw),
- new Person("Lavender", "Brown", House.Gryffindor),
- new Person("Cho", "Chang", House.Ravenclaw),
- new Person("Michael", "Corner", House.Ravenclaw),
- new Person("Colin", "Creevey", House.Gryffindor),
- new Person("Marietta", "Edgecombe", House.Ravenclaw),
- new Person("Justin", "Finch-Fletchley", House.Hufflepuff),
- new Person("Seamus", "Finnigan", House.Gryffindor),
- new Person("Anthony", "Goldstein", House.Ravenclaw),
- new Person("Hermione", "Granger", House.Gryffindor),
- new Person("Angelina", "Johnson", House.Gryffindor),
- new Person("Lee", "Jordan", House.Gryffindor),
- new Person("Neville", "Longbottom", House.Gryffindor),
- new Person("Luna", "Lovegood", House.Ravenclaw),
- new Person("Ernie", "Macmillan", House.Hufflepuff),
- new Person("Parvati", "Patil", House.Gryffindor),
- new Person("Padma", "Patil", House.Ravenclaw),
- new Person("Harry", "Potter", House.Gryffindor),
- new Person("Zacharias", "Smith", House.Hufflepuff),
- new Person("Alicia", "Spinnet", House.Gryffindor),
- new Person("Dean", "Thomas", House.Gryffindor),
- new Person("Fred", "Weasley", House.Gryffindor),
- new Person("George", "Weasley", House.Gryffindor),
- new Person("Ginny", "Weasley", House.Gryffindor),
- new Person("Ron", "Weasley", House.Gryffindor)
+ new Person("Hannah", "Abbott", House.Hufflepuff),
+ new Person("Katie", "Bell", House.Gryffindor),
+ new Person("Susan", "Bones", House.Hufflepuff),
+ new Person("Terry", "Boot", House.Ravenclaw),
+ new Person("Lavender", "Brown", House.Gryffindor),
+ new Person("Cho", "Chang", House.Ravenclaw),
+ new Person("Michael", "Corner", House.Ravenclaw),
+ new Person("Colin", "Creevey", House.Gryffindor),
+ new Person("Marietta", "Edgecombe", House.Ravenclaw),
+ new Person("Justin", "Finch-Fletchley", House.Hufflepuff),
+ new Person("Seamus", "Finnigan", House.Gryffindor),
+ new Person("Anthony", "Goldstein", House.Ravenclaw),
+ new Person("Hermione", "Granger", House.Gryffindor),
+ new Person("Angelina", "Johnson", House.Gryffindor),
+ new Person("Lee", "Jordan", House.Gryffindor),
+ new Person("Neville", "Longbottom", House.Gryffindor),
+ new Person("Luna", "Lovegood", House.Ravenclaw),
+ new Person("Ernie", "Macmillan", House.Hufflepuff),
+ new Person("Parvati", "Patil", House.Gryffindor),
+ new Person("Padma", "Patil", House.Ravenclaw),
+ new Person("Harry", "Potter", House.Gryffindor),
+ new Person("Zacharias", "Smith", House.Hufflepuff),
+ new Person("Alicia", "Spinnet", House.Gryffindor),
+ new Person("Dean", "Thomas", House.Gryffindor),
+ new Person("Fred", "Weasley", House.Gryffindor),
+ new Person("George", "Weasley", House.Gryffindor),
+ new Person("Ginny", "Weasley", House.Gryffindor),
+ new Person("Ron", "Weasley", House.Gryffindor)
};
@Override
@@ -47,7 +58,62 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
+ initViews();
+
+ ArrayAdapter peopleAdapter =
+ new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, PEOPLE);
list = (ListView) findViewById(R.id.list);
+ list.setAdapter(peopleAdapter);
+ }
+
+ private void initViews() {
+ btnName = (Button) findViewById(R.id.button_name);
+ btnColor = (Button) findViewById(R.id.button_color);
+ }
+
+ @Override
+ public void onClick(View v) {
+
}
+ public class ListAdapter extends ArrayAdapter {
+ public ListAdapter(Context context, ArrayList people) {
+ super(context, 0, people);
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ // Get data for current position
+ Person person = getItem(position);
+
+ // Is existing view being used? If not, inflate a view.
+ if (convertView == null) {
+ convertView = LayoutInflater.from(getContext()).inflate(R.layout.listitem_member, parent, false);
+ }
+
+ // Lookup view for person
+ TextView tvName = (TextView) convertView.findViewById(R.id.text_name);
+ TextView tvHouse = (TextView) convertView.findViewById(R.id.text_house);
+
+ // Populate data into view using data object
+ tvName.setText(person.getFirstName() + " " + person.getLastName());
+ tvHouse.setText(person.getHouse().name());
+
+ // Set row background color
+
+ if (person.getHouse().toString().equalsIgnoreCase("gryffindor")) {
+ convertView.setBackgroundColor(getResources().getColor(R.color.gryffindor_red));
+ } else if (person.getHouse().toString().equalsIgnoreCase("ravenclaw")) {
+ convertView.setBackgroundColor(getResources().getColor(R.color.ravenclaw_blue));
+ } else if (person.getHouse().toString().equalsIgnoreCase("hufflepuff")) {
+ convertView.setBackgroundColor(getResources().getColor(R.color.hufflepuff_yellow));
+ } else if (person.getHouse().toString().equalsIgnoreCase("slytherin")) {
+ convertView.setBackgroundColor(getResources().getColor(R.color.slytherin_green));
+ } else {
+ convertView.setBackgroundColor(Color.parseColor("#000000"));
+ }
+
+ return convertView;
+ }
+ }
}
diff --git a/src/main/java/nyc/c4q/Members.java b/src/main/java/nyc/c4q/Members.java
new file mode 100644
index 0000000..7dabe82
--- /dev/null
+++ b/src/main/java/nyc/c4q/Members.java
@@ -0,0 +1,123 @@
+package nyc.c4q;
+
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+
+public class Members {
+
+ @Expose
+ private Integer id;
+ @Expose
+ private String name;
+ @SerializedName("dob_month")
+ @Expose
+ private Integer dobMonth;
+ @SerializedName("dob_day")
+ @Expose
+ private Integer dobDay;
+ @SerializedName("dob_year")
+ @Expose
+ private Integer dobYear;
+ @Expose
+ private String city;
+ @Expose
+ private String state;
+
+ /**
+ * @return The id
+ */
+ public Integer getId() {
+ return id;
+ }
+
+ /**
+ * @param id The id
+ */
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ /**
+ * @return The name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name The name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return The dobMonth
+ */
+ public Integer getDobMonth() {
+ return dobMonth;
+ }
+
+ /**
+ * @param dobMonth The dob_month
+ */
+ public void setDobMonth(Integer dobMonth) {
+ this.dobMonth = dobMonth;
+ }
+
+ /**
+ * @return The dobDay
+ */
+ public Integer getDobDay() {
+ return dobDay;
+ }
+
+ /**
+ * @param dobDay The dob_day
+ */
+ public void setDobDay(Integer dobDay) {
+ this.dobDay = dobDay;
+ }
+
+ /**
+ * @return The dobYear
+ */
+ public Integer getDobYear() {
+ return dobYear;
+ }
+
+ /**
+ * @param dobYear The dob_year
+ */
+ public void setDobYear(Integer dobYear) {
+ this.dobYear = dobYear;
+ }
+
+ /**
+ * @return The city
+ */
+ public String getCity() {
+ return city;
+ }
+
+ /**
+ * @param city The city
+ */
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ /**
+ * @return The state
+ */
+ public String getState() {
+ return state;
+ }
+
+ /**
+ * @param state The state
+ */
+ public void setState(String state) {
+ this.state = state;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/nyc/c4q/PaceCalculatorActivity.java b/src/main/java/nyc/c4q/PaceCalculatorActivity.java
index 5c0616e..1810d37 100644
--- a/src/main/java/nyc/c4q/PaceCalculatorActivity.java
+++ b/src/main/java/nyc/c4q/PaceCalculatorActivity.java
@@ -1,14 +1,183 @@
package nyc.c4q;
-import android.support.v4.app.FragmentActivity;
+import android.app.Fragment;
+import android.app.FragmentManager;
+import android.app.FragmentTransaction;
import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Toast;
+
+import java.util.ArrayList;
public class PaceCalculatorActivity extends FragmentActivity {
+ private double inputDistance;
+ private int inputTimeMin;
+ private int inputTimeSec;
+ private int inputPaceMin;
+ private int inputPaceSec;
+
+ private String distanceStr;
+ private String timeStr;
+ private String paceStr;
+
+ private String timeMinStr;
+ private String timeSecStr;
+ private String paceMinStr;
+ private String paceSecStr;
+
+ private EditText etDistance;
+ private EditText etTimeMin;
+ private EditText etTimeSec;
+ private EditText etPaceMin;
+ private EditText etPaceSec;
+ private Button btnCalculate;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pace_calculator);
+
+ initViews();
+
+ // get fragment manager
+ FragmentManager fm = getFragmentManager();
+
+ CalcFragment calcFrag = new CalcFragment();
+
+ // fragment add
+ FragmentTransaction ft = fm.beginTransaction();
+ ft.add(R.id.fragment_pace_calculator, calcFrag);
+ ft.commit();
+
+ // todo: fix fragment, calculate
+ }
+
+ private void initViews() {
+ etDistance = (EditText) findViewById(R.id.input_distance);
+ etTimeMin = (EditText) findViewById(R.id.input_time_min);
+ etTimeSec = (EditText) findViewById(R.id.input_time_sec);
+ etPaceMin = (EditText) findViewById(R.id.input_pace_min);
+ etPaceSec = (EditText) findViewById(R.id.input_pace_sec);
+ }
+
+ private double calculate(String distanceStr, String timeStr, String paceStr) {
+ double answer = 0;
+
+ // if distance + time, time + pace, or pace + distance
+ if ((!distanceStr.isEmpty()) && (!timeStr.isEmpty())) {
+ answer = inputDistance / Integer.parseInt(timeStr);
+ } else if ((!timeStr.isEmpty()) && (!paceStr.isEmpty())) {
+ answer = Integer.parseInt(timeStr) * Integer.parseInt(paceStr);
+ } else if ((!distanceStr.isEmpty()) && (!paceStr.isEmpty())) {
+ answer = inputDistance / Integer.parseInt(paceStr);
+ } else {
+ Toast.makeText(this, "Error", Toast.LENGTH_SHORT);
+ }
+
+ // return, plug in to third field
+ return answer;
+
}
+ private void validateInput(String distanceStr,
+ String timeMinStr,
+ String timeSecStr,
+ String paceMinStr,
+ String paceSecStr) {
+
+ String decimal = ".";
+ timeStr = timeMinStr += decimal += timeSecStr;
+ paceStr = paceMinStr += decimal += paceSecStr;
+
+ checkIfInputValid(distanceStr, timeStr, paceStr);
+ checkIfNoInputsEmpty(distanceStr, timeStr, paceStr);
+ checkIfTwoInputsEmpty(distanceStr, timeStr, paceStr);
+ checkIfAllInputsEmpty(distanceStr, timeStr, paceStr);
+ }
+
+ private void checkIfInputValid(String distanceStr, String timeStr, String paceStr) {
+ ArrayList input = new ArrayList<>();
+ input.add(distanceStr);
+ input.add(timeStr);
+ input.add(paceStr);
+
+ // iterate and verify whether input is in numeric characters only. ignore decimal.
+// for (String field : input) {
+// if (field.charAt(i).isNumber || field.charAt(i).equals('.')) {
+// // continue
+// }
+// }
+ }
+
+ private void checkIfNoInputsEmpty(String distanceStr, String timeStr, String paceStr) {
+ // if all have data specified...
+ if ((!distanceStr.isEmpty()) &&
+ (!timeStr.isEmpty()) &&
+ (!paceStr.isEmpty())) {
+ // do nothing
+ }
+ }
+
+ private void checkIfTwoInputsEmpty(String distanceStr, String timeStr, String paceStr) {
+ // if only one has data specified...
+ if ((!distanceStr.isEmpty()) &&
+ (timeStr.isEmpty()) &&
+ (paceStr.isEmpty())) {
+ // do nothing
+ }
+
+ if ((distanceStr.isEmpty()) &&
+ (!timeStr.isEmpty()) &&
+ (paceStr.isEmpty())) {
+ // do nothing
+ }
+
+ if ((distanceStr.isEmpty()) &&
+ (timeStr.isEmpty()) &&
+ (!paceStr.isEmpty())) {
+ // do nothing
+ }
+ }
+
+ private void checkIfAllInputsEmpty(String distanceStr, String timeStr, String paceStr) {
+ // if none have data specified...
+ if ((distanceStr.isEmpty()) &&
+ (timeStr.isEmpty()) &&
+ (paceStr.isEmpty())) {
+ // do nothing
+ }
+ }
+
+ public class CalcFragment extends Fragment implements View.OnClickListener {
+ private Button btnCalculate;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_pace_calculator, null);
+ btnCalculate = (Button) findViewById(R.id.button_calculate);
+ btnCalculate.setOnClickListener(this);
+
+ return view;
+ }
+
+ @Override
+ public void onClick(View v) {
+ // get values from edittexts
+ distanceStr = etDistance.getText().toString();
+ timeMinStr = etTimeMin.getText().toString();
+ timeSecStr = etTimeSec.getText().toString();
+ paceMinStr = etPaceMin.getText().toString();
+ paceSecStr = etPaceSec.getText().toString();
+
+ validateInput(distanceStr, timeMinStr, timeSecStr, paceMinStr, paceSecStr);
+
+ calculate(distanceStr, timeStr, paceStr);
+ }
+ }
}
diff --git a/src/main/java/nyc/c4q/Person.java b/src/main/java/nyc/c4q/Person.java
index 2f2f167..f29d842 100644
--- a/src/main/java/nyc/c4q/Person.java
+++ b/src/main/java/nyc/c4q/Person.java
@@ -10,4 +10,16 @@ public Person(String firstName, String lastName, House house) {
this.lastName = lastName;
this.house = house;
}
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public House getHouse() {
+ return house;
+ }
}
diff --git a/src/main/res/layout/activity_pace_calculator.xml b/src/main/res/layout/activity_pace_calculator.xml
index ed76b3e..1137324 100644
--- a/src/main/res/layout/activity_pace_calculator.xml
+++ b/src/main/res/layout/activity_pace_calculator.xml
@@ -1,8 +1,14 @@
-
+ android:orientation="vertical">
+
+
+
+
\ No newline at end of file
diff --git a/src/main/res/raw/books.json b/src/main/res/raw/books.json
index 8cc9673..79b378e 100644
--- a/src/main/res/raw/books.json
+++ b/src/main/res/raw/books.json
@@ -838,7 +838,7 @@
"isbn": "0439554934",
"isbn13": "9780439554930",
"publisher": "Scholastic",
- "publishyear": 2003.
+ "publishyear": 2003,
"checkedout": true,
"checkedoutby": 38,
"checkoutdateyear": 2015,