|
@@ -22,6 +22,7 @@ import android.content.SharedPreferences;
|
|
|
import android.content.SharedPreferences.Editor;
|
|
|
import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
+import android.preference.PreferenceManager;
|
|
|
import android.support.v4.app.FragmentTransaction;
|
|
|
import android.util.Log;
|
|
|
import android.view.Gravity;
|
|
@@ -212,6 +213,11 @@ public class ViewLog extends Activity {
|
|
|
public void onClick(DialogInterface dialog, int id) {
|
|
|
// Clear all Data
|
|
|
dbh.clearData();
|
|
|
+ SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
+ Editor editor = pref.edit();
|
|
|
+ editor.putInt("ATTACK_ID_COUNTER", 0);
|
|
|
+ editor.putInt("LAST_UPLOADED_ATTACK_ID", -1);
|
|
|
+ editor.commit();
|
|
|
Toast.makeText(getApplicationContext(),
|
|
|
"Database cleared!", Toast.LENGTH_SHORT)
|
|
|
.show();
|
|
@@ -273,16 +279,14 @@ public class ViewLog extends Activity {
|
|
|
}
|
|
|
|
|
|
private void setFirstAndLastAttack() {
|
|
|
- int attackCount = dbh.getRecordCount();
|
|
|
- if (attackCount > 0) {
|
|
|
-
|
|
|
- Date resultdate = new Date(dbh.getRecordOfAttackId(0)
|
|
|
- .getTimestamp());
|
|
|
+ int firstAttackId = dbh.getSmallestAttackId();
|
|
|
+ int lastAttackId = dbh.getHighestAttackId();
|
|
|
+ if (firstAttackId != -1) {
|
|
|
+ Date resultdate = new Date(dbh.getRecordOfAttackId(firstAttackId).getTimestamp());
|
|
|
TextView text = (TextView) findViewById(R.id.textFirstAttackValue);
|
|
|
text.setText(sdf.format(resultdate));
|
|
|
text = (TextView) findViewById(R.id.textLastAttackValue);
|
|
|
- resultdate = new Date(dbh.getRecordOfAttackId(
|
|
|
- dbh.getAttackCount() - 1).getTimestamp());
|
|
|
+ resultdate = new Date(dbh.getRecordOfAttackId(lastAttackId).getTimestamp());
|
|
|
text.setText(sdf.format(resultdate));
|
|
|
} else {
|
|
|
TextView text = (TextView) findViewById(R.id.textFirstAttackValue);
|