int index = -1;   if (loadPicture != null) { index = pictures.indexOf(loadPicture);  if (wantDownloaded.contains(loadPicture) && (loadPicture != userPicture || user)) {  wantDownloaded.remove(loadPicture); }
if (loadPicture != null && wantDownloaded.contains(loadPicture) && (loadPicture != userPicture || user)) {  wantDownloaded.remove(loadPicture);
	public boolean next(boolean user) {		int index = -1;		//Log.log(Log.LEVEL_TRACE, MODULE, "running: " + running + " shutdown: " + shutdown + " loadpicture " + loadPicture);		if (loadPicture != null) {			index = pictures.indexOf(loadPicture);			if (wantDownloaded.contains(loadPicture) && (loadPicture != userPicture || user)) {				// we no longer want the current picture				wantDownloaded.remove(loadPicture);			}		}		index++;		if (index >= pictures.size()) {			return false;		}		Log.log(Log.LEVEL_TRACE, MODULE, "Next picture");		//Log.logStack(Log.LEVEL_TRACE, MODULE);		// display next picture		Picture picture = (Picture) pictures.get(index);		if (user) {			userPicture = picture;		} else if (userPicture != null && userPicture != picture) {			// automatic move trying to move away from user-chosen picture			// add delay to prevent endless loop			try {				Thread.sleep(1000);			} catch (InterruptedException e) {}			return true;		}		wantDownloaded.add(picture);		updateProgress(picture, STATE_NONE);		displayPicture(picture, false);		// and cache the one after it		if (++index < pictures.size() && (imageIcons.get(picture = (Picture) pictures.get(index))) == null) {			wantDownloaded.add(picture);			previewLoader.loadPreview(picture, true);		}		return true;	}