int to double in the isOlderThan()
This commit is contained in:
parent
af0140f6b9
commit
2eca7f0a02
1 changed files with 27 additions and 1 deletions
|
@ -5,6 +5,7 @@ import android.graphics.Color;
|
|||
import com.j256.ormlite.field.DatabaseField;
|
||||
import com.j256.ormlite.table.DatabaseTable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -97,6 +98,14 @@ public class CareportalEvent implements DataPointWithLabelInterface {
|
|||
return diff.get(TimeUnit.DAYS) + " " + MainApp.sResources.getString(R.string.days) + " " + diff.get(TimeUnit.HOURS) + " " + MainApp.sResources.getString(R.string.hours);
|
||||
}
|
||||
|
||||
public boolean isOlderThan(double threshold) {
|
||||
Map<TimeUnit, Long> diff = computeDiff(date, System.currentTimeMillis());
|
||||
if(diff.get(TimeUnit.DAYS) > threshold)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public String log() {
|
||||
return "CareportalEvent{" +
|
||||
"date= " + date +
|
||||
|
@ -184,13 +193,24 @@ public class CareportalEvent implements DataPointWithLabelInterface {
|
|||
try {
|
||||
JSONObject object = new JSONObject(json);
|
||||
if (object.has("notes"))
|
||||
return object.getString("notes");
|
||||
return StringUtils.abbreviate(object.getString("notes"), 40);
|
||||
} catch (JSONException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
return Translator.translate(eventType);
|
||||
}
|
||||
|
||||
public String getNotes() {
|
||||
try {
|
||||
JSONObject object = new JSONObject(json);
|
||||
if (object.has("notes"))
|
||||
return object.getString("notes");
|
||||
} catch (JSONException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDuration() {
|
||||
try {
|
||||
|
@ -242,4 +262,10 @@ public class CareportalEvent implements DataPointWithLabelInterface {
|
|||
return Color.GRAY;
|
||||
return Color.GRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSecondColor() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue