Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/backend/GTTJSONFetcher.java
Show All 12 Lines | BusTO (backend components) | ||||
GNU General Public License for more details. | GNU General Public License for more details. | ||||
You should have received a copy of the GNU General Public License | You should have received a copy of the GNU General Public License | ||||
along with this program. If not, see <http://www.gnu.org/licenses/>. | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
package it.reyboz.bustorino.backend; | package it.reyboz.bustorino.backend; | ||||
import android.support.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import org.json.JSONArray; | import org.json.JSONArray; | ||||
import org.json.JSONException; | import org.json.JSONException; | ||||
import org.json.JSONObject; | import org.json.JSONObject; | ||||
import java.net.URL; | import java.net.URL; | ||||
import java.net.URLEncoder; | import java.net.URLEncoder; | ||||
import java.util.concurrent.atomic.AtomicReference; | import java.util.concurrent.atomic.AtomicReference; | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | public Palina ReadArrivalTimesAll(String stopID, AtomicReference<result> res) { | ||||
bacino = "U"; | bacino = "U"; | ||||
} | } | ||||
pos = p.addRoute(routename, thisroute.getString("Direzione"), FiveTNormalizer.decodeType(routename, bacino)); | pos = p.addRoute(routename, thisroute.getString("Direzione"), FiveTNormalizer.decodeType(routename, bacino)); | ||||
passaggi = thisroute.getJSONArray("PassaggiRT"); | passaggi = thisroute.getJSONArray("PassaggiRT"); | ||||
howManyPassaggi = passaggi.length(); | howManyPassaggi = passaggi.length(); | ||||
for(j = 0; j < howManyPassaggi; j++) { | for(j = 0; j < howManyPassaggi; j++) { | ||||
p.addPassaggio(passaggi.getString(j).concat("*"), Passaggio.Source.GTTJSON, pos); | String mPassaggio = passaggi.getString(j); | ||||
if (mPassaggio.contains("__")){ | |||||
mPassaggio = mPassaggio.replace("_", ""); | |||||
} | |||||
p.addPassaggio(mPassaggio.concat("*"), Passaggio.Source.GTTJSON, pos); | |||||
} | } | ||||
passaggi = thisroute.getJSONArray("PassaggiPR"); // now the non-real-time ones | passaggi = thisroute.getJSONArray("PassaggiPR"); // now the non-real-time ones | ||||
howManyPassaggi = passaggi.length(); | howManyPassaggi = passaggi.length(); | ||||
for(j = 0; j < howManyPassaggi; j++) { | for(j = 0; j < howManyPassaggi; j++) { | ||||
p.addPassaggio(passaggi.getString(j), Passaggio.Source.GTTJSON, pos); | p.addPassaggio(passaggi.getString(j), Passaggio.Source.GTTJSON, pos); | ||||
} | } | ||||
} | } | ||||
} catch (JSONException e) { | } catch (JSONException e) { | ||||
res.set(result.PARSER_ERROR); | res.set(result.PARSER_ERROR); | ||||
return p; | return p; | ||||
} | } | ||||
p.sortRoutes(); | p.sortRoutes(); | ||||
res.set(result.OK); | res.set(result.OK); | ||||
return p; | return p; | ||||
} | } | ||||
@Override | |||||
public Passaggio.Source getSourceForFetcher() { | |||||
return Passaggio.Source.GTTJSON; | |||||
} | |||||
} | } |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register