mirror of
https://github.com/zxing/zxing.git
synced 2025-01-12 19:57:27 -08:00
Attempt to plug some odd recent force closes
git-svn-id: https://zxing.googlecode.com/svn/trunk@1640 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
754e8d3910
commit
20cac4ff82
|
@ -51,8 +51,8 @@ public final class ViewfinderView extends View {
|
|||
private final int laserColor;
|
||||
private final int resultPointColor;
|
||||
private int scannerAlpha;
|
||||
private Collection<ResultPoint> possibleResultPoints;
|
||||
private Collection<ResultPoint> lastPossibleResultPoints;
|
||||
private volatile Collection<ResultPoint> possibleResultPoints;
|
||||
private volatile Collection<ResultPoint> lastPossibleResultPoints;
|
||||
|
||||
// This constructor is used when the class is built from an XML resource.
|
||||
public ViewfinderView(Context context, AttributeSet attrs) {
|
||||
|
|
|
@ -25,7 +25,7 @@ import android.content.Context;
|
|||
*/
|
||||
final class DBHelper extends SQLiteOpenHelper {
|
||||
|
||||
private static final int DB_VERSION = 2;
|
||||
private static final int DB_VERSION = 3;
|
||||
private static final String DB_NAME = "barcode_scanner_history.db";
|
||||
static final String TABLE_NAME = "history";
|
||||
static final String ID_COL = "id";
|
||||
|
|
|
@ -22,6 +22,7 @@ import android.content.DialogInterface;
|
|||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteException;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
|
@ -33,6 +34,7 @@ import java.io.IOException;
|
|||
import java.io.OutputStreamWriter;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
@ -80,7 +82,13 @@ public final class HistoryManager {
|
|||
List<Result> getHistoryItems() {
|
||||
SQLiteOpenHelper helper = new DBHelper(activity);
|
||||
List<Result> items = new ArrayList<Result>();
|
||||
SQLiteDatabase db = helper.getReadableDatabase();
|
||||
SQLiteDatabase db;
|
||||
try {
|
||||
db = helper.getWritableDatabase();
|
||||
} catch (SQLiteException sqle) {
|
||||
Log.w(TAG, "Error while opening database", sqle);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = db.query(DBHelper.TABLE_NAME,
|
||||
|
@ -135,7 +143,13 @@ public final class HistoryManager {
|
|||
}
|
||||
|
||||
SQLiteOpenHelper helper = new DBHelper(activity);
|
||||
SQLiteDatabase db = helper.getWritableDatabase();
|
||||
SQLiteDatabase db;
|
||||
try {
|
||||
db = helper.getWritableDatabase();
|
||||
} catch (SQLiteException sqle) {
|
||||
Log.w(TAG, "Error while opening database", sqle);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// Insert
|
||||
ContentValues values = new ContentValues();
|
||||
|
@ -151,7 +165,13 @@ public final class HistoryManager {
|
|||
|
||||
private void deletePrevious(String text) {
|
||||
SQLiteOpenHelper helper = new DBHelper(activity);
|
||||
SQLiteDatabase db = helper.getWritableDatabase();
|
||||
SQLiteDatabase db;
|
||||
try {
|
||||
db = helper.getWritableDatabase();
|
||||
} catch (SQLiteException sqle) {
|
||||
Log.w(TAG, "Error while opening database", sqle);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
db.delete(DBHelper.TABLE_NAME, DBHelper.TEXT_COL + "=?", new String[] { text });
|
||||
} finally {
|
||||
|
@ -161,7 +181,13 @@ public final class HistoryManager {
|
|||
|
||||
public void trimHistory() {
|
||||
SQLiteOpenHelper helper = new DBHelper(activity);
|
||||
SQLiteDatabase db = helper.getWritableDatabase();
|
||||
SQLiteDatabase db;
|
||||
try {
|
||||
db = helper.getWritableDatabase();
|
||||
} catch (SQLiteException sqle) {
|
||||
Log.w(TAG, "Error while opening database", sqle);
|
||||
return;
|
||||
}
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = db.query(DBHelper.TABLE_NAME,
|
||||
|
@ -200,7 +226,13 @@ public final class HistoryManager {
|
|||
CharSequence buildHistory() {
|
||||
StringBuilder historyText = new StringBuilder(1000);
|
||||
SQLiteOpenHelper helper = new DBHelper(activity);
|
||||
SQLiteDatabase db = helper.getReadableDatabase();
|
||||
SQLiteDatabase db;
|
||||
try {
|
||||
db = helper.getWritableDatabase();
|
||||
} catch (SQLiteException sqle) {
|
||||
Log.w(TAG, "Error while opening database", sqle);
|
||||
return "";
|
||||
}
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = db.query(DBHelper.TABLE_NAME,
|
||||
|
@ -258,7 +290,13 @@ public final class HistoryManager {
|
|||
|
||||
void clearHistory() {
|
||||
SQLiteOpenHelper helper = new DBHelper(activity);
|
||||
SQLiteDatabase db = helper.getWritableDatabase();
|
||||
SQLiteDatabase db;
|
||||
try {
|
||||
db = helper.getWritableDatabase();
|
||||
} catch (SQLiteException sqle) {
|
||||
Log.w(TAG, "Error while opening database", sqle);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
db.delete(DBHelper.TABLE_NAME, null, null);
|
||||
} finally {
|
||||
|
|
|
@ -50,25 +50,11 @@ final class LoadPackagesAsyncTask extends AsyncTask<List<String[]>,Void,List<Str
|
|||
|
||||
|
||||
private final AppPickerActivity activity;
|
||||
private DialogInterface dialog;
|
||||
|
||||
LoadPackagesAsyncTask(AppPickerActivity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized void onPreExecute() {
|
||||
dialog = ProgressDialog.show(activity, "", activity.getString(R.string.msg_loading_apps), true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized void onCancelled() {
|
||||
if (dialog != null) {
|
||||
dialog.dismiss();
|
||||
dialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String[]> doInBackground(List<String[]>... objects) {
|
||||
List<String[]> labelsPackages = objects[0];
|
||||
|
@ -110,13 +96,8 @@ final class LoadPackagesAsyncTask extends AsyncTask<List<String[]>,Void,List<Str
|
|||
for (String[] result : results) {
|
||||
labels.add(result[0]);
|
||||
}
|
||||
ListAdapter listAdapter = new ArrayAdapter<String>(
|
||||
activity, android.R.layout.simple_list_item_1, labels);
|
||||
ListAdapter listAdapter = new ArrayAdapter<String>(activity, android.R.layout.simple_list_item_1, labels);
|
||||
activity.setListAdapter(listAdapter);
|
||||
if (dialog != null) {
|
||||
dialog.dismiss();
|
||||
dialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ByFirstStringComparator implements Comparator<String[]>, Serializable {
|
||||
|
|
|
@ -179,11 +179,15 @@ public final class ShareActivity extends Activity {
|
|||
Bundle bundle = new Bundle();
|
||||
if (contactCursor != null && contactCursor.moveToFirst()) {
|
||||
int nameColumn = contactCursor.getColumnIndex(Contacts.PeopleColumns.NAME);
|
||||
String name = contactCursor.getString(nameColumn);
|
||||
if (nameColumn >= 0) {
|
||||
String name = contactCursor.getString(nameColumn);
|
||||
|
||||
// Don't require a name to be present, this contact might be just a phone number.
|
||||
if (name != null && name.length() > 0) {
|
||||
bundle.putString(Contacts.Intents.Insert.NAME, massageContactData(name));
|
||||
// Don't require a name to be present, this contact might be just a phone number.
|
||||
if (name != null && name.length() > 0) {
|
||||
bundle.putString(Contacts.Intents.Insert.NAME, massageContactData(name));
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "Unable to find column? " + Contacts.PeopleColumns.NAME);
|
||||
}
|
||||
contactCursor.close();
|
||||
|
||||
|
|
Loading…
Reference in a new issue