Add filter for failed get users requests
parent
5b2ff57d5d
commit
4acb04c4eb
|
@ -107,10 +107,16 @@ public class MainActivity extends AppCompatActivity {
|
||||||
return RestClient.getGitHubApi().getUsers(new Random().nextInt(1000)).execute().body();
|
return RestClient.getGitHubApi().getUsers(new Random().nextInt(1000)).execute().body();
|
||||||
} catch (IOException ioException) {
|
} catch (IOException ioException) {
|
||||||
ioException.printStackTrace();
|
ioException.printStackTrace();
|
||||||
return new ArrayList<GitHubUser>();
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.filter(new Func1<List<GitHubUser>, Boolean>() {
|
||||||
|
@Override
|
||||||
|
public Boolean call(List<GitHubUser> gitHubUsers) {
|
||||||
|
return gitHubUsers != null;
|
||||||
|
}
|
||||||
|
})
|
||||||
.subscribeOn(Schedulers.io()).
|
.subscribeOn(Schedulers.io()).
|
||||||
observeOn(AndroidSchedulers.mainThread());
|
observeOn(AndroidSchedulers.mainThread());
|
||||||
|
|
||||||
|
@ -121,12 +127,10 @@ public class MainActivity extends AppCompatActivity {
|
||||||
public void onCompleted() {
|
public void onCompleted() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(List<GitHubUser> gitHubUsers) {
|
public void onNext(List<GitHubUser> gitHubUsers) {
|
||||||
adapter.setItems(gitHubUsers);
|
adapter.setItems(gitHubUsers);
|
||||||
|
|
Reference in New Issue