mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-23 23:48:51 -05:00
some coding practice and potential bug fixes
This commit is contained in:
parent
570b7a6d8e
commit
b42f02ba92
@ -1017,7 +1017,10 @@ public class Apg {
|
||||
keyIds.add(c.getInt(0));
|
||||
} while (c.moveToNext());
|
||||
}
|
||||
c.close();
|
||||
|
||||
if (c != null) {
|
||||
c.close();
|
||||
}
|
||||
|
||||
return keyIds;
|
||||
}
|
||||
|
@ -10,6 +10,12 @@ public class CachedPassPhrase {
|
||||
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) {
|
||||
if (!(other instanceof CachedPassPhrase)) {
|
||||
return false;
|
||||
|
@ -755,6 +755,7 @@ public class EncryptActivity extends BaseActivity {
|
||||
EncryptActivity.this.
|
||||
startActivity(Intent.createChooser(emailIntent,
|
||||
getString(R.string.title_sendEmail)));
|
||||
break;
|
||||
}
|
||||
|
||||
case Id.target.file: {
|
||||
|
@ -200,7 +200,10 @@ public class Database extends SQLiteOpenHelper {
|
||||
}
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@ -427,7 +430,10 @@ public class Database extends SQLiteOpenHelper {
|
||||
rowId = mDb.insert(KeyRings.TABLE_NAME, KeyRings.WHO_ID, values);
|
||||
mStatus = Id.return_value.ok;
|
||||
}
|
||||
c.close();
|
||||
|
||||
if (c != null) {
|
||||
c.close();
|
||||
}
|
||||
|
||||
return rowId;
|
||||
}
|
||||
@ -465,11 +471,14 @@ public class Database extends SQLiteOpenHelper {
|
||||
if (c != null && c.moveToFirst()) {
|
||||
rowId = c.getLong(0);
|
||||
mDb.update(UserIds.TABLE_NAME, values,
|
||||
UserIds._ID + " = ?", new String[] { "" + rowId });
|
||||
UserIds._ID + " = ?", new String[] { "" + rowId });
|
||||
} else {
|
||||
rowId = mDb.insert(UserIds.TABLE_NAME, UserIds.USER_ID, values);
|
||||
}
|
||||
c.close();
|
||||
|
||||
if (c != null) {
|
||||
c.close();
|
||||
}
|
||||
|
||||
return rowId;
|
||||
}
|
||||
@ -500,7 +509,10 @@ public class Database extends SQLiteOpenHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
c.close();
|
||||
|
||||
if (c != null) {
|
||||
c.close();
|
||||
}
|
||||
|
||||
return keyRing;
|
||||
}
|
||||
@ -522,7 +534,10 @@ public class Database extends SQLiteOpenHelper {
|
||||
if (c != null && c.moveToFirst()) {
|
||||
data = c.getBlob(0);
|
||||
}
|
||||
c.close();
|
||||
|
||||
if (c != null) {
|
||||
c.close();
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
@ -539,7 +554,10 @@ public class Database extends SQLiteOpenHelper {
|
||||
if (c != null && c.moveToFirst()) {
|
||||
data = c.getBlob(0);
|
||||
}
|
||||
c.close();
|
||||
|
||||
if (c != null) {
|
||||
c.close();
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
@ -561,7 +579,10 @@ public class Database extends SQLiteOpenHelper {
|
||||
deleteKey(keyId);
|
||||
} while (c.moveToNext());
|
||||
}
|
||||
c.close();
|
||||
|
||||
if (c != null) {
|
||||
c.close();
|
||||
}
|
||||
|
||||
mDb.setTransactionSuccessful();
|
||||
mDb.endTransaction();
|
||||
|
Loading…
Reference in New Issue
Block a user