Permalink
Browse files

[Mobile] Added support for new v2 RTPI API, which has new per-directi…

…on fields: message, forecastsEnabled and operatingNormally.
  • Loading branch information...
thecosmicfrog committed Dec 12, 2017
1 parent c7ecd23 commit 376400a13f3ea7205fe270955f5838cc1860867c
@@ -900,7 +900,12 @@ private void updateStopForecast(StopForecast stopForecast) {
/* If a valid stop forecast exists... */
if (stopForecast != null) {
String status;
boolean operatingNormally = stopForecast.getOperatingNormally();
boolean operatingNormally = false;
if (stopForecast.getStopForecastStatusDirectionInbound().getOperatingNormally()
&& stopForecast.getStopForecastStatusDirectionOutbound().getOperatingNormally()) {
operatingNormally = true;
}
if (localeDefault.startsWith(GAEILGE)) {
status = getString(R.string.message_success);
@@ -21,27 +21,28 @@
package org.thecosmicfrog.luasataglance.api;
import com.google.gson.annotations.SerializedName;
import org.thecosmicfrog.luasataglance.object.StopForecastStatus;
import org.thecosmicfrog.luasataglance.object.Tram;
import java.util.List;
public class ApiTimes {
private String message;
private boolean forecastsEnabled;
private boolean operatingNormally;
@SerializedName("status")
private StopForecastStatus stopForecastStatus;
private List<Tram> trams;
public String getMessage() {
return message;
}
public boolean getForecastsEnabled() {
return forecastsEnabled;
}
public boolean getOperatingNormally() {
return operatingNormally;
public StopForecastStatus getStopForecastStatus() {
return stopForecastStatus;
}
public List<Tram> getTrams() {
@@ -52,12 +53,8 @@ public void setMessage(String m) {
message = m;
}
public void setForecastsEnabled(boolean f) {
forecastsEnabled = f;
}
public void setOperatingNormally(boolean o) {
operatingNormally = o;
public void setStopForecastStatus(StopForecastStatus s) {
stopForecastStatus = s;
}
public void setTrams(List<Tram> t) {
@@ -29,17 +29,17 @@
private static final long serialVersionUID = 0L;
private final String LOG_TAG = StopForecast.class.getSimpleName();
private String message;
private boolean forecastsEnabled;
private boolean operatingNormally;
private StopForecastStatusDirection stopForecastStatusDirectionInbound;
private StopForecastStatusDirection stopForecastStatusDirectionOutbound;
private List<Tram> inboundTrams;
private List<Tram> outboundTrams;
public StopForecast() {
inboundTrams = new ArrayList<>();
outboundTrams = new ArrayList<>();
stopForecastStatusDirectionInbound = new StopForecastStatusDirection();
stopForecastStatusDirectionOutbound = new StopForecastStatusDirection();
}
public void addInboundTram(Tram t) {
@@ -58,12 +58,12 @@ public void setMessage(String m) {
message = m;
}
public void setForecastsEnabled(boolean f) {
forecastsEnabled = f;
public void setStopForecastStatusDirectionInbound(StopForecastStatusDirection f) {
stopForecastStatusDirectionInbound = f;
}
public void setOperatingNormally(boolean o) {
operatingNormally = o;
public void setStopForecastStatusDirectionOutbound(StopForecastStatusDirection f) {
stopForecastStatusDirectionOutbound = f;
}
public void setInboundTrams(List<Tram> i) {
@@ -78,12 +78,12 @@ public String getMessage() {
return message;
}
public boolean getForecastsEnabled() {
return forecastsEnabled;
public StopForecastStatusDirection getStopForecastStatusDirectionInbound() {
return stopForecastStatusDirectionInbound;
}
public boolean getOperatingNormally() {
return operatingNormally;
public StopForecastStatusDirection getStopForecastStatusDirectionOutbound() {
return stopForecastStatusDirectionOutbound;
}
public List<Tram> getInboundTrams() {
@@ -0,0 +1,53 @@
/**
* @author Aaron Hastings
*
* Copyright 2015-2017 Aaron Hastings
*
* This file is part of Luas at a Glance.
*
* Luas at a Glance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Luas at a Glance is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Luas at a Glance. If not, see <http://www.gnu.org/licenses/>.
*/
package org.thecosmicfrog.luasataglance.object;
import com.google.gson.annotations.SerializedName;
public class StopForecastStatus {
@SerializedName("inbound")
private StopForecastStatusDirection stopForecastStatusDirectionInbound;
@SerializedName("outbound")
private StopForecastStatusDirection stopForecastStatusDirectionOutbound;
public StopForecastStatus() {
stopForecastStatusDirectionInbound = new StopForecastStatusDirection();
stopForecastStatusDirectionOutbound = new StopForecastStatusDirection();
}
public StopForecastStatusDirection getStopForecastStatusDirectionInbound() {
return stopForecastStatusDirectionInbound;
}
public StopForecastStatusDirection getStopForecastStatusDirectionOutbound() {
return stopForecastStatusDirectionOutbound;
}
public void setStopForecastStatusDirectionInbound(StopForecastStatusDirection f) {
stopForecastStatusDirectionInbound = f;
}
public void setStopForecastStatusDirectionOutbound(StopForecastStatusDirection f) {
stopForecastStatusDirectionOutbound = f;
}
}
@@ -0,0 +1,52 @@
/**
* @author Aaron Hastings
*
* Copyright 2015-2017 Aaron Hastings
*
* This file is part of Luas at a Glance.
*
* Luas at a Glance is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Luas at a Glance is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Luas at a Glance. If not, see <http://www.gnu.org/licenses/>.
*/
package org.thecosmicfrog.luasataglance.object;
public class StopForecastStatusDirection {
private String message;
private boolean forecastsEnabled;
private boolean operatingNormally;
public String getMessage() {
return message;
}
public boolean getForecastsEnabled() {
return forecastsEnabled;
}
public boolean getOperatingNormally() {
return operatingNormally;
}
public void setMessage(String m) {
message = m;
}
public void setForecastsEnabled(boolean f) {
forecastsEnabled = f;
}
public void setOperatingNormally(boolean o) {
operatingNormally = o;
}
}
@@ -164,7 +164,43 @@ public static StopForecast createStopForecast(ApiTimes apiTimes) {
stopForecast.setMessage(apiTimes.getMessage());
}
stopForecast.setOperatingNormally(apiTimes.getOperatingNormally());
if (apiTimes.getStopForecastStatus() != null) {
if (apiTimes.getStopForecastStatus().getStopForecastStatusDirectionInbound() != null) {
if (apiTimes.getStopForecastStatus().getStopForecastStatusDirectionInbound()
.getMessage() != null) {
stopForecast.getStopForecastStatusDirectionInbound().setMessage(
apiTimes.getStopForecastStatus()
.getStopForecastStatusDirectionInbound().getMessage()
);
stopForecast.getStopForecastStatusDirectionInbound().setForecastsEnabled(
apiTimes.getStopForecastStatus()
.getStopForecastStatusDirectionInbound().getForecastsEnabled()
);
stopForecast.getStopForecastStatusDirectionInbound().setOperatingNormally(
apiTimes.getStopForecastStatus()
.getStopForecastStatusDirectionInbound().getOperatingNormally()
);
}
}
if (apiTimes.getStopForecastStatus().getStopForecastStatusDirectionOutbound() != null) {
if (apiTimes.getStopForecastStatus().getStopForecastStatusDirectionOutbound()
.getMessage() != null) {
stopForecast.getStopForecastStatusDirectionOutbound().setMessage(
apiTimes.getStopForecastStatus()
.getStopForecastStatusDirectionOutbound().getMessage()
);
stopForecast.getStopForecastStatusDirectionOutbound().setForecastsEnabled(
apiTimes.getStopForecastStatus()
.getStopForecastStatusDirectionOutbound().getForecastsEnabled()
);
stopForecast.getStopForecastStatusDirectionOutbound().setOperatingNormally(
apiTimes.getStopForecastStatus()
.getStopForecastStatusDirectionOutbound().getOperatingNormally()
);
}
}
}
if (apiTimes.getTrams() != null) {
for (Tram tram : apiTimes.getTrams()) {
@@ -189,4 +225,3 @@ public static StopForecast createStopForecast(ApiTimes apiTimes) {
return stopForecast;
}
}

0 comments on commit 376400a

Please sign in to comment.