mirror of
				https://github.com/bspeice/itcs4180
				synced 2025-11-04 02:10:32 -05:00 
			
		
		
		
	Fixed main activity errors and added click function to start
GalleryActivity. Started working on GalleryActivity.
This commit is contained in:
		
							
								
								
									
										53
									
								
								HW4/src/com/example/hw4/GalleryActivity.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								HW4/src/com/example/hw4/GalleryActivity.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,53 @@
 | 
			
		||||
package com.example.hw4;
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Bradlee Speice, Brandon Rodenmayer
 | 
			
		||||
 * ITIS 4180
 | 
			
		||||
 * Homework 4
 | 
			
		||||
 * GalleryActivity.java
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
import android.app.Activity;
 | 
			
		||||
import android.os.Bundle;
 | 
			
		||||
import android.view.LayoutInflater;
 | 
			
		||||
import android.view.Menu;
 | 
			
		||||
import android.view.MenuItem;
 | 
			
		||||
import android.view.View;
 | 
			
		||||
import android.widget.GridView;
 | 
			
		||||
import android.widget.Toast;
 | 
			
		||||
 | 
			
		||||
public class GalleryActivity extends Activity 
 | 
			
		||||
{
 | 
			
		||||
	GridView gallery;
 | 
			
		||||
	int thumbsId;
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	protected void onCreate(Bundle savedInstanceState) 
 | 
			
		||||
	{
 | 
			
		||||
		super.onCreate(savedInstanceState);
 | 
			
		||||
		setContentView(R.layout.activity_gallery);
 | 
			
		||||
		
 | 
			
		||||
		thumbsId = getIntent().getExtras().getInt("thumbsId");
 | 
			
		||||
		Toast.makeText(getApplicationContext(), thumbsId, Toast.LENGTH_LONG).show();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean onCreateOptionsMenu(Menu menu) {
 | 
			
		||||
 | 
			
		||||
		// Inflate the menu; this adds items to the action bar if it is present.
 | 
			
		||||
		getMenuInflater().inflate(R.menu.gallery, menu);
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean onOptionsItemSelected(MenuItem item) {
 | 
			
		||||
		// Handle action bar item clicks here. The action bar will
 | 
			
		||||
		// automatically handle clicks on the Home/Up button, so long
 | 
			
		||||
		// as you specify a parent activity in AndroidManifest.xml.
 | 
			
		||||
		int id = item.getItemId();
 | 
			
		||||
		if (id == R.id.action_settings) {
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
		return super.onOptionsItemSelected(item);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -3,8 +3,8 @@ package com.example.hw4;
 | 
			
		||||
/*
 | 
			
		||||
 * Bradlee Speice, Brandon Rodenmayer
 | 
			
		||||
 * ITIS 4180
 | 
			
		||||
 * In Class 3
 | 
			
		||||
 * PhotoActivity.java
 | 
			
		||||
 * Homework 4
 | 
			
		||||
 * MainActivity.java
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
@ -15,12 +15,15 @@ import android.os.Bundle;
 | 
			
		||||
import android.app.Activity;
 | 
			
		||||
import android.app.ProgressDialog;
 | 
			
		||||
import android.content.Context;
 | 
			
		||||
import android.content.Intent;
 | 
			
		||||
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.AdapterView;
 | 
			
		||||
import android.widget.AdapterView.OnItemClickListener;
 | 
			
		||||
import android.widget.BaseAdapter;
 | 
			
		||||
import android.widget.Button;
 | 
			
		||||
import android.widget.GridView;
 | 
			
		||||
@ -33,19 +36,23 @@ public class MainActivity 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};
 | 
			
		||||
	int[] imageUrlIds = {R.string.uncc_main_thumb, R.string.football_main_thumb,
 | 
			
		||||
			R.string.ifest_main_thumb, R.string.commencement_main_thumb
 | 
			
		||||
	}; 
 | 
			
		||||
	int[] imageNames = {R.string.label_uncc, R.string.label_sports, R.string.label_ifest, R.string.label_commencement};
 | 
			
		||||
	int[] thumbNames = {R.array.uncc_thumbs, R.array.football_thumbs, R.array.ifest_thumbs, R.array.commencement_thumbs};
 | 
			
		||||
	ArrayList<Bitmap> bitmapList = new ArrayList<Bitmap>();
 | 
			
		||||
	ArrayList<String> bitmapNames = new ArrayList<String>();
 | 
			
		||||
	int downloadProgress;
 | 
			
		||||
	Intent galleryIntent;
 | 
			
		||||
	ImageAdapter imageAdapter;
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	protected void onCreate(Bundle savedInstanceState) {
 | 
			
		||||
		super.onCreate(savedInstanceState);
 | 
			
		||||
		setContentView(R.layout.activity_main);
 | 
			
		||||
		
 | 
			
		||||
		galleryIntent = new Intent(this, GalleryActivity.class);
 | 
			
		||||
		root = (LinearLayout)findViewById(R.id.layout_async);
 | 
			
		||||
		photoGrid = (GridView)findViewById(R.id.grid_async);
 | 
			
		||||
		downloadProgress = 0;
 | 
			
		||||
@ -109,7 +116,20 @@ public class MainActivity extends Activity {
 | 
			
		||||
			{
 | 
			
		||||
				progress.dismiss();
 | 
			
		||||
				//all images are loaded, so set them in the grid
 | 
			
		||||
				photoGrid.setAdapter(new ImageAdapter(photoGrid.getContext()));
 | 
			
		||||
				imageAdapter = new ImageAdapter(photoGrid.getContext());
 | 
			
		||||
				photoGrid.setAdapter(imageAdapter);
 | 
			
		||||
				
 | 
			
		||||
				photoGrid.setOnItemClickListener(new OnItemClickListener()
 | 
			
		||||
				{
 | 
			
		||||
					@Override
 | 
			
		||||
					public void onItemClick(AdapterView<?> parent, View view,
 | 
			
		||||
							int position, long id) 
 | 
			
		||||
					{
 | 
			
		||||
						//Send intent with R.array.label
 | 
			
		||||
						galleryIntent.putExtra("thumbsId", (int)(imageAdapter.getItem(position)));
 | 
			
		||||
						startActivity(galleryIntent);
 | 
			
		||||
					}
 | 
			
		||||
				});
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@ -130,9 +150,9 @@ public class MainActivity extends Activity {
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		@Override
 | 
			
		||||
		public Object getItem(int position)//no purpose. only to fill the requirement of needing the method.
 | 
			
		||||
		public Object getItem(int position)
 | 
			
		||||
		{
 | 
			
		||||
			return position;
 | 
			
		||||
			return thumbNames[position];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		@Override
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user