package com.uncc.hw3; /* * Bradlee Speice, Brandon Rodenmayer * ITIS 4180 * Homework 3 * MainActivity.java */ import java.util.ArrayList; import java.util.Collections; import android.os.Bundle; import android.os.Handler; import android.app.Activity; import android.view.Menu; import android.view.View; import android.widget.ImageView; public class MainActivity extends Activity { ImageView iv; public int [] imageViews = {R.id.imgTile1_1, R.id.imgTile1_2, R.id.imgTile1_3, R.id.imgTile1_4, R.id.imgTile2_1, R.id.imgTile2_2, R.id.imgTile2_3, R.id.imgTile2_4, R.id.imgTile3_1, R.id.imgTile3_2, R.id.imgTile3_3, R.id.imgTile3_4, R.id.imgTile4_1, R.id.imgTile4_2, R.id.imgTile4_3, R.id.imgTile4_4,}; public int[] iconIds = {R.drawable.diamond, R.drawable.garnet, R.drawable.gem, R.drawable.pearl, R.drawable.ruby, R.drawable.sapphire, R.drawable.swarovski, R.drawable.toppaz}; static ArrayList tiles; static ArrayList focusImages; Handler handler = new Handler(); static int focusIndex; static long startTime, endTime; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // If the result activity calls us with an EXIT in the extras, quit. if (getIntent().getBooleanExtra("EXIT", false)) finish(); newGame((View)findViewById(R.id.LinearLayout1)); focusImages.get(focusIndex).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.main, menu); return true; } public void newGame(View v) { tiles = new ArrayList(); focusImages = new ArrayList(); ArrayList focusImagesTemp = new ArrayList(); //Create list of board tiles and tiles to find for(int x: iconIds) { tiles.add(new Tile(null, x)); tiles.add(new Tile(null, x)); focusImagesTemp.add(new Tile((ImageView)findViewById(R.id.imgResult), x)); } //Shuffle Tiles Collections.shuffle(tiles); Collections.shuffle(focusImagesTemp); //Set focusImages list for(int x=0; x