Skip to content

Commit 8800a7d

Browse files
committed
Added logging to RequestHandle cancelling
1 parent 9e117fa commit 8800a7d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
package com.loopj.android.http.sample;
22

3+
import android.util.Log;
4+
35
import com.loopj.android.http.RequestHandle;
46

57
public class CancelRequestHandleSample extends ThreadingTimeoutSample {
68

9+
private static final String LOG_TAG = "ThreadingTimeoutSample";
10+
711
@Override
812
public int getSampleTitle() {
913
return R.string.title_cancel_handle;
1014
}
1115

1216
@Override
1317
public void onCancelButtonPressed() {
18+
Log.d(LOG_TAG, String.format("Number of handles found: %d", getRequestHandles().size()));
19+
int counter = 0;
1420
for (RequestHandle handle : getRequestHandles()) {
1521
if (!handle.isCancelled() && !handle.isFinished()) {
16-
handle.cancel(true);
22+
Log.d(LOG_TAG, String.format("Cancelling handle %d", counter));
23+
Log.d(LOG_TAG, String.format("Handle %d cancel", counter) + (handle.cancel(true) ? " succeeded" : " failed"));
24+
} else {
25+
Log.d(LOG_TAG, String.format("Handle %d already non-cancellable", counter));
1726
}
27+
counter++;
1828
}
1929
}
2030
}

0 commit comments

Comments
 (0)