Example #1
0
 private void hideLoading() {
   ViewAnimator viewAnimator = (ViewAnimator) findViewById(R.id.viewAnimator);
   viewAnimator.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left));
   viewAnimator.setOutAnimation(
       AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right));
   viewAnimator.showNext();
 }
  private void setupInput() {
    inputSwitcher.setInAnimation(getAnimation(R.anim.alpha_in, true));
    inputSwitcher.setOutAnimation(getAnimation(R.anim.alpha_out, false));

    inputSwitcher.removeAllViews();
    for (int i = 0; i < steps.size(); i++) {
      inputSwitcher.addView(getStep(i).getView());
    }
  }
  private void setupInput() {
    mInputSwitcher.setInAnimation(getAnimation(R.anim.alpha_in, true));
    mInputSwitcher.setOutAnimation(getAnimation(R.anim.alpha_out, false));

    mInputSwitcher.removeAllViews();
    System.out.println("Step size = " + stepsSize());
    for (int i = 0; i < stepsSize(); i++) {
      System.out.println("Problem with " + i + "?");
      mInputSwitcher.addView(getStep(i).getView());
    }
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRoot = inflater.inflate(R.layout.humidor, container, false);
    FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
    mFragment = new FloatingActionButtonBasicFragment();

    // Creating The ViewPagerAdapter and Passing Fragment Manager, Titles fot the Tabs and Number Of
    // Tabs.
    adapter = new ViewPagerAdapter(getActivity().getSupportFragmentManager(), Titles, Numboftabs);

    // Assigning ViewPager View and setting the adapter
    pager = (ViewPager) mRoot.findViewById(R.id.pager);
    pager.setAdapter(adapter);

    // Assiging the Sliding Tab Layout View
    tabs = (SlidingTabLayout) mRoot.findViewById(R.id.tabs);
    // To make the Tabs Fixed set this true, This makes the tabs Space Evenly in Available width
    // Setting Custom Color for the Scroll bar indicator of the Tab View
    tabs.setCustomTabColorizer(
        new SlidingTabLayout.TabColorizer() {

          @Override
          public int getIndicatorColor(int position) {
            return getResources().getColor(R.color.accent);
          }

          @Override
          public int getDividerColor(int position) {
            return getResources().getColor(R.color.tab);
          }
        });

    // Setting the ViewPager For the SlidingTabsLayout
    tabs.setViewPager(pager);
    transaction.replace(R.id.action_button_fragment, mFragment);
    transaction.commit();
    mAnimate = (ViewAnimator) mRoot.findViewById(R.id.cigaradd);
    mAnimate.setInAnimation(
        AnimationUtils.loadAnimation(getActivity(), R.anim.abc_grow_fade_in_from_bottom));
    mAnimate.setOutAnimation(
        AnimationUtils.loadAnimation(getActivity(), R.anim.abc_shrink_fade_out_from_bottom));
    mButton = (Button) mRoot.findViewById(R.id.toggle);
    mButton.setOnClickListener(this);
    return mRoot;
  }
  /**
   * Flip to the next view of the {@code ViewAnimator}'s subviews. A call to this method will
   * initiate a {@link FlipAnimation} to show the next View. If the currently visible view is the
   * last view, flip direction will be reversed for this transition.
   *
   * @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);
  }
  @SuppressWarnings("deprecation")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mSavedInstanceState = savedInstanceState;

    final Animation inAnimation = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left);
    inAnimation.setAnimationListener(mInAnimationListener);

    final Animation outAnimation = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left);

    mRepeatHandler = new RepeatHandler(this);

    mFeedbackController = new FeedbackController(this);

    mViewAnimator = new ViewAnimator(this);
    mViewAnimator.setInAnimation(inAnimation);
    mViewAnimator.setOutAnimation(outAnimation);
    mViewAnimator.addView(new TouchTutorialModule1(this));
    mViewAnimator.addView(new TouchTutorialModule2(this));
    mViewAnimator.addView(new TouchTutorialModule3(this));
    mViewAnimator.addView(new TouchTutorialModule4(this));

    // Module 5 (text editing) requires JellyBean MR2 (API 18) features.
    if (Build.VERSION.SDK_INT >= TouchTutorialModule5.MIN_API_LEVEL) {
      mViewAnimator.addView(new TouchTutorialModule5(this));
    }

    // Ensure the screen stays on and doesn't change orientation.
    final Window window = getWindow();
    final WindowManager.LayoutParams params = window.getAttributes();
    params.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
    params.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
    window.setAttributes(params);

    setContentView(mViewAnimator);

    mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE);

    // Lock the screen orientation until the first instruction is read.
    lockOrientation();

    mFirstTimeResume = true;
  }
  public ViewAnimator(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a =
        context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.ViewAnimator);
    int resource = a.getResourceId(com.android.internal.R.styleable.ViewAnimator_inAnimation, 0);
    if (resource > 0) {
      setInAnimation(context, resource);
    }

    resource = a.getResourceId(com.android.internal.R.styleable.ViewAnimator_outAnimation, 0);
    if (resource > 0) {
      setOutAnimation(context, resource);
    }
    a.recycle();

    initViewAnimator(context, attrs);
  }
  public void flipTransition(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);
    Animation[] animc = AnimationFactory.flipAnimation(fromView, toView, dir, 500, null);

    animc[0].setAnimationListener(this);

    viewAnimator.setOutAnimation(animc[0]);
    viewAnimator.setInAnimation(animc[1]);

    viewAnimator.showNext();
  }
 /**
  * Specifies the animation used to animate a View that exit the screen.
  *
  * @param context The application's environment.
  * @param resourceID The resource id of the animation.
  * @see #getOutAnimation()
  * @see #setOutAnimation(android.view.animation.Animation)
  */
 public void setOutAnimation(Context context, int resourceID) {
   setOutAnimation(AnimationUtils.loadAnimation(context, resourceID));
 }