forked from bisq-network/bisq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dfcda39
commit 9f01e9e
Showing
20 changed files
with
1,192 additions
and
688 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/main/java/bisq/desktop/main/dao/cycles/CyclesListItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* This file is part of Bisq. | ||
* | ||
* Bisq 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. | ||
* | ||
* Bisq 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 | ||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package bisq.desktop.main.dao.cycles; | ||
|
||
import bisq.desktop.main.dao.cycles.model.CycleResult; | ||
|
||
import bisq.core.dao.voting.proposal.compensation.CompensationProposal; | ||
import bisq.core.locale.Res; | ||
import bisq.core.util.BsqFormatter; | ||
|
||
import org.bitcoinj.core.Coin; | ||
|
||
import java.util.Date; | ||
|
||
import lombok.Getter; | ||
|
||
public class CyclesListItem { | ||
private BsqFormatter bsqFormatter; | ||
@Getter | ||
private CycleResult cycleResult; | ||
|
||
public CyclesListItem(CycleResult cycleResult, | ||
BsqFormatter bsqFormatter) { | ||
this.cycleResult = cycleResult; | ||
this.bsqFormatter = bsqFormatter; | ||
} | ||
|
||
public String getCycle() { | ||
int displayIndex = cycleResult.getCycleIndex() + 1; | ||
String dateTime = bsqFormatter.formatDateTime(new Date(cycleResult.getCycleStartTime())); | ||
return Res.get("dao.results.results.table.item.cycle", displayIndex, dateTime); | ||
} | ||
|
||
public String getNumProposals() { | ||
return String.valueOf(cycleResult.getEvaluatedProposals().size()); | ||
} | ||
|
||
public String getNumVotesAsString() { | ||
return String.valueOf(cycleResult.getNumVotes()); | ||
} | ||
|
||
public String getStake() { | ||
return bsqFormatter.formatCoinWithCode(Coin.valueOf(cycleResult.getTotalStake())); | ||
} | ||
|
||
public String getIssuance() { | ||
long totalIssuance = cycleResult.getEvaluatedProposals().stream() | ||
.filter(e -> e.getProposal() instanceof CompensationProposal) | ||
.map(e -> (CompensationProposal) e.getProposal()) | ||
.mapToLong(e -> e.getRequestedBsq().value) | ||
.sum(); | ||
return bsqFormatter.formatCoinWithCode(Coin.valueOf(totalIssuance)); | ||
} | ||
|
||
public Long getCycleStartTime() { | ||
return cycleResult.getCycleStartTime(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.