Coder Social home page Coder Social logo

smallbang's Introduction

SmallBang

twitter like animation for any view 💓

Demo APK

Usage

dependencies {
    implementation 'pub.hanks:smallbang:1.2.2'
}
<xyz.hanks.library.bang.SmallBangView
    android:id="@+id/like_heart"
    android:layout_width="56dp"
    android:layout_height="56dp">

    <ImageView
        android:id="@+id/image"
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:layout_gravity="center"
        android:src="@drawable/heart_selector"
        android:text="Hello World!"/>
</xyz.hanks.library.bang.SmallBangView>

or

<xyz.hanks.library.bang.SmallBangView
    android:id="@+id/like_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:circle_end_color="#ffbc00"
    app:circle_start_color="#fa9651"
    app:dots_primary_color="#fa9651"
    app:dots_secondary_color="#ffbc00">

    <TextView
        android:id="@+id/text"
        android:layout_width="50dp"
        android:layout_height="20dp"
        android:layout_gravity="center"
        android:gravity="center"
        android:text="hanks"
        android:textColor="@color/text_selector"
        android:textSize="14sp"/>
</xyz.hanks.library.bang.SmallBangView>

Donate

If this project help you reduce time to develop, you can give me a cup of coffee :)

paypal

Contact & Help

Please fell free to contact me if there is any problem when using the library.

welcome to commit issue & pr


License

This library is licensed under the Apache Software License, Version 2.0.

See LICENSE for full of the license text.

Copyright (C) 2015 [Hanks](https://github.com/hanks-zyh)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

smallbang's People

Contributors

cesarferreira avatar hanks-zyh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smallbang's Issues

Library not working

I have installed the library from nuget package and used it as below:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:app="http://schemas.android.com/apk/res-auto"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:gravity="center_horizontal"
             android:orientation="vertical">
    <xyz.hanks.library.bang.SmallBangView
        android:id="@+id/like_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="156dp"
        app:circle_end_color="#ffbc00"
        app:circle_start_color="#fa9651"
        app:dots_primary_color="#fa9651"
        app:dots_secondary_color="#ffbc00">

        <TextView
            android:id="@+id/textone"
            android:layout_width="50dp"
            android:layout_height="20dp"
            android:layout_gravity="center"
            android:gravity="center"
            android:text="hanks"
            android:textColor="@color/text_selector"
            android:textSize="14sp"/>
    </xyz.hanks.library.bang.SmallBangView>
</FrameLayout>

When I click on the text there is no animation happening.Nothing seems to work.
Target Android Version:Android 9.0
Minimum Android Version:Android 5.0
Karamunting.Android.HanksZyh.SmallBang Version:1.2.2
Xamarin.Android.Support.v4 Version:28.0.0.1

需要點擊第2次

先謝謝你的分享, 覺得很漂亮實用

然後我想請問一下, 我把它放到RecyclerView裡使用
但是我發覺, 點擊有些Item需要點第2次, 才會出現動畫效果

我點擊的時候, 是直接調用like_heart.likeAnimation()

想請問一下, 是什麼原因? 我忽略了那些細節?

Speed Up of Animation

Hi @hanks-zyh

It was great animation on widget, i want to speed up (fast) animation on click, is it possible ? then how ? in my code ...

`
imgHome.setOnClickListener(new View.OnClickListener() {
@OverRide
public void onClick(View v) {
mSmallBang.bang(view,50,new SmallBangListener() {
@OverRide
public void onAnimationStart() { }

            @Override
            public void onAnimationEnd() {    }
        });
        }
    });

`

Thanks.

Having Crash at scaleView.setScaleX(0) in likeAnimation

having a crash during the likeAnimation method call.
I am using the ImageView inside the SmallBang

       <xyz.hanks.library.bang.SmallBangView

        android:id="@+id/bang_icthumsup"
        android:layout_width="match_parent"
        android:layout_height="74dp">

        <ImageView
            android:id="@+id/ivthumbsup"
            android:layout_width="64dp"
            android:layout_height="64dp"
            android:layout_gravity="center_horizontal"
            android:padding="10dp"
            android:src="@drawable/ic_thumbsup" />

and Just initlize the
mSmallBang =(SmallBangView) findViewById(R.id.bang_icthumsup);
if(mSmallBang!=null)
mSmallBang.likeAnimation();

but got crash with null poiner exception for scaleView

scaleView is null and causing exceptions

The latest version implementation 'pub.hanks:smallbang:1.2.2' is crashing on load. It looks like onMeasure override isn't being called in my scenario. Debugging shows that onMeasure isn't called in my case, and crashes here when calling likeAnimation.

I'm also having trouble downloading the old working smallbang on my CI. Is it still available on maven?

 E/UncaughtException: java.lang.RuntimeException: Unable to start activity ComponentInfo: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setScaleX(float)' on a null object reference
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
    at android.app.ActivityThread.-wrap11(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6494)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
 Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setScaleX(float)' on a null object reference
    at xyz.hanks.library.bang.SmallBangView.likeAnimation(SmallBangView.java:190)
    at xyz.hanks.library.bang.SmallBangView.likeAnimation(SmallBangView.java:181)
    at myapppackage.fragments.MyFragment.animateView(MyFragment.java:107)
    at myapppackage.fragments.MyFragment.setQuantity(MyFragment.java:97)
    at myapppackage.fragments.MyFragment.onCreateView(MyFragment.java:69)
    at android.support.v4.app.Fragment.performCreateView(Fragment.java:2261)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419)
    at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1750)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1819)
    at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:797)
    at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2590)
    at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2377)
    at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2332)
    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2239)
    at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3231)
    at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3181)
    at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:192)
    at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:572)
    at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:177)
    at myapppackage.activities.MyAppActivity.onStart(MyAppActivity.java:29)
    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1334)
    at android.app.Activity.performStart(Activity.java:7019)

源码里有些地方没看懂

view.getGlobalVisibleRect(r);
int[] location = new int[2];
getLocationOnScreen(location);
//下面这两个表示啥啊,偏移后插入?
r.offset(-location[0], -location[1]);
r.inset(-mExpandInset[0], -mExpandInset[1]);

Converted to Kotlin

Hey, I've converted this library into Kotlin and updated it for the latest version of Android over on my repository. I would have made a merge request but the demo app that this library uses was made pre-AndroidX which brings up a few issues in migration so I removed it in my fork. Would these migrations to Kotlin be useful to implement into SmallBang?

Option to set start and end view?

Something like the heart icon for example. Would need to start grey and become red once tapped and the animation has been finished. I presume this can be done in the onAnimationEnd but how well does that sync with the animation? I can imagine it looking like it's just popping in at the end instead of flowing nicely

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setScaleX(float)' on a null object reference

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setScaleX(float)' on a null object reference
at xyz.hanks.library.bang.SmallBangView.likeAnimation(SmallBangView.java:190)
at com.yourpackagename.CatJobActivity$JobListFragment$JobListingAdapter.onBindViewHolder(CatJobActivity.java:915)
at com.yourpackagename.CatJobActivity$JobListFragment$JobListingAdapter.onBindViewHolder(CatJobActivity.java:867)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6356)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6389)
at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5335)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5598)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5440)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5436)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2224)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1551)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1511)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:595)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3583)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3312)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3844)
at android.view.View.layout(View.java:19055)
at android.view.ViewGroup.layout(ViewGroup.java:5935)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
at android.view.View.layout(View.java:19055)
at android.view.ViewGroup.layout(ViewGroup.java:5935)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:19055)
at android.view.ViewGroup.layout(ViewGroup.java:5935)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:19055)
at android.view.ViewGroup.layout(ViewGroup.java:5935)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
at android.view.View.layout(View.java:19055)
at android.view.ViewGroup.layout(ViewGroup.java:5935)
at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:131)
at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1391)
at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:870)
at android.view.View.layout(View.java:19055)
at android.view.ViewGroup.layout(ViewGroup.java:5935)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:19055)
at android.view.ViewGroup.layout(ViewGroup.java:5935)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:19055)
at android.view.ViewGroup.layout(ViewGroup.java:5935)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
at android.view.View.layout(View.java:19055)
at android.view.ViewGroup.layout(ViewGroup.java:5935)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
at android.view.View.layout(View.java:19055)
at android.view.ViewGroup.layout(ViewGroup.java:5935)
at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1167)
at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:852)
at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:871)
at android.view.View.layout(View.java:19055)
at android.view.ViewGroup.layout(ViewGroup.java:5935)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:19055)
at android.view.ViewGroup.layout(ViewGroup.java:5935)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:19055)
at android.view.ViewGroup.layout(ViewGroup.java:5935)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:19055)
at android.view.ViewGroup.layout(ViewGroup.java:5935)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:19055)
at android.view.ViewGroup.layout(ViewGroup.java:5935)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:954)
at android.view.View.layout(View.java:19055)
at android.view.ViewGroup.layout(ViewGroup.java:5935)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2716)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2431)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1569)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7301)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:930)
at android.view.Choreographer.doCallbacks(Choreographer.java:705)
at android.view.Choreographer.doFrame(Choreographer.java:640)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:916)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6816)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1563)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1451)

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.