Possible small bug fix and cleanup of unneeded code

git-svn-id: https://zxing.googlecode.com/svn/trunk@924 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2009-05-01 17:23:17 +00:00
parent ae1241880b
commit e168d0c3c6
2 changed files with 6 additions and 35 deletions

View file

@ -16,7 +16,6 @@
package com.google.zxing.client.android; package com.google.zxing.client.android;
import android.util.Log;
import org.apache.http.Header; import org.apache.http.Header;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
@ -69,9 +68,6 @@ public final class AndroidHttpClient implements HttpClient {
// Gzip of data shorter than this probably won't be worthwhile // Gzip of data shorter than this probably won't be worthwhile
private static final long DEFAULT_SYNC_MIN_GZIP_BYTES = 256; private static final long DEFAULT_SYNC_MIN_GZIP_BYTES = 256;
private static final String TAG = "AndroidHttpClient";
/** /**
* Set if HTTP requests are blocked from being executed on this thread * Set if HTTP requests are blocked from being executed on this thread
*/ */
@ -129,8 +125,6 @@ public final class AndroidHttpClient implements HttpClient {
private final HttpClient delegate; private final HttpClient delegate;
private RuntimeException mLeakedException = new IllegalStateException(
"AndroidHttpClient created and never closed");
private AndroidHttpClient(ClientConnectionManager ccm, HttpParams params) { private AndroidHttpClient(ClientConnectionManager ccm, HttpParams params) {
this.delegate = new DefaultHttpClient(ccm, params) { this.delegate = new DefaultHttpClient(ccm, params) {
@ -155,15 +149,6 @@ public final class AndroidHttpClient implements HttpClient {
}; };
} }
@Override
protected void finalize() throws Throwable {
super.finalize();
if (mLeakedException != null) {
Log.e(TAG, "Leak found", mLeakedException);
mLeakedException = null;
}
}
/** /**
* Block this thread from executing HTTP requests. * Block this thread from executing HTTP requests.
* Used to guard against HTTP requests blocking the main application thread. * Used to guard against HTTP requests blocking the main application thread.
@ -212,15 +197,8 @@ public final class AndroidHttpClient implements HttpClient {
return responseStream; return responseStream;
} }
/**
* Release resources associated with this client. You must call this,
* or significant resources (sockets and memory) may be leaked.
*/
public void close() { public void close() {
if (mLeakedException != null) { // do nothing
getConnectionManager().shutdown();
mLeakedException = null;
}
} }
public HttpParams getParams() { public HttpParams getParams() {
@ -279,7 +257,7 @@ public final class AndroidHttpClient implements HttpClient {
*/ */
public static AbstractHttpEntity getCompressedEntity(byte[] data) throws IOException { public static AbstractHttpEntity getCompressedEntity(byte[] data) throws IOException {
AbstractHttpEntity entity; AbstractHttpEntity entity;
if (data.length < getMinGzipSize()) { if (data.length < DEFAULT_SYNC_MIN_GZIP_BYTES) {
entity = new ByteArrayEntity(data); entity = new ByteArrayEntity(data);
} else { } else {
ByteArrayOutputStream arr = new ByteArrayOutputStream(); ByteArrayOutputStream arr = new ByteArrayOutputStream();
@ -295,11 +273,4 @@ public final class AndroidHttpClient implements HttpClient {
return entity; return entity;
} }
/**
* Retrieves the minimum size for compressing data.
* Shorter data will not be compressed.
*/
private static long getMinGzipSize() {
return DEFAULT_SYNC_MIN_GZIP_BYTES;
}
} }

View file

@ -147,8 +147,8 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
} }
Intent intent = getIntent(); Intent intent = getIntent();
String action = intent.getAction(); String action = intent == null ? null : intent.getAction();
String dataString = intent.getDataString(); String dataString = intent == null ? null : intent.getDataString();
if (intent != null && action != null) { if (intent != null && action != null) {
if (action.equals(Intents.Scan.ACTION) || action.equals(Intents.Scan.DEPRECATED_ACTION)) { if (action.equals(Intents.Scan.ACTION) || action.equals(Intents.Scan.DEPRECATED_ACTION)) {
// Scan the formats the intent requested, and return the result to the calling activity. // Scan the formats the intent requested, and return the result to the calling activity.
@ -156,7 +156,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
mDecodeMode = intent.getStringExtra(Intents.Scan.MODE); mDecodeMode = intent.getStringExtra(Intents.Scan.MODE);
resetStatusView(); resetStatusView();
} else if (dataString != null && dataString.contains(PRODUCT_SEARCH_URL_PREFIX) && } else if (dataString != null && dataString.contains(PRODUCT_SEARCH_URL_PREFIX) &&
dataString.contains(PRODUCT_SEARCH_URL_PREFIX)) { dataString.contains(PRODUCT_SEARCH_URL_SUFFIX)) {
// Scan only products and send the result to mobile Product Search. // Scan only products and send the result to mobile Product Search.
mSource = Source.PRODUCT_SEARCH_LINK; mSource = Source.PRODUCT_SEARCH_LINK;
mSourceUrl = dataString; mSourceUrl = dataString;
@ -465,7 +465,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
startActivity(intent); startActivity(intent);
} }
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
Log.w(TAG, e);
} }
} }