sharedData.getListeningRequests().incrementAndGet();
return id;
}
private long getRandomPieceId() {
Piece piece;
long maxId = sharedData.getMaxId();
if (maxId == 0) {
maxId = dao.getMaxPieceId();
}
long id = 0;
int attempts = 0;
while (attempts < 5) {
id = (long) (1 + (Math.random() * maxId));
piece = dao.getById(Piece.class, id);
if (piece != null && piece.getLikes() >= -3) {
break;
}
attempts++;
}
return id;