olarak adlandırılmamış iş parçacığı içinde işleyici oluşturulamıyor, bu yüzden benim Android uygulamasında kullanıyorum bir RxJava Gözlemlenebilir ile biraz sorun yaşıyorum. Bu son derece sinir bozucu çünkü bu bir süredir çalışıyor ve şimdi sadece yukarıdaki hatayı atıyor. Bunun başka bir iş parçacığından bir kullanıcı arabirimi işlemi gerçekleştirdiğimi, ancak bunun nerede olduğunu görmediğimin farkındayım. Bu flatmap hata oluyor nerede olduğunu tespitRxJava Looper.prepare()
ConnectionsList.getInstance(this).getConnectionsFromParse(mCurrentUser)
.delay(3, TimeUnit.SECONDS)
.flatMap(s -> mainData.getDataFromNetwork(this, mCurrentUser, mSimpleFacebook))
.flatMap(s -> mainData.getPictureFromUrl(s))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<Bitmap>() {
@Override
public void onCompleted() {
if (mCurrentUser.get(Constants.NAME) != null) {
mNavNameField.setText((String) mCurrentUser.get(Constants.NAME));
}
mSearchFragment.setupActivity();
}
@Override
public void onError(Throwable e) {
e.printStackTrace();
mSearchFragment.setEmptyView();
}
@Override
public void onNext(Bitmap bitmap) {
mNavProfImageField.setImageBitmap(bitmap);
mainData.saveImageToParse(bitmap); //save the image to Parse backend
}
});
bazı ayıklama sonra: Yani burada gözlemlenebilir
Bunun içinde.flatMap(s -> mainData.getDataFromNetwork(this, mCurrentUser, mSimpleFacebook))
şu, ben bir yorum nerede hata eklemiş edilir atılıyor:
return Observable.create(subscriber -> {
//set the username field if ParseUser is not null
if(currentUser != null) {
username = (String) currentUser.get(Constants.NAME);
}
//if prof pic is null then request from facebook. Should only be on the first login
if (currentUser != null && currentUser.getParseFile(Constants.PROFILE_IMAGE) == null) {
if (AccessToken.getCurrentAccessToken() != null) { //check if session opened properly
//get simple facebook and add the user properties we are looking to retrieve
Profile.Properties properties = new Profile.Properties.Builder()
.add(Profile.Properties.FIRST_NAME)
.add(Profile.Properties.GENDER)
.add(Profile.Properties.BIRTHDAY)
.add(Profile.Properties.ID)
.add(Profile.Properties.EMAIL)
.build();
//The following line is where the debugger stops
//and the error gets thrown
simpleFacebook.getProfile(properties, new OnProfileListener() {
@Override
public void onComplete(Profile response) {
String id = response.getId();
String name = response.getFirstName();
String gender = response.getGender();
String birthday = response.getBirthday();
String email = response.getEmail();
String age = getAge(birthday);
currentUser.put(Constants.NAME, name);
currentUser.put(Constants.AGE, age);
currentUser.put(Constants.GENDER, gender);
currentUser.put(Constants.EMAIL, email);
currentUser.saveInBackground();
if (id != null) { //display the profile image from facebook
subscriber.onNext("https://graph.facebook.com/" + id + "/picture?type=large");
}
}
Burada neler oluyor? Olduğu gibi çalışıyor ve şimdi bazı yardımcı iplik üzerinde olduğumu söylüyor. Bildiğim kadarıyla bu noktaya kadar UI iş parçacığı vardı. Eğer birisi bana yardım ederse, o zaman bana yardımcı olamadığı için RxJava'yı bırakmak zorunda kalabilirim. Şimdiden teşekkürler!
Sorunu şüpheli şudur: '.subscribeOn (Schedulers.io())'. Ağ işlemleriniz eşzamansız göründüğü için ana iş parçacığı programına abone olmalısınız. – corsair992
Yığın izini gönderir misiniz? 'GetProfile' ana iş parçacığında çağrılması gereken için mi? – zsxwing
Ben getprofile ana iş parçacığı üzerinde çağrılması gerekiyor sanıyorum ama neden daha önce çalışıyordu neden olduğu beni şaşırtmıyor. Abone Olmalı mıyım (AndroidSchedulers.MainThread)? –