txusballesteros / bubbles-for-android

Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your development.
Apache License 2.0
1.48k stars 281 forks source link

Null pointer exception #3

Closed Lir10 closed 9 years ago

Lir10 commented 9 years ago

java.lang.NullPointerException at android.animation.PropertyValuesHolder.setupSetterAndGetter(PropertyValuesHolder.java:505) at android.animation.ObjectAnimator.initAnimation(ObjectAnimator.java:487) at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:517) at android.animation.ValueAnimator.start(ValueAnimator.java:936) at android.animation.ValueAnimator.start(ValueAnimator.java:946) at android.animation.ObjectAnimator.start(ObjectAnimator.java:465) at android.animation.AnimatorSet.start(AnimatorSet.java:563) at com.txusballesteros.bubbles.BubbleTrashLayout.playAnimation(BubbleTrashLayout.java:78) at com.txusballesteros.bubbles.BubbleTrashLayout.setVisibility(BubbleTrashLayout.java:54) at com.txusballesteros.bubbles.BubblesService.addTrash(BubblesService.java:102) at com.txusballesteros.bubbles.BubblesManager.configureBubblesService(BubblesManager.java:67) at com.txusballesteros.bubbles.BubblesManager.access$100(BubblesManager.java:33) at com.txusballesteros.bubbles.BubblesManager$1.onServiceConnected(BubblesManager.java:52) at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1114) at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1131) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5586) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084) at dalvik.system.NativeStart.main(Native Method)

my code :

public class BubbleActivity extends AppCompatActivity {

    private BubblesManager bubblesManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initializeBubblesManager();
        addNewBubble();

    }

    private void addNewBubble() {
        BubbleLayout bubbleView = (BubbleLayout) LayoutInflater.from(this).inflate(R.layout.bubble_layout, null);
        ImageView avatar =(ImageView)bubbleView.findViewById(R.id.avatar);
        avatar.setImageResource(R.drawable.walking);
        bubbleView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) { }
        });
        bubbleView.setOnBubbleRemoveListener(new BubbleLayout.OnBubbleRemoveListener() {
            @Override
            public void onBubbleRemoved(BubbleLayout bubble) { }
        });
        bubblesManager.addBubble(bubbleView, 60, 20);
    }

    private void initializeBubblesManager() {
        bubblesManager = new BubblesManager.Builder(this)
                                    .setTrashLayout(R.layout.bubble_trash_layout)
                                    .build();
        bubblesManager.initialize();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        bubblesManager.recycle();
    }
txusballesteros commented 9 years ago

Hi, What version of the Lib are you using?

Lir10 commented 9 years ago

1.0

txusballesteros commented 9 years ago

Please, Can you check with the latest version? 1.0.1

Lir10 commented 9 years ago

is it in gradle ? i cant compile com.txusballesteros:bubbles:1.0.1

txusballesteros commented 9 years ago

Can you check now?

Lir10 commented 9 years ago

looks like it is fixed but still i see empty activity

txusballesteros commented 9 years ago

The problem is that you are adding the bubble before the service is be started.

Lir10 commented 9 years ago

thx now it's working!

txusballesteros commented 9 years ago

Now, with the new version, the 1.1 you can use this code. I have added a new callback to detect when the service has been started.

bubblesManager = new BubblesManager.Builder(this) .setTrashLayout(R.layout.bubble_trash_layout) .setInitializationCallback(new OnInitializedCallback() { @Override public void onInitialized() { addNewBubble(); } }) .build(); bubblesManager.initialize();