greenrobot-eventbus

Event Bus Fragment Unregister

烈酒焚心 提交于 2019-12-18 11:59:40
问题 I've a splashscreen Fragment that is registered to event bus: @Override public void onStart() { super.onStart(); EventBus.getDefault().register(this); } @Override public void onStop() { EventBus.getDefault().unregister(this); super.onStop(); } If the screen goes autolock (or any other event that could call onStop), the container activity goes onStop and the fragment is no more capable to receive the (network) event. I'm thinking about moving "unregister" logic to onDestroy method. Is it a

Subscriber class has no public methods called on Event

独自空忆成欢 提交于 2019-12-14 04:16:13
问题 while using green Robot Eventbus I got an error E/AndroidRuntime(2537): Caused by: de.greenrobot.event.EventBusException: Subscriber class com.example.MyActivity has no public methods called onEvent Details: I'm loading Activity which contains a fragment with 10 child fragments, rather than calling EventBus.getDefault().register(this); in every nested (child) fragment I called that register in a parent activity of that fragment. 回答1: Solved by declaring the onEventMainThread method and

EventBus Not on the main thread

戏子无情 提交于 2019-12-13 12:41:21
问题 I'm trying to get the positions from my WS and update my markers in my GoogleMap fragment so what I'm doing is: I've my HomeActivity which contains 2 fragments (2 GoogleMaps where one have TileOverlay). In my GoogleMap fragment I'm trying to obtain my Markers Positions from OnCameraChangeListener so the markers are added as the user moves on. I'm using EventBus and Okhttp for an async request! My GoogleMapFragment: public class GoogleMapFragment extends FragmentBase { @Override public void

EventBus on Android: how to implement dynamic queues vs. class-based event subscription?

强颜欢笑 提交于 2019-12-12 19:15:43
问题 I want to use EventBus (by Greenrobot, or any other) for the communication between the components of my Android application. In all the example, the pub/sub was implemented using a "class" as a "topic", i.e. each subscriber declares the exact class of events it should receive. I wonder if there is a more dynamic mechanism. Here is what I need to accomplish: my app needs to send commands (say, "Hello!") to multiple systems: 1, 2, ... N. The structure of the command is the same for all of them.

Android app long-click: works in from Android Studio, not otherwise

好久不见. 提交于 2019-12-12 03:55:54
问题 This is a really bizarre one.... I've written a very simple Android shopping-list app which uses a RecyclerView . I want the user to long-click on an item to select it for deletion, etc. The long-click works fine when I run the app from Android Studio, both on the emulator and via USB on a real device; it doesn't work when the app is installed independently. By "doesn't work", I mean that the app simply doesn't respond to a long-click. It doesn't crash or anything; just nothing happens.

subscriber does not get posted message from eventBus

牧云@^-^@ 提交于 2019-12-11 07:23:50
问题 I want to use eventbus into my app. for that I add eventbus lib to my gradle.then I have created a class like this: public class UserEvent { private User eUser; // esup user model private String domain; private String securitySrv; private Cookie cookie; private int totalUsersSecurity; private ExecutorService executorService; // constructor and getter then into main fragment I have added this lines and finally I have posted my message: UserEvent userEvent = new UserEvent(eUser, domain,

Eventbus onMessageEvent not getting called

蹲街弑〆低调 提交于 2019-12-11 03:35:53
问题 I have implemented EventBus in my project but I am not getting all of my events public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button button = findViewById(R.id.btn); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { EventBus.getDefault().post(new MessageEvent()); EventBus.getDefault().post(new

Android : Notified when all Async calls are completed

。_饼干妹妹 提交于 2019-12-11 01:38:16
问题 I am stuck in one implementation. I am developing an Android application, into which I integrated 3rd party SDK (library) and calling its APIs. Function calling of SDK is actually Async calls (WebAPI calls called by the library) which gives a response (success or failure). Now, I am trying to explain the situation by code. for (................) { AsyncAPICall (SuccessListener { onSuccess() { for (................) { AsyncAPICall (SuccessListener { onSuccess() { for (................) {

Kotlin: Can we use @Subscribe of EventBus (GreenRobot) in Kotlin?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 02:26:55
问题 My onEvent in a fragment as below, capturing the authentication of the activity, in my Kotlin function. However, I can't get that onEvent triggered. @Subscribe fun onEvent(event: AuthenticationEvent) { if (event.isAuthenticated) { startFragment(signInFragment, SignInFragment.TAG) } else { startFragment(signOutFragment, SignOutFragment.TAG) } } In my build.gradle file, I have add this compile 'org.greenrobot:eventbus:3.0.0' Is there anything I need to do to get this trigger? 回答1: To use

How does eventbus register the onevent method before the class is invoked?

冷暖自知 提交于 2019-12-08 04:04:03
问题 The listItemFragment post an event to the ItemDetailFragment to refresh the UI. BUt the ItemDetailFragment is never used before, so the register() method in ItemDetailFragment is never invoked. So I want to know how the posted event in listItemFragment know the onevent method in ItemDetailFragment. Here is the source code: package com.angeldevil.eventbusdemo; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.View; import android.widget.ArrayAdapter;