Giter VIP home page Giter VIP logo

hipraiseanimation's Introduction

HiPraiseAnimation

一个可以在异步线程绘制点赞动画(不仅是)的库,可以实现映客直播直播间的点赞效果,它支持使用SurfaceView或者TextureView来绘制,当然,也可以是用View在UI线程绘制动画
。动画的绘制和绘制的过程分离,可以支持任意的动画实现。这里还附带点小福利,这里包含了一个点赞动画的实现,使用了三阶赛贝尔曲线来描述动画的运行 轨迹。

image

怎么使用(超级简单)

1.首先把View添加到布局中

  <org.limlee.hipraiseanimationlib.HiPraiseAnimationView
        android:id="@+id/praise_animation"
        android:layout_width="200dp"
        android:layout_height="400dp"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"/>

2.要在适当的时机启动动画的绘制,例如在Activity的OnResume()和OnStop()中开启和关闭动画的绘制

    @Override
    protected void onResume() {
        super.onResume();
        mHiPraiseAnimationView.start(); //添加点赞动画之前要先开始启动绘制,如果没有,是添加不了任何的动画对象
    }

    @Override
    protected void onStop() {
        super.onStop();
        mHiPraiseAnimationView.stop(); //停止绘制点赞动画,停止后会clear掉整个画布和清空掉所有绘制的对象
    }

3.最后,可以添加动画(点赞)对象了,支持下面两个方式

1.普通的添加方法

    /**
     * 添加点赞动画,没有绘制结果的回调
     */
    private void addPraise() {
        final IPraise hiPraise = new HiPraise(getHeartBitmap());
        mHiPraiseAnimationView.addPraise(hiPraise);
    }

2.带有动画绘制结束回调的添加方法

    /**
     * 添加具有回调的点赞动画
     */
    private void addPraiseWithCallback() {
        final IPraise hiPraiseWithCallback = new HiPraiseWithCallback(getHeartBitmap(),
                new OnDrawCallback() {
                    @Override
                    public void onFinish() {
                        Log.d(TAG, "绘制完成了!");
                    }
                });
        mHiPraiseAnimationView.addPraise(hiPraiseWithCallback);
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.