some coding practice and potential bug fixes

This commit is contained in:
Thialfihar 2010-05-27 20:27:21 +00:00
parent 570b7a6d8e
commit b42f02ba92
4 changed files with 40 additions and 9 deletions

View File

@ -1017,7 +1017,10 @@ public class Apg {
keyIds.add(c.getInt(0)); keyIds.add(c.getInt(0));
} while (c.moveToNext()); } while (c.moveToNext());
} }
if (c != null) {
c.close(); c.close();
}
return keyIds; return keyIds;
} }

View File

@ -10,6 +10,12 @@ public class CachedPassPhrase {
this.passPhrase = passPhrase; this.passPhrase = passPhrase;
} }
public int hashCode() {
int hc1 = (int)(this.timestamp & 0xffffffff);
int hc2 = (this.passPhrase == null ? 0 : this.passPhrase.hashCode());
return (hc1 + hc2) * hc2 + hc1;
}
public boolean equals(Object other) { public boolean equals(Object other) {
if (!(other instanceof CachedPassPhrase)) { if (!(other instanceof CachedPassPhrase)) {
return false; return false;

View File

@ -755,6 +755,7 @@ public class EncryptActivity extends BaseActivity {
EncryptActivity.this. EncryptActivity.this.
startActivity(Intent.createChooser(emailIntent, startActivity(Intent.createChooser(emailIntent,
getString(R.string.title_sendEmail))); getString(R.string.title_sendEmail)));
break;
} }
case Id.target.file: { case Id.target.file: {

View File

@ -200,7 +200,10 @@ public class Database extends SQLiteOpenHelper {
} }
} while (cursor.moveToNext()); } while (cursor.moveToNext());
} }
if (cursor != null) {
cursor.close(); cursor.close();
}
break; break;
} }
@ -427,7 +430,10 @@ public class Database extends SQLiteOpenHelper {
rowId = mDb.insert(KeyRings.TABLE_NAME, KeyRings.WHO_ID, values); rowId = mDb.insert(KeyRings.TABLE_NAME, KeyRings.WHO_ID, values);
mStatus = Id.return_value.ok; mStatus = Id.return_value.ok;
} }
if (c != null) {
c.close(); c.close();
}
return rowId; return rowId;
} }
@ -469,7 +475,10 @@ public class Database extends SQLiteOpenHelper {
} else { } else {
rowId = mDb.insert(UserIds.TABLE_NAME, UserIds.USER_ID, values); rowId = mDb.insert(UserIds.TABLE_NAME, UserIds.USER_ID, values);
} }
if (c != null) {
c.close(); c.close();
}
return rowId; return rowId;
} }
@ -500,7 +509,10 @@ public class Database extends SQLiteOpenHelper {
} }
} }
} }
if (c != null) {
c.close(); c.close();
}
return keyRing; return keyRing;
} }
@ -522,7 +534,10 @@ public class Database extends SQLiteOpenHelper {
if (c != null && c.moveToFirst()) { if (c != null && c.moveToFirst()) {
data = c.getBlob(0); data = c.getBlob(0);
} }
if (c != null) {
c.close(); c.close();
}
return data; return data;
} }
@ -539,7 +554,10 @@ public class Database extends SQLiteOpenHelper {
if (c != null && c.moveToFirst()) { if (c != null && c.moveToFirst()) {
data = c.getBlob(0); data = c.getBlob(0);
} }
if (c != null) {
c.close(); c.close();
}
return data; return data;
} }
@ -561,7 +579,10 @@ public class Database extends SQLiteOpenHelper {
deleteKey(keyId); deleteKey(keyId);
} while (c.moveToNext()); } while (c.moveToNext());
} }
if (c != null) {
c.close(); c.close();
}
mDb.setTransactionSuccessful(); mDb.setTransactionSuccessful();
mDb.endTransaction(); mDb.endTransaction();