Skip to content

Commit

Permalink
增加注释
Browse files Browse the repository at this point in the history
  • Loading branch information
hupei committed Jul 11, 2016
1 parent 38159c3 commit 8300f78
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 291 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.google.zxing.client.result.ParsedResultType;
import com.google.zxing.client.result.URIParsedResult;
import com.mylhyl.zxing.scanner.OnScannerCompletionListener;
import com.mylhyl.zxing.scanner.common.Intents;
import com.mylhyl.zxing.scanner.common.Scanner;

/**
Expand All @@ -23,7 +24,6 @@
public abstract class BasicScannerActivity extends AppCompatActivity implements OnScannerCompletionListener {
public static final int REQUEST_CODE_SCANNER = 188;
public static final String EXTRA_RETURN_SCANNER_RESULT = "return_scanner_result";
public static final String EXTRA_RETURN_SCANNER_RESULT_TEXT = "return_scanner_result_text";

private boolean mReturnScanResult;

Expand Down Expand Up @@ -61,18 +61,18 @@ public void OnScannerCompletion(Result rawResult, ParsedResult parsedResult, Bit
switch (type) {
case ADDRESSBOOK:
AddressBookParsedResult addressResult = (AddressBookParsedResult) parsedResult;
bundle.putStringArray(Scanner.result.EXTRA_RESULT_ADDRESS_BOOK_NAME, addressResult.getNames());
bundle.putStringArray(Scanner.result.EXTRA_RESULT_ADDRESS_BOOK_PHONE_NUMBER, addressResult.getPhoneNumbers());
bundle.putStringArray(Scanner.result.EXTRA_RESULT_ADDRESS_BOOK_EMAIL, addressResult.getEmails());
bundle.putStringArray(Intents.AddressBookConnect.NAME, addressResult.getNames());
bundle.putStringArray(Intents.AddressBookConnect.NUMBER, addressResult.getPhoneNumbers());
bundle.putStringArray(Intents.AddressBookConnect.EMAIL, addressResult.getEmails());
break;
case PRODUCT:
break;
case URI:
URIParsedResult uriParsedResult = (URIParsedResult) parsedResult;
bundle.putString(Scanner.result.EXTRA_RESULT_URI, uriParsedResult.getURI());
bundle.putString(Intents.URIContents.URI, uriParsedResult.getURI());
break;
case TEXT:
bundle.putString(Scanner.result.EXTRA_RESULT_TEXT, rawResult.getText());
bundle.putString(Intents.Scan.RESULT, rawResult.getText());
break;
case GEO:
break;
Expand All @@ -86,7 +86,7 @@ public void OnScannerCompletion(Result rawResult, ParsedResult parsedResult, Bit

private void onReturnScanResult(Result rawResult) {
Intent intent = getIntent();
intent.putExtra(EXTRA_RETURN_SCANNER_RESULT_TEXT, rawResult.getText());
intent.putExtra(Intents.Scan.RESULT, rawResult.getText());
setResult(Activity.RESULT_OK, intent);
finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.google.zxing.client.result.ParsedResultType;
import com.mylhyl.zxing.scanner.common.Contents;
import com.mylhyl.zxing.scanner.common.Intents;
import com.mylhyl.zxing.scanner.encode.QREncode;

import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -114,7 +115,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != Activity.RESULT_CANCELED && resultCode == Activity.RESULT_OK) {
if (requestCode == EnCodeActivity.REQUEST_CODE_SCANNER) {
if (data != null) {
String stringExtra = data.getStringExtra(EnCodeActivity.EXTRA_RETURN_SCANNER_RESULT_TEXT);
String stringExtra = data.getStringExtra(Intents.Scan.RESULT);
tvResult.setText(stringExtra);
}
} else if (requestCode == PICK_CONTACT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import android.os.Bundle;
import android.widget.TextView;

import com.mylhyl.zxing.scanner.common.Scanner;
import com.mylhyl.zxing.scanner.common.Intents;
import com.mylhyl.zxing.scanner.sample.BasicActivity;
import com.mylhyl.zxing.scanner.sample.R;

Expand All @@ -23,9 +23,9 @@ protected void onCreate(Bundle savedInstanceState) {

Bundle extras = getIntent().getExtras();

String[] names = extras.getStringArray(Scanner.result.EXTRA_RESULT_ADDRESS_BOOK_NAME);
String[] phoneNumbers = extras.getStringArray(Scanner.result.EXTRA_RESULT_ADDRESS_BOOK_PHONE_NUMBER);
String[] emails = extras.getStringArray(Scanner.result.EXTRA_RESULT_ADDRESS_BOOK_EMAIL);
String[] names = extras.getStringArray(Intents.AddressBookConnect.NAME);
String[] phoneNumbers = extras.getStringArray(Intents.AddressBookConnect.NUMBER);
String[] emails = extras.getStringArray(Intents.AddressBookConnect.EMAIL);

StringBuffer sb = new StringBuffer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import android.os.Bundle;
import android.widget.TextView;

import com.mylhyl.zxing.scanner.common.Scanner;
import com.mylhyl.zxing.scanner.common.Intents;
import com.mylhyl.zxing.scanner.sample.BasicActivity;
import com.mylhyl.zxing.scanner.sample.R;

Expand All @@ -20,7 +20,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_text);
Bundle extras = getIntent().getExtras();
if (extras != null)
((TextView) findViewById(R.id.textView3)).setText(extras.getString(Scanner.result.EXTRA_RESULT_TEXT));
((TextView) findViewById(R.id.textView3)).setText(extras.getString(Intents.Scan.RESULT));
}

public static void gotoActivity(Activity activity, Bundle bundle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import android.webkit.WebViewClient;

import com.mylhyl.crlayout.SwipeRefreshWebView;
import com.mylhyl.zxing.scanner.common.Scanner;
import com.mylhyl.zxing.scanner.common.Intents;
import com.mylhyl.zxing.scanner.sample.BasicActivity;
import com.mylhyl.zxing.scanner.sample.R;

Expand All @@ -21,7 +21,7 @@ public class UriActivity extends BasicActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_uri);
String uri = getIntent().getStringExtra(Scanner.result.EXTRA_RESULT_URI);
String uri = getIntent().getStringExtra(Intents.URIContents.URI);
swipeRefreshWebView = (SwipeRefreshWebView) findViewById(R.id.webView);
swipeRefreshWebView.getScrollView().loadUrl(uri);
swipeRefreshWebView.getScrollView().setWebViewClient(new SampleWebViewClient());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Vibrator;
import android.util.Log;

import java.io.Closeable;
import java.io.IOException;
Expand All @@ -31,8 +30,6 @@
*/
final class BeepManager implements MediaPlayer.OnErrorListener, Closeable {

// private static final String TAG = BeepManager.class.getSimpleName();

private static final float BEEP_VOLUME = 0.10f;
private static final long VIBRATE_DURATION = 200L;

Expand Down Expand Up @@ -110,7 +107,6 @@ private MediaPlayer buildMediaPlayer(Context activity) {
mediaPlayer.prepare();
return mediaPlayer;
} catch (IOException ioe) {
// Log.w(TAG, ioe);
mediaPlayer.release();
return null;
}
Expand All @@ -121,7 +117,6 @@ public synchronized boolean onError(MediaPlayer mp, int what, int extra) {
if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
//播放错误
} else {
// possibly media player error, so release and recreate
close();
updatePrefs();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public void handleMessage(Message message) {
if (compressedBitmap != null) {
barcode = BitmapFactory.decodeByteArray(compressedBitmap,
0, compressedBitmap.length, null);
// Mutable copy:
barcode = barcode.copy(Bitmap.Config.ARGB_8888, true);
}
scaleFactor = bundle
Expand All @@ -95,8 +94,6 @@ public void handleMessage(Message message) {
.handleDecode((Result) message.obj, barcode, scaleFactor);
break;
case Scanner.DECODE_FAILED:
// We're decoding as fast as possible, so when one decode fails,
// start another.
state = State.PREVIEW;
cameraManager.requestPreviewFrame(decodeThread.getHandler(),
Scanner.DECODE);
Expand All @@ -114,14 +111,11 @@ public void quitSynchronously() {
Message quit = Message.obtain(decodeThread.getHandler(), Scanner.QUIT);
quit.sendToTarget();
try {
// Wait at most half a second; should be enough time, and onPause()
// will timeout quickly
decodeThread.join(500L);
} catch (InterruptedException e) {
// continue
e.printStackTrace();
}

// Be absolutely sure we don't send any queued up messages
removeMessages(Scanner.DECODE_SUCCEEDED);
removeMessages(Scanner.DECODE_FAILED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,9 @@ final class ViewfinderView extends View {
private boolean drawTextGravityBottom = true;//提示文字位置
private int drawTextMargin;//提示文字与扫描框距离
private boolean isLaserGridLine;//是否为网格资源文件
private boolean isDraw;//是否绘制过(扫描框、扫描框4角、扫描提示文字)

// This constructor is used when the class is built from an XML resource.
public ViewfinderView(Context context, AttributeSet attrs) {
super(context, attrs);
// Initialize these once for performance rather than calling them every time in onDraw().
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
possibleResultPoints = new ArrayList<>(5);
lastPossibleResultPoints = null;
Expand Down Expand Up @@ -293,7 +290,6 @@ public void drawViewfinder() {
if (resultBitmap != null) {
resultBitmap.recycle();
}
isDraw = false;
invalidate();
}

Expand Down
Loading

0 comments on commit 8300f78

Please sign in to comment.