diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index ea076f1..16d2d23 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -4,6 +4,9 @@ android:versionCode="2" android:versionName="1.0.0-SNAPSHOT"> + + + (getApplicationContext(), android.R.layout.simple_list_item_1, COLORS); + list.setAdapter(listAdapter); + + + + for (int i = 0; i < COLORS.length; i++) { + list.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + textLog.setText("You clicked on Item(position=" + i + ", color=" + COLORS[i] + ")"); + + view.setBackgroundColor(Color.parseColor(COLORS[i])); + + } + }); + + View v = listAdapter.getView(i, null, list); + ColorDrawable background = new ColorDrawable(); + background.setColor(Color.parseColor(COLORS[i])); + v.setBackground(background); + + } + + + + + + + + + + + // TODO: FINISH !! +// list.performItemClick(View v, int position, long id) { +// textLog.setText("You clicked on Item(" + position=%s + "," + color=%s + ")"); +// } + + + } } diff --git a/src/main/java/nyc/c4q/NetworkActivity.java b/src/main/java/nyc/c4q/NetworkActivity.java index 3604cfc..b49c30b 100644 --- a/src/main/java/nyc/c4q/NetworkActivity.java +++ b/src/main/java/nyc/c4q/NetworkActivity.java @@ -3,6 +3,7 @@ import android.app.Activity; import android.os.AsyncTask; import android.os.Bundle; +import android.os.Handler; import android.text.method.ScrollingMovementMethod; import android.util.Log; import android.view.View; @@ -50,6 +51,33 @@ protected void onCreate(Bundle savedInstanceState) { httptextlog = (TextView) findViewById(R.id.httptextlog); httptextlog.setMovementMethod(new ScrollingMovementMethod()); + + new Handler().post(new Runnable() { + @Override + public void run() { + httpbinget.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + httptextlog.setText(urlParams); + } + }); + } + }); + + + new Handler().post(new Runnable() { + @Override + public void run() { + httpbingetokhttp.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + httptextlog.setText(urlParams.replaceAll("\\+"," ")); + } + }); + } + }); + + /* The goal is to use AsyncTasks here. Shortcut to create URL in Java: diff --git a/src/main/java/nyc/c4q/NotificationActivity.java b/src/main/java/nyc/c4q/NotificationActivity.java index f1f56ad..b66777f 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.Intent; import android.os.Bundle; +import android.renderscript.RenderScript; +import android.support.v4.app.NotificationCompat; +import android.view.View; import android.widget.Button; public class NotificationActivity extends Activity { @@ -21,9 +27,108 @@ protected void onCreate(Bundle savedInstanceState) { Button autocancelnotification = (Button) findViewById(R.id.autocancelnotification); Button swipenotification = (Button) findViewById(R.id.swipenotification); - Button permanentnotification = (Button) findViewById(R.id.permanentnotification); + final Button permanentnotification = (Button) findViewById(R.id.permanentnotification); Button dismisspermanentnotification = (Button) findViewById(R.id.dismisspermanentnotification); - Button buttonnotification = (Button) findViewById(R.id.buttonnotification); + final Button buttonnotification = (Button) findViewById(R.id.buttonnotification); + + autocancelnotification.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + String title = "default@c4q.nyc"; + String text = "Touch me to dismiss me!"; + + + NotificationCompat.Builder mBuilder = + new NotificationCompat.Builder(getApplicationContext()) + .setSmallIcon(R.drawable.c4qfavicon) + .setContentTitle("default@c4q.nyc") + .setContentText(text); + + mBuilder.setAutoCancel(true); + + + Notification autoNotification = mBuilder.build(); + notificationManager.notify(1, autoNotification); + } + }); + + + + + + swipenotification.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + String title = "swipe@c4q.nyc"; + String text = "Swipe right if you want to meet me. Otherwise, I'm not going away."; + + NotificationCompat.Builder mBuilder = + new NotificationCompat.Builder(getApplicationContext()) + .setSmallIcon(R.drawable.c4qfavicon) + .setContentTitle(title) + .setContentText(text); + + + + Notification swipeNotification = mBuilder.build(); + notificationManager.notify(2, swipeNotification); + } + }); + + + + + permanentnotification.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + String title = "permanent@c4q.nyc"; + String text = "I'm staying planted right here."; + + NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getApplicationContext()); + mBuilder.setContentTitle(title); + mBuilder.setContentText(text); + mBuilder.setSmallIcon(R.drawable.c4qfavicon); + + + mBuilder.setOngoing(true); + Notification permaNotification = mBuilder.build(); + notificationManager.notify(3, permaNotification); + } + }); + + + + dismisspermanentnotification.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + notificationManager.cancel(3); + } + }); + + + + + + buttonnotification.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + String title = "permanent@c4q.nyc"; + String text = "I'm staying planted right here."; + + NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getApplicationContext()); + mBuilder.setSmallIcon(R.drawable.c4qfavicon); + mBuilder.setContentTitle(title); + mBuilder.setContentText(text); + + mBuilder.setOngoing(true); + Notification buttonNotification = mBuilder.build(); + notificationManager.notify(4, buttonNotification); + } + }); + + + } } diff --git a/src/main/java/nyc/c4q/json/Zipcode.java b/src/main/java/nyc/c4q/json/Zipcode.java index 6d4761f..1b69f94 100644 --- a/src/main/java/nyc/c4q/json/Zipcode.java +++ b/src/main/java/nyc/c4q/json/Zipcode.java @@ -1,4 +1,5 @@ package nyc.c4q.json; public class Zipcode { + } diff --git a/src/main/res/layout/activity_listview.xml b/src/main/res/layout/activity_listview.xml index 0d4b9d6..b1bd99d 100644 --- a/src/main/res/layout/activity_listview.xml +++ b/src/main/res/layout/activity_listview.xml @@ -9,20 +9,34 @@ + android:layout_width="0dp" + android:layout_weight="3.0" + android:layout_height="match_parent" + android:text="You have not clicked anything." + android:textColor="#FFF" + android:gravity="center"/> + + + + + + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="9.0"/> \ No newline at end of file