More reckless refactoring and code style tweaks -- mostly adding braces around conditional/loops, and using @Override

git-svn-id: https://zxing.googlecode.com/svn/trunk@784 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2008-12-11 23:34:49 +00:00
parent c91265df17
commit 131cfe4c5c
40 changed files with 128 additions and 71 deletions

View file

@ -20,7 +20,6 @@ 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.HttpEntityEnclosingRequest; import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpException;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
import org.apache.http.HttpMessage; import org.apache.http.HttpMessage;
import org.apache.http.HttpRequest; import org.apache.http.HttpRequest;
@ -212,7 +211,9 @@ public final class AndroidHttpClient implements HttpClient {
if (contentEncoding == null) { if (contentEncoding == null) {
return responseStream; return responseStream;
} }
if (contentEncoding.contains("gzip")) responseStream = new GZIPInputStream(responseStream); if (contentEncoding.contains("gzip")) {
responseStream = new GZIPInputStream(responseStream);
}
return responseStream; return responseStream;
} }
@ -281,7 +282,7 @@ public final class AndroidHttpClient implements HttpClient {
* @param data The bytes to compress * @param data The bytes to compress
* @return Entity holding the data * @return Entity holding the data
*/ */
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 < getMinGzipSize()) {
entity = new ByteArrayEntity(data); entity = new ByteArrayEntity(data);
@ -371,7 +372,7 @@ public final class AndroidHttpClient implements HttpClient {
* Logs cURL commands equivalent to requests. * Logs cURL commands equivalent to requests.
*/ */
private final class CurlLogger implements HttpRequestInterceptor { private final class CurlLogger implements HttpRequestInterceptor {
public final void process(HttpRequest request, HttpContext context) public void process(HttpRequest request, HttpContext context)
throws IOException { throws IOException {
LoggingConfiguration configuration = curlConfiguration; LoggingConfiguration configuration = curlConfiguration;
if (configuration != null if (configuration != null

View file

@ -51,7 +51,7 @@ public final class BookmarkPickerActivity extends ListActivity {
private Cursor mCursor; private Cursor mCursor;
@Override @Override
protected final void onCreate(Bundle icicle) { protected void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
mCursor = getContentResolver().query(Browser.BOOKMARKS_URI, BOOKMARK_PROJECTION, mCursor = getContentResolver().query(Browser.BOOKMARKS_URI, BOOKMARK_PROJECTION,
@ -64,7 +64,7 @@ public final class BookmarkPickerActivity extends ListActivity {
} }
@Override @Override
protected final void onListItemClick(ListView l, View view, int position, long id) { protected void onListItemClick(ListView l, View view, int position, long id) {
if (mCursor.moveToPosition(position)) { if (mCursor.moveToPosition(position)) {
Intent intent = new Intent(); Intent intent = new Intent();
intent.putExtra(Browser.BookmarkColumns.TITLE, mCursor.getString(TITLE_COLUMN)); intent.putExtra(Browser.BookmarkColumns.TITLE, mCursor.getString(TITLE_COLUMN));

View file

@ -223,7 +223,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
startActivity(intent); startActivity(intent);
break; break;
} }
case ABOUT_ID: { case ABOUT_ID:
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.title_about); builder.setTitle(R.string.title_about);
builder.setMessage(getString(R.string.msg_about) + "\n\n" + getString(R.string.zxing_url)); builder.setMessage(getString(R.string.msg_about) + "\n\n" + getString(R.string.zxing_url));
@ -232,7 +232,6 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
builder.setNegativeButton(R.string.button_cancel, null); builder.setNegativeButton(R.string.button_cancel, null);
builder.show(); builder.show();
break; break;
}
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

View file

@ -53,6 +53,7 @@ public final class CaptureActivityHandler extends Handler {
} }
} }
@Override
public void handleMessage(Message message) { public void handleMessage(Message message) {
switch (message.what) { switch (message.what) {
case R.id.auto_focus: case R.id.auto_focus:

View file

@ -75,6 +75,7 @@ final class DecodeThread extends Thread {
public void run() { public void run() {
Looper.prepare(); Looper.prepare();
mHandler = new Handler() { mHandler = new Handler() {
@Override
public void handleMessage(Message message) { public void handleMessage(Message message) {
switch (message.what) { switch (message.what) {
case R.id.decode: case R.id.decode:

View file

@ -94,6 +94,7 @@ public final class EncodeActivity extends Activity {
}; };
public final Handler mHandler = new Handler() { public final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message message) { public void handleMessage(Message message) {
switch (message.what) { switch (message.what) {
case R.id.encode_succeeded: case R.id.encode_succeeded:

View file

@ -65,9 +65,13 @@ public final class QRCodeEncoder {
// TODO: The string encoding should live in the core ZXing library. // TODO: The string encoding should live in the core ZXing library.
private boolean encodeContents(Intent intent) { private boolean encodeContents(Intent intent) {
if (intent == null) return false; if (intent == null) {
return false;
}
String type = intent.getStringExtra(Intents.Encode.TYPE); String type = intent.getStringExtra(Intents.Encode.TYPE);
if (type == null || type.length() == 0) return false; if (type == null || type.length() == 0) {
return false;
}
if (type.equals(Contents.Type.TEXT)) { if (type.equals(Contents.Type.TEXT)) {
String string = intent.getStringExtra(Intents.Encode.DATA); String string = intent.getStringExtra(Intents.Encode.DATA);
@ -142,7 +146,7 @@ public final class QRCodeEncoder {
return mContents != null && mContents.length() > 0; return mContents != null && mContents.length() > 0;
} }
private final static class EncodeThread extends Thread { private static final class EncodeThread extends Thread {
private final String mContents; private final String mContents;
private final Handler mHandler; private final Handler mHandler;
@ -154,7 +158,7 @@ public final class QRCodeEncoder {
mPixelResolution = pixelResolution; mPixelResolution = pixelResolution;
} }
public final void run() { public void run() {
try { try {
ByteMatrix result = new MultiFormatWriter().encode(mContents, BarcodeFormat.QR_CODE, ByteMatrix result = new MultiFormatWriter().encode(mContents, BarcodeFormat.QR_CODE,
mPixelResolution, mPixelResolution); mPixelResolution, mPixelResolution);

View file

@ -113,6 +113,7 @@ public final class SearchBookContentsActivity extends Activity {
} }
public final Handler mHandler = new Handler() { public final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message message) { public void handleMessage(Message message) {
switch (message.what) { switch (message.what) {
case R.id.search_book_contents_succeeded: case R.id.search_book_contents_succeeded:
@ -237,7 +238,8 @@ public final class SearchBookContentsActivity extends Activity {
mUserAgent = userAgent; mUserAgent = userAgent;
} }
public final void run() { @Override
public void run() {
AndroidHttpClient client = null; AndroidHttpClient client = null;
try { try {
// These return a JSON result which describes if and where the query was found. This API may // These return a JSON result which describes if and where the query was found. This API may

View file

@ -57,7 +57,9 @@ public final class SearchBookContentsListItem extends LinearLayout {
int offset = 0; int offset = 0;
while (true) { while (true) {
int pos = lowerSnippet.indexOf(lowerQuery, offset); int pos = lowerSnippet.indexOf(lowerQuery, offset);
if (pos < 0) break; if (pos < 0) {
break;
}
styledSnippet.setSpan(boldSpan, pos, pos + queryLength, 0); styledSnippet.setSpan(boldSpan, pos, pos + queryLength, 0);
offset = pos + queryLength; offset = pos + queryLength;
} }

View file

@ -18,7 +18,7 @@ package com.google.zxing.client.android;
public final class SearchBookContentsResult { public final class SearchBookContentsResult {
static private String sQuery; private static String sQuery;
private final String mPageNumber; private final String mPageNumber;
private final String mSnippet; private final String mSnippet;

View file

@ -18,7 +18,6 @@ package com.google.zxing.client.android;
import android.app.Activity; import android.app.Activity;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
@ -38,7 +37,7 @@ public final class ShareActivity extends Activity {
private static final int METHODS_KIND_COLUMN = 1; private static final int METHODS_KIND_COLUMN = 1;
private static final int METHODS_DATA_COLUMN = 2; private static final int METHODS_DATA_COLUMN = 2;
private static final String[] METHODS_PROJECTION = new String[] { private static final String[] METHODS_PROJECTION = {
Contacts.People.ContactMethods._ID, // 0 Contacts.People.ContactMethods._ID, // 0
Contacts.People.ContactMethods.KIND, // 1 Contacts.People.ContactMethods.KIND, // 1
Contacts.People.ContactMethods.DATA, // 2 Contacts.People.ContactMethods.DATA, // 2
@ -63,7 +62,7 @@ public final class ShareActivity extends Activity {
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
if (clipboard.hasText()) { if (clipboard.hasText()) {
mClipboardButton.setEnabled(true); mClipboardButton.setEnabled(true);
mClipboardButton.setText(R.string.button_share_clipboard); mClipboardButton.setText(R.string.button_share_clipboard);
@ -95,7 +94,7 @@ public final class ShareActivity extends Activity {
private final Button.OnClickListener mClipboardListener = new Button.OnClickListener() { private final Button.OnClickListener mClipboardListener = new Button.OnClickListener() {
public void onClick(View v) { public void onClick(View v) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
// Should always be true, because we grey out the clipboard button in onResume() if it's empty // Should always be true, because we grey out the clipboard button in onResume() if it's empty
if (clipboard.hasText()) { if (clipboard.hasText()) {
Intent intent = new Intent(Intents.Encode.ACTION); Intent intent = new Intent(Intents.Encode.ACTION);
@ -158,8 +157,8 @@ public final class ShareActivity extends Activity {
boolean foundPostal = false; boolean foundPostal = false;
if (methodsCursor != null) { if (methodsCursor != null) {
while (methodsCursor.moveToNext()) { while (methodsCursor.moveToNext()) {
final int kind = methodsCursor.getInt(METHODS_KIND_COLUMN); int kind = methodsCursor.getInt(METHODS_KIND_COLUMN);
final String data = methodsCursor.getString(METHODS_DATA_COLUMN); String data = methodsCursor.getString(METHODS_DATA_COLUMN);
switch (kind) { switch (kind) {
case Contacts.KIND_EMAIL: case Contacts.KIND_EMAIL:
if (!foundEmail) { if (!foundEmail) {

View file

@ -43,8 +43,12 @@ public final class AddressBookResultHandler extends ResultHandler {
if (index < mButtonCount) { if (index < mButtonCount) {
int count = -1; int count = -1;
for (int x = 0; x < MAX_BUTTON_COUNT; x++) { for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
if (mFields[x]) count++; if (mFields[x]) {
if (count == index) return x; count++;
}
if (count == index) {
return x;
}
} }
} }
return -1; return -1;
@ -68,14 +72,18 @@ public final class AddressBookResultHandler extends ResultHandler {
mButtonCount = 0; mButtonCount = 0;
for (int x = 0; x < MAX_BUTTON_COUNT; x++) { for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
if (mFields[x]) mButtonCount++; if (mFields[x]) {
mButtonCount++;
}
} }
} }
@Override
public int getButtonCount() { public int getButtonCount() {
return mButtonCount; return mButtonCount;
} }
@Override
public int getButtonText(int index) { public int getButtonText(int index) {
int action = mapIndexToAction(index); int action = mapIndexToAction(index);
switch (action) { switch (action) {
@ -92,6 +100,7 @@ public final class AddressBookResultHandler extends ResultHandler {
} }
} }
@Override
public void handleButtonPress(int index) { public void handleButtonPress(int index) {
AddressBookParsedResult addressResult = (AddressBookParsedResult) mResult; AddressBookParsedResult addressResult = (AddressBookParsedResult) mResult;
int action = mapIndexToAction(index); int action = mapIndexToAction(index);
@ -165,6 +174,7 @@ public final class AddressBookResultHandler extends ResultHandler {
} }
} }
@Override
public int getDisplayTitle() { public int getDisplayTitle() {
return R.string.result_address_book; return R.string.result_address_book;
} }

View file

@ -41,14 +41,17 @@ public final class CalendarResultHandler extends ResultHandler {
super(activity, result); super(activity, result);
} }
@Override
public int getButtonCount() { public int getButtonCount() {
return mButtons.length; return mButtons.length;
} }
@Override
public int getButtonText(int index) { public int getButtonText(int index) {
return mButtons[index]; return mButtons[index];
} }
@Override
public void handleButtonPress(int index) { public void handleButtonPress(int index) {
CalendarParsedResult calendarResult = (CalendarParsedResult) mResult; CalendarParsedResult calendarResult = (CalendarParsedResult) mResult;
switch (index) { switch (index) {
@ -68,7 +71,9 @@ public final class CalendarResultHandler extends ResultHandler {
// The end can be null if the event has no duration, so use the start time. // The end can be null if the event has no duration, so use the start time.
String endString = calResult.getEnd(); String endString = calResult.getEnd();
if (endString == null) endString = calResult.getStart(); if (endString == null) {
endString = calResult.getStart();
}
appendTime(endString, result); appendTime(endString, result);
ParsedResult.maybeAppend(calResult.getLocation(), result); ParsedResult.maybeAppend(calResult.getLocation(), result);
@ -77,7 +82,7 @@ public final class CalendarResultHandler extends ResultHandler {
return result.toString(); return result.toString();
} }
private void appendTime(String when, StringBuffer result) { private static void appendTime(String when, StringBuffer result) {
if (when.length() == 8) { if (when.length() == 8) {
// Show only year/month/day // Show only year/month/day
Date date; Date date;
@ -101,6 +106,7 @@ public final class CalendarResultHandler extends ResultHandler {
} }
} }
@Override
public int getDisplayTitle() { public int getDisplayTitle() {
return R.string.result_calendar; return R.string.result_calendar;
} }

View file

@ -32,14 +32,17 @@ public final class EmailAddressResultHandler extends ResultHandler {
super(activity, result); super(activity, result);
} }
@Override
public int getButtonCount() { public int getButtonCount() {
return mButtons.length; return mButtons.length;
} }
@Override
public int getButtonText(int index) { public int getButtonText(int index) {
return mButtons[index]; return mButtons[index];
} }
@Override
public void handleButtonPress(int index) { public void handleButtonPress(int index) {
EmailAddressParsedResult emailResult = (EmailAddressParsedResult) mResult; EmailAddressParsedResult emailResult = (EmailAddressParsedResult) mResult;
switch (index) { switch (index) {
@ -54,6 +57,7 @@ public final class EmailAddressResultHandler extends ResultHandler {
} }
} }
@Override
public int getDisplayTitle() { public int getDisplayTitle() {
return R.string.result_email_address; return R.string.result_email_address;
} }

View file

@ -32,14 +32,17 @@ public final class GeoResultHandler extends ResultHandler {
super(activity, result); super(activity, result);
} }
@Override
public int getButtonCount() { public int getButtonCount() {
return mButtons.length; return mButtons.length;
} }
@Override
public int getButtonText(int index) { public int getButtonText(int index) {
return mButtons[index]; return mButtons[index];
} }
@Override
public void handleButtonPress(int index) { public void handleButtonPress(int index) {
GeoParsedResult geoResult = (GeoParsedResult) mResult; GeoParsedResult geoResult = (GeoParsedResult) mResult;
switch (index) { switch (index) {
@ -52,6 +55,7 @@ public final class GeoResultHandler extends ResultHandler {
} }
} }
@Override
public int getDisplayTitle() { public int getDisplayTitle() {
return R.string.result_geo; return R.string.result_geo;
} }

View file

@ -33,14 +33,17 @@ public final class ISBNResultHandler extends ResultHandler {
super(activity, result); super(activity, result);
} }
@Override
public int getButtonCount() { public int getButtonCount() {
return mButtons.length; return mButtons.length;
} }
@Override
public int getButtonText(int index) { public int getButtonText(int index) {
return mButtons[index]; return mButtons[index];
} }
@Override
public void handleButtonPress(int index) { public void handleButtonPress(int index) {
ISBNParsedResult isbnResult = (ISBNParsedResult) mResult; ISBNParsedResult isbnResult = (ISBNParsedResult) mResult;
switch (index) { switch (index) {
@ -56,6 +59,7 @@ public final class ISBNResultHandler extends ResultHandler {
} }
} }
@Override
public int getDisplayTitle() { public int getDisplayTitle() {
return R.string.result_isbn; return R.string.result_isbn;
} }

View file

@ -32,14 +32,17 @@ public final class ProductResultHandler extends ResultHandler {
super(activity, result); super(activity, result);
} }
@Override
public int getButtonCount() { public int getButtonCount() {
return mButtons.length; return mButtons.length;
} }
@Override
public int getButtonText(int index) { public int getButtonText(int index) {
return mButtons[index]; return mButtons[index];
} }
@Override
public void handleButtonPress(int index) { public void handleButtonPress(int index) {
ProductParsedResult productResult = (ProductParsedResult) mResult; ProductParsedResult productResult = (ProductParsedResult) mResult;
switch (index) { switch (index) {
@ -52,6 +55,7 @@ public final class ProductResultHandler extends ResultHandler {
} }
} }
@Override
public int getDisplayTitle() { public int getDisplayTitle() {
return R.string.result_product; return R.string.result_product;
} }

View file

@ -33,14 +33,17 @@ public final class SMSResultHandler extends ResultHandler {
super(activity, result); super(activity, result);
} }
@Override
public int getButtonCount() { public int getButtonCount() {
return mButtons.length; return mButtons.length;
} }
@Override
public int getButtonText(int index) { public int getButtonText(int index) {
return mButtons[index]; return mButtons[index];
} }
@Override
public void handleButtonPress(int index) { public void handleButtonPress(int index) {
SMSParsedResult smsResult = (SMSParsedResult) mResult; SMSParsedResult smsResult = (SMSParsedResult) mResult;
switch (index) { switch (index) {
@ -65,6 +68,7 @@ public final class SMSResultHandler extends ResultHandler {
return contents.toString(); return contents.toString();
} }
@Override
public int getDisplayTitle() { public int getDisplayTitle() {
return R.string.result_sms; return R.string.result_sms;
} }

View file

@ -33,14 +33,17 @@ public final class TelResultHandler extends ResultHandler {
super(activity, result); super(activity, result);
} }
@Override
public int getButtonCount() { public int getButtonCount() {
return mButtons.length; return mButtons.length;
} }
@Override
public int getButtonText(int index) { public int getButtonText(int index) {
return mButtons[index]; return mButtons[index];
} }
@Override
public void handleButtonPress(int index) { public void handleButtonPress(int index) {
TelParsedResult telResult = (TelParsedResult) mResult; TelParsedResult telResult = (TelParsedResult) mResult;
switch (index) { switch (index) {
@ -63,6 +66,7 @@ public final class TelResultHandler extends ResultHandler {
return PhoneNumberUtils.formatNumber(contents); return PhoneNumberUtils.formatNumber(contents);
} }
@Override
public int getDisplayTitle() { public int getDisplayTitle() {
return R.string.result_tel; return R.string.result_tel;
} }

View file

@ -35,14 +35,17 @@ public final class TextResultHandler extends ResultHandler {
super(activity, result); super(activity, result);
} }
@Override
public int getButtonCount() { public int getButtonCount() {
return mButtons.length; return mButtons.length;
} }
@Override
public int getButtonText(int index) { public int getButtonText(int index) {
return mButtons[index]; return mButtons[index];
} }
@Override
public void handleButtonPress(int index) { public void handleButtonPress(int index) {
switch (index) { switch (index) {
case 0: case 0:
@ -57,6 +60,7 @@ public final class TextResultHandler extends ResultHandler {
} }
} }
@Override
public int getDisplayTitle() { public int getDisplayTitle() {
return R.string.result_text; return R.string.result_text;
} }

View file

@ -33,14 +33,17 @@ public final class URIResultHandler extends ResultHandler {
super(activity, result); super(activity, result);
} }
@Override
public int getButtonCount() { public int getButtonCount() {
return mButtons.length; return mButtons.length;
} }
@Override
public int getButtonText(int index) { public int getButtonText(int index) {
return mButtons[index]; return mButtons[index];
} }
@Override
public void handleButtonPress(int index) { public void handleButtonPress(int index) {
URIParsedResult uriResult = (URIParsedResult) mResult; URIParsedResult uriResult = (URIParsedResult) mResult;
switch (index) { switch (index) {
@ -56,6 +59,7 @@ public final class URIResultHandler extends ResultHandler {
} }
} }
@Override
public int getDisplayTitle() { public int getDisplayTitle() {
return R.string.result_uri; return R.string.result_uri;
} }

View file

@ -37,7 +37,7 @@ public final class BenchmarkActivity extends Activity {
private BenchmarkThread mBenchmarkThread; private BenchmarkThread mBenchmarkThread;
@Override @Override
public final void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
setContentView(R.layout.benchmark); setContentView(R.layout.benchmark);
@ -61,6 +61,7 @@ public final class BenchmarkActivity extends Activity {
}; };
public final Handler mHandler = new Handler() { public final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message message) { public void handleMessage(Message message) {
switch (message.what) { switch (message.what) {
case R.id.benchmark_done: case R.id.benchmark_done:

View file

@ -35,21 +35,21 @@ public final class BenchmarkItem {
mFormat = null; mFormat = null;
} }
public final void addResult(int microseconds) { public void addResult(int microseconds) {
mTimes[mPosition] = microseconds; mTimes[mPosition] = microseconds;
mPosition++; mPosition++;
} }
public final void setDecoded(boolean decoded) { public void setDecoded(boolean decoded) {
mDecoded = decoded; mDecoded = decoded;
} }
public final void setFormat(BarcodeFormat format) { public void setFormat(BarcodeFormat format) {
mFormat = format; mFormat = format;
} }
@Override @Override
public final String toString() { public String toString() {
StringBuffer result = new StringBuffer(); StringBuffer result = new StringBuffer();
result.append(mDecoded ? ("DECODED " + mFormat.toString() + ": ") : "FAILED: "); result.append(mDecoded ? ("DECODED " + mFormat.toString() + ": ") : "FAILED: ");
result.append(mPath); result.append(mPath);

View file

@ -76,19 +76,18 @@ public final class CameraTestActivity extends Activity implements SurfaceHolder.
} }
public final Handler mHandler = new Handler() { public final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message message) { public void handleMessage(Message message) {
switch (message.what) { switch (message.what) {
case R.id.auto_focus: case R.id.auto_focus:
// Do not continuously auto focus // Do not continuously auto focus
break; break;
case R.id.save_succeeded: { case R.id.save_succeeded:
Toast.makeText(CameraTestActivity.this, R.string.save_succeeded, 500).show(); Toast.makeText(CameraTestActivity.this, R.string.save_succeeded, 500).show();
break; break;
} case R.id.save_failed:
case R.id.save_failed: {
Toast.makeText(CameraTestActivity.this, R.string.save_failed, 2000).show(); Toast.makeText(CameraTestActivity.this, R.string.save_failed, 2000).show();
break; break;
}
} }
} }
}; };

View file

@ -62,19 +62,19 @@ public final class RGBMonochromeBitmapSource extends BaseMonochromeBitmapSource
} }
} }
public final int getHeight() { public int getHeight() {
return mHeight; return mHeight;
} }
public final int getWidth() { public int getWidth() {
return mWidth; return mWidth;
} }
protected final int getLuminance(int x, int y) { protected int getLuminance(int x, int y) {
return mLuminances[y * mWidth + x] & 0xff; return mLuminances[y * mWidth + x] & 0xff;
} }
protected final int[] getLuminanceRow(int y, int[] row) { protected int[] getLuminanceRow(int y, int[] row) {
int width = mWidth; int width = mWidth;
if (row == null || row.length < width) { if (row == null || row.length < width) {
row = new int[width]; row = new int[width];
@ -86,7 +86,7 @@ public final class RGBMonochromeBitmapSource extends BaseMonochromeBitmapSource
return row; return row;
} }
protected final int[] getLuminanceColumn(int x, int[] column) { protected int[] getLuminanceColumn(int x, int[] column) {
int width = mWidth; int width = mWidth;
int height = mHeight; int height = mHeight;
if (column == null || column.length < height) { if (column == null || column.length < height) {

View file

@ -48,6 +48,7 @@ final class SaveThread extends Thread {
public void run() { public void run() {
Looper.prepare(); Looper.prepare();
mHandler = new Handler() { mHandler = new Handler() {
@Override
public void handleMessage(Message message) { public void handleMessage(Message message) {
switch (message.what) { switch (message.what) {
case R.id.save: case R.id.save:

View file

@ -44,7 +44,7 @@ public final class ViewfinderView extends View {
} }
@Override @Override
public final void onDraw(Canvas canvas) { public void onDraw(Canvas canvas) {
Rect frame = CameraManager.get().getFramingRect(); Rect frame = CameraManager.get().getFramingRect();
int width = canvas.getWidth(); int width = canvas.getWidth();
int height = canvas.getHeight(); int height = canvas.getHeight();

View file

@ -27,7 +27,7 @@ import android.widget.Button;
public final class ZXingTestActivity extends Activity { public final class ZXingTestActivity extends Activity {
@Override @Override
public final void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
setContentView(R.layout.test); setContentView(R.layout.test);
@ -124,7 +124,7 @@ public final class ZXingTestActivity extends Activity {
}; };
@Override @Override
public final void onActivityResult(int requestCode, int resultCode, Intent intent) { public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) { if (requestCode == 0) {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT"); String contents = intent.getStringExtra("SCAN_RESULT");

View file

@ -46,7 +46,7 @@ public final class ResultMetadataType {
* the complete raw bytes in the barcode for these formats, it does not offer the bytes * the complete raw bytes in the barcode for these formats, it does not offer the bytes
* from the byte segments alone.</p> * from the byte segments alone.</p>
* *
* <p>This maps to a {@link java.util.Vector} of {@link byte[]}s corresponding to the * <p>This maps to a {@link java.util.Vector} of byte arrays corresponding to the
* raw bytes in the byte segments in the barcode, in order.</p> * raw bytes in the byte segments in the barcode, in order.</p>
*/ */
public static final ResultMetadataType BYTE_SEGMENTS = new ResultMetadataType(); public static final ResultMetadataType BYTE_SEGMENTS = new ResultMetadataType();
@ -54,4 +54,4 @@ public final class ResultMetadataType {
private ResultMetadataType() { private ResultMetadataType() {
} }
} }

View file

@ -61,7 +61,7 @@ final class VCardResultParser extends ResultParser {
private static String[] matchVCardPrefixedField(String prefix, String rawText, boolean trim) { private static String[] matchVCardPrefixedField(String prefix, String rawText, boolean trim) {
Vector matches = null; Vector matches = null;
int i = 0; int i = 0;
final int max = rawText.length(); int max = rawText.length();
while (i < max) { while (i < max) {
i = rawText.indexOf(prefix, i); i = rawText.indexOf(prefix, i);
if (i < 0) { if (i < 0) {

View file

@ -39,31 +39,31 @@ public final class ByteMatrix {
this.width = width; this.width = width;
} }
public final int height() { public int height() {
return height; return height;
} }
public final int width() { public int width() {
return width; return width;
} }
public final byte get(int y, int x) { public byte get(int y, int x) {
return bytes[y][x]; return bytes[y][x];
} }
public final byte[][] getArray() { public byte[][] getArray() {
return bytes; return bytes;
} }
public final void set(int y, int x, byte value) { public void set(int y, int x, byte value) {
bytes[y][x] = value; bytes[y][x] = value;
} }
public final void set(int y, int x, int value) { public void set(int y, int x, int value) {
bytes[y][x] = (byte) value; bytes[y][x] = (byte) value;
} }
public final void clear(byte value) { public void clear(byte value) {
for (int y = 0; y < height; ++y) { for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) { for (int x = 0; x < width; ++x) {
bytes[y][x] = value; bytes[y][x] = value;
@ -71,7 +71,7 @@ public final class ByteMatrix {
} }
} }
public final String toString() { public String toString() {
StringBuffer result = new StringBuffer(); StringBuffer result = new StringBuffer();
for (int y = 0; y < height; ++y) { for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) { for (int x = 0; x < width; ++x) {

View file

@ -134,7 +134,7 @@ public final class Detector {
} }
// Bottom left is correct but top left and bottom right might be switched // Bottom left is correct but top left and bottom right might be switched
ResultPoint[] corners = new ResultPoint[] { maybeTopLeft, bottomLeft, maybeBottomRight }; ResultPoint[] corners = { maybeTopLeft, bottomLeft, maybeBottomRight };
// Use the dot product trick to sort them out // Use the dot product trick to sort them out
GenericResultPoint.orderBestPatterns(corners); GenericResultPoint.orderBestPatterns(corners);

View file

@ -73,7 +73,7 @@ public final class ITFReader extends AbstractOneDReader {
{N, W, N, W, N} // 9 {N, W, N, W, N} // 9
}; };
public final Result decodeRow(int rowNumber, BitArray row, Hashtable hints) throws ReaderException { public Result decodeRow(int rowNumber, BitArray row, Hashtable hints) throws ReaderException {
StringBuffer result = new StringBuffer(20); StringBuffer result = new StringBuffer(20);
@ -149,7 +149,7 @@ public final class ITFReader extends AbstractOneDReader {
*/ */
int[] decodeStart(BitArray row) throws ReaderException { int[] decodeStart(BitArray row) throws ReaderException {
int endStart = skipWhiteSpace(row); int endStart = skipWhiteSpace(row);
int startPattern[] = findGuardPattern(row, endStart, START_PATTERN); int[] startPattern = findGuardPattern(row, endStart, START_PATTERN);
// Determine the width of a narrow line in pixels. We can do this by // Determine the width of a narrow line in pixels. We can do this by
// getting the width of the start pattern and dividing by 4 because its // getting the width of the start pattern and dividing by 4 because its
@ -231,7 +231,7 @@ public final class ITFReader extends AbstractOneDReader {
row.reverse(); row.reverse();
int endStart = skipWhiteSpace(row); int endStart = skipWhiteSpace(row);
int endPattern[]; int[] endPattern;
try { try {
endPattern = findGuardPattern(row, endStart, END_PATTERN_REVERSED); endPattern = findGuardPattern(row, endStart, END_PATTERN_REVERSED);
} catch (ReaderException e) { } catch (ReaderException e) {

View file

@ -20,7 +20,6 @@ import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType; import com.google.zxing.EncodeHintType;
import com.google.zxing.Writer; import com.google.zxing.Writer;
import com.google.zxing.WriterException; import com.google.zxing.WriterException;
import com.google.zxing.common.ByteArray;
import com.google.zxing.common.ByteMatrix; import com.google.zxing.common.ByteMatrix;
import com.google.zxing.qrcode.encoder.Encoder; import com.google.zxing.qrcode.encoder.Encoder;
import com.google.zxing.qrcode.encoder.QRCode; import com.google.zxing.qrcode.encoder.QRCode;
@ -74,7 +73,7 @@ public final class QRCodeWriter implements Writer {
// Note that the input matrix uses 0 == white, 1 == black, while the output matrix uses // Note that the input matrix uses 0 == white, 1 == black, while the output matrix uses
// 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap). // 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).
private ByteMatrix renderResult(QRCode code, final int width, final int height) { private ByteMatrix renderResult(QRCode code, int width, int height) {
ByteMatrix input = code.getMatrix(); ByteMatrix input = code.getMatrix();
int inputWidth = input.width(); int inputWidth = input.width();
int inputHeight = input.height(); int inputHeight = input.height();
@ -104,7 +103,7 @@ public final class QRCodeWriter implements Writer {
} }
// 2. Expand the QR image to the multiple // 2. Expand the QR image to the multiple
final byte[][] inputArray = input.getArray(); byte[][] inputArray = input.getArray();
for (int y = 0; y < inputHeight; y++) { for (int y = 0; y < inputHeight; y++) {
// a. Write the white pixels at the left of each row // a. Write the white pixels at the left of each row
for (int x = 0; x < leftPadding; x++) { for (int x = 0; x < leftPadding; x++) {

View file

@ -16,8 +16,6 @@
package com.google.zxing.qrcode.decoder; package com.google.zxing.qrcode.decoder;
import com.google.zxing.ReaderException;
/** /**
* <p>See ISO 18004:2006, 6.5.1. This enum encapsulates the four error correction levels * <p>See ISO 18004:2006, 6.5.1. This enum encapsulates the four error correction levels
* defined by the QR code standard.</p> * defined by the QR code standard.</p>

View file

@ -72,7 +72,7 @@ final class FormatInformation {
* Offset i holds the number of 1 bits in the binary representation of i * Offset i holds the number of 1 bits in the binary representation of i
*/ */
private static final int[] BITS_SET_IN_HALF_BYTE = private static final int[] BITS_SET_IN_HALF_BYTE =
new int[]{0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}; {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
private final ErrorCorrectionLevel errorCorrectionLevel; private final ErrorCorrectionLevel errorCorrectionLevel;
private final byte dataMask; private final byte dataMask;

View file

@ -35,9 +35,6 @@ final class AdvancedMultimediaManager implements MultimediaManager {
private static final long FOCUS_TIME_MS = 750L; private static final long FOCUS_TIME_MS = 750L;
private static final String DESIRED_METERING = "center-weighted"; private static final String DESIRED_METERING = "center-weighted";
AdvancedMultimediaManager() {
}
public void setFocus(Controllable player) { public void setFocus(Controllable player) {
FocusControl focusControl = (FocusControl) FocusControl focusControl = (FocusControl)
player.getControl("javax.microedition.amms.control.camera.FocusControl"); player.getControl("javax.microedition.amms.control.camera.FocusControl");

View file

@ -25,9 +25,6 @@ import javax.microedition.media.Controllable;
*/ */
final class DefaultMultimediaManager implements MultimediaManager { final class DefaultMultimediaManager implements MultimediaManager {
DefaultMultimediaManager() {
}
public void setFocus(Controllable player) { public void setFocus(Controllable player) {
} }

View file

@ -84,10 +84,12 @@ public final class BufferedImageMonochromeBitmapSource extends BaseMonochromeBit
return image; return image;
} }
@Override
public int getHeight() { public int getHeight() {
return height; return height;
} }
@Override
public int getWidth() { public int getWidth() {
return width; return width;
} }
@ -127,6 +129,7 @@ public final class BufferedImageMonochromeBitmapSource extends BaseMonochromeBit
* *
* where R, G, and B are values in [0,1]. * where R, G, and B are values in [0,1].
*/ */
@Override
protected int getLuminance(int x, int y) { protected int getLuminance(int x, int y) {
int pixel = image.getRGB(left + x, top + y); int pixel = image.getRGB(left + x, top + y);
// Coefficients add up to 1024 to make the divide into a fast shift // Coefficients add up to 1024 to make the divide into a fast shift
@ -135,6 +138,7 @@ public final class BufferedImageMonochromeBitmapSource extends BaseMonochromeBit
117 * (pixel & 0xFF)) >> 10; 117 * (pixel & 0xFF)) >> 10;
} }
@Override
protected int[] getLuminanceRow(int y, int[] row) { protected int[] getLuminanceRow(int y, int[] row) {
if (row == null || row.length < width) { if (row == null || row.length < width) {
row = new int[width]; row = new int[width];
@ -149,6 +153,7 @@ public final class BufferedImageMonochromeBitmapSource extends BaseMonochromeBit
return row; return row;
} }
@Override
protected int[] getLuminanceColumn(int x, int[] column) { protected int[] getLuminanceColumn(int x, int[] column) {
if (column == null || column.length < height) { if (column == null || column.length < height) {
column = new int[height]; column = new int[height];

View file

@ -58,7 +58,9 @@ public final class ImageConverter {
} }
} }
for (String arg : args) { for (String arg : args) {
if (arg.startsWith("-")) continue; if (arg.startsWith("-")) {
continue;
}
File inputFile = new File(arg); File inputFile = new File(arg);
if (inputFile.exists()) { if (inputFile.exists()) {
if (inputFile.isDirectory()) { if (inputFile.isDirectory()) {