android.animation.ObjectAnimator.addListener()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(11.3k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中android.animation.ObjectAnimator.addListener()方法的一些代码示例,展示了ObjectAnimator.addListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectAnimator.addListener()方法的具体详情如下:
包路径:android.animation.ObjectAnimator
类名称:ObjectAnimator
方法名:addListener

ObjectAnimator.addListener介绍

暂无

代码示例

代码示例来源:origin: PhilJay/MPAndroidChart

@SuppressLint("NewApi")
public AnimatedZoomJob(ViewPortHandler viewPortHandler, View v, Transformer trans, YAxis axis, float xAxisRange, float scaleX, float scaleY, float xOrigin, float yOrigin, float zoomCenterX, float zoomCenterY, float zoomOriginX, float zoomOriginY, long duration) {
  super(viewPortHandler, scaleX, scaleY, trans, v, xOrigin, yOrigin, duration);
  this.zoomCenterX = zoomCenterX;
  this.zoomCenterY = zoomCenterY;
  this.zoomOriginX = zoomOriginX;
  this.zoomOriginY = zoomOriginY;
  this.animator.addListener(this);
  this.yAxis = axis;
  this.xAxisRange = xAxisRange;
}

代码示例来源:origin: ZieIony/Carbon

public static void setAutoCancel(final ObjectAnimator animator) {
  animator.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationStart(Animator animation) {
      for (WeakReference<ObjectAnimator> wa : sRunningAnimators) {
        ObjectAnimator a = wa.get();
        if (a == null) {
          continue;
        }
        if (hasSameTargetAndProperties(animator, a)) {
          a.cancel();
        }
      }
    }
  });
}

代码示例来源:origin: PhilJay/MPAndroidChart

public AnimatedViewPortJob(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, View v, float xOrigin, float yOrigin, long duration) {
  super(viewPortHandler, xValue, yValue, trans, v);
  this.xOrigin = xOrigin;
  this.yOrigin = yOrigin;
  animator = ObjectAnimator.ofFloat(this, "phase", 0f, 1f);
  animator.setDuration(duration);
  animator.addUpdateListener(this);
  animator.addListener(this);
}

代码示例来源:origin: frogermcs/InstaMaterial

private void setupSimulateProgressAnimator() {
  simulateProgressAnimator = ObjectAnimator.ofFloat(this, "currentProgress", 0, 100).setDuration(2000);
  simulateProgressAnimator.setInterpolator(new AccelerateInterpolator());
  simulateProgressAnimator.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
      changeState(STATE_DONE_STARTED);
    }
  });
}

代码示例来源:origin: TakuSemba/Spotlight

void finishSpotlight(long duration, TimeInterpolator animation,
  AbstractAnimatorListener listener) {
 ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(this, "alpha", 1f, 0f);
 objectAnimator.setDuration(duration);
 objectAnimator.setInterpolator(animation);
 objectAnimator.addListener(listener);
 objectAnimator.start();
}

代码示例来源:origin: TakuSemba/Spotlight

void startSpotlight(long duration, TimeInterpolator animation,
  AbstractAnimatorListener listener) {
 ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(this, "alpha", 0f, 1f);
 objectAnimator.setDuration(duration);
 objectAnimator.setInterpolator(animation);
 objectAnimator.addListener(listener);
 objectAnimator.start();
}

代码示例来源:origin: frogermcs/InstaMaterial

private void setupDoneAnimators() {
  doneBgAnimator = ObjectAnimator.ofFloat(this, "currentDoneBgOffset", MAX_DONE_BG_OFFSET, 0).setDuration(300);
  doneBgAnimator.setInterpolator(new DecelerateInterpolator());
  checkmarkAnimator = ObjectAnimator.ofFloat(this, "currentCheckmarkOffset", MAX_DONE_IMG_OFFSET, 0).setDuration(300);
  checkmarkAnimator.setInterpolator(new OvershootInterpolator());
  checkmarkAnimator.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
      changeState(STATE_FINISHED);
    }
  });
}

代码示例来源:origin: arimorty/floatingsearchview

@Override
public void onFocus() {
  int headerHeight = getResources().getDimensionPixelOffset(R.dimen.sliding_search_view_header_height);
  ObjectAnimator anim = ObjectAnimator.ofFloat(mSearchView, "translationY",
      headerHeight, 0);
  anim.setDuration(350);
  fadeDimBackground(0, 150, null);
  anim.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
      //show suggestions when search bar gains focus (typically history suggestions)
      mSearchView.swapSuggestions(DataHelper.getHistory(getActivity(), 3));
    }
  });
  anim.start();
  Log.d(TAG, "onFocus()");
}

代码示例来源:origin: naman14/Timber

private void hideBubble() {
  if (currentAnimator != null)
    currentAnimator.cancel();
  currentAnimator = ObjectAnimator.ofFloat(bubble, "alpha", 1f, 0f).setDuration(BUBBLE_ANIMATION_DURATION);
  currentAnimator.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
      super.onAnimationEnd(animation);
      bubble.setVisibility(INVISIBLE);
      currentAnimator = null;
    }
    @Override
    public void onAnimationCancel(Animator animation) {
      super.onAnimationCancel(animation);
      bubble.setVisibility(INVISIBLE);
      currentAnimator = null;
    }
  });
  currentAnimator.start();
}

代码示例来源:origin: lyft/scissors

@OnClick(R.id.ratio_fab)
public void onRatioClicked() {
  final float oldRatio = cropView.getImageRatio();
  selectedRatio = (selectedRatio + 1) % ASPECT_RATIOS.length;
  // Since the animation needs to interpolate to the native
  // ratio, we need to get that instead of using 0
  float newRatio = ASPECT_RATIOS[selectedRatio];
  if (Float.compare(0, newRatio) == 0) {
    newRatio = cropView.getImageRatio();
  }
  ObjectAnimator viewportRatioAnimator = ObjectAnimator.ofFloat(cropView, "viewportRatio", oldRatio, newRatio)
      .setDuration(420);
  autoCancel(viewportRatioAnimator);
  viewportRatioAnimator.addListener(animatorListener);
  viewportRatioAnimator.start();
  Toast.makeText(this, ASPECT_LABELS[selectedRatio], Toast.LENGTH_SHORT).show();
}

代码示例来源:origin: seven332/EhViewer

private void showSlider(View sliderPanel) {
  if (null != mSeekBarPanelAnimator) {
    mSeekBarPanelAnimator.cancel();
    mSeekBarPanelAnimator = null;
  }
  sliderPanel.setTranslationY(sliderPanel.getHeight());
  sliderPanel.setVisibility(View.VISIBLE);
  mSeekBarPanelAnimator = ObjectAnimator.ofFloat(sliderPanel, "translationY", 0.0f);
  mSeekBarPanelAnimator.setDuration(SLIDER_ANIMATION_DURING);
  mSeekBarPanelAnimator.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR);
  mSeekBarPanelAnimator.addUpdateListener(mUpdateSliderListener);
  mSeekBarPanelAnimator.addListener(mShowSliderListener);
  mSeekBarPanelAnimator.start();
  if (null != mSystemUiHelper) {
    mSystemUiHelper.show();
    mShowSystemUi = true;
  }
}

代码示例来源:origin: seven332/EhViewer

private void hideSlider(View sliderPanel) {
  if (null != mSeekBarPanelAnimator) {
    mSeekBarPanelAnimator.cancel();
    mSeekBarPanelAnimator = null;
  }
  mSeekBarPanelAnimator = ObjectAnimator.ofFloat(sliderPanel, "translationY", sliderPanel.getHeight());
  mSeekBarPanelAnimator.setDuration(SLIDER_ANIMATION_DURING);
  mSeekBarPanelAnimator.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR);
  mSeekBarPanelAnimator.addUpdateListener(mUpdateSliderListener);
  mSeekBarPanelAnimator.addListener(mHideSliderListener);
  mSeekBarPanelAnimator.start();
  if (null != mSystemUiHelper) {
    mSystemUiHelper.hide();
    mShowSystemUi = false;
  }
}

代码示例来源:origin: frogermcs/InstaMaterial

public void startFromLocation(int[] tapLocationOnScreen) {
  changeState(STATE_FILL_STARTED);
  startLocationX = tapLocationOnScreen[0];
  startLocationY = tapLocationOnScreen[1];
  revealAnimator = ObjectAnimator.ofInt(this, "currentRadius", 0, getWidth() + getHeight()).setDuration(FILL_TIME);
  revealAnimator.setInterpolator(INTERPOLATOR);
  revealAnimator.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
      changeState(STATE_FINISHED);
    }
  });
  revealAnimator.start();
}

代码示例来源:origin: k9mail/k-9

public void displayViewOnLoadFinished(boolean finishProgressBar) {
  if (!finishProgressBar || !isShowingProgress) {
    viewAnimator.setDisplayedChild(2);
    return;
  }
  ObjectAnimator animator = ObjectAnimator.ofInt(
      progressBar, "progress", progressBar.getProgress(), PROGRESS_MAX);
  animator.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animator) {
      viewAnimator.setDisplayedChild(2);
    }
  });
  animator.setDuration(PROGRESS_STEP_DURATION);
  animator.start();
}

代码示例来源:origin: PhilJay/MPAndroidChart

protected void resetAnimator(){
  animator.removeAllListeners();
  animator.removeAllUpdateListeners();
  animator.reverse();
  animator.addUpdateListener(this);
  animator.addListener(this);
}

代码示例来源:origin: Flipboard/bottomsheet

/**
 * Set the presented sheet to be in a peeked state.
 */
public void peekSheet() {
  cancelCurrentAnimation();
  setSheetLayerTypeIfEnabled(LAYER_TYPE_HARDWARE);
  ObjectAnimator anim = ObjectAnimator.ofFloat(this, SHEET_TRANSLATION, getPeekSheetTranslation());
  anim.setDuration(ANIMATION_DURATION);
  anim.setInterpolator(animationInterpolator);
  anim.addListener(new CancelDetectionAnimationListener() {
    @Override
    public void onAnimationEnd(@NonNull Animator animation) {
      if (!canceled) {
        currentAnimator = null;
      }
    }
  });
  anim.start();
  currentAnimator = anim;
  setState(State.PEEKED);
}

代码示例来源:origin: Flipboard/bottomsheet

/**
 * Set the presented sheet to be in an expanded state.
 */
public void expandSheet() {
  cancelCurrentAnimation();
  setSheetLayerTypeIfEnabled(LAYER_TYPE_NONE);
  ObjectAnimator anim = ObjectAnimator.ofFloat(this, SHEET_TRANSLATION, getMaxSheetTranslation());
  anim.setDuration(ANIMATION_DURATION);
  anim.setInterpolator(animationInterpolator);
  anim.addListener(new CancelDetectionAnimationListener() {
    @Override
    public void onAnimationEnd(@NonNull Animator animation) {
      if (!canceled) {
        currentAnimator = null;
      }
    }
  });
  anim.start();
  currentAnimator = anim;
  setState(State.EXPANDED);
}

代码示例来源:origin: xmuSistone/AndroidPileLayout

private void transitionSecene(int position) {
  if (transitionAnimator != null) {
    transitionAnimator.cancel();
  }
  countryView.saveNextPosition(position, dataList.get(position).getCountry() + "-" + position);
  temperatureView.saveNextPosition(position, dataList.get(position).getTemperature());
  addressView.saveNextPosition(position, dataList.get(position).getAddress());
  bottomView.saveNextPosition(position, dataList.get(position).getMapImageUrl());
  timeView.saveNextPosition(position, dataList.get(position).getTime());
  transitionAnimator = ObjectAnimator.ofFloat(this, "transitionValue", 0.0f, 1.0f);
  transitionAnimator.setDuration(300);
  transitionAnimator.start();
  transitionAnimator.addListener(animatorListener);
}

代码示例来源:origin: Clans/FloatingActionButton

private void createCustomAnimation() {
  AnimatorSet set = new AnimatorSet();
  ObjectAnimator scaleOutX = ObjectAnimator.ofFloat(menuGreen.getMenuIconView(), "scaleX", 1.0f, 0.2f);
  ObjectAnimator scaleOutY = ObjectAnimator.ofFloat(menuGreen.getMenuIconView(), "scaleY", 1.0f, 0.2f);
  ObjectAnimator scaleInX = ObjectAnimator.ofFloat(menuGreen.getMenuIconView(), "scaleX", 0.2f, 1.0f);
  ObjectAnimator scaleInY = ObjectAnimator.ofFloat(menuGreen.getMenuIconView(), "scaleY", 0.2f, 1.0f);
  scaleOutX.setDuration(50);
  scaleOutY.setDuration(50);
  scaleInX.setDuration(150);
  scaleInY.setDuration(150);
  scaleInX.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationStart(Animator animation) {
      menuGreen.getMenuIconView().setImageResource(menuGreen.isOpened()
          ? R.drawable.ic_close : R.drawable.ic_star);
    }
  });
  set.play(scaleOutX).with(scaleOutY);
  set.play(scaleInX).with(scaleInY).after(scaleOutX);
  set.setInterpolator(new OvershootInterpolator(2));
  menuGreen.setIconToggleAnimatorSet(set);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void start_shouldRunAnimation() {
 final ObjectAnimator animator = ObjectAnimator.ofInt(target, "transparency", 0, 1, 2, 3, 4);
 Robolectric.getForegroundThreadScheduler().pause();
 animator.setDuration(1000);
 animator.addListener(listener);
 animator.start();
 assertThat(listenerEvents).containsExactly("started");
 assertThat(target.getTransparency()).isEqualTo(0);
 Robolectric.flushForegroundThreadScheduler();
 assertThat(listenerEvents).containsExactly("started", "ended");
 assertThat(target.getTransparency()).isEqualTo(4);
}

相关文章