Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/backend/FiveTAPIFetcher.java
Show All 11 Lines | BusTO - Backend components | ||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
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.Nullable; | import androidx.annotation.Nullable; | ||||
import android.util.Log; | import android.util.Log; | ||||
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.io.UnsupportedEncodingException; | import java.io.UnsupportedEncodingException; | ||||
import java.net.MalformedURLException; | import java.net.MalformedURLException; | ||||
import java.net.URL; | import java.net.URL; | ||||
import java.net.URLEncoder; | import java.net.URLEncoder; | ||||
import java.security.MessageDigest; | |||||
import java.security.NoSuchAlgorithmException; | |||||
import java.util.*; | import java.util.*; | ||||
import java.util.concurrent.atomic.AtomicReference; | import java.util.concurrent.atomic.AtomicReference; | ||||
public class FiveTAPIFetcher implements ArrivalsFetcher{ | public class FiveTAPIFetcher implements ArrivalsFetcher{ | ||||
private static final String DEBUG_NAME = "FiveTAPIFetcher"; | private static final String DEBUG_NAME = "FiveTAPIFetcher"; | ||||
private final Map<String,String> defaultHeaders = getDefaultHeaders(); | private final Map<String,String> defaultHeaders = getDefaultHeaders(); | ||||
final static LinkedList<String> apiDays = new LinkedList<>(Arrays.asList("dom","lun","mar","mer","gio","ven","sab")); | final static LinkedList<String> apiDays = new LinkedList<>(Arrays.asList("dom","lun","mar","mer","gio","ven","sab")); | ||||
Show All 23 Lines | public Palina ReadArrivalTimesAll(String stopID, AtomicReference<result> res) { | ||||
res.set(result.PARSER_ERROR); | res.set(result.PARSER_ERROR); | ||||
return null; | return null; | ||||
} | } | ||||
res.set(result.OK); | res.set(result.OK); | ||||
p.sortRoutes(); | p.sortRoutes(); | ||||
return p; | return p; | ||||
} | } | ||||
@Override | |||||
public Passaggio.Source getSourceForFetcher() { | |||||
return Passaggio.Source.FiveTAPI; | |||||
} | |||||
List<Route> parseArrivalsServerResponse(String JSONresponse, AtomicReference<result> res) throws JSONException{ | List<Route> parseArrivalsServerResponse(String JSONresponse, AtomicReference<result> res) throws JSONException{ | ||||
ArrayList<Route> routes = new ArrayList<>(3); | ArrayList<Route> routes = new ArrayList<>(3); | ||||
/* | /* | ||||
Slight problem: | Slight problem: | ||||
"longName": ==> DESCRIPTION | "longName": ==> DESCRIPTION | ||||
"name": "13N", | "name": "13N", | ||||
"departures": [ | "departures": [ | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 314 Lines • Show Last 20 Lines |
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