ViewAnimator getCurrentView - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:getChildAt, getChildCount, getCurrentView, getDisplayedChild, setDisplayedChild
	 * @param viewAnimator the {@code ViewAnimator} 
	 * @param dir the direction of flip 
	 */ 
	public static void flipTransition(final ViewAnimator viewAnimator, FlipDirection dir, long duration) {   
		 
		final View fromView = viewAnimator.getCurrentView();
		 
		final int currentIndex = viewAnimator.getDisplayedChild();
		final int nextIndex = (currentIndex + 1) % viewAnimator.getChildCount();
		 
		final View toView = viewAnimator.getChildAt(nextIndex);
 
		Animation[] animc = AnimationFactory.flipAnimation(fromView, toView, dir, duration);
   
		viewAnimator.setOutAnimation(animc[0]);
		viewAnimator.setInAnimation(animc[1]);
		 
		viewAnimator.setDisplayedChild(nextIndex); 
	} 
	 

6
CodeRank
This code example shows how to use the following methods:getCurrentView, setInAnimation, setOutAnimation, showNext, showPrevious
This code example shows how to use the following methods:addView, getCurrentView, getDisplayedChild, showNext
    @Test 
    public void testAnimatorHandlesCyclingViews() { 
        View v1 = new View(null);
        View v2 = new View(null);
         
        animator.addView(v1);
        animator.addView(v2);
         
        animator.showNext();
         
        assertEquals(1, animator.getDisplayedChild());
        assertEquals(v2, animator.getCurrentView());
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getChildAt, getChildCount, getCurrentView, getDisplayedChild, setInAnimation
         * @param viewAnimator the {@code ViewAnimator} 
         * @param dir the direction of flip 
         */ 
        public static void flipTransition(final ViewAnimator viewAnimator, FlipDirection dir) {  
                
                final View fromView = viewAnimator.getCurrentView();
                final int currentIndex = viewAnimator.getDisplayedChild();
                final int nextIndex = (currentIndex + 1)%viewAnimator.getChildCount();
                
                final View toView = viewAnimator.getChildAt(nextIndex);
 
                Animation[] animc = AnimationFactory.flipAnimation(fromView, toView, (nextIndex < currentIndex?dir.theOtherDirection():dir), 500, null);
  
                viewAnimator.setOutAnimation(animc[0]);
                viewAnimator.setInAnimation(animc[1]);
                
                viewAnimator.showNext();  
        } 
        
        ////////////// 

5
CodeRank
This code example shows how to use the following methods:getCurrentView, setInAnimation, setOutAnimation, showNext
This code example shows how to use the following methods:getChildCount, indexOfChild, getCurrentView
			} 
 
		} 
 
		public boolean hasNext(ViewFlipper flipper) {
			if (flipper.indexOfChild(flipper.getCurrentView()) == flipper
					.getChildCount() - 1) {
				return false; 
			} 
			return true; 
		} 
 
		public boolean hasPrevious(ViewFlipper flipper) {
			if (flipper.indexOfChild(flipper.getCurrentView()) == 0) {
				return false; 
			} 
			return true; 
		} 
 
	} 
5
CodeRank
This code example shows how to use the following methods:getChildAt, getCurrentView, showNext
	public boolean onTouch(View v, MotionEvent event) {
		ViewFlipper f = (ViewFlipper) v;
		f.showNext();
		//Make sure only one ListItem is currently flipped 
		//TODO check feedback what way is better 
		if (currentlyFlipped != null && currentlyFlipped.getCurrentView().equals(
						currentlyFlipped.getChildAt(1)) && currentlyFlipped != f){
			currentlyFlipped.showNext();
		} 
		currentlyFlipped = f;
		return false; 
	} 
 
} 
5
CodeRank
This code example shows how to use the following methods:getChildCount, indexOfChild, getCurrentView
			} 
 
		} 
 
		public boolean hasNext(ViewFlipper flipper) {
			if (flipper.indexOfChild(flipper.getCurrentView()) == flipper
					.getChildCount() - 1) {
				return false; 
			} 
			return true; 
		} 
 
		public boolean hasPrevious(ViewFlipper flipper) {
			if (flipper.indexOfChild(flipper.getCurrentView()) == 0) {
				return false; 
			} 
			return true; 
		} 
 
	} 
5
CodeRank
This code example shows how to use the following methods:invalidate, getCurrentView, showNext
      progressBar.setMax(totalSize);
      progressBar.setProgress(bytesDone);
    } else { 
      progressDetails.setText(String.format(PROGRESS_FORMAT, bytesDone / 1024));
    } 
    progressDisplay.invalidate();
  } 
 
  /** 
   * Switch the UI to display either a progress bar or a spinner with details 
   * about download progress. 
   * 
   * @param displayBar if {@code true} will display progress bar, otherwise will 
   * display spinner and text view with downloaded byte count 
   */ 
  private void displayProgressBar(boolean displayBar) {
    boolean needsSwitching =
        (displayBar ? progressDisplay.getCurrentView() != progressBar :
                      progressDisplay.getCurrentView() == progressBar);
    if (needsSwitching) {

5
CodeRank
This code example shows how to use the following methods:getChildAt, getCurrentView
  public void setContentView(int which) {
    flipper.setDisplayedChild(which);
  } 
 
  public void animateContentView(final int child) {
    final View currentView = flipper.getCurrentView();
    final View nextView = flipper.getChildAt(child);
    TextView text1 = (TextView) currentView.findViewById(android.R.id.text1);
    TextView text2 = (TextView) currentView.findViewById(android.R.id.text2);
 
    AnimatorSet fadeAnim = new AnimatorSet();
    fadeAnim.playTogether(ObjectAnimator.ofFloat(text1, "alpha", 1, 0),
        ObjectAnimator.ofFloat(text2, "alpha", 1, 0));
 
    // AnimatorSet scaleAnim = new AnimatorSet(); 
    // scaleAnim.playTogether(ObjectAnimator.ofFloat(currentView, "scaleX", 1, 0.5f), 
    // ObjectAnimator.ofFloat(currentView, "scaleY", 1, 0.5f)); 
    // 
    // AnimatorSet flipAnim = new AnimatorSet(); 
    // flipAnim.playTogether(ObjectAnimator.ofFloat(currentView, "rotationX", 0, 90)); 
5
CodeRank

Related ViewAnimator getCurrentView Questions & Answers:

getCurrentView Method Overview
Returns the View corresponding to the currently displayed child.
See Code Examples for other Android ViewAnimator Methods: