Code example for AtomicBoolean

Methods: getAndSet, set

0
		VolumeView volume = (VolumeView)view.findViewById(R.id.brightnessPicker);
		volume.setOnVolumeChangedListener(new VolumeView.OnVolumeChangedListener() {
			private AtomicBoolean mChangeIsInProgress = new AtomicBoolean(false);
			 
			public void onVolumeChanged(int percent) {
				if(!mChangeIsInProgress.getAndSet(true)) {		
					final int intensity = (int)(2.55f * percent);
					final int c = (((intensity << 8) | intensity) << 8) | intensity;
					onSetColor(c);
					mChangeIsInProgress.set(false);
				} 
			} 
		}); 
		return view;
	} 
}