tajchert / BusWear

EventBus for Android Wear devices.
Apache License 2.0
257 stars 23 forks source link

BusWear with Parceler #3

Closed theshapguy closed 9 years ago

theshapguy commented 9 years ago
 02-23 20:25:15.805    3253-3253/np.pushy D/Event﹕ No local subscribers registered for event class com.neptiun.pushy.event.ButtonClickEvent$$Parcelable

I parceled objects with "Parceler", the infamous parceler library, however, I'm getting no subscribers registered for event.

Any way possible for them to work together?

There is too much boilerplate code involved in extending Parceler, would be great if they both worked together?

Parceler Library Link

tajchert commented 9 years ago

Do you have any class that have "onEvent(ClassThatYouUseParcelerFor object){}" ? Because error states that there are no local subscribers to that event class. However Parcerel might not be possible to combine with Android Wear at all as in classes generated by it there are missing some methods - I had very simple classes so I ended up using manually Parcelable.

But back to your problem, it would be nice to see some code, how you are sending it, what object etc.

theshapguy commented 9 years ago

Parceler Objec via Parceler

@Parcel
public class ButtonClickEvent {
    String test;

    public ButtonClickEvent(){

    }

    public ButtonClickEvent(String test){
        this.test = test;
    }

    public String getName() { return test; }

}

Event Post

    @OnClick(R.id.button)
    public void test_button(View v){
        //Log.d(TAG, "Test Button");

        Parcelable wrapped = Parcels.wrap(new ButtonClickEvent("Andy"));

        EventBus.getDefault().postLocal(wrapped);

    }

Event Receiver

 public void onEvent(ButtonClickEvent parcler){

        Log.d("Event", "Button Event");
    }

Since Parceler is being automatically generated I cannot have a onEvent(ButtonClickEvent$$Parcelable) Any possible get arounds?

theshapguy commented 9 years ago

Also in your code you have written, implements Parcelable but I would suggest using Parceler or Auto-Parcel library (or any other). therefore I used that library, but have some doubts now.

tajchert commented 9 years ago

Yeah, I also find that issue later on working on other project with Wear (without that library). And couldn't get it to work with Android Wear, so I move to manual Parcelabling. After all I forgot to update README. Anybody with solution is welcome here at this point.

theshapguy commented 9 years ago

I ended up using Parcelabler. Works fine till now.