history changes
This commit is contained in:
@@ -25,10 +25,7 @@ import org.solovyev.common.utils.*;
|
||||
import org.solovyev.common.utils.Filter;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
@@ -41,7 +38,8 @@ public class CalculatorHistoryActivity extends ListActivity {
|
||||
@Override
|
||||
public int compare(CalculatorHistoryState state1, CalculatorHistoryState state2) {
|
||||
if (state1.isSaved() == state2.isSaved()) {
|
||||
return state2.getTime().compareTo(state1.getTime());
|
||||
long l = state2.getTime() - state1.getTime();
|
||||
return l > 0l ? 1 : (l < 0l ? -1 : 0);
|
||||
} else if (state1.isSaved()) {
|
||||
return -1;
|
||||
} else if (state2.isSaved()) {
|
||||
@@ -134,7 +132,7 @@ public class CalculatorHistoryActivity extends ListActivity {
|
||||
@Override
|
||||
public boolean equals(@Nullable CalculatorHistoryState first, @Nullable CalculatorHistoryState second) {
|
||||
return first != null && second != null &&
|
||||
first.getTime().getTime() == second.getTime().getTime() &&
|
||||
first.getTime() == second.getTime() &&
|
||||
first.getDisplayState().equals(second.getDisplayState()) &&
|
||||
first.getEditorState().equals(second.getEditorState());
|
||||
}
|
||||
@@ -195,7 +193,7 @@ public class CalculatorHistoryActivity extends ListActivity {
|
||||
final CalculatorHistoryState state = getItem(position);
|
||||
|
||||
final TextView time = (TextView) result.findViewById(R.id.history_time);
|
||||
time.setText(new SimpleDateFormat().format(state.getTime()));
|
||||
time.setText(new SimpleDateFormat().format(new Date(state.getTime())));
|
||||
|
||||
final TextView editor = (TextView) result.findViewById(R.id.history_item);
|
||||
editor.setText(getHistoryText(state));
|
||||
|
@@ -21,8 +21,7 @@ import java.util.Date;
|
||||
public class AbstractHistoryState implements Cloneable{
|
||||
|
||||
@Element
|
||||
@NotNull
|
||||
private Date time = new Date();
|
||||
private long time = new Date().getTime();
|
||||
|
||||
@Element(required = false)
|
||||
@Nullable
|
||||
@@ -42,12 +41,11 @@ public class AbstractHistoryState implements Cloneable{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Date getTime() {
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(@NotNull Date time) {
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@@ -74,7 +72,6 @@ public class AbstractHistoryState implements Cloneable{
|
||||
|
||||
try {
|
||||
clone = (AbstractHistoryState)super.clone();
|
||||
clone.time = new Date(this.time.getTime());
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new UnsupportedOperationException(e);
|
||||
}
|
||||
|
@@ -97,6 +97,7 @@ public enum CalculatorHistory implements HistoryHelper<CalculatorHistoryState> {
|
||||
public void load(@Nullable Context context, @Nullable SharedPreferences preferences) {
|
||||
if (context != null && preferences != null) {
|
||||
final String value = preferences.getString(context.getString(R.string.p_calc_history), null);
|
||||
this.savedHistory.clear();
|
||||
HistoryUtils.fromXml(value, this.savedHistory);
|
||||
for (CalculatorHistoryState historyState : savedHistory) {
|
||||
historyState.setSaved(true);
|
||||
|
Reference in New Issue
Block a user