2024-01-10 18:54:00 +01:00
|
|
|
/* Copyright (C) 2019-2024 Andreas Böhler
|
2019-02-27 09:21:41 +01:00
|
|
|
|
|
|
|
This file is part of Gadgetbridge.
|
|
|
|
|
|
|
|
Gadgetbridge is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published
|
|
|
|
by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Gadgetbridge is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
2024-01-10 18:54:00 +01:00
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
2019-02-27 09:21:41 +01:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.service.btle;
|
|
|
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
public abstract class AbstractTransaction {
|
|
|
|
private final String mName;
|
|
|
|
private final long creationTimestamp = System.currentTimeMillis();
|
|
|
|
|
|
|
|
public AbstractTransaction(String taskName) {
|
|
|
|
this.mName = taskName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getTaskName() {
|
|
|
|
return mName;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected String getCreationTime() {
|
|
|
|
return DateFormat.getTimeInstance(DateFormat.MEDIUM).format(new Date(creationTimestamp));
|
|
|
|
}
|
|
|
|
|
2019-02-27 19:07:53 +01:00
|
|
|
public abstract int getActionCount();
|
2019-02-27 09:21:41 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
2019-02-27 19:07:53 +01:00
|
|
|
return String.format(Locale.US, "%s: Transaction task: %s with %d actions", getCreationTime(), getTaskName(), getActionCount());
|
2019-02-27 09:21:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|