otto

Communicative Between Fragments on Android

醉酒当歌 提交于 2019-12-20 03:20:16
问题 I am attempting to build an Android application that has two tabs, one for a textField/button and TreeMenu (where each element has a checkbox associated with it) and another for a list. I am also using an ActionBarSherlock. I have already successfully written the program in a single main activity, but am having difficulty figuring out how to divide this original activity to correspond with the two new fragment instances I need to create for each tab. Moreover, each time an item is added in

IllegalArgumentException with Otto Event bus in Fragment instance

给你一囗甜甜゛ 提交于 2019-12-18 10:55:18
问题 I am using Otto Event bus to subscribe to certain events in a ListFragment. The bus instance is stored and created in an subclass of Application, in other words, it bus should work as a singleton. It seems like this is not a case... The fragment is registering to the bus in onActivityCreated(Bundle) and unregistering in onDestroy() . This does not work as it should. I have gotten several crash reports from devices where the app crashes when calling unregister() (java.lang

How to send event from Service to Activity with Otto event bus?

你离开我真会死。 提交于 2019-12-17 10:11:19
问题 Simple BusProvider.getInstance().post() bring exception not main thread . How to send event from Service to Activity with Otto event bus? 回答1: To post from any thread (main or background) and receive on the main thread, try something like public class MainThreadBus extends Bus { private final Handler mHandler = new Handler(Looper.getMainLooper()); @Override public void post(final Object event) { if (Looper.myLooper() == Looper.getMainLooper()) { super.post(event); } else { mHandler.post(new

Is event bus library mechanism as bad as the use of static variables to pass data between activities?

a 夏天 提交于 2019-12-12 17:05:39
问题 I'm learning Android, and AFAIK, the standard Android mechanism to pass data between Activities is using Intents which in turn are implemented as IPC on lower level (maybe I'm wrong). It seems that recently have emerged a bunch of libraries to make life easier to Android devs. Between them, the famous Event Bus (Greenrobot's one, Square's Otto). I've been trying both (almost exact interface semantics) and have seen some posts around on how to use Greenrobot event bus to post events to an

How to manage otto registration methods in ViewPager

余生颓废 提交于 2019-12-08 13:48:33
问题 I am using otto to communicate service and map fragment. In the service, location provider obtains location data sends to map fragment. It works perfectly but i can not manage otto's register and unregister methods with ViewPager . This question refers neither otto nor ViewPager problem. As mentioned above, when the service received location data it sends to map fragment. For this, i have to register/unregister fragment and service in their specific lifecycle events. At this point i am facing

RuntimeException: Could not dispatch event @ otto

不打扰是莪最后的温柔 提交于 2019-12-06 19:10:48
问题 we have an issue in our current app-version with the EventHandler from otto. We get a RuntimeException in our crash-log, with following description: "Reason: java.lang.RuntimeException: Could not dispatch event: classcom.nameOfBrand.ui.events.SwitchFragmentEvent to handler [EventHandler public void com.nameOfBrand.ui.activities.MainActivity.onSwitchFragmentEvent(com.nameOfBrand.ui.events.SwitchFragmentEvent)]" We have a button and in its onClickListener we fire an self-defined

Subscriber not getting fired when using Otto

筅森魡賤 提交于 2019-12-06 07:44:53
问题 I'm trying out Otto on Android and i'm trying to send back a message from my Fragment to the Activity. Here's the basics of my code: My Bus provider: public final class BusProvider { private static final Bus mInstance = new Bus(); private BusProvider() {} public static Bus getBusProviderInstance() { return mInstance; } } My Activity has the following code: public class MyActivity extends BaseActivity { // .... @Override public void onCreate(Bundle savedInstanceState) { super.onCreate

Passing data from Activity to Fragment using Otto

谁说我不能喝 提交于 2019-12-06 07:16:50
问题 In my application I'm adding Fragments dynamically to the container in main activity view. I would like to know what is the best way to pass data when using Otto when we add Fragment. Currently this is how I'm doing it, please in example I'm not posting my CustomObject Inside My Main Activity getSupportFragmentManager().beginTransaction() .add(R.id.fragment_container, MY_CUSTOM_FRAGMENT).commit(); BusProvider.getInstance().post(produceCustomString()); Inside My Fragment @Subscribe public void

RuntimeException: Could not dispatch event @ otto

被刻印的时光 ゝ 提交于 2019-12-05 00:46:39
we have an issue in our current app-version with the EventHandler from otto. We get a RuntimeException in our crash-log, with following description: "Reason: java.lang.RuntimeException: Could not dispatch event: classcom.nameOfBrand.ui.events.SwitchFragmentEvent to handler [EventHandler public void com.nameOfBrand.ui.activities.MainActivity.onSwitchFragmentEvent(com.nameOfBrand.ui.events.SwitchFragmentEvent)]" We have a button and in its onClickListener we fire an self-defined SwitchFragmentEvent . In some weird situations, the framework can't dispatch the Event and throws an RuntimeException

Synchronize ListFragment and SupportMapFragment selection

青春壹個敷衍的年華 提交于 2019-12-04 19:31:06
I have 2 views of essentially the same data: List of items in a android.support.v4.app. ListFragment Markers on a map in a com.google.android.gms.maps. SupportMapFragment Both of the above are using loader pattern to obtain the same data (extending LoaderCallbacks , querying ContentProvider , and so on) Both are hosted within a single activity inside a ViewPager. What will be the best strategy to synchronize currently selected list item / marker for both of these fragments? (Think of "My Places" edit UI, or "Directions" of the Google Maps with their left-hand pane and a map in the center).