use of zipkin2.Call in project retrofit by square.
the class CancelDisposeTest method disposeCancelsCall.
@Test
public void disposeCancelsCall() {
Subscription subscription = service.go().subscribe();
List<Call> calls = client.dispatcher().runningCalls();
assertEquals(1, calls.size());
subscription.unsubscribe();
assertTrue(calls.get(0).isCanceled());
}
use of zipkin2.Call in project retrofit by square.
the class CancelDisposeTest method cancelDoesNotDispose.
@Test
public void cancelDoesNotDispose() {
Subscription subscription = service.go().subscribe();
List<Call> calls = client.dispatcher().runningCalls();
assertEquals(1, calls.size());
calls.get(0).cancel();
assertFalse(subscription.isUnsubscribed());
}
use of zipkin2.Call in project retrofit by square.
the class CancelDisposeTest method cancelDoesNotDispose.
@Test
public void cancelDoesNotDispose() {
Disposable disposable = service.go().subscribe();
List<Call> calls = client.dispatcher().runningCalls();
assertEquals(1, calls.size());
calls.get(0).cancel();
assertFalse(disposable.isDisposed());
}
use of zipkin2.Call in project Online_Android_2018_Spring by coding-blocks-archives.
the class MainActivity method makeNetworkCall.
void makeNetworkCall(String url) throws IOException {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(url).build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
// Show a toast
}
@Override
public void onResponse(Call call, Response response) throws IOException {
// This method does not run on the Main Thread
String result = response.body().string();
// ArrayList<GithubUser> users = parseJson(result);
Gson gson = new Gson();
ApiResult apiResult = gson.fromJson(result, ApiResult.class);
final GithubUserAdapter githubUserAdapter = new GithubUserAdapter(apiResult.getItems());
MainActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
// Code here runs on the Main thread
RecyclerView recyclerView = findViewById(R.id.rvUsers);
recyclerView.setLayoutManager(new LinearLayoutManager(getBaseContext()));
recyclerView.setAdapter(githubUserAdapter);
}
});
}
});
}
use of zipkin2.Call in project Dxditor by kimi2009.
the class MainpageModel method getTestData.
@Override
public void getTestData(final ValueCallBack<List<SbxxBean>> callBack) {
list = new ArrayList<SbxxBean>();
if (Constants.testData) {
list.add(new SbxxBean(0, "", "3"));
list.add(new SbxxBean(1, "", "57"));
list.add(new SbxxBean(2, "", "31"));
callBack.onSuccess(list);
} else {
Request request = new Request.Builder().url(Constants.getAppDeviceStausCount).build();
okHttpClient.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String res = response.body().string();
System.out.println("getAppDeviceStausCount:" + res);
try {
JSONObject js = new JSONObject(res);
if (js.getBoolean("success")) {
list = gson.fromJson(js.getString("data"), new TypeToken<ArrayList<SbxxBean>>() {
}.getType());
callBack.onSuccess(list);
} else {
callBack.onFail("01");
}
} catch (Exception e) {
callBack.onFail("01");
e.printStackTrace();
}
}
});
}
}
Aggregations