push
This commit is contained in:
parent
5a7d53f600
commit
4ccdb53aa0
2 changed files with 18 additions and 3 deletions
|
@ -2,24 +2,38 @@ package data;
|
||||||
|
|
||||||
import api.GetApiData;
|
import api.GetApiData;
|
||||||
import database.Sqlite;
|
import database.Sqlite;
|
||||||
|
import gui.LoadingStatus;
|
||||||
|
|
||||||
public class RequestLevelLength {
|
public class RequestLevelLength {
|
||||||
|
|
||||||
GetApiData data = new GetApiData();
|
GetApiData data = new GetApiData();
|
||||||
FetchData fetch = new FetchData();
|
FetchData fetch = new FetchData();
|
||||||
Sqlite sql = new Sqlite("levels");
|
Sqlite sql = new Sqlite("levels");
|
||||||
|
LoadingStatus status = new LoadingStatus();
|
||||||
|
|
||||||
public void request() {
|
public void request() {
|
||||||
|
|
||||||
sql.queryData("levels");
|
sql.queryData("levels");
|
||||||
|
|
||||||
|
status.initialize();
|
||||||
|
status.changeState("API wird auf Levellänge abgefragt...");
|
||||||
|
|
||||||
Thread thread = new Thread(new Runnable( ) {
|
Thread thread = new Thread(new Runnable( ) {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
for(int i = 0; i < ManageFiles.getMissinglevels().size(); i++) {
|
for(int i = 0; i < ManageFiles.getMissinglevels().size(); i++) {
|
||||||
sql.modifyData(sql.getLevelname().get(sql.getRawLevelNames().indexOf(sql.getRawLevelNames().get(i))), Boolean.parseBoolean(sql.getCompleted().get(i).toString()), sql.getAttempts().get(i).intValue(), sql.getLocked().get(i).booleanValue(), sql.getPbarr().get(i), "" + data.getLevelLength(Integer.parseInt(sql.getLevelID().get(sql.getRawLevelNames().indexOf(ManageFiles.getMissinglevels().get(i))))));
|
status.update(sql.getLevelname().get(sql.getRawLevelNames().indexOf(sql.getRawLevelNames().get(i))), i);
|
||||||
|
|
||||||
|
sql.modifyData(sql.getLevelname().get(sql.getRawLevelNames().indexOf(sql.getRawLevelNames().get(i))),
|
||||||
|
Boolean.parseBoolean(sql.getCompleted().get(i).toString()),
|
||||||
|
sql.getAttempts().get(i).intValue(),
|
||||||
|
sql.getLocked().get(i).booleanValue(),
|
||||||
|
sql.getPbarr().get(i),
|
||||||
|
"" + data.getLevelLength(Integer.parseInt(sql.getLevelID().get(sql.getRawLevelNames().indexOf(ManageFiles.getMissinglevels().get(i)))))
|
||||||
|
);
|
||||||
try {
|
try {
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class LoadingStatus {
|
||||||
private JLabel info = new JLabel("Updateroutine wird durchgeführt...");
|
private JLabel info = new JLabel("Updateroutine wird durchgeführt...");
|
||||||
private FetchData data = new FetchData();
|
private FetchData data = new FetchData();
|
||||||
|
|
||||||
private LoadingStatus() {
|
public LoadingStatus() {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ public class LoadingStatus {
|
||||||
area.setEditable(false);
|
area.setEditable(false);
|
||||||
area.setLineWrap(true);
|
area.setLineWrap(true);
|
||||||
area.setWrapStyleWord(true);
|
area.setWrapStyleWord(true);
|
||||||
area.setCaretPosition(area.getDocument().getLength());
|
|
||||||
|
|
||||||
JScrollPane scroll = new JScrollPane(area);
|
JScrollPane scroll = new JScrollPane(area);
|
||||||
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||||
|
@ -63,6 +63,7 @@ public class LoadingStatus {
|
||||||
public void update(String level, int barValue) {
|
public void update(String level, int barValue) {
|
||||||
area.append(level + "\n");
|
area.append(level + "\n");
|
||||||
bar.setValue(barValue + 1);
|
bar.setValue(barValue + 1);
|
||||||
|
area.setCaretPosition(area.getDocument().getLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
|
Loading…
Reference in a new issue