diff --git a/HW4/.classpath b/HW4/.classpath
new file mode 100644
index 0000000..26bdfa6
--- /dev/null
+++ b/HW4/.classpath
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/HW4/.project b/HW4/.project
new file mode 100644
index 0000000..d1ac1ed
--- /dev/null
+++ b/HW4/.project
@@ -0,0 +1,33 @@
+
+
+ HW4
+
+
+
+
+
+ com.android.ide.eclipse.adt.ResourceManagerBuilder
+
+
+
+
+ com.android.ide.eclipse.adt.PreCompilerBuilder
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ com.android.ide.eclipse.adt.ApkBuilder
+
+
+
+
+
+ com.android.ide.eclipse.adt.AndroidNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/HW4/AndroidManifest.xml b/HW4/AndroidManifest.xml
new file mode 100644
index 0000000..095eab4
--- /dev/null
+++ b/HW4/AndroidManifest.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/HW4/bin/AndroidManifest.xml b/HW4/bin/AndroidManifest.xml
new file mode 100644
index 0000000..095eab4
--- /dev/null
+++ b/HW4/bin/AndroidManifest.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/HW4/ic_launcher-web.png b/HW4/ic_launcher-web.png
new file mode 100644
index 0000000..df8cdb2
Binary files /dev/null and b/HW4/ic_launcher-web.png differ
diff --git a/HW4/proguard-project.txt b/HW4/proguard-project.txt
new file mode 100644
index 0000000..f2fe155
--- /dev/null
+++ b/HW4/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/HW4/project.properties b/HW4/project.properties
new file mode 100644
index 0000000..4ab1256
--- /dev/null
+++ b/HW4/project.properties
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-19
diff --git a/HW4/res/drawable-hdpi/ic_launcher.png b/HW4/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..3709e51
Binary files /dev/null and b/HW4/res/drawable-hdpi/ic_launcher.png differ
diff --git a/HW4/res/drawable-mdpi/ic_launcher.png b/HW4/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..6c67bab
Binary files /dev/null and b/HW4/res/drawable-mdpi/ic_launcher.png differ
diff --git a/HW4/res/drawable-xhdpi/ic_launcher.png b/HW4/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..812eaa0
Binary files /dev/null and b/HW4/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/HW4/res/drawable-xxhdpi/ic_launcher.png b/HW4/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..352b378
Binary files /dev/null and b/HW4/res/drawable-xxhdpi/ic_launcher.png differ
diff --git a/HW4/res/layout/activity_main.xml b/HW4/res/layout/activity_main.xml
new file mode 100644
index 0000000..a51b19d
--- /dev/null
+++ b/HW4/res/layout/activity_main.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
diff --git a/HW4/res/layout/activity_photo.xml b/HW4/res/layout/activity_photo.xml
new file mode 100644
index 0000000..12bd166
--- /dev/null
+++ b/HW4/res/layout/activity_photo.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
diff --git a/HW4/res/layout/grid_schema.xml b/HW4/res/layout/grid_schema.xml
new file mode 100644
index 0000000..1b99a6a
--- /dev/null
+++ b/HW4/res/layout/grid_schema.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
diff --git a/HW4/res/menu/main.xml b/HW4/res/menu/main.xml
new file mode 100644
index 0000000..d122a4b
--- /dev/null
+++ b/HW4/res/menu/main.xml
@@ -0,0 +1,9 @@
+
diff --git a/HW4/res/values-sw600dp/dimens.xml b/HW4/res/values-sw600dp/dimens.xml
new file mode 100644
index 0000000..c876987
--- /dev/null
+++ b/HW4/res/values-sw600dp/dimens.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
diff --git a/HW4/res/values-sw720dp-land/dimens.xml b/HW4/res/values-sw720dp-land/dimens.xml
new file mode 100644
index 0000000..0df3067
--- /dev/null
+++ b/HW4/res/values-sw720dp-land/dimens.xml
@@ -0,0 +1,9 @@
+
+
+
+ 128dp
+
+
diff --git a/HW4/res/values-v11/styles.xml b/HW4/res/values-v11/styles.xml
new file mode 100644
index 0000000..e3ef53d
--- /dev/null
+++ b/HW4/res/values-v11/styles.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/HW4/res/values-v14/styles.xml b/HW4/res/values-v14/styles.xml
new file mode 100644
index 0000000..94dd245
--- /dev/null
+++ b/HW4/res/values-v14/styles.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
diff --git a/HW4/res/values/dimens.xml b/HW4/res/values/dimens.xml
new file mode 100644
index 0000000..e77ff50
--- /dev/null
+++ b/HW4/res/values/dimens.xml
@@ -0,0 +1,10 @@
+
+
+
+ 16dp
+ 16dp
+ 5dp
+ 140dp
+ 140dp
+
+
diff --git a/HW4/res/values/integers.xml b/HW4/res/values/integers.xml
new file mode 100644
index 0000000..7721714
--- /dev/null
+++ b/HW4/res/values/integers.xml
@@ -0,0 +1,4 @@
+
+
+ 2
+
diff --git a/HW4/res/values/strings.xml b/HW4/res/values/strings.xml
new file mode 100644
index 0000000..0dd31f2
--- /dev/null
+++ b/HW4/res/values/strings.xml
@@ -0,0 +1,20 @@
+
+
+
+ In Class 3
+ Settings
+ Hello world!
+ http://farm9.staticflickr.com/8083/8415182658_5402d77eeb_z.jpg
+ http://farm9.staticflickr.com/8218/8278724118_9a28024cf5_z.jpg
+ http://farm9.staticflickr.com/8196/8114421135_7c5cbb874b_z.jpg
+ http://farm9.staticflickr.com/8441/7882624916_5f62cb318f_z.jpg
+ UNC Charlotte Photos
+ UNC Charlotte Photos
+ Exit
+ Error Downloading
+ UNC Charlotte
+ Sports
+ Ifest
+ Commencement
+
+
diff --git a/HW4/res/values/styles.xml b/HW4/res/values/styles.xml
new file mode 100644
index 0000000..4ea9326
--- /dev/null
+++ b/HW4/res/values/styles.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
diff --git a/HW4/src/com/example/hw4/MainActivity.java b/HW4/src/com/example/hw4/MainActivity.java
new file mode 100644
index 0000000..a5bc410
--- /dev/null
+++ b/HW4/src/com/example/hw4/MainActivity.java
@@ -0,0 +1,39 @@
+package com.example.hw4;
+
+/*
+ * Bradlee Speice, Brandon Rodenmayer
+ * ITIS 4180
+ * In Class 3
+ * MainActivity.java
+ */
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.content.Intent;
+import android.view.Menu;
+import android.view.View;
+
+public class MainActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+ public void onClick(View v) {
+ // One of our buttons has been clicked, let's start the activity and go!
+ if (v.getId() == R.id.btnAsync)
+ startActivity(new Intent(this, PhotoActivity.class));
+ else
+ startActivity(new Intent(this, PhotoThread.class));
+ }
+
+}
diff --git a/HW4/src/com/example/hw4/PhotoActivity.java b/HW4/src/com/example/hw4/PhotoActivity.java
new file mode 100644
index 0000000..f5f199c
--- /dev/null
+++ b/HW4/src/com/example/hw4/PhotoActivity.java
@@ -0,0 +1,182 @@
+package com.example.hw4;
+
+/*
+ * Bradlee Speice, Brandon Rodenmayer
+ * ITIS 4180
+ * In Class 3
+ * PhotoActivity.java
+ */
+
+import java.net.URL;
+import java.util.ArrayList;
+
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.app.Activity;
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.Button;
+import android.widget.GridView;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+public class PhotoActivity extends Activity {
+
+ ProgressDialog progress;
+ LinearLayout root;
+ GridView photoGrid;
+ int[] imageUrlIds = {R.string.uncc_main_image, R.string.football_main_image,
+ R.string.ifest_main_image, R.string.commencement_main_image
+ };
+ int[] imageNames = {R.string.uncc, R.string.sports, R.string.ifest, R.string.commencement};
+ ArrayList bitmapList = new ArrayList();
+ ArrayList bitmapNames = new ArrayList();
+ int downloadProgress;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_photo);
+
+ root = (LinearLayout)findViewById(R.id.layout_async);
+ photoGrid = (GridView)findViewById(R.id.grid_async);
+ downloadProgress = 0;
+
+ //set the progress dialog
+ progress = new ProgressDialog(this);
+ progress.setMessage("Loading...");
+ progress.setCancelable(false);
+ progress.show();
+
+ for(int x : imageUrlIds)//download images
+ {
+ new DownloadPhoto().execute(getString(x));
+ }
+
+ //create exit button
+ Button exit = (Button)findViewById(R.id.btn_exit_async);
+ exit.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v)
+ {
+ finish();
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.photo, menu);
+ return true;
+ }
+
+ private class DownloadPhoto extends AsyncTask
+ {
+ @Override
+ protected Bitmap doInBackground(String... url)
+ {
+ Bitmap image = null;
+
+ try
+ {
+ URL imageUrl = new URL(url[0]);
+ image = BitmapFactory.decodeStream(imageUrl.openStream());
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ }
+ return image;
+ }
+
+ @Override
+ protected void onPostExecute(Bitmap result)
+ {
+ //already a default picture included in grid_schema.xml, so no need to set a blank pic
+ bitmapList.add(result);
+ bitmapNames.add(getString(imageNames[downloadProgress]));
+
+ downloadProgress++;
+ if(downloadProgress>=imageUrlIds.length)
+ {
+ progress.dismiss();
+ //all images are loaded, so set them in the grid
+ photoGrid.setAdapter(new ImageAdapter(photoGrid.getContext()));
+ }
+ }
+ }
+
+ public class ImageAdapter extends BaseAdapter
+ {
+ private Context context;
+
+ public ImageAdapter(Context context)
+ {
+ this.context = context;
+ }
+
+ @Override
+ public int getCount()
+ {
+ return imageUrlIds.length;
+ }
+
+ @Override
+ public Object getItem(int position)//no purpose. only to fill the requirement of needing the method.
+ {
+ return position;
+ }
+
+ @Override
+ public long getItemId(int position)//no purpose. only to fill the requirement of needing the method.
+ {
+ return position;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent)
+ {
+ Holder holder = new Holder();
+ View vi = convertView;
+
+ if(vi == null)
+ {
+ //create layout of what we want one grid section to look like
+ vi = getLayoutInflater().inflate(R.layout.grid_schema, null);
+
+ holder.textView = (TextView)vi.findViewById(R.id.textView1);
+ holder.imageView = (ImageView)vi.findViewById(R.id.imageView1);
+
+ vi.setTag(holder);//associate the views in the holder to the grid
+ }
+ else
+ {
+ holder = (Holder)(vi.getTag());
+ }
+ //set the views in the grid to what was loaded
+ holder.textView.setText(getString(R.string.download_error));
+ if(bitmapList.get(position)!=null)
+ {
+ holder.imageView.setImageBitmap(bitmapList.get(position));
+ holder.textView.setText(bitmapNames.get(position));
+ }
+
+ return vi;
+ }
+ }
+
+ //views included in one grid section
+ static class Holder
+ {
+ TextView textView;
+ ImageView imageView;
+ }
+}