We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
大大你好,你写的文章上说Subscriber.onStart()总是在 subscribe所发生的线程被调用,但下面的代码并没有报错: String baseUrl = "https://api.douban.com/v2/movie/"; Retrofit retrofit = new Retrofit.Builder() .baseUrl(baseUrl) .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .build();
ClientApi clientApi = retrofit.create(ClientApi.class); clientApi.getTopMovies(0, 5) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Subscriber<MovieEntity>() { @Override public void onStart() { progressBar.setVisibility(View.VISIBLE); } @Override public void onCompleted() { progressBar.setVisibility(View.GONE); Toast.makeText(context, "完成网络请求!", Toast.LENGTH_LONG).show(); } @Override public void onError(Throwable e) { text.setText(e.getMessage()); } @Override public void onNext(MovieEntity movieEntity) { text.setText(movieEntity.toString()); } });
我使用subscribeOn设置subscribe()在IO线程,直接在onStart()方法中显示progressBar,按理说progressBar没有在主线程执行,应用会奔溃才对,但是一切正常
The text was updated successfully, but these errors were encountered:
onStart()应该是跟随你当前线程的,如果你当前在主线程的话,肯定不会异常
Sorry, something went wrong.
progress是貌似是可以在线程中使用的唯一的一个VIEW
RXJAVA 可以指定ONSTART的使用线程
确实有这个问题,是什么原因,指定是子线程,但onStart也可以显示dialog或者其他的loading
No branches or pull requests
大大你好,你写的文章上说Subscriber.onStart()总是在 subscribe所发生的线程被调用,但下面的代码并没有报错:
String baseUrl = "https://api.douban.com/v2/movie/";
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();
我使用subscribeOn设置subscribe()在IO线程,直接在onStart()方法中显示progressBar,按理说progressBar没有在主线程执行,应用会奔溃才对,但是一切正常
The text was updated successfully, but these errors were encountered: