small handleMenuAction refactor
This commit is contained in:
parent
f5d5808a72
commit
169dc19bb7
1 changed files with 14 additions and 12 deletions
|
|
@ -72,28 +72,30 @@ public class MainFrame {
|
||||||
public void handleMenuAction(MenuAction action) {
|
public void handleMenuAction(MenuAction action) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case ACTION_UP -> {
|
case ACTION_UP -> {
|
||||||
if (menuPosition == MenuPosition.MENU_CATEGORIES) {
|
switch (menuPosition) {
|
||||||
categoryIndex = (categoryIndex - 1) % categoryData.length;
|
case MENU_CATEGORIES -> categoryIndex = (categoryIndex - 1) % categoryData.length;
|
||||||
} else if (menuPosition == MenuPosition.MENU_CHANNELS) {
|
case MENU_CHANNELS -> channelIndex = (channelIndex - 1) % channelData.length;
|
||||||
channelIndex = (channelIndex - 1) % channelData.length;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case ACTION_DOWN -> {
|
case ACTION_DOWN -> {
|
||||||
if (menuPosition == MenuPosition.MENU_CATEGORIES) {
|
switch (menuPosition) {
|
||||||
categoryIndex = (categoryIndex + 1) % categoryData.length;
|
case MENU_CATEGORIES -> categoryIndex = (categoryIndex + 1) % categoryData.length;
|
||||||
} else if (menuPosition == MenuPosition.MENU_CHANNELS) {
|
case MENU_CHANNELS -> channelIndex = (channelIndex + 1) % channelData.length;
|
||||||
channelIndex = (channelIndex + 1) % channelData.length;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case ACTION_LEFT -> menuPosition = MenuPosition.MENU_CATEGORIES;
|
case ACTION_LEFT -> menuPosition = MenuPosition.MENU_CATEGORIES;
|
||||||
case ACTION_RIGHT -> menuPosition = MenuPosition.MENU_CHANNELS;
|
case ACTION_RIGHT -> menuPosition = MenuPosition.MENU_CHANNELS;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (menuPosition) {
|
switch (menuPosition) {
|
||||||
case MENU_CATEGORIES -> categoryList.setSelectedIndex(categoryIndex);
|
case MENU_CATEGORIES -> {
|
||||||
case MENU_CHANNELS -> channelList.setSelectedIndex(channelIndex);
|
categoryList.setSelectedIndex(categoryIndex);
|
||||||
|
categoryList.ensureIndexIsVisible(categoryIndex);
|
||||||
|
}
|
||||||
|
case MENU_CHANNELS -> {
|
||||||
|
channelList.setSelectedIndex(channelIndex);
|
||||||
|
channelList.ensureIndexIsVisible(channelIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue