Drawable getLevel - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Drawable getLevel method.

This code example shows how to use the following methods:getLevel
        final Drawable levelListDrawable = findViewById(R.id.LevelListButton).getBackground();
        timer.scheduleAtFixedRate(
                new TimerTask() {
                    @Override 
                    public void run() { 
                        final int level = levelListDrawable.getLevel();
                        handler.post(new Runnable() {
                            @Override 
                            public void run() { 
                                if (level == 0) {
                                    levelListDrawable.setLevel(1);
                                } else { 
                                    levelListDrawable.setLevel(0);
                                } 
                            } 
                        }); 
                    } 
                }, 
                TIMER_TASK_DELAY, TIMER_TASK_PERIOD);
 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getLevel, setLevel
        update(); 
        Animations.fadeIn(this, null);
    } 
 
    private void update() { 
        image.setLevel((image.getLevel() + 1) % 12);
        postDelayed(new Runnable() {
            @Override 
            public void run() { 
                update(); 
            } 
        }, 100); 
    } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getLevel, setLevel
        update(); 
        Animations.fadeIn(this, null);
    } 
 
    private void update() { 
        image.setLevel((image.getLevel() + 1) % 12);
        postDelayed(new Runnable() {
            @Override 
            public void run() { 
                update(); 
            } 
        }, 100); 
    } 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getLevel, setLevel
		mHandler.removeCallbacks(mUpdateTimeTask);  //Remove old timer
	    mHandler.postDelayed(mUpdateTimeTask, 100); //How fast thread updated
	} 
    
   public void buttonPressed(View view){
	   drawable.setLevel(drawable.getLevel() + 1);
	   Toast.makeText(this, "button pressed", Toast.LENGTH_SHORT).show();
   } 
    
	protected void onResume(){ 
		super.onResume(); 
	} 
	 
	public void slide(View view, float fromX, float toX, float fromY, float toY, int duration){
        TranslateAnimation slide = new TranslateAnimation(
        		Animation.RELATIVE_TO_PARENT, fromX/100,
        		Animation.RELATIVE_TO_PARENT, toX/100,
        		Animation.RELATIVE_TO_PARENT, fromY/100,
        		Animation.RELATIVE_TO_PARENT, toY/100);
        slide.setDuration(duration);
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getLevel, setLevel
		//always use the .png (.jpg could cause error) 
		final Handler handler = new Handler(){
			@Override 
			public void handleMessage(Message msg) {
				if (msg.what == 0x123) {
					drawable.setLevel(drawable.getLevel() + 200);
				} 
			} 
		}; 
		 
		final Timer timer = new Timer();
		timer.schedule(new TimerTask() {
			 
			@Override 
			public void run() { 
				Message msg = new Message();
				msg.what = 0x123;
				handler.sendMessage(msg);
				if (drawable.getLevel() >= 10000) {
					timer.cancel();
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getLevel, setLevel
        imageView = (ImageView) this.findViewById(R.id.imageView);
    } 
     
    public void changeImage(View v){
    	ClipDrawable clipDrawable = (ClipDrawable) imageView.getDrawable();
    	clipDrawable.setLevel(clipDrawable.getLevel()+1000);
    	 
    	/* 
    	TransitionDrawable transitionDrawable = (TransitionDrawable) ((Button)v).getBackground(); 
    	transitionDrawable.startTransition(500); 
    	*/ 
    	 
    	/* 
    	LevelListDrawable levelListDrawable = (LevelListDrawable) imageView.getDrawable(); 
    	levelListDrawable.setLevel(12); 
    	*/ 
    	/* 
    	//LayerDrawable layerDrawable = (LayerDrawable) imageView.getDrawable(); 
    	LayerDrawable layerDrawable = (LayerDrawable)getResources().getDrawable(R.drawable.layerlist); 
    	Drawable drawable = getResources().getDrawable(R.drawable.icon); 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getLevel, setLevel
    
   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
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Drawable getLevel Questions & Answers:

getLevel Method Overview
Retrieve the current level.
See Code Examples for other Android Drawable Methods: