Fixed crash when N is present in grades

This commit is contained in:
Thastertyn 2023-03-04 10:49:32 +01:00
parent 3a37456337
commit 34d84b9e10
11 changed files with 33 additions and 14 deletions

4
.vscode/launch.json vendored
View File

@ -8,14 +8,14 @@
"type": "java", "type": "java",
"name": "Launch Current File", "name": "Launch Current File",
"request": "launch", "request": "launch",
"mainClass": "${file}" "mainClass": "${file}",
}, },
{ {
"type": "java", "type": "java",
"name": "Launch App", "name": "Launch App",
"request": "launch", "request": "launch",
"mainClass": "xyz.thastertyn.App", "mainClass": "xyz.thastertyn.App",
"projectName": "jecnak-tui" "projectName": "jecnak-tui",
} }
] ]
} }

View File

@ -39,6 +39,11 @@ public class Znamky {
int divisor = 0; int divisor = 0;
for(Pair<Integer, Double> p : a) for(Pair<Integer, Double> p : a)
{ {
if(p.getValue0() == -1)
{
continue;
}
divident += p.getValue0() * p.getValue1(); divident += p.getValue0() * p.getValue1();
divisor += p.getValue1(); divisor += p.getValue1();
} }
@ -84,7 +89,14 @@ public class Znamky {
break; break;
} }
int znamka = Integer.parseInt(znamkaElement.select("span.value").text()); String zn = znamkaElement.select("span.value").text();
int znamka;
if(zn.toLowerCase().equals("n") || zn.toLowerCase().equals("u"))
{
znamka = -1;
}else{
znamka = Integer.parseInt(znamkaElement.select("span.value").text());
}
// Mala znamka se bude pocitat jako polovicni vaha // Mala znamka se bude pocitat jako polovicni vaha
if(znamkaElement.hasClass("scoreSmall")) if(znamkaElement.hasClass("scoreSmall"))

View File

@ -15,8 +15,8 @@ public class Rozvrh extends JecnaContent {
private xyz.thastertyn.Jecna.Rozvrh rozvrh = new xyz.thastertyn.Jecna.Rozvrh(); private xyz.thastertyn.Jecna.Rozvrh rozvrh = new xyz.thastertyn.Jecna.Rozvrh();
//private String[] labels = {"Den", "7:30-8:15", "8:25-9:10", "9:20-10:05", "10:20-11:05", "11:15-12:00", "12:10-12:55", "13:05-13:50", "14:00-14:45", "14:55-15:40", "15:50-16:35"}; private String[] labels = {"Den", "7:30-8:15", "8:25-9:10", "9:20-10:05", "10:20-11:05", "11:15-12:00", "12:10-12:55", "13:05-13:50", "14:00-14:45", "14:55-15:40", "15:50-16:35"};
private String[] labels = {"Den", "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10."}; //private String[] labels = {"Den", "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10."};
String[] days = {"PO", "UT", "ST", "CT", "PA"}; String[] days = {"PO", "UT", "ST", "CT", "PA"};

View File

@ -48,6 +48,10 @@ public class Znamky extends JecnaContent {
Label znamkaLabel = new Label(znamka.getValue0() + ""); Label znamkaLabel = new Label(znamka.getValue0() + "");
switch(znamka.getValue0()) switch(znamka.getValue0())
{ {
case -1:
znamkaLabel.setText("N");
znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.WHITE, TextColor.ANSI.BLACK));
break;
case 1: case 1:
znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, TextColor.ANSI.GREEN)); znamkaLabel.setTheme(new SimpleTheme(TextColor.ANSI.BLACK, TextColor.ANSI.GREEN));
break; break;

View File

@ -4,6 +4,8 @@ import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import com.googlecode.lanterna.TextColor; import com.googlecode.lanterna.TextColor;
import com.googlecode.lanterna.gui2.BasicWindow; import com.googlecode.lanterna.gui2.BasicWindow;
import com.googlecode.lanterna.gui2.Border;
import com.googlecode.lanterna.gui2.Borders;
import com.googlecode.lanterna.gui2.DefaultWindowManager; import com.googlecode.lanterna.gui2.DefaultWindowManager;
import com.googlecode.lanterna.gui2.Direction; import com.googlecode.lanterna.gui2.Direction;
import com.googlecode.lanterna.gui2.EmptySpace; import com.googlecode.lanterna.gui2.EmptySpace;
@ -51,14 +53,16 @@ public class MainWindow {
window.setComponent(mainPanel); window.setComponent(mainPanel);
mainPanel.addComponent(new Separator(Direction.VERTICAL).setLayoutData(LinearLayout.createLayoutData(LinearLayout.Alignment.Fill))); mainPanel.addComponent(new Separator(Direction.VERTICAL).setLayoutData(LinearLayout.createLayoutData(LinearLayout.Alignment.Fill)));
String text = "Jecnak";
Panel content = new Panel(); Panel content = new Panel();
content.addTo(mainPanel); mainPanel.addComponent(content.withBorder(Borders.singleLine(text)));
Login login = new Login(); Login login = new Login();
login.showDialog(textGUI); login.showDialog(textGUI);
window.addWindowListener(new WindowSwitchListener(content, login.getJessionId())); window.addWindowListener(new WindowSwitchListener(content, login.getJessionId(), text));
textGUI.addWindowAndWait(window); textGUI.addWindowAndWait(window);

View File

@ -4,7 +4,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import com.googlecode.lanterna.TerminalPosition; import com.googlecode.lanterna.TerminalPosition;
import com.googlecode.lanterna.TerminalSize; import com.googlecode.lanterna.TerminalSize;
import com.googlecode.lanterna.gui2.Label;
import com.googlecode.lanterna.gui2.Panel; import com.googlecode.lanterna.gui2.Panel;
import com.googlecode.lanterna.gui2.Window; import com.googlecode.lanterna.gui2.Window;
import com.googlecode.lanterna.gui2.WindowBasedTextGUI; import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
@ -25,11 +24,11 @@ public class WindowSwitchListener implements WindowListener {
private String JsessionId; private String JsessionId;
Panel panel; Panel panel;
Label label; String label;
int current = 0; int current = 0;
public WindowSwitchListener(Panel holder, String JsessionId) public WindowSwitchListener(Panel holder, String JsessionId, String label)
{ {
panel = holder; panel = holder;
this.JsessionId = JsessionId; this.JsessionId = JsessionId;
@ -42,7 +41,7 @@ public class WindowSwitchListener implements WindowListener {
contents[0].download(JsessionId); contents[0].download(JsessionId);
panel.removeAllComponents(); panel.removeAllComponents();
panel.addComponent(contents[0].getPanel()); panel.addComponent(contents[0].getPanel());
//label.setText(contents[0].getLabel()); label = contents[0].getLabel();
} }
public void next() public void next()
@ -58,11 +57,11 @@ public class WindowSwitchListener implements WindowListener {
{ {
contents[current].download(JsessionId); contents[current].download(JsessionId);
} }
panel.removeAllComponents(); panel.removeAllComponents();
panel.addComponent(contents[current].getPanel()); panel.addComponent(contents[current].getPanel());
//label.setText(contents[current].getLabel()); label = contents[current].getLabel();
} }
public void previous() public void previous()
@ -81,7 +80,7 @@ public class WindowSwitchListener implements WindowListener {
panel.removeAllComponents(); panel.removeAllComponents();
panel.addComponent(contents[current].getPanel()); panel.addComponent(contents[current].getPanel());
//label.setText(contents[current].getLabel()); label = contents[current].getLabel();
} }