/** * On the start of the activity use the selected photo and compare to the next closest photo by * default and then allow the user to select the second photo to compare to * * @param savedInstanceState all extras passed from the previous intents */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setCount(0); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.photo_comp); Vector<String> group = new Vector<String>(); Vector<PhotoEntry> photo = new Vector<PhotoEntry>(); Bundle extra = getIntent().getExtras(); final int photoId = (Integer) extra.get("photo"); photoEntry = PhotoApplication.getPhotoByID(photoId); group.add(photoEntry.getGroup()); groupText = (TextView) findViewById(R.id.comp_group); groupText.setText(photoEntry.getGroup().toString()); photo = PhotoApplication.getPhotosByValues(group, null); photoThumbIds = new Bitmap[photo.size()]; for (int i = 0; i < photo.size(); i++) { photoThumbIds[i] = photo.elementAt(i).getThumbnail(); } photoImageIds = new Bitmap[photo.size()]; for (int i = 0; i < photo.size(); i++) { photoThumbIds[i] = photo.elementAt(i).getBitmap(); } firstPhoto = (ImageView) findViewById(R.id.Photo1); secondPhoto = (ImageView) findViewById(R.id.Photo2); Gallery compGallery = (Gallery) findViewById(R.id.compGallery); compGallery.setAdapter(new ImageAdapter(this)); compGallery.setOnItemSelectedListener(this); }
public void onItemSelected(AdapterView<?> adapter, View v, int position, long id) { System.out.println("Iam here!!!\n"); System.out.print(position); System.out.println("\n"); if (flag == 2) { super.onStart(); firstPhoto.setImageBitmap(photoEntry.getBitmap()); secondPhoto.setImageBitmap(photoThumbIds[position]); } }