Skip to content

Commit 52abf6c

Browse files
committed
update HttpHandler
1 parent 5c5c8f0 commit 52abf6c

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

library/src/com/lidroid/xutils/http/HttpHandler.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private ResponseInfo<T> sendRequest(HttpRequestBase request) throws HttpExceptio
141141

142142
@Override
143143
protected Void doInBackground(Object... params) {
144-
if (mStopped || params == null || params.length == 0) return null;
144+
if (this.state == State.STOPPED || params == null || params.length == 0) return null;
145145

146146
if (params.length > 3) {
147147
fileSavePath = String.valueOf(params[1]);
@@ -151,7 +151,7 @@ protected Void doInBackground(Object... params) {
151151
}
152152

153153
try {
154-
if (mStopped) return null;
154+
if (this.state == State.STOPPED) return null;
155155
// init request & requestUrl
156156
request = (HttpRequestBase) params[0];
157157
requestUrl = request.getURI().toString();
@@ -183,7 +183,7 @@ protected Void doInBackground(Object... params) {
183183
@Override
184184
@SuppressWarnings("unchecked")
185185
protected void onProgressUpdate(Object... values) {
186-
if (mStopped || values == null || values.length == 0 || callback == null) return;
186+
if (this.state == State.STOPPED || values == null || values.length == 0 || callback == null) return;
187187
switch ((Integer) values[0]) {
188188
case UPDATE_START:
189189
this.state = State.STARTED;
@@ -254,14 +254,10 @@ private ResponseInfo<T> handleResponse(HttpResponse response) throws HttpExcepti
254254
return null;
255255
}
256256

257-
private boolean mStopped = false;
258-
259257
/**
260258
* stop request task.
261259
*/
262-
@Override
263260
public void stop() {
264-
this.mStopped = true;
265261
this.state = State.STOPPED;
266262

267263
if (request != null && !request.isAborted()) {
@@ -282,9 +278,8 @@ public void stop() {
282278
}
283279
}
284280

285-
@Override
286281
public boolean isStopped() {
287-
return mStopped;
282+
return this.state == State.STOPPED;
288283
}
289284

290285
public RequestCallBack<T> getRequestCallBack() {
@@ -295,7 +290,7 @@ public RequestCallBack<T> getRequestCallBack() {
295290

296291
@Override
297292
public boolean updateProgress(long total, long current, boolean forceUpdateUI) {
298-
if (callback != null && !mStopped) {
293+
if (callback != null && this.state != State.STOPPED) {
299294
if (forceUpdateUI) {
300295
this.publishProgress(UPDATE_LOADING, total, current);
301296
} else {
@@ -306,7 +301,7 @@ public boolean updateProgress(long total, long current, boolean forceUpdateUI) {
306301
}
307302
}
308303
}
309-
return !mStopped;
304+
return this.state != State.STOPPED;
310305
}
311306

312307
public enum State {

library/src/com/lidroid/xutils/http/callback/RequestCallBackHandler.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,4 @@ public interface RequestCallBackHandler {
2323
* @return continue
2424
*/
2525
boolean updateProgress(long total, long current, boolean forceUpdateUI);
26-
27-
void stop();
28-
29-
boolean isStopped();
3026
}

0 commit comments

Comments
 (0)