Skip to content

Commit fb5cb28

Browse files
authored
Merge pull request kaushikgopal#62 from ObjectiveTruth/master
Added javadoc comments and removed line in the Volley + RxAndroid example
2 parents a4d5a44 + c2124da commit fb5cb28

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

app/src/main/java/com/morihacky/android/rxjava/volley/VolleyDemoFragment.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ public void onDestroyView() {
7474
ButterKnife.unbind(this);
7575
}
7676

77+
/**
78+
* Creates and returns an observable generated from the Future returned from
79+
* {@code getRouteData()}. The observable can then be subscribed to as shown in
80+
* {@code startVolleyRequest()}
81+
* @return Observable<JSONObject>
82+
*/
7783
public Observable<JSONObject> newGetRouteData() {
7884
return Observable.defer(() -> {
7985
try {
@@ -119,11 +125,16 @@ public void onNext(JSONObject jsonObject) {
119125
}
120126
}));
121127
}
122-
128+
/**
129+
* Converts the Asynchronous Request into a Synchronous Future that can be used to
130+
* block via {@code Future.get()}. Observables require blocking/synchronous functions
131+
* @return JSONObject
132+
* @throws ExecutionException
133+
* @throws InterruptedException
134+
*/
123135
private JSONObject getRouteData() throws ExecutionException, InterruptedException {
124136
RequestFuture<JSONObject> future = RequestFuture.newFuture();
125137
String url = "http://www.weather.com.cn/adat/sk/101010100.html";
126-
final Request.Priority priority = Request.Priority.IMMEDIATE;
127138
JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET, url, future, future);
128139
MyVolley.getRequestQueue().add(req);
129140
return future.get();

0 commit comments

Comments
 (0)