-
Notifications
You must be signed in to change notification settings - Fork 15
Example 5: Using FolderItems within FolderItems
Roland edited this page Sep 17, 2018
·
3 revisions
THIS TUTORIAL IS OUTDATED ATM
This example creates 15 items, puts them into a folder and put that folder into another folder, which acts as root folder. The root folder and the StreamDeck device is given to the StreamDeckController, which handles traversing the given folders and handing over KeyEvents to non-folder items.
import de.rcblum.stream.deck.StreamDeck;
import de.rcblum.stream.deck.StreamDeckController;
import de.rcblum.stream.deck.StreamDeckDevices;
import de.rcblum.stream.deck.items.FolderItem;
import de.rcblum.stream.deck.items.ExecutableItem;
// Get one of the connected stream devices
StreamDeck sd = StreamDeckDevices.getStreamDeck();
// Reset device
sd.reset();
// Set brightness to 50%
sd.setBrightness(50);
// Create 15 items
StreamItem[] items = new StreamItem[15];
for (int i = 0; i < items.length; i++) {
System.out.println("resources" + File.separator + "icon" + (i+1) + ".png");
byte[] icon = IconHelper.loadImage(
"resources" + File.separator + "icon" + (i+1) + ".png"
);
ExecutableItem eI = new ExecutableItem(icon, "explorer");
items[i] = eI;
}
// Put items into folder
FolderItem dir = new FolderItem("Folder Level 1", null, items);
// Put folder with items in root folder
StreamItem[] rootDirs = new StreamItem[15];
rootDirs[4] = dir;
FolderItem root = new FolderItem(null, null, rootDirs);
// Create stream deck controller that will
// handle folders and events sent from the stream deck
StreamDeckController controller = new StreamDeckController(sd, root);