android.animation.AnimatorInflater Java Examples

The following examples show how to use android.animation.AnimatorInflater. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PropertyAnimationActivity.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
/**
 * use property animation by xml;
 *
 * @return
 */
private Animator getAnimationByXml() {
    final int height = mPuppet.getLayoutParams().height;
    final int width = mPuppet.getLayoutParams().width;
    AnimatorSet animatorSet = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.animatorset);

    //ValueAnimator usage:add AnimatorUpdateListener;
    ArrayList<Animator> childAnimations = animatorSet.getChildAnimations();
    ((ValueAnimator) childAnimations.get(childAnimations.size() - 1))
            .addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    float animatedValue = (float) valueAnimator.getAnimatedValue();
                    mPuppet.getLayoutParams().height = (int) (height * animatedValue);
                    mPuppet.getLayoutParams().width = (int) (width * animatedValue);
                    mPuppet.requestLayout();
                }
            });

    animatorSet.setTarget(mPuppet);
    return animatorSet;
}
 
Example #2
Source File: KeyPreviewDrawParams.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
public Animator createShowUpAnimator(final View target) {
    if (mHasCustomAnimationParams) {
        final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(
                target, View.SCALE_X, mShowUpStartXScale,
                KEY_PREVIEW_SHOW_UP_END_SCALE);
        final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(
                target, View.SCALE_Y, mShowUpStartYScale,
                KEY_PREVIEW_SHOW_UP_END_SCALE);
        final AnimatorSet showUpAnimator = new AnimatorSet();
        showUpAnimator.play(scaleXAnimator).with(scaleYAnimator);
        showUpAnimator.setDuration(mShowUpDuration);
        showUpAnimator.setInterpolator(DECELERATE_INTERPOLATOR);
        return showUpAnimator;
    }
    final Animator animator = AnimatorInflater.loadAnimator(
            target.getContext(), mShowUpAnimatorResId);
    animator.setTarget(target);
    animator.setInterpolator(DECELERATE_INTERPOLATOR);
    return animator;
}
 
Example #3
Source File: LiveBarcodeScanningActivity.java    From mlkit-material-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_live_barcode);
  preview = findViewById(R.id.camera_preview);
  graphicOverlay = findViewById(R.id.camera_preview_graphic_overlay);
  graphicOverlay.setOnClickListener(this);
  cameraSource = new CameraSource(graphicOverlay);

  promptChip = findViewById(R.id.bottom_prompt_chip);
  promptChipAnimator =
      (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.bottom_prompt_chip_enter);
  promptChipAnimator.setTarget(promptChip);

  findViewById(R.id.close_button).setOnClickListener(this);
  flashButton = findViewById(R.id.flash_button);
  flashButton.setOnClickListener(this);
  settingsButton = findViewById(R.id.settings_button);
  settingsButton.setOnClickListener(this);

  setUpWorkflowModel();
}
 
Example #4
Source File: KeyPreviewDrawParams.java    From openboard with GNU General Public License v3.0 6 votes vote down vote up
public Animator createDismissAnimator(final View target) {
    if (mHasCustomAnimationParams) {
        final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(
                target, View.SCALE_X, mDismissEndXScale);
        final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(
                target, View.SCALE_Y, mDismissEndYScale);
        final AnimatorSet dismissAnimator = new AnimatorSet();
        dismissAnimator.play(scaleXAnimator).with(scaleYAnimator);
        final int dismissDuration = Math.min(mDismissDuration, mLingerTimeout);
        dismissAnimator.setDuration(dismissDuration);
        dismissAnimator.setInterpolator(ACCELERATE_INTERPOLATOR);
        return dismissAnimator;
    }
    final Animator animator = AnimatorInflater.loadAnimator(
            target.getContext(), mDismissAnimatorResId);
    animator.setTarget(target);
    animator.setInterpolator(ACCELERATE_INTERPOLATOR);
    return animator;
}
 
Example #5
Source File: KeyPreviewDrawParams.java    From openboard with GNU General Public License v3.0 6 votes vote down vote up
public Animator createShowUpAnimator(final View target) {
    if (mHasCustomAnimationParams) {
        final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(
                target, View.SCALE_X, mShowUpStartXScale,
                KEY_PREVIEW_SHOW_UP_END_SCALE);
        final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(
                target, View.SCALE_Y, mShowUpStartYScale,
                KEY_PREVIEW_SHOW_UP_END_SCALE);
        final AnimatorSet showUpAnimator = new AnimatorSet();
        showUpAnimator.play(scaleXAnimator).with(scaleYAnimator);
        showUpAnimator.setDuration(mShowUpDuration);
        showUpAnimator.setInterpolator(DECELERATE_INTERPOLATOR);
        return showUpAnimator;
    }
    final Animator animator = AnimatorInflater.loadAnimator(
            target.getContext(), mShowUpAnimatorResId);
    animator.setTarget(target);
    animator.setInterpolator(DECELERATE_INTERPOLATOR);
    return animator;
}
 
Example #6
Source File: MotionSpec.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
/** Inflates an instance of MotionSpec from the given animator resource. */
@Nullable
public static MotionSpec createFromResource(@NonNull Context context, @AnimatorRes int id) {
  try {
    Animator animator = AnimatorInflater.loadAnimator(context, id);
    if (animator instanceof AnimatorSet) {
      AnimatorSet set = (AnimatorSet) animator;
      return createSpecFromAnimators(set.getChildAnimations());
    } else if (animator != null) {
      List<Animator> animators = new ArrayList<>();
      animators.add(animator);
      return createSpecFromAnimators(animators);
    } else {
      return null;
    }
  } catch (Exception e) {
    Log.w(TAG, "Can't load animation resource ID #0x" + Integer.toHexString(id), e);
    return null;
  }
}
 
Example #7
Source File: DashboardFlipViewHolder.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
public DashboardFlipViewHolder(View view) {
    super(view);
    context = view.getContext();
    previousFlipDirection = NOT_SET;
    setRightOut = (AnimatorSet) AnimatorInflater.loadAnimator(context,
            R.animator.card_flip_right_out);

    setLeftIn = (AnimatorSet) AnimatorInflater.loadAnimator(context,
            R.animator.card_flip_left_in);

    setRightIn = (AnimatorSet) AnimatorInflater.loadAnimator(context,
            R.animator.card_flip_right_in);

    setLeftOut = (AnimatorSet) AnimatorInflater.loadAnimator(context,
            R.animator.card_flip_left_out);
    front = (FrameLayout) view.findViewById(R.id.card_front);
    back = (FrameLayout) view.findViewById(R.id.card_back);
}
 
Example #8
Source File: ProgramInfoViewBase.java    From zapp with MIT License 6 votes vote down vote up
public ProgramInfoViewBase(Context context, AttributeSet attrs) {
	super(context, attrs);

	setOrientation(LinearLayout.VERTICAL);
	setGravity(Gravity.CENTER_VERTICAL);

	LayoutInflater inflater = (LayoutInflater) context
		.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	Objects.requireNonNull(inflater).inflate(getViewId(), this, true);

	showTitleView = getRootView().findViewById(R.id.text_show_title);
	showSubtitleView = getRootView().findViewById(R.id.text_show_subtitle);
	showTimeView = getRootView().findViewById(R.id.text_show_time);
	progressBarView = getRootView().findViewById(R.id.progressbar_show_progress);

	updateShowInfoIntervalSeconds = getResources().getInteger(R.integer.view_program_info_update_show_info_interval_seconds);
	updateShowTimeIntervalSeconds = getResources().getInteger(R.integer.view_program_info_update_show_time_interval_seconds);

	showProgressAnimator = (ObjectAnimator) AnimatorInflater.loadAnimator(context,
		R.animator.view_program_info_show_progress);
	showProgressAnimator.setTarget(progressBarView);
}
 
Example #9
Source File: PropertyAnimationActivity.java    From Android-Animation-Set with Apache License 2.0 6 votes vote down vote up
/**
 * use property animation by xml;
 *
 * @return
 */
private Animator getAnimationByXml() {
    final int height = mPuppet.getLayoutParams().height;
    final int width = mPuppet.getLayoutParams().width;
    AnimatorSet animatorSet = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.animatorset);

    //ValueAnimator usage:add AnimatorUpdateListener;
    ArrayList<Animator> childAnimations = animatorSet.getChildAnimations();
    ((ValueAnimator) childAnimations.get(childAnimations.size() - 1))
            .addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    float animatedValue = (float) valueAnimator.getAnimatedValue();
                    mPuppet.getLayoutParams().height = (int) (height * animatedValue);
                    mPuppet.getLayoutParams().width = (int) (width * animatedValue);
                    mPuppet.requestLayout();
                }
            });

    animatorSet.setTarget(mPuppet);
    return animatorSet;
}
 
Example #10
Source File: RecorderButton.java    From PlayTogether with Apache License 2.0 6 votes vote down vote up
public RecorderButton(Context context, AttributeSet attrs)
	{
		super(context, attrs);
		mBtnAnim = AnimatorInflater.loadAnimator(getContext(), R.animator.recorder_btn_press_anim);
		mBtnAnim.setTarget(this);
		mDialogManager = new RecorderDialogManager(context);
		mAudioManager = AudioManager.getInstance();
		this.setOnLongClickListener(new OnLongClickListener()
		{
			@Override
			public boolean onLongClick(View v)
			{
//				Log.e("TAG", "long click");
				mBtnAnim.start();
				isRecording = true;
				mAudioManager.prepareAudio();
				return false;
			}
		});
		mAudioManager.setAudioStateListener(this);
	}
 
Example #11
Source File: MountState.java    From litho with Apache License 2.0 6 votes vote down vote up
private static void setViewStateListAnimator(View view, ViewNodeInfo viewNodeInfo) {
  StateListAnimator stateListAnimator = viewNodeInfo.getStateListAnimator();
  final int stateListAnimatorRes = viewNodeInfo.getStateListAnimatorRes();
  if (stateListAnimator == null && stateListAnimatorRes == 0) {
    return;
  }
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    throw new IllegalStateException(
        "MountState has a ViewNodeInfo with stateListAnimator, "
            + "however the current Android version doesn't support stateListAnimator on Views");
  }
  if (stateListAnimator == null) {
    stateListAnimator =
        AnimatorInflater.loadStateListAnimator(view.getContext(), stateListAnimatorRes);
  }
  view.setStateListAnimator(stateListAnimator);
}
 
Example #12
Source File: CircleIndicator.java    From XERUNG with Apache License 2.0 6 votes vote down vote up
private void checkIndicatorConfig(Context context) {
    mIndicatorWidth = (mIndicatorWidth < 0) ? dip2px(DEFAULT_INDICATOR_WIDTH) : mIndicatorWidth;
    mIndicatorHeight =
            (mIndicatorHeight < 0) ? dip2px(DEFAULT_INDICATOR_WIDTH) : mIndicatorHeight;
    mIndicatorMargin =
            (mIndicatorMargin < 0) ? dip2px(DEFAULT_INDICATOR_WIDTH) : mIndicatorMargin;

    mAnimatorResId = (mAnimatorResId == 0) ? R.animator.scale_with_alpha : mAnimatorResId;
    mAnimationOut = AnimatorInflater.loadAnimator(context, mAnimatorResId);
    if (mAnimatorReverseResId == 0) {
        mAnimationIn = AnimatorInflater.loadAnimator(context, mAnimatorResId);
        mAnimationIn.setInterpolator(new ReverseInterpolator());
    } else {
        mAnimationIn = AnimatorInflater.loadAnimator(context, mAnimatorReverseResId);
    }
    mIndicatorBackgroundResId = (mIndicatorBackgroundResId == 0) ? R.drawable.white_radius
            : mIndicatorBackgroundResId;
    mIndicatorUnselectedBackgroundResId =
            (mIndicatorUnselectedBackgroundResId == 0) ? mIndicatorBackgroundResId
                    : mIndicatorUnselectedBackgroundResId;
}
 
Example #13
Source File: CircleIndicator.java    From XERUNG with Apache License 2.0 6 votes vote down vote up
private void checkIndicatorConfig(Context context) {
    mIndicatorWidth = (mIndicatorWidth < 0) ? dip2px(DEFAULT_INDICATOR_WIDTH) : mIndicatorWidth;
    mIndicatorHeight =
            (mIndicatorHeight < 0) ? dip2px(DEFAULT_INDICATOR_WIDTH) : mIndicatorHeight;
    mIndicatorMargin =
            (mIndicatorMargin < 0) ? dip2px(DEFAULT_INDICATOR_WIDTH) : mIndicatorMargin;

    mAnimatorResId = (mAnimatorResId == 0) ? R.animator.scale_with_alpha : mAnimatorResId;
    mAnimationOut = AnimatorInflater.loadAnimator(context, mAnimatorResId);
    if (mAnimatorReverseResId == 0) {
        mAnimationIn = AnimatorInflater.loadAnimator(context, mAnimatorResId);
        mAnimationIn.setInterpolator(new ReverseInterpolator());
    } else {
        mAnimationIn = AnimatorInflater.loadAnimator(context, mAnimatorReverseResId);
    }
    mIndicatorBackgroundResId = (mIndicatorBackgroundResId == 0) ? R.drawable.white_radius
            : mIndicatorBackgroundResId;
    mIndicatorUnselectedBackgroundResId =
            (mIndicatorUnselectedBackgroundResId == 0) ? mIndicatorBackgroundResId
                    : mIndicatorUnselectedBackgroundResId;
}
 
Example #14
Source File: WallpapersAdapter.java    From wallpaperboard with Apache License 2.0 6 votes vote down vote up
ViewHolder(View itemView) {
    super(itemView);
    ButterKnife.bind(this, itemView);
    setCardViewToFlat(card);

    if (!Preferences.get(mContext).isShadowEnabled()) {
        card.setCardElevation(0f);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        StateListAnimator stateListAnimator = AnimatorInflater
                .loadStateListAnimator(mContext, R.animator.card_lift_long);
        card.setStateListAnimator(stateListAnimator);
    }

    card.setOnClickListener(this);
    card.setOnLongClickListener(this);
    favorite.setOnClickListener(this);
}
 
Example #15
Source File: MainGameActivity.java    From ColorPhun with Apache License 2.0 6 votes vote down vote up
protected void setupProgressView() {
    timerProgress = (ProgressBar) findViewById(R.id.progress_bar);
    pointsTextView = (TextView) findViewById(R.id.points_value);
    levelTextView = (TextView) findViewById(R.id.level_value);
    TextView pointsLabel = (TextView) findViewById(R.id.points_label);
    TextView levelsLabel = (TextView) findViewById(R.id.level_label);

    // setting up fonts
    Typeface avenir_black = Typeface.createFromAsset(getAssets(), "fonts/avenir_black.ttf");
    Typeface avenir_book = Typeface.createFromAsset(getAssets(), "fonts/avenir_book.ttf");
    pointsTextView.setTypeface(avenir_black);
    levelTextView.setTypeface(avenir_black);
    pointsLabel.setTypeface(avenir_book);
    levelsLabel.setTypeface(avenir_book);

    // setting up animations
    pointAnim = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.points_animations);
    pointAnim.setTarget(pointsTextView);
    levelAnim = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.level_animations);
    levelAnim.setTarget(levelTextView);
}
 
Example #16
Source File: KeyPreviewDrawParams.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
public Animator createShowUpAnimator(final View target) {
    if (mHasCustomAnimationParams) {
        final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(
                target, View.SCALE_X, mShowUpStartXScale,
                KEY_PREVIEW_SHOW_UP_END_SCALE);
        final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(
                target, View.SCALE_Y, mShowUpStartYScale,
                KEY_PREVIEW_SHOW_UP_END_SCALE);
        final AnimatorSet showUpAnimator = new AnimatorSet();
        showUpAnimator.play(scaleXAnimator).with(scaleYAnimator);
        showUpAnimator.setDuration(mShowUpDuration);
        showUpAnimator.setInterpolator(DECELERATE_INTERPOLATOR);
        return showUpAnimator;
    }
    final Animator animator = AnimatorInflater.loadAnimator(
            target.getContext(), mShowUpAnimatorResId);
    animator.setTarget(target);
    animator.setInterpolator(DECELERATE_INTERPOLATOR);
    return animator;
}
 
Example #17
Source File: KeyPreviewDrawParams.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
public Animator createDismissAnimator(final View target) {
    if (mHasCustomAnimationParams) {
        final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(
                target, View.SCALE_X, mDismissEndXScale);
        final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(
                target, View.SCALE_Y, mDismissEndYScale);
        final AnimatorSet dismissAnimator = new AnimatorSet();
        dismissAnimator.play(scaleXAnimator).with(scaleYAnimator);
        final int dismissDuration = Math.min(mDismissDuration, mLingerTimeout);
        dismissAnimator.setDuration(dismissDuration);
        dismissAnimator.setInterpolator(ACCELERATE_INTERPOLATOR);
        return dismissAnimator;
    }
    final Animator animator = AnimatorInflater.loadAnimator(
            target.getContext(), mDismissAnimatorResId);
    animator.setTarget(target);
    animator.setInterpolator(ACCELERATE_INTERPOLATOR);
    return animator;
}
 
Example #18
Source File: KeyPreviewDrawParams.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
public Animator createDismissAnimator(final View target) {
    if (mHasCustomAnimationParams) {
        final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(
                target, View.SCALE_X, mDismissEndXScale);
        final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(
                target, View.SCALE_Y, mDismissEndYScale);
        final AnimatorSet dismissAnimator = new AnimatorSet();
        dismissAnimator.play(scaleXAnimator).with(scaleYAnimator);
        final int dismissDuration = Math.min(mDismissDuration, mLingerTimeout);
        dismissAnimator.setDuration(dismissDuration);
        dismissAnimator.setInterpolator(ACCELERATE_INTERPOLATOR);
        return dismissAnimator;
    }
    final Animator animator = AnimatorInflater.loadAnimator(
            target.getContext(), mDismissAnimatorResId);
    animator.setTarget(target);
    animator.setInterpolator(ACCELERATE_INTERPOLATOR);
    return animator;
}
 
Example #19
Source File: DragAndDropItemCallback.java    From SimpleRecyclerView with Apache License 2.0 6 votes vote down vote up
@Override
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
  if (actionState != ItemTouchHelper.ACTION_STATE_DRAG) {
    super.onSelectedChanged(viewHolder, actionState);
    return;
  }

  if (dragAndDropCallback != null) {
    dragAndDropCallback.onCellDragStarted(simpleRecyclerView, viewHolder.itemView, draggingItem, draggingItemPosition);
  }

  if (options.isDefaultEffectEnabled()) {
    viewHolder.itemView.setSelected(true);
    viewHolder.itemView.setAlpha(0.95f);
    if (Build.VERSION.SDK_INT >= 21 && animator == null) {
      animator = AnimatorInflater.loadStateListAnimator(viewHolder.itemView.getContext(), R.animator.raise);
      viewHolder.itemView.setStateListAnimator(animator);
    }
  }

  super.onSelectedChanged(viewHolder, actionState);
}
 
Example #20
Source File: IconPackResourcesProvider.java    From GeometricWeather with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Nullable
private Animator getAnimator(@NonNull String resName) {
    try {
        return AnimatorInflater.loadAnimator(
                context,
                ResourceUtils.nonNull(getResId(context, resName, "animator"))
        );
    } catch (Exception e) {
        return null;
    }
}
 
Example #21
Source File: CustomCompoundToggleButton.java    From ToggleButtonGroup with Apache License 2.0 5 votes vote down vote up
public CustomCompoundToggleButton(Context context, AttributeSet attrs) {
    super(context, attrs);

    LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.view_custom_compound_toggle_button, this, true);

    mIvFront = findViewById(R.id.iv_front);
    mIvBack = findViewById(R.id.iv_back);

    TypedArray a = context.getTheme().obtainStyledAttributes(attrs,
            R.styleable.CustomCompoundToggleButton, 0, 0);
    try {
        Drawable front = a.getDrawable(R.styleable.CustomCompoundToggleButton_tbgFrontImage);
        mIvFront.setImageDrawable(front);
        Drawable back = a.getDrawable(R.styleable.CustomCompoundToggleButton_tbgBackImage);
        mIvBack.setImageDrawable(back);
    } finally {
        a.recycle();
    }

    CheckedAnimationListener animationListener = new CheckedAnimationListener();
    mFlipOut = (AnimatorSet) AnimatorInflater.loadAnimator(getContext(),
            R.animator.flip_out);
    mFlipOut.addListener(animationListener);
    mFlipIn = (AnimatorSet) AnimatorInflater.loadAnimator(getContext(),
            R.animator.flip_in);
    mFlipIn.addListener(animationListener);
}
 
Example #22
Source File: CircleIndicator.java    From MNImageBrowser with GNU General Public License v3.0 5 votes vote down vote up
private Animator createAnimatorIn(Context context) {
    Animator animatorIn;
    if (mAnimatorReverseResId == 0) {
        animatorIn = AnimatorInflater.loadAnimator(context, mAnimatorResId);
        animatorIn.setInterpolator(new ReverseInterpolator());
    } else {
        animatorIn = AnimatorInflater.loadAnimator(context, mAnimatorReverseResId);
    }
    return animatorIn;
}
 
Example #23
Source File: CustomActivity2.java    From LoadingLayout with Apache License 2.0 5 votes vote down vote up
@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_custom2);

        mLoadingLayout = (LoadingLayout) findViewById(R.id.loading_layout);

        mLoadingLayout.setLoadingView(getLayoutInflater().inflate(R.layout.loading_layout, null));
//        mLoadingLayout.setLoadingView(R.layout.loading_layout);
        mLoadingLayout.setLoadingAnim(AnimatorInflater.loadAnimator(this, R.animator.loading));
//        mLoadingLayout.setLoadingAnim(R.animator.loading);

        mLoadingLayout.setErrorDrawable(R.drawable.failure);
//        mLoadingLayout.setErrorDrawable(getResources().getDrawable(R.drawable.failure));
        mLoadingLayout.setErrorText(R.string.failure_text);
//        mLoadingLayout.setErrorText(getResources().getText(R.string.failure_text).toString());

//        mLoadingLayout.setEmptyDrawable(R.drawable.icon_empty);
        mLoadingLayout.setEmptyDrawable(getResources().getDrawable(R.drawable.icon_empty));
//        mLoadingLayout.setErrorText(R.string.empty_text);
        mLoadingLayout.setEmptyText(getResources().getText(R.string.empty_text).toString());

        // 如果调用了setLoadingView(),需要手动调用showLoading()
        mLoadingLayout.showLoading();

        mLoadingLayout.setOnRetryLoadListener(this);

        // 延时3s模拟数据获取
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                mLoadingLayout.loadFailure();
            }
        }, 3000);
    }
 
Example #24
Source File: BubbleLayout.java    From bubbles-for-android with Apache License 2.0 5 votes vote down vote up
private void playAnimationClickUp() {
    if (!isInEditMode()) {
        AnimatorSet animator = (AnimatorSet) AnimatorInflater
                .loadAnimator(getContext(), R.animator.bubble_up_click_animator);
        animator.setTarget(this);
        animator.start();
    }
}
 
Example #25
Source File: WallpaperDetailsCategoryAdapter.java    From wallpaperboard with Apache License 2.0 5 votes vote down vote up
ViewHolder(View itemView) {
    super(itemView);
    ButterKnife.bind(this, itemView);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        StateListAnimator stateListAnimator = AnimatorInflater
                .loadStateListAnimator(mContext, R.animator.card_lift_long);
        card.setStateListAnimator(stateListAnimator);
    }
    card.setOnClickListener(this);
}
 
Example #26
Source File: PropertyAnimActivity.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
public void testAnimatorInfalter(View v) {
    // 加载xml动画
    Animator animator = AnimatorInflater.loadAnimator(PropertyAnimActivity.this, R.anim.sda_animatorset_anim);
    animator.setTarget(mTestSwitch?v:mAnimView);
    animator.start();
    mTestSwitch = !mTestSwitch;
}
 
Example #27
Source File: CircleIndicator.java    From SuperIndicator with Apache License 2.0 5 votes vote down vote up
private Animator createAnimatorIn(Context context) {
    Animator animatorIn;
    if (mAnimatorReverseResId == 0) {
        animatorIn = AnimatorInflater.loadAnimator(context, mAnimatorResId);
        animatorIn.setInterpolator(new ReverseInterpolator());
    } else {
        animatorIn = AnimatorInflater.loadAnimator(context, mAnimatorReverseResId);
    }
    return animatorIn;
}
 
Example #28
Source File: CircleIndicator.java    From LefishGuide with Apache License 2.0 5 votes vote down vote up
private Animator createAnimatorIn(Context context) {
    Animator animatorIn;
    if (mAnimatorReverseResId == 0) {
        animatorIn = AnimatorInflater.loadAnimator(context, mAnimatorResId);
        animatorIn.setInterpolator(new ReverseInterpolator());
    } else {
        animatorIn = AnimatorInflater.loadAnimator(context, mAnimatorReverseResId);
    }
    return animatorIn;
}
 
Example #29
Source File: ConversationFragment.java    From Pix-Art-Messenger with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Animator onCreateAnimator(int transit, boolean enter, int nextAnim) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        int animator = enter ? R.animator.fade_right_in : R.animator.fade_right_out;
        return AnimatorInflater.loadAnimator(getActivity(), animator);
    } else {
        return null;
    }
}
 
Example #30
Source File: DataLayout.java    From power-adapters with Apache License 2.0 5 votes vote down vote up
@Nullable
private static Animator loadAnimator(@NonNull Context context,
                                     @NonNull TypedArray typedArray,
                                     int index,
                                     int fallbackIndex,
                                     @AnimatorRes int defaultValue) {
    return AnimatorInflater.loadAnimator(context,
            typedArray.getResourceId(index, typedArray.getResourceId(fallbackIndex, defaultValue)));
}