diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index ea076f1..bf09603 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -4,6 +4,9 @@
android:versionCode="2"
android:versionName="1.0.0-SNAPSHOT">
+
+
+
();
+ //Double [] location = {-73.939393,40.750316};
+
+ String JSON_ZIPCODE = "{\"_id\":\"11101\",\"city\":\"ASTORIA\",\"loc\":[-73.939393,40.750316],\"pop\":23142,\"state\":\"NY\"}";
+ Gson gson = new Gson();
+ Zipcode z = gson.fromJson(JSON_ZIPCODE, Zipcode.class);
+
+ zipcodes.add(z);
+
Button savejson = (Button) findViewById(R.id.savejson);
Button loadjson = (Button) findViewById(R.id.loadjson);
Button addjson = (Button) findViewById(R.id.addjson);
@@ -48,11 +57,14 @@ public void onClick(View v) {
}
});
+
+
savejson.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
File directory = getExternalCacheDir();
File file = new File(directory, "zipcodes.json");
+
}
});
diff --git a/src/main/java/nyc/c4q/ListViewActivity.java b/src/main/java/nyc/c4q/ListViewActivity.java
index 78104c6..140d670 100644
--- a/src/main/java/nyc/c4q/ListViewActivity.java
+++ b/src/main/java/nyc/c4q/ListViewActivity.java
@@ -1,7 +1,16 @@
package nyc.c4q;
import android.app.Activity;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Adapter;
+import android.widget.ArrayAdapter;
+import android.widget.ListAdapter;
+import android.widget.ListView;
import android.widget.TextView;
public class ListViewActivity extends Activity {
@@ -19,11 +28,29 @@ public class ListViewActivity extends Activity {
"#bf538d"
};
public TextView textLog;
+ public ListView list;
+ public ListAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listview);
+
textLog = (TextView) findViewById(R.id.textLog);
+ list = (ListView) findViewById(R.id.list);
+
+
+ adapter = new ArrayAdapter(this,
+ android.R.layout.simple_list_item_multiple_choice,
+ COLORS);
+ list.setAdapter(adapter);
+
+ for (int i = 0; i < COLORS.length; i++) {
+ View v = adapter.getView(i, null, list);
+ v.setBackgroundColor(Color.parseColor(COLORS[i]));
+ }
}
+
+
+
}
diff --git a/src/main/java/nyc/c4q/NetworkActivity.java b/src/main/java/nyc/c4q/NetworkActivity.java
index 3604cfc..b76a119 100644
--- a/src/main/java/nyc/c4q/NetworkActivity.java
+++ b/src/main/java/nyc/c4q/NetworkActivity.java
@@ -16,6 +16,8 @@
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;
+import org.assertj.android.api.Assertions;
+
import java.io.BufferedInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
@@ -76,12 +78,19 @@ protected void onCreate(Bundle savedInstanceState) {
httpbinget.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+
+ httptextlog.setText(urlParams);
+
}
});
httpbingetokhttp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+
+ String replaced = urlParams.replaceAll("\\+"," ");
+ httptextlog.setText(replaced);
+
}
});
diff --git a/src/main/java/nyc/c4q/NotificationActivity.java b/src/main/java/nyc/c4q/NotificationActivity.java
index f1f56ad..9ef90cf 100644
--- a/src/main/java/nyc/c4q/NotificationActivity.java
+++ b/src/main/java/nyc/c4q/NotificationActivity.java
@@ -1,8 +1,14 @@
package nyc.c4q;
import android.app.Activity;
+import android.app.Notification;
import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
import android.os.Bundle;
+import android.support.v4.app.NotificationCompat;
+import android.view.View;
import android.widget.Button;
public class NotificationActivity extends Activity {
@@ -12,11 +18,14 @@ public class NotificationActivity extends Activity {
public static final int ID_PERMANENT_NOTIFICATION = 3;
public static final int ID_BUTTON_NOTIFICATION = 4;
+ NotificationCompat.Builder mBuilder;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notification);
+ //make instance of notification manager
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Button autocancelnotification = (Button) findViewById(R.id.autocancelnotification);
@@ -25,5 +34,79 @@ protected void onCreate(Bundle savedInstanceState) {
Button dismisspermanentnotification = (Button) findViewById(R.id.dismisspermanentnotification);
Button buttonnotification = (Button) findViewById(R.id.buttonnotification);
+ autocancelnotification.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+
+ mBuilder =
+ new NotificationCompat.Builder(NotificationActivity.this)
+ .setSmallIcon(R.drawable.c4qfavicon)
+ .setContentTitle("default@c4q.nyc")
+ .setContentText("Touch me to dismiss me!")
+ .setAutoCancel(true);
+ mBuilder.getNotification().flags |= Notification.FLAG_AUTO_CANCEL;
+ // Builds the notification and issues it.
+ notificationManager.notify(ID_AUTOCANCEL_NOTIFICATION, mBuilder.build());
+ }
+ });
+
+ swipenotification.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+
+ mBuilder =
+ new NotificationCompat.Builder(NotificationActivity.this)
+ .setSmallIcon(R.drawable.c4qfavicon)
+ .setContentTitle("swipe@c4q.nyc")
+ .setContentText("Swipe right if you want to meet me. Otherwise, I'm not going away.");
+ mBuilder.getNotification().flags |= Notification.FLAG_AUTO_CANCEL;
+ // Builds the notification and issues it.
+ notificationManager.notify(ID_SWIPE_NOTIFICATION, mBuilder.build());
+ }
+
+
+ });
+
+ permanentnotification.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+
+ mBuilder =
+ new NotificationCompat.Builder(NotificationActivity.this)
+ .setSmallIcon(R.drawable.c4qfavicon)
+ .setContentTitle("permanent@c4q.nyc")
+ .setContentText("I'm staying planted right here.")
+ .setOngoing(true);
+ // Builds the notification and issues it.
+ notificationManager.notify(ID_PERMANENT_NOTIFICATION, mBuilder.build());
+ }
+ });
+
+ dismisspermanentnotification.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+
+ mBuilder =
+ new NotificationCompat.Builder(NotificationActivity.this)
+ .setSmallIcon(R.drawable.c4qfavicon)
+ .setContentTitle("permanent@c4q.nyc")
+ .setContentText("I'm staying planted right here.");
+
+ notificationManager.cancel(ID_PERMANENT_NOTIFICATION);
+ }
+ });
+
+ buttonnotification.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+
+ mBuilder =
+ new NotificationCompat.Builder(NotificationActivity.this)
+ .setSmallIcon(R.drawable.c4qfavicon)
+ .setContentTitle("My notification")
+ .setContentText("Hello World!")
+ .setAutoCancel(true);
+ // Builds the notification and issues it.
+ notificationManager.notify(ID_BUTTON_NOTIFICATION, mBuilder.build());
+ }
+ });
+
}
+
}
+
diff --git a/src/main/java/nyc/c4q/json/Zipcode.java b/src/main/java/nyc/c4q/json/Zipcode.java
index 6d4761f..92a77c4 100644
--- a/src/main/java/nyc/c4q/json/Zipcode.java
+++ b/src/main/java/nyc/c4q/json/Zipcode.java
@@ -1,4 +1,60 @@
package nyc.c4q.json;
+
public class Zipcode {
+
+ public String _id;
+ public String city;
+ public String state;
+ public double [] loc;
+ public int pop;
+
+ public Zipcode (String _id, String city, double [] loc, int pop, String state) {
+
+ this._id = _id;
+ this.city = city;
+ this.state = state;
+ this.loc = loc;
+ this.pop = pop;
+ }
+
+ public String get_id() {
+ return _id;
+ }
+
+ public void set_id(String _id) {
+ this._id = _id;
+ }
+
+ 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 double[] getLoc() {
+ return loc;
+ }
+
+ public void setLoc(double[] loc) {
+ this.loc = loc;
+ }
+
+ public int getPop() {
+ return pop;
+ }
+
+ public void setPop(int pop) {
+ this.pop = pop;
+ }
}
diff --git a/src/main/res/layout/activity_listview.xml b/src/main/res/layout/activity_listview.xml
index 0d4b9d6..99ba32e 100644
--- a/src/main/res/layout/activity_listview.xml
+++ b/src/main/res/layout/activity_listview.xml
@@ -9,20 +9,32 @@
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="3"
+ android:text="You have not clicked anything." />
+
+
+
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="9"/>
\ No newline at end of file
diff --git a/src/test/java/nyc/c4q/Part3JSONActivityTests.java b/src/test/java/nyc/c4q/Part3JSONActivityTests.java
index 8693962..59ef135 100644
--- a/src/test/java/nyc/c4q/Part3JSONActivityTests.java
+++ b/src/test/java/nyc/c4q/Part3JSONActivityTests.java
@@ -52,6 +52,7 @@ public void test16JSONActivityCreateJSONMappingID() throws NoSuchFieldException,
assertThat(Zipcode.class.getField("_id").get(z), instanceOf(String.class));
assertThat((String) Zipcode.class.getField("_id").get(z), equalTo("11101"));
+
assertThat(Zipcode.class.getField("city").get(z), instanceOf(String.class));
assertThat((String) Zipcode.class.getField("city").get(z), equalTo("ASTORIA"));