Code example for ClipDrawable

Methods: getLevelsetLevel

0
    
   private Runnable mUpdateTimeTask = new Runnable() {
		long start = SystemClock.uptimeMillis(); 
		public void run() { 
			long millis = SystemClock.uptimeMillis() - start; 
			drawable.setLevel(drawable.getLevel()  + (slideDistance/10 * slideDirection)); 
			if(( drawable.getLevel() > slideTarget && slideDirection == -1) || ( drawable.getLevel() < slideTarget && slideDirection == 1)) 
			mHandler.postAtTime(this, start + millis); 
			else  mHandler.removeCallbacks(mUpdateTimeTask); 
		} 
	}; 
	 
	public void cropSlide(int direction, int target){
		slideDirection = direction;
		slideTarget  = (int) (10000.0 - target/100.0*7500.0);
		Log.i("State", "target: " +slideTarget);
		slideOrigin = drawable.getLevel();
		slideDistance = Math.abs(slideTarget-slideOrigin);
		mHandler.removeCallbacks(mUpdateTimeTask);  //Remove old timer
	    mHandler.postDelayed(mUpdateTimeTask, 100); //How fast thread updated
	}