Search in sources :

Example 1 with FixedSizeProfileBlock

use of sugar.free.sightremote.utils.FixedSizeProfileBlock in project SightRemote by TebbeUbben.

the class EditBRProfileActivity method onBlockChange.

@Override
public void onBlockChange(FixedSizeProfileBlock changedBlock, int endTime, double amount) {
    changedBlock.setAmount(amount);
    changedBlock.setEndTime(endTime);
    for (FixedSizeProfileBlock block : new ArrayList<>(profileBlocks)) {
        if (block == changedBlock)
            continue;
        if (block.getEndTime() <= changedBlock.getStartTime())
            continue;
        if (block.getEndTime() <= endTime)
            profileBlocks.remove(block);
        else if (block.getStartTime() <= endTime)
            block.setStartTime(endTime);
    }
    FixedSizeProfileBlock latest = profileBlocks.get(profileBlocks.size() - 1);
    if (latest.getEndTime() < 24 * 60)
        profileBlocks.add(new FixedSizeProfileBlock(latest.getEndTime(), 24 * 60, latest.getAmount()));
    adapter.notifyDataSetChanged();
}
Also used : FixedSizeProfileBlock(sugar.free.sightremote.utils.FixedSizeProfileBlock) ArrayList(java.util.ArrayList)

Example 2 with FixedSizeProfileBlock

use of sugar.free.sightremote.utils.FixedSizeProfileBlock in project SightRemote by TebbeUbben.

the class EditBRProfileActivity method onClick.

@Override
public void onClick(int position) {
    FixedSizeProfileBlock profileBlock = profileBlocks.get(position);
    EditBRBlockDialog.showDialog(this, this, profileBlocks.get(position), position == 23, position != profileBlocks.size() - 1 ? profileBlock.getEndTime() : profileBlock.getStartTime() + 15, minBRAmount, maxBRAmount);
}
Also used : FixedSizeProfileBlock(sugar.free.sightremote.utils.FixedSizeProfileBlock)

Aggregations

FixedSizeProfileBlock (sugar.free.sightremote.utils.FixedSizeProfileBlock)2 ArrayList (java.util.ArrayList)1