Skip to content
This repository has been archived by the owner on Apr 20, 2019. It is now read-only.

submit 6:15pm #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ListViewActivity"
android:windowSoftInputMode="adjustPan" />
<activity android:name=".NetworkActivity" />
<activity android:name=".JSONActivity" />
<activity android:name=".NotificationActivity" />

<activity
android:name=".PaceCalculatorActivity"
android:label="@string/title_activity_pace_calculator"
Expand Down
60 changes: 60 additions & 0 deletions src/main/java/nyc/c4q/LibraryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

import org.json.JSONArray;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;


public class LibraryActivity extends Activity {

Expand All @@ -15,9 +24,59 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_library);

MySQLiteHelper db = new MySQLiteHelper(this);

inputParameter = (EditText) findViewById(R.id.input_parameter);

InputStream inputStreamMembers = getResources().openRawResource(R.raw.members);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

int ctr;
try {
ctr = inputStreamMembers.read();
while (ctr != -1) {
byteArrayOutputStream.write(ctr);
ctr = inputStreamMembers.read();
}
inputStreamMembers.close();
} catch (IOException e) {
e.printStackTrace();
}
Log.v("Text Data", byteArrayOutputStream.toString());
try {

JSONArray jArray = new JSONArray(byteArrayOutputStream.toString());
String id = "";
String name = "";
String dob_month = "";
String dob_day = "";
String dob_year = "";
String city = "";
String state = "";
for (int i = 0; i < jArray.length(); i++) {
id = jArray.getJSONObject(i).getString("id");
name = jArray.getJSONObject(i).getString("name");
dob_month = jArray.getJSONObject(i).getString("dob_month");
dob_day = jArray.getJSONObject(i).getString("dob_day");
dob_year = jArray.getJSONObject(i).getString("dob_year");
city = jArray.getJSONObject(i).getString("city");
state = jArray.getJSONObject(i).getString("state");
HashMap<String, String> memberData = new HashMap<String, String>();
memberData.put(id, "id");
memberData.put(name, "name");
memberData.put(dob_month, "dob_month");
memberData.put(dob_day, "dob_day");
memberData.put(dob_year, "dob_year");
memberData.put(city, "city");
memberData.put(state, "state");
}
} catch (Exception e) {
e.printStackTrace();
}

}


public void checkOut(int memberId, int bookId) {
// TODO This method is called when the member with the given ID checks
// out the book with the given ID. Update the system accordingly.
Expand All @@ -34,6 +93,7 @@ public boolean checkIn(int memberId, int bookId) {
}

public void button_getMember_onClick(View view) {
MySQLiteHelper db = new MySQLiteHelper(this);
String name = inputParameter.getText().toString();

// TODO Display member information for the member with the given name.
Expand Down
91 changes: 62 additions & 29 deletions src/main/java/nyc/c4q/ListActivity.java
Original file line number Diff line number Diff line change
@@ -1,45 +1,58 @@
package nyc.c4q;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;


public class ListActivity extends Activity {

public ListView list;
public Button button_name;
Context mContext;

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
Expand All @@ -48,6 +61,26 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_list);

list = (ListView) findViewById(R.id.list);
}
Button button_name = (Button) findViewById(R.id.button_name);
Button button_color = (Button) findViewById(R.id.button_color);

final ArrayAdapter<Person> adapter = new ArrayAdapter<Person>(this, android.R.layout.simple_list_item_1, PEOPLE);
list.setAdapter(adapter);

button_name.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

adapter.getItem(1);
adapter.getItem(0);
// list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
// public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// HashMap<String, Object> obj = (HashMap<String, Object>) adapter.getItem(position);
// String lastName = (String) obj.get("lastName");
// String firstName = (String) obj.get("firstName");

}
});

}
}
95 changes: 95 additions & 0 deletions src/main/java/nyc/c4q/Members.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package nyc.c4q;

/**
* Created by c4q-vanice on 8/30/15.
*/
public class Members {

protected String id;
protected String name;
protected String dob_month;
protected String dob_day;
protected String dob_year;
protected String city;
protected String state;
protected String location;

public Members(){

}

public Members(String id, String name, String dob_month, String dob_day, String dob_year, String location) {
this.id = id;
this.name = name;
this.dob_month = dob_month;
this.dob_day = dob_day;
this.dob_year = dob_year;
this.location = location;
}

public String getId() {

return id;
}

public void setId(String id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getDob_month() {
return dob_month;
}

public void setDob_month(String dob_month) {
this.dob_month = dob_month;
}

public String getDob_day() {
return dob_day;
}

public void setDob_day(String dob_day) {
this.dob_day = dob_day;
}

public String getDob_year() {
return dob_year;
}

public void setDob_year(String dob_year) {
this.dob_year = dob_year;
}

public String getCity() {
return city;
}

public void setCity(String city) {
this.city = city;
}

public String getState() {
return state;
}

public void setState(String state) {
this.state = state;
}

public String getLocation(){
return location;
}

public void location(String city, String state ){
this.state = state;
this.city = city;
}
}
71 changes: 71 additions & 0 deletions src/main/java/nyc/c4q/MySQLiteHelper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package nyc.c4q;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
* Created by c4q-vanice on 8/30/15.
*/
public class MySQLiteHelper extends SQLiteOpenHelper {

public static final String DATABASE_MEMBERS = "members.db";
public static final String TABLE_MEMBERS = "members";
public static final String TABLE_COLUMN_ID = "id";
public static final String TABLE_COLUMN_NAME = "name";
public static final String TABLE_COLUMN_MONTH = "dob_month";
public static final String TABLE_COLUMN_DAY = "dob_day";
public static final String TABLE_COLUMN_YEAR = "dob_year";
public static final String TABLE_COLUMN_LOCATION = "location";

public static final int VERSION = 1;
private static MySQLiteHelper INSTANCE;

public static synchronized MySQLiteHelper getInstance(Context context)
{
if(INSTANCE == null)
{
INSTANCE = new MySQLiteHelper(context.getApplicationContext());
}

return INSTANCE;
}

protected MySQLiteHelper(Context context) {
super(context, DATABASE_MEMBERS, null, VERSION);
}


@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_TABLE = "CREATE TABLE" + DATABASE_MEMBERS + "(" + TABLE_COLUMN_ID + "id," + TABLE_COLUMN_NAME
+ "name, " + TABLE_COLUMN_DAY + "dob_day, " + TABLE_COLUMN_MONTH + "dob_month, " + TABLE_COLUMN_YEAR + "dob_year, " +
TABLE_COLUMN_LOCATION + "location, " + ")";
db.execSQL(CREATE_TABLE);

}

@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

}

public Members addMembers(Members members ){
SQLiteDatabase db = this.getWritableDatabase();

ContentValues values = new ContentValues();

values.put(TABLE_COLUMN_ID, members.getId());
values.put(TABLE_COLUMN_NAME, members.getName());
values.put(TABLE_COLUMN_MONTH, members.getDob_month());
values.put(TABLE_COLUMN_DAY, members.getDob_day());
values.put(TABLE_COLUMN_YEAR, members.getDob_year());
values.put(TABLE_COLUMN_LOCATION, members.getCity() + members.getState());

db.insert(TABLE_MEMBERS, null, values);
db.close();

return members;
}
}
Loading