Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

additional commit #12

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
2 changes: 1 addition & 1 deletion src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package="nyc.c4q"
android:versionCode="2"
android:versionName="1.0.0-SNAPSHOT">

<uses-permission android:name="android.permission.INTERNET"/>
<application android:name=".Unit2AssessmentApplication">
<activity
android:name=".Unit2AssessmentActivity"
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/nyc/c4q/JSONActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

import com.google.gson.Gson;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
Expand Down Expand Up @@ -42,6 +46,21 @@ protected void onCreate(Bundle savedInstanceState) {
final TextView _lat = (TextView) findViewById(R.id.fieldloclatvalue);
final TextView _long = (TextView) findViewById(R.id.fieldloclongvalue);

JSONArray address = new JSONArray(zipcodes);
for (int i = 0; i < address.length(); i++) {
try {
JSONObject info = address.getJSONObject(i);
Zipcode data = new Zipcode();
data.set_id(info.getString("_id"));
data.setCity(info.getString("city"));
data.setState(info.getString("state"));
data.setPop(info.getInt("pop"));

} catch (JSONException e) {
e.printStackTrace();
}
}

addjson.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/nyc/c4q/NetworkActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package nyc.c4q;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
Expand All @@ -9,15 +11,20 @@
import android.widget.Button;
import android.widget.TextView;

import com.squareup.okhttp.Call;
import com.squareup.okhttp.Callback;
import com.squareup.okhttp.FormEncodingBuilder;
import com.squareup.okhttp.HttpUrl;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;

import org.json.JSONException;

import java.io.BufferedInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
Expand Down Expand Up @@ -76,12 +83,15 @@ 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);
}
});

Expand All @@ -100,7 +110,7 @@ public void onClick(View v) {
cleartextlog.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
httptextlog.setText("cleared HTTP response");
httptextlog.setText(urlParams);
}
});
}
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/nyc/c4q/NotificationActivity.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package nyc.c4q;

import android.app.Activity;
import android.app.AlertDialog;
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 {
Expand All @@ -11,6 +18,7 @@ public class NotificationActivity extends Activity {
public static final int ID_SWIPE_NOTIFICATION = 2;
public static final int ID_PERMANENT_NOTIFICATION = 3;
public static final int ID_BUTTON_NOTIFICATION = 4;
Context mContext;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -19,11 +27,40 @@ 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);
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) {

NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext);
builder.setSmallIcon(R.drawable.c4qfavicon)
.setAutoCancel(true)
.setContentTitle("[email protected]")
.setContentText("Touch me to dismiss me!");
Notification n = builder.build();
n.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(1, n);
}
});

swipenotification.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext);
builder.setSmallIcon(R.drawable.c4qfavicon)
.setContentTitle("[email protected]")
.setContentText("Swipe right if you want to meet me. Otherwise, I'm not going away.");
Notification n = builder.build();

notificationManager.notify(2, n);
}
});

}
}
37 changes: 37 additions & 0 deletions src/main/java/nyc/c4q/json/Zipcode.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,41 @@
package nyc.c4q.json;

public class Zipcode {

public String _id;
public String city;
public String state;
public int 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 int getPop() {
return pop;
}

public void setPop(int pop) {
this.pop = pop;
}
}
24 changes: 17 additions & 7 deletions src/main/res/layout/activity_listview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,30 @@

<LinearLayout
android:id="@+id/header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">

<TextView
android:id="@+id/textLog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fill this textview" />
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:text="You have not clicked anything." />

<EditText
android:id="@+id/adapterCount"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:inputType="phone"/>

</LinearLayout>

<ListView
android:id="@+id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9"/>
</LinearLayout>