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",
"name": "Launch Current File",
"request": "launch",
"mainClass": "${file}"
"mainClass": "${file}",
},
{
"type": "java",
"name": "Launch App",
"request": "launch",
"mainClass": "xyz.thastertyn.App",
"projectName": "jecnak-tui"
"projectName": "jecnak-tui",
}
]
}

View File

@ -39,6 +39,11 @@ public class Znamky {
int divisor = 0;
for(Pair<Integer, Double> p : a)
{
if(p.getValue0() == -1)
{
continue;
}
divident += p.getValue0() * p.getValue1();
divisor += p.getValue1();
}
@ -84,7 +89,14 @@ public class Znamky {
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
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 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", "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."};
String[] days = {"PO", "UT", "ST", "CT", "PA"};

View File

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

View File

@ -4,6 +4,8 @@ import java.io.IOException;
import java.util.Arrays;
import com.googlecode.lanterna.TextColor;
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.Direction;
import com.googlecode.lanterna.gui2.EmptySpace;
@ -52,13 +54,15 @@ public class MainWindow {
mainPanel.addComponent(new Separator(Direction.VERTICAL).setLayoutData(LinearLayout.createLayoutData(LinearLayout.Alignment.Fill)));
String text = "Jecnak";
Panel content = new Panel();
content.addTo(mainPanel);
mainPanel.addComponent(content.withBorder(Borders.singleLine(text)));
Login login = new Login();
login.showDialog(textGUI);
window.addWindowListener(new WindowSwitchListener(content, login.getJessionId()));
window.addWindowListener(new WindowSwitchListener(content, login.getJessionId(), text));
textGUI.addWindowAndWait(window);

View File

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