com.github.florent37.expectanim.ExpectAnim Java Examples

The following examples show how to use com.github.florent37.expectanim.ExpectAnim. 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: ExpectAnimRotationActivity.java    From ExpectAnim with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.expectanim_activity_rotation);
    ButterKnife.bind(this);

    this.expectAnimMove = new ExpectAnim()

            .expect(text1)
            .toBe(
                    topOfParent(),
                    leftOfParent(),
                    rotated(90)
            )

            .expect(text2)
            .toBe(
                    alignLeft(text1),
                    belowOf(text1)
            )

            .expect(text3)
            .toBe(
                    alignTop(text1),
                    toRightOf(text1)
            )

            .expect(text4)
            .toBe(
                    belowOf(text3),
                    alignLeft(text3)
            )

            .toAnimation()
            .setDuration(1500);
}
 
Example #2
Source File: ExpectAnimAlphaActivity.java    From ExpectAnim with Apache License 2.0 5 votes vote down vote up
@OnClick(R.id.visible)
public void onVisibleClicked() {
    new ExpectAnim()
            .expect(image1)
            .toBe(
                    visible()
            )
            .toAnimation()
            .setDuration(1000)
            .start();
}
 
Example #3
Source File: ExpectAnimAlphaActivity.java    From ExpectAnim with Apache License 2.0 5 votes vote down vote up
@OnClick(R.id.invisible)
public void onInvisibleClicked() {
    new ExpectAnim()
            .expect(image1)
            .toBe(
                    invisible()
            )
            .toAnimation()
            .setDuration(1000)
            .start();
}
 
Example #4
Source File: ExpectAnimFlipActivity.java    From ExpectAnim with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.expectanim_activity_flip);
    ButterKnife.bind(this);

    this.expectAnimMove = new ExpectAnim()
            .expect(image1)
            .toBe(
                    withCameraDistance(500f),
                    flippedHorizontally()
            )
            .expect(image2)
            .toBe(
                    withCameraDistance(1000f),
                    flippedVertically()
            )
            .expect(image3)
            .toBe(
                    withCameraDistance(1500f),
                    flippedVertically()
            )
            .expect(image4)
            .toBe(
                    withCameraDistance(2000f),
                    flippedHorizontallyAndVertically()
            )
            .toAnimation()
            .setDuration(1500);
}
 
Example #5
Source File: ExpectAnimSetNowActivity.java    From ExpectAnim with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.expectanim_activity_set_now);
    ButterKnife.bind(this);

    new ExpectAnim()
            .expect(view)
            .toBe(
                    invisible()
            )
            .toAnimation()
            .setNow();

}
 
Example #6
Source File: UserActivity.java    From diycode with Apache License 2.0 5 votes vote down vote up
private void initScrollAnimation(ViewHolder holder) {
    NestedScrollView scrollView = holder.get(R.id.scroll_view);
    ImageView avatar = holder.get(R.id.avatar);
    TextView username = holder.get(R.id.username);
    View backbground = holder.get(R.id.background);

    this.expectAnimMove = new ExpectAnim()
            .expect(avatar)
            .toBe(
                    topOfParent().withMarginDp(13),
                    leftOfParent().withMarginDp(13),
                    scale(0.5f, 0.5f)
            )
            .expect(username)
            .toBe(
                    toRightOf(avatar).withMarginDp(16),
                    sameCenterVerticalAs(avatar),
                    alpha(0.5f)
            )
            .expect(backbground)
            .toBe(
                    height(DensityUtils.dip2px(this, 60)).withGravity(Gravity.LEFT, Gravity.TOP)
            )
            .toAnimation();

    scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int
                oldScrollX, int oldScrollY) {
            final float percent = (scrollY * 1f) / v.getMaxScrollAmount();
            expectAnimMove.setPercent(percent);
        }
    });
}
 
Example #7
Source File: RecordFragment.java    From CoolChat with Apache License 2.0 5 votes vote down vote up
private void initViews(View rootView) {
    RecordButton recordButton = (RecordButton) rootView.findViewById(R.id.btn_record);
    ImageView img_play = (ImageView) rootView.findViewById(R.id.img_play);
    ExpectAnim expectAnim = new ExpectAnim()
            .expect(img_play)
            .toBe(
                    width(180).toDp().keepRatio()
            )
            .toAnimation()
            .setDuration(250)
            .start();
    expectAnim.reset();

    recordButton.setOnFinishRecordListener(new RecordButton.OnFinishedRecordListener() {

        @Override
        public void onFinishedRecord(String audioFilePath, String audioLength) {
            LogUtils.e("录音位置完成:位置:" + audioFilePath + ";长度:" + audioLength);
            SendMessageUtils.sendAudioMessage(getActivity(), new File(audioFilePath), audioLength);
        }

        @Override
        public void onCancelRecord(String msg) {
            //ToastUtils.showShort(getActivity(), "录音取消");
            LogUtils.e("录音取消");
        }
    });
}
 
Example #8
Source File: TestActivity.java    From CoolChat with Apache License 2.0 5 votes vote down vote up
private void initView() {
    ImageView img = (ImageView) findViewById(R.id.img_avatar);
    ExpectAnim anim = new ExpectAnim()
            .expect(img)
            .toBe(
                    bottomOfParent().withMarginDp(16),
                    leftOfParent().withMarginDp(16),
                    width(40).toDp().keepRatio()
            )
            .toAnimation()
            .setDuration(2000)
            .start();
    anim.setPercent(20);
}
 
Example #9
Source File: ExpectAnimScrollActivity.java    From ExpectAnim with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.expectanim_activity_scroll);
    ButterKnife.bind(this);

    this.expectAnimMove = new ExpectAnim()
            .expect(avatar)
            .toBe(
                    topOfParent().withMarginDp(20),
                    leftOfParent().withMarginDp(20),
                    scale(0.5f, 0.5f)
            )

            .expect(username)
            .toBe(
                    toRightOf(avatar).withMarginDp(16),
                    sameCenterVerticalAs(avatar),

                    alpha(0.5f)
            )

            .expect(follow)
            .toBe(
                    rightOfParent().withMarginDp(20),
                    sameCenterVerticalAs(avatar)
            )

            .expect(backbground)
            .toBe(
                    height(height).withGravity(Gravity.LEFT, Gravity.TOP)
            )

            .toAnimation();

    scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            final float percent = (scrollY * 1f) / v.getMaxScrollAmount();
            expectAnimMove.setPercent(percent);
        }
    });
}
 
Example #10
Source File: ExpectAnimConcatActivity.java    From ExpectAnim with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.expectanim_activity_flip);
    ButterKnife.bind(this);

    this.expectAnimMove = ExpectAnim.concat(
            new ExpectAnim()
                    .expect(image1)
                    .toBe(
                            withCameraDistance(500f),
                            flippedHorizontally()
                    )
                    .toAnimation()
                    .setDuration(1000),
            new ExpectAnim()
                    .expect(image2)
                    .toBe(
                            withCameraDistance(1000f),
                            flippedVertically()
                    )
                    .toAnimation()
                    .setDuration(500),
            new ExpectAnim()
                    .expect(image3)
                    .toBe(
                            withCameraDistance(1500f),
                            flippedVertically()
                    )
                    .toAnimation()
                    .setDuration(300),
            new ExpectAnim()
                    .expect(image4)
                    .toBe(
                            withCameraDistance(2000f),
                            flippedHorizontallyAndVertically()
                    )
                    .toAnimation()
                    .setDuration(1000)
    )
    .start();
}
 
Example #11
Source File: ExpectAnimSampleActivity.java    From ExpectAnim with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.expectanim_activity_sample);
    ButterKnife.bind(this);

    new ExpectAnim()
            .expect(bottomLayout)
            .toBe(
                    outOfScreen(Gravity.BOTTOM)
            )
            .expect(content)
            .toBe(
                    outOfScreen(Gravity.BOTTOM),
                    invisible()
            )
            .toAnimation()
            .setNow();

    this.expectAnimMove = new ExpectAnim()

            .expect(avatar)
            .toBe(
                    bottomOfParent().withMarginDp(36),
                    leftOfParent().withMarginDp(16),
                    width(40).toDp().keepRatio()
            )

            .expect(name)
            .toBe(
                    toRightOf(avatar).withMarginDp(16),
                    sameCenterVerticalAs(avatar),
                    toHaveTextColor(Color.WHITE)
            )

            .expect(subname)
            .toBe(
                    toRightOf(name).withMarginDp(5),
                    sameCenterVerticalAs(name),
                    toHaveTextColor(Color.WHITE)
            )

            .expect(follow)
            .toBe(
                    rightOfParent().withMarginDp(4),
                    bottomOfParent().withMarginDp(12),
                    toHaveBackgroundAlpha(0f)
            )

            .expect(message)
            .toBe(
                    aboveOf(follow).withMarginDp(4),
                    rightOfParent().withMarginDp(4),
                    toHaveBackgroundAlpha(0f)
            )

            .expect(bottomLayout)
            .toBe(
                    atItsOriginalPosition()
            )

            .expect(content)
            .toBe(
                    atItsOriginalPosition(),
                    visible()
            )

            .toAnimation()
            .setDuration(1500);
}
 
Example #12
Source File: AnimationStartListener.java    From ExpectAnim with Apache License 2.0 votes vote down vote up
void onAnimationStart(ExpectAnim expectAnim); 
Example #13
Source File: AnimationEndListener.java    From ExpectAnim with Apache License 2.0 votes vote down vote up
void onAnimationEnd(ExpectAnim expectAnim); 
Example #14
Source File: AnimationStartListener.java    From diycode with Apache License 2.0 votes vote down vote up
void onAnimationStart(ExpectAnim expectAnim); 
Example #15
Source File: AnimationEndListener.java    From diycode with Apache License 2.0 votes vote down vote up
void onAnimationEnd(ExpectAnim expectAnim);