mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
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:
parent
ae1241880b
commit
e168d0c3c6
|
@ -16,7 +16,6 @@
|
|||
|
||||
package com.google.zxing.client.android;
|
||||
|
||||
import android.util.Log;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpEntity;
|
||||
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
|
||||
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
|
||||
*/
|
||||
|
@ -129,8 +125,6 @@ public final class AndroidHttpClient implements HttpClient {
|
|||
|
||||
private final HttpClient delegate;
|
||||
|
||||
private RuntimeException mLeakedException = new IllegalStateException(
|
||||
"AndroidHttpClient created and never closed");
|
||||
|
||||
private AndroidHttpClient(ClientConnectionManager ccm, HttpParams 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.
|
||||
* Used to guard against HTTP requests blocking the main application thread.
|
||||
|
@ -212,15 +197,8 @@ public final class AndroidHttpClient implements HttpClient {
|
|||
return responseStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release resources associated with this client. You must call this,
|
||||
* or significant resources (sockets and memory) may be leaked.
|
||||
*/
|
||||
public void close() {
|
||||
if (mLeakedException != null) {
|
||||
getConnectionManager().shutdown();
|
||||
mLeakedException = null;
|
||||
}
|
||||
// do nothing
|
||||
}
|
||||
|
||||
public HttpParams getParams() {
|
||||
|
@ -279,7 +257,7 @@ public final class AndroidHttpClient implements HttpClient {
|
|||
*/
|
||||
public static AbstractHttpEntity getCompressedEntity(byte[] data) throws IOException {
|
||||
AbstractHttpEntity entity;
|
||||
if (data.length < getMinGzipSize()) {
|
||||
if (data.length < DEFAULT_SYNC_MIN_GZIP_BYTES) {
|
||||
entity = new ByteArrayEntity(data);
|
||||
} else {
|
||||
ByteArrayOutputStream arr = new ByteArrayOutputStream();
|
||||
|
@ -295,11 +273,4 @@ public final class AndroidHttpClient implements HttpClient {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,8 +147,8 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
|||
}
|
||||
|
||||
Intent intent = getIntent();
|
||||
String action = intent.getAction();
|
||||
String dataString = intent.getDataString();
|
||||
String action = intent == null ? null : intent.getAction();
|
||||
String dataString = intent == null ? null : intent.getDataString();
|
||||
if (intent != null && action != null) {
|
||||
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.
|
||||
|
@ -156,7 +156,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
|||
mDecodeMode = intent.getStringExtra(Intents.Scan.MODE);
|
||||
resetStatusView();
|
||||
} 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.
|
||||
mSource = Source.PRODUCT_SEARCH_LINK;
|
||||
mSourceUrl = dataString;
|
||||
|
@ -465,7 +465,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
|||
startActivity(intent);
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue