diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index ea076f1..b6e4c90 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -4,6 +4,8 @@
android:versionCode="2"
android:versionName="1.0.0-SNAPSHOT">
+
+
zipcodes;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -32,8 +47,8 @@ protected void onCreate(Bundle savedInstanceState) {
zipcodes = new ArrayList();
Button savejson = (Button) findViewById(R.id.savejson);
- Button loadjson = (Button) findViewById(R.id.loadjson);
- Button addjson = (Button) findViewById(R.id.addjson);
+ final Button loadjson = (Button) findViewById(R.id.loadjson);
+ final Button addjson = (Button) findViewById(R.id.addjson);
final TextView _id = (TextView) findViewById(R.id.field_idvalue);
final TextView pop = (TextView) findViewById(R.id.fieldpopvalue);
@@ -42,9 +57,15 @@ protected void onCreate(Bundle savedInstanceState) {
final TextView _lat = (TextView) findViewById(R.id.fieldloclatvalue);
final TextView _long = (TextView) findViewById(R.id.fieldloclongvalue);
+ //_id.setText(zipcodes.hashCode());
+
+
+
+
addjson.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+
}
});
@@ -53,6 +74,18 @@ public void onClick(View v) {
public void onClick(View v) {
File directory = getExternalCacheDir();
File file = new File(directory, "zipcodes.json");
+
+
+ ObjectOutputStream outputStream = null;
+ try{
+ outputStream = new ObjectOutputStream(new FileOutputStream(file));
+ System.out.println("Start Writings");
+ outputStream.writeObject(file);
+ outputStream.flush();
+ outputStream.close();
+ }catch (Exception e){
+ System.err.println("Error: " + e);
+ }
}
});
@@ -62,6 +95,7 @@ public void onClick(View v) {
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..20fd5ba 100644
--- a/src/main/java/nyc/c4q/ListViewActivity.java
+++ b/src/main/java/nyc/c4q/ListViewActivity.java
@@ -1,10 +1,20 @@
package nyc.c4q;
import android.app.Activity;
+import android.os.AsyncTask;
import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.EditText;
+import android.widget.ListView;
import android.widget.TextView;
+import android.widget.Toast;
+
+import java.util.List;
public class ListViewActivity extends Activity {
+ ListView list;
public static final String[] COLORS = {
"#142b44",
@@ -18,12 +28,37 @@ public class ListViewActivity extends Activity {
"#fa5e5b",
"#bf538d"
};
+
public TextView textLog;
+ public EditText adapterCount;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listview);
textLog = (TextView) findViewById(R.id.textLog);
+ adapterCount = (EditText) findViewById(R.id.adapterCount);
+ list = (ListView) findViewById(R.id.list);
+
+ ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, android.R.id.text1, COLORS);
+ list.setAdapter(adapter);
+ list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
+
+ int position = i;
+ String value = (String) list.getItemAtPosition(i);
+ //TODO working on the onClickItem
+ }
+ });
+//
+//
+// // Show Alert
+// Toast.makeText(getApplicationContext(),
+// "Position :" + itemPosition + " ListItem : " + itemValue, Toast.LENGTH_LONG)
+// .show();
+//
+// }
+// }
}
}
diff --git a/src/main/java/nyc/c4q/NetworkActivity.java b/src/main/java/nyc/c4q/NetworkActivity.java
index 3604cfc..ae23427 100644
--- a/src/main/java/nyc/c4q/NetworkActivity.java
+++ b/src/main/java/nyc/c4q/NetworkActivity.java
@@ -16,13 +16,24 @@
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONException;
+import org.json.JSONObject;
+
import java.io.BufferedInputStream;
import java.io.DataOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
+import java.util.List;
public class NetworkActivity extends Activity {
@@ -50,6 +61,7 @@ protected void onCreate(Bundle savedInstanceState) {
httptextlog = (TextView) findViewById(R.id.httptextlog);
httptextlog.setMovementMethod(new ScrollingMovementMethod());
+ // new LoadingAsyntask().execute();
/*
The goal is to use AsyncTasks here.
Shortcut to create URL in Java:
@@ -73,15 +85,19 @@ protected void onCreate(Bundle savedInstanceState) {
https://httpbin.org/post
*/
+
+
httpbinget.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+
}
});
httpbingetokhttp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
+
}
});
@@ -103,5 +119,50 @@ public void onClick(View v) {
httptextlog.setText("cleared HTTP response");
}
});
+
+
+ }
+
+ public class LoadingAsyntask extends AsyncTask {
+
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+
+ }
+
+ @Override
+ protected Boolean doInBackground(String... strings) {
+
+ try {
+
+ HttpGet httppost = new HttpGet(urlParams);
+ HttpClient httpclient = new DefaultHttpClient();
+ HttpResponse response = httpclient.execute(httppost);
+
+ // StatusLine stat = response.getStatusLine();
+ int status = response.getStatusLine().getStatusCode();
+
+ if (status == 200) {
+ HttpEntity entity = response.getEntity();
+ String data = EntityUtils.toString(entity);
+
+
+ JSONObject jsono = new JSONObject(data);
+
+ return true;
+ }
+
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (JSONException e) {
+
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ }
+
}
-}
diff --git a/src/main/java/nyc/c4q/NotificationActivity.java b/src/main/java/nyc/c4q/NotificationActivity.java
index f1f56ad..59a0a94 100644
--- a/src/main/java/nyc/c4q/NotificationActivity.java
+++ b/src/main/java/nyc/c4q/NotificationActivity.java
@@ -1,8 +1,11 @@
package nyc.c4q;
import android.app.Activity;
+import android.app.Notification;
import android.app.NotificationManager;
import android.os.Bundle;
+import android.support.v4.app.NotificationCompat;
+import android.view.View;
import android.widget.Button;
public class NotificationActivity extends Activity {
@@ -20,10 +23,77 @@ protected void onCreate(Bundle savedInstanceState) {
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Button autocancelnotification = (Button) findViewById(R.id.autocancelnotification);
- Button swipenotification = (Button) findViewById(R.id.swipenotification);
- Button permanentnotification = (Button) findViewById(R.id.permanentnotification);
+ final Button swipenotification = (Button) findViewById(R.id.swipenotification);
+ final Button permanentnotification = (Button) findViewById(R.id.permanentnotification);
Button dismisspermanentnotification = (Button) findViewById(R.id.dismisspermanentnotification);
Button buttonnotification = (Button) findViewById(R.id.buttonnotification);
+
+
+ autocancelnotification.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ autoCanel(view);
+ }
+ });
+
+ swipenotification.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ swipeNotification(view);
+ }
+ });
+
+ permanentnotification.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ permanNotification(view);
+ }
+ });
+
+ dismisspermanentnotification.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ dismissPermanNotification(view);
+ }
+ });
+ }
+
+
+ public void autoCanel (View view) {
+ Notification.Builder nb = new Notification.Builder(NotificationActivity.this);
+ nb.setContentTitle("default@c4q.nyc");
+ nb.setContentText("Touch me to dismiss me!");
+ nb.setSmallIcon(R.drawable.c4qfavicon);
+ nb.setAutoCancel(true);
+ Notification notification = nb.build();
+ notificationManager.notify(1,notification);
+ }
+
+ public void swipeNotification(View view) {
+ Notification.Builder nb = new Notification.Builder(NotificationActivity.this);
+ nb.setContentTitle("swipe@c4q.nyc");
+ nb.setContentText("Swipe right if you want to meet me. Otherwise, I'm not going away.");
+ nb.setSmallIcon(R.drawable.c4qfavicon);
+ Notification notification = nb.build();
+ notificationManager.notify(1,notification);
}
+
+ public void permanNotification(View view) {
+ Notification.Builder pn = new Notification.Builder(NotificationActivity.this);
+ pn.setContentTitle("permanent@c4q.nyc");
+ pn.setContentText("I'm staying planted right here.");
+ pn.setSmallIcon(R.drawable.c4qfavicon);
+ pn.setOngoing(true);
+ Notification notification = pn.build();
+ notificationManager.notify(1,notification);
+
+ }
+
+ public void dismissPermanNotification(View view) {
+ notificationManager.cancelAll();
+
+ }
+
+
}
diff --git a/src/main/java/nyc/c4q/json/Zipcode.java b/src/main/java/nyc/c4q/json/Zipcode.java
index 6d4761f..6a8555b 100644
--- a/src/main/java/nyc/c4q/json/Zipcode.java
+++ b/src/main/java/nyc/c4q/json/Zipcode.java
@@ -1,4 +1,50 @@
package nyc.c4q.json;
public class Zipcode {
+ 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 String getLoc() {
+ return loc;
+ }
+
+ public void setLoc(String loc) {
+ this.loc = loc;
+ }
+
+ public int getPop() {
+ return pop;
+ }
+
+ public void setPop(int pop) {
+ this.pop = pop;
+ }
+
+ public String _id;
+ public String city;
+ public String state;
+ public String loc;
+ public int pop;
+
}
diff --git a/src/main/res/layout/activity_json.xml b/src/main/res/layout/activity_json.xml
index b378881..5634592 100644
--- a/src/main/res/layout/activity_json.xml
+++ b/src/main/res/layout/activity_json.xml
@@ -2,7 +2,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="wrap_content">
+
+
+
+
+
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:text="You have not clicked anything."
+ android:layout_weight="3"/>
+
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="9"/>
+
+
\ No newline at end of file