当前位置: 首页>>代码示例>>Java>>正文


Java SimpleSpringListener类代码示例

本文整理汇总了Java中com.facebook.rebound.SimpleSpringListener的典型用法代码示例。如果您正苦于以下问题:Java SimpleSpringListener类的具体用法?Java SimpleSpringListener怎么用?Java SimpleSpringListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SimpleSpringListener类属于com.facebook.rebound包,在下文中一共展示了SimpleSpringListener类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setSpringSystem

import com.facebook.rebound.SimpleSpringListener; //导入依赖的package包/类
private void setSpringSystem() {
    mSpringSystem = SpringSystem.create();
    mSpringsAlpha = mSpringSystem.createSpring()
            .setSpringConfig(alphaconfig)
            .setCurrentValue(1);

    mSpringsAlpha.addListener(new SimpleSpringListener() {

        @Override
        public void onSpringUpdate(Spring mSpring) {
            float value = (float) mSpring.getCurrentValue();
            mLockView.setAlpha(value);
        }
    });


}
 
开发者ID:MartinRGB,项目名称:android_camera_experiment,代码行数:18,代码来源:SandriosCameraActivity.java

示例2: applyFloatingAnimation

import com.facebook.rebound.SimpleSpringListener; //导入依赖的package包/类
@Override
public void applyFloatingAnimation(@NonNull final FloatingTextView view) {

    Spring scaleAnim = createSpringByBouncinessAndSpeed(10, 15)
            .addListener(new SimpleSpringListener() {
                @Override
                public void onSpringUpdate(@NonNull Spring spring) {
                    float transition = transition((float) spring.getCurrentValue(), 0.0f, 1.0f);
                    view.setScaleX(transition);
                    view.setScaleY(transition);
                }
            });
    
    ValueAnimator alphaAnimator = ObjectAnimator.ofFloat(1.0f, 0.0f);
    alphaAnimator.setDuration(duration);
    alphaAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(@NonNull ValueAnimator valueAnimator) {
            view.setAlpha((Float) valueAnimator.getAnimatedValue());
        }
    });
    scaleAnim.setEndValue(1f);
    alphaAnimator.start();
}
 
开发者ID:yzbzz,项目名称:beautifullife,代码行数:25,代码来源:ScaleFloatingAnimator.java

示例3: disappear

import com.facebook.rebound.SimpleSpringListener; //导入依赖的package包/类
public void disappear(boolean immediate, boolean animate) {
    ySpring.setEndValue(mParentHeight - centerY + chatHeadManager.getConfig().getCloseButtonHeight());
    ySpring.setSpringConfig(SpringConfigsHolder.NOT_DRAGGING);
    xSpring.setEndValue(0);
    ySpring.addListener(new SimpleSpringListener() {
        @Override
        public void onSpringAtRest(Spring spring) {
            super.onSpringAtRest(spring);
            ySpring.removeListener(this);
        }
    });
    scaleSpring.setEndValue(0.1f);
    if (!animate) {
        ySpring.setCurrentValue(mParentHeight, true);
        xSpring.setCurrentValue(0, true);
    }
    disappeared = true;
    if (listener != null) listener.onCloseButtonDisappear();

}
 
开发者ID:flipkart-incubator,项目名称:springy-heads,代码行数:21,代码来源:ChatHeadCloseButton.java

示例4: setMoreViewAnim

import com.facebook.rebound.SimpleSpringListener; //导入依赖的package包/类
public void setMoreViewAnim(){
    /*
    其中带参数的第一个参数表示起主导作用spring的拉力系数,
    第二个参数表示起主导作用Spring的摩擦力系数,
    第三个和第四个表示附属的拉力和摩擦力系数
     */
    SpringChain springChain = SpringChain.create(40,6,50,7);

    int childCount = viewGroup.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View view = viewGroup.getChildAt(i);

        springChain.addSpring(new SimpleSpringListener() {
            @Override
            public void onSpringUpdate(Spring spring) {
                view.setTranslationY((float) spring.getCurrentValue());
            }
        });
    }

    List<Spring> springs = springChain.getAllSprings();
    for (int i = 0; i < springs.size(); i++) {
        springs.get(i).setCurrentValue(400);
    }

    springChain.setControlSpringIndex(4).getControlSpring().setEndValue(0);

}
 
开发者ID:garyhu1,项目名称:collapselrecycler,代码行数:29,代码来源:FaceBookAnimActivity.java

示例5: initializeListeners

import com.facebook.rebound.SimpleSpringListener; //导入依赖的package包/类
private void initializeListeners() {
  SimpleSpringListener simpleSpringListener = null;
  if (prismPosition == PrismPosition.RIGHT) {
    simpleSpringListener = translationRight;
  } else if (prismPosition == PrismPosition.LEFT) {
    simpleSpringListener = translationLeft;
  } else if (prismPosition == PrismPosition.TOP) {
    simpleSpringListener = translationTop;
  } else if (prismPosition == PrismPosition.BOTTOM) {
    simpleSpringListener = translationBottom;
  }
  if (simpleSpringListener != null) {
    moveSpring().removeAllListeners().addListener(simpleSpringListener);
  }
}
 
开发者ID:ppamorim,项目名称:PrismView,代码行数:16,代码来源:PrismActivity.java

示例6: getFollowerListenerX

import com.facebook.rebound.SimpleSpringListener; //导入依赖的package包/类
public SimpleSpringListener getFollowerListenerX() {
    return followerListenerX;
}
 
开发者ID:monkeywiiu,项目名称:Discover,代码行数:4,代码来源:FloatButton.java

示例7: getFollowerListenerY

import com.facebook.rebound.SimpleSpringListener; //导入依赖的package包/类
public SimpleSpringListener getFollowerListenerY() {
    return followerListenerY;
}
 
开发者ID:monkeywiiu,项目名称:Discover,代码行数:4,代码来源:FloatButton.java

示例8: OrigamiExample

import com.facebook.rebound.SimpleSpringListener; //导入依赖的package包/类
public OrigamiExample(Context context, AttributeSet attrs, int defStyle) {
  super(context, attrs, defStyle);

  // Inflate the layout.
  LayoutInflater inflater = LayoutInflater.from(context);
  ViewGroup root = (ViewGroup) inflater.inflate(R.layout.origami_example, this, false);
  addView(root);

  // Listen for clicks on the root view.
  root.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
      handleClick(v);
    }
  });

  // Get references to our views.
  mPhotoGrid = root.findViewById(R.id.grid);
  mSelectedPhoto = root.findViewById(R.id.selection);
  mFeedbackBar = root.findViewById(R.id.feedback);
  mSpringConfiguratorView = (SpringConfiguratorView) root.findViewById(R.id.spring_configurator);

  // Setup the Spring by creating a SpringSystem adding a SimpleListener that renders the
  // animation whenever the spring is updated.
  mSpring = SpringSystem
      .create()
      .createSpring()
      .setSpringConfig(ORIGAMI_SPRING_CONFIG)
      .addListener(new SimpleSpringListener() {
        @Override
        public void onSpringUpdate(Spring spring) {
          // Just tell the UI to update based on the springs current state.
          render();
        }
      });


  // Here we just wait until the first layout pass finishes and call our render method to update
  // the animation to the initial resting state of the spring.
  mPhotoGrid.getViewTreeObserver().addOnGlobalLayoutListener(
      new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
          render();
          mPhotoGrid.getViewTreeObserver().removeOnGlobalLayoutListener(this);
        }
      });

  /** Optional - Live Spring Tuning **/

  // Put our config into a registry. This is optional, but it gives you the ability to live tune
  // the spring using the SpringConfiguratorView which will show up at the bottom of the screen.
  SpringConfigRegistry.getInstance().addSpringConfig(ORIGAMI_SPRING_CONFIG, "origami animation spring");
  // Tell the SpringConfiguratorView that we've updated the registry to allow you to live tune the animation spring.
  mSpringConfiguratorView.refreshSpringConfigurations();

  // Uncomment this line to actually show the SpringConfiguratorView allowing you to live tune
  // the Spring constants as you manipulate the UI.
  mSpringConfiguratorView.setVisibility(View.VISIBLE);
}
 
开发者ID:cheyiliu,项目名称:test4XXX,代码行数:61,代码来源:OrigamiExample.java

示例9: PhotoGalleryExample

import com.facebook.rebound.SimpleSpringListener; //导入依赖的package包/类
public PhotoGalleryExample(Context context) {
  super(context);

  int viewCount = ROWS * COLS;

  for (int i = 0; i < viewCount; i++) {
    final int j = i;

    // Create the View.
    final ImageView imageView = new ImageView(context);
    mImageViews.add(imageView);
    addView(imageView);
    imageView.setAlpha(0f);
    imageView.setBackgroundColor(Util.randomColor());
    imageView.setLayerType(LAYER_TYPE_HARDWARE, null);

    // Add an image for each view.
    int res = getResources().getIdentifier("d" + (i % 11 + 1), "drawable", context.getPackageName());
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    imageView.setImageResource(res);

    // Add a click listener to handle scaling up the view.
    imageView.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        int endValue = mSpring.getEndValue() == 0 ? 1 : 0;
        imageView.bringToFront();
        mActiveIndex = j;
        mSpring.setEndValue(endValue);
      }
    });

    // Add a spring to the SpringChain to do an entry animation.
    mSpringChain.addSpring(new SimpleSpringListener() {
      @Override
      public void onSpringUpdate(Spring spring) {
        render();
      }
    });
  }

  // Wait for layout.
  getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
    @Override
    public void onGlobalLayout() {
      layout();
      getViewTreeObserver().removeOnGlobalLayoutListener(this);

      postOnAnimationDelayed(new Runnable() {
        @Override
        public void run() {
          mSpringChain.setControlSpringIndex(0).getControlSpring().setEndValue(1);
        }
      }, 500);
    }
  });

}
 
开发者ID:cheyiliu,项目名称:test4XXX,代码行数:59,代码来源:PhotoGalleryExample.java

示例10: SpringChainExample

import com.facebook.rebound.SimpleSpringListener; //导入依赖的package包/类
public SpringChainExample(Context context) {
  super(context);

  LayoutInflater inflater = LayoutInflater.from(context);
  ViewGroup container = (ViewGroup) inflater.inflate(R.layout.cascade_effect, this, false);
  addView(container);
  ViewGroup rootView = (ViewGroup) container.findViewById(R.id.root);
  int bgColor = Color.argb(255, 17, 148, 231);
  setBackgroundColor(bgColor);
  rootView.setBackgroundResource(R.drawable.rebound_tiles);

  int startColor = Color.argb(255, 255, 64, 230);
  int endColor = Color.argb(255, 255, 230, 64);
  ArgbEvaluator evaluator = new ArgbEvaluator();
  int viewCount = 10;
  for (int i = 0; i < viewCount; i++) {
    final View view = new View(context);
    view.setLayoutParams(
        new TableLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT,
            1f));
    mSpringChain.addSpring(new SimpleSpringListener() {
      @Override
      public void onSpringUpdate(Spring spring) {
        float value = (float) spring.getCurrentValue();
        view.setTranslationX(value);
      }
    });
    int color = (Integer) evaluator.evaluate((float) i / (float) viewCount, startColor, endColor);
    view.setBackgroundColor(color);
    view.setOnTouchListener(new OnTouchListener() {
      @Override
      public boolean onTouch(View v, MotionEvent event) {
        return handleRowTouch(v, event);
      }
    });
    mViews.add(view);
    rootView.addView(view);
  }

  getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
    @Override
    public void onGlobalLayout() {
      getViewTreeObserver().removeOnGlobalLayoutListener(this);
      List<Spring> springs = mSpringChain.getAllSprings();
      for (int i = 0; i < springs.size(); i++) {
        springs.get(i).setCurrentValue(-mViews.get(i).getWidth());
      }
      postDelayed(new Runnable() {
        @Override
        public void run() {
          mSpringChain
              .setControlSpringIndex(0)
              .getControlSpring()
              .setEndValue(0);
        }
      }, 500);
    }
  });
}
 
开发者ID:cheyiliu,项目名称:test4XXX,代码行数:62,代码来源:SpringChainExample.java

示例11: OrigamiExample

import com.facebook.rebound.SimpleSpringListener; //导入依赖的package包/类
public OrigamiExample(Context context, AttributeSet attrs, int defStyle) {
  super(context, attrs, defStyle);

  // Inflate the layout.
  LayoutInflater inflater = LayoutInflater.from(context);
  ViewGroup root = (ViewGroup) inflater.inflate(R.layout.origami_example, this, false);
  addView(root);

  // Listen for clicks on the root view.
  root.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
      handleClick(v);
    }
  });

  // Get references to our views.
  mPhotoGrid = root.findViewById(R.id.grid);
  mSelectedPhoto = root.findViewById(R.id.selection);
  mFeedbackBar = root.findViewById(R.id.feedback);
  mSpringConfiguratorView = (SpringConfiguratorView) root.findViewById(R.id.spring_configurator);

  // Setup the Spring by creating a SpringSystem adding a SimpleListener that renders the
  // animation whenever the spring is updated.
  mSpring = SpringSystem
      .create()
      .createSpring()
      .setSpringConfig(ORIGAMI_SPRING_CONFIG)
      .addListener(new SimpleSpringListener() {
        @Override
        public void onSpringUpdate(Spring spring) {
          // Just tell the UI to update based on the springs current state.
          render();
        }
      });


  // Here we just wait until the first layout pass finishes and call our render method to update
  // the animation to the initial resting state of the spring.
  mPhotoGrid.getViewTreeObserver().addOnGlobalLayoutListener(
      new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
          render();
          mPhotoGrid.getViewTreeObserver().removeGlobalOnLayoutListener(this);
        }
      });

  /** Optional - Live Spring Tuning **/

  // Put our config into a registry. This is optional, but it gives you the ability to live tune
  // the spring using the SpringConfiguratorView which will show up at the bottom of the screen.
  SpringConfigRegistry.getInstance().addSpringConfig(ORIGAMI_SPRING_CONFIG, "origami animation spring");
  // Tell the SpringConfiguratorView that we've updated the registry to allow you to live tune the animation spring.
  mSpringConfiguratorView.refreshSpringConfigurations();

  // Uncomment this line to actually show the SpringConfiguratorView allowing you to live tune
  // the Spring constants as you manipulate the UI.
  mSpringConfiguratorView.setVisibility(View.VISIBLE);
}
 
开发者ID:ozodrukh,项目名称:Green,代码行数:61,代码来源:OrigamiExample.java


注:本文中的com.facebook.rebound.SimpleSpringListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。