56 lines
1.4 KiB
Java
56 lines
1.4 KiB
Java
package com.thebrokenrail.mtudining.activity.menu;
|
|
|
|
import com.thebrokenrail.mtudining.activity.task.Task;
|
|
import com.thebrokenrail.mtudining.api.Connection;
|
|
import com.thebrokenrail.mtudining.api.method.Periods;
|
|
import com.thebrokenrail.mtudining.util.Constants;
|
|
|
|
import java.util.Date;
|
|
|
|
public class MenuTask extends Task<MenuData> {
|
|
private final Connection connection;
|
|
|
|
private String locationId;
|
|
private Date date;
|
|
|
|
public MenuTask(Connection connection) {
|
|
this.connection = connection;
|
|
}
|
|
|
|
/**
|
|
* Setup task.
|
|
* @param locationId Location ID (or null to use existing)
|
|
* @param date Date
|
|
*/
|
|
void setup(String locationId, Date date) {
|
|
if (locationId != null) {
|
|
this.locationId = locationId;
|
|
}
|
|
this.date = date;
|
|
}
|
|
|
|
/**
|
|
* Get date.
|
|
* @return The date
|
|
*/
|
|
public Date getDate() {
|
|
return date;
|
|
}
|
|
|
|
@Override
|
|
protected void startImpl(long id) {
|
|
// Get Periods
|
|
Periods periods = new Periods(Constants.PLATFORM, locationId, date);
|
|
connection.send(periods, periodsResponse -> {
|
|
// Loaded Periods
|
|
for (Periods.Response.Period period : periodsResponse.periods) {
|
|
System.out.println("Period: " + period.name);
|
|
}
|
|
done(id, null);
|
|
}, () -> {
|
|
// Error
|
|
done(id, null);
|
|
});
|
|
}
|
|
}
|