otto

Best Practices for Handling Search

主宰稳场 提交于 2019-12-04 17:35:15
问题 I've got a SearchView setup, and I have a loosely decoupled architecture using Retrofit and Otto . I am wondering what the Best Practices are for Search in Android, or any mobile application in general (meaning something like this could be applied to iOS as well). Specifically I am using an AutoCompleteTextView to handle suggestions in my SearchView and the data is coming straight from the API . I don't believe this is a best practice since everytime a user changes text in the SearchView

Passing data from Activity to Fragment using Otto

寵の児 提交于 2019-12-04 14:29:49
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 onCustomStringChanged(String customString) { } Jake Wharton Methods annotated with @Subscribe will

Subscriber not getting fired when using Otto

可紊 提交于 2019-12-04 12:15:46
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(savedInstanceState); BusProvider.getBusProviderInstance().register(this); // .... } @OnClick(R.id.profile_image

Which Activity lifecycle methods are best to register/unregister to event bus?

£可爱£侵袭症+ 提交于 2019-12-03 14:48:56
问题 What is the best place to register and unregister to an event bus (like otto, EventBus, or tinybus) in an Activity and why? onCreate()-onDestroy() onStart()-onStop() onResume()-onPause() Otto's example uses onResume()-onPause(), EventBus's mentions onStart()-onStop(), and we needed to use onCreate()-onDestroy() in our app to update the activity's UI even when it was in the background. So I guess it can be any of the three depending on the nature of the events and their handling, but I was

Gradle could not resolve otto library

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I try to embed Otto library, which exists at the Maven Central . buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.6.3' } } apply plugin: 'android' dependencies { compile 'com.google.android.gms:play-services:4.0.30' compile 'com.android.support:support-v13:19.0.0' compile 'com.squareup:otto:1.3.4' } But I get the exception: A problem occurred configuring root project 'sample-project'. > Failed to notify project evaluation listener. > Could not resolve all dependencies for configuration

How do I effectively use an event bus?

北慕城南 提交于 2019-12-03 08:41:57
Right now I am exploring some options for an android learning project. I am trying to communicate with my rails api (also a learning project). After doing some research, I think I have settled on a scheme that uses retrofit and otto. What I end up with is this. When I want to make a call to my rails server (in this case to do a signup) I do this in the activity. mBus.post(new SignupRequestEvent(new UserRequestParams(mName,mEmail,mPassword,mPasswordConfirmation ))); and then in the same activity I have this. @Subscribe public void onSignupCompleted(SignupCompletedEvent event) { System.out

Using Intents or an event bus to communicate within the same app

社会主义新天地 提交于 2019-12-03 05:41:54
问题 I understand how to use Intents to communicate with the system/other apps. I understand how to use Intents within the same App. I also understand how to use Otto to communicate within the same App. What are the Pro/Cons of using Otto vs. Intents to communicate between my Activities/Services? 回答1: Pros for using Otto: You get to design your own event types, versus having to use custom actions or something to distinguish one Intent from another Everything is within your own process (contrast

Which Activity lifecycle methods are best to register/unregister to event bus?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 04:35:39
What is the best place to register and unregister to an event bus (like otto, EventBus, or tinybus) in an Activity and why? onCreate()-onDestroy() onStart()-onStop() onResume()-onPause() Otto's example uses onResume()-onPause(), EventBus's mentions onStart()-onStop(), and we needed to use onCreate()-onDestroy() in our app to update the activity's UI even when it was in the background. So I guess it can be any of the three depending on the nature of the events and their handling, but I was wondering if there is anything more to it that should be considered. @levavare, I think the correct time

IllegalArgumentException with Otto Event bus in Fragment instance

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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.IllegalArgumentException: Missing event handler for an annotated

Using Intents or an event bus to communicate within the same app

一曲冷凌霜 提交于 2019-12-02 20:15:51
I understand how to use Intents to communicate with the system/other apps. I understand how to use Intents within the same App. I also understand how to use Otto to communicate within the same App. What are the Pro/Cons of using Otto vs. Intents to communicate between my Activities/Services? Pros for using Otto: You get to design your own event types, versus having to use custom actions or something to distinguish one Intent from another Everything is within your own process (contrast with startActivity() and kin, which always involve IPC, even if the activity you are starting is in your own