mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-14 00:30:31 +00:00
handle typical network exceptions in AsyncTasks
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@343 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
45465a87ee
commit
114f8db546
5 changed files with 12 additions and 53 deletions
|
@ -17,10 +17,8 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
@ -113,10 +111,6 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
{
|
||||
throw new RuntimeException(x);
|
||||
}
|
||||
catch (final SocketTimeoutException x)
|
||||
{
|
||||
throw new RuntimeException(x);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (is != null)
|
||||
|
@ -289,13 +283,13 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
stations.add(ownStation);
|
||||
|
||||
if (maxStations == 0 || maxStations >= stations.size())
|
||||
return new NearbyStationsResult(uri, stations);
|
||||
return new NearbyStationsResult(stations);
|
||||
else
|
||||
return new NearbyStationsResult(uri, stations.subList(0, maxStations));
|
||||
return new NearbyStationsResult(stations.subList(0, maxStations));
|
||||
}
|
||||
else if ("notidentified".equals(nameState))
|
||||
{
|
||||
return new NearbyStationsResult(uri, NearbyStationsResult.Status.INVALID_STATION);
|
||||
return new NearbyStationsResult(NearbyStationsResult.Status.INVALID_STATION);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -306,14 +300,6 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
{
|
||||
throw new RuntimeException(x);
|
||||
}
|
||||
catch (final FileNotFoundException x)
|
||||
{
|
||||
return new NearbyStationsResult(uri, NearbyStationsResult.Status.SERVICE_DOWN);
|
||||
}
|
||||
catch (final SocketTimeoutException x)
|
||||
{
|
||||
return new NearbyStationsResult(uri, NearbyStationsResult.Status.SERVICE_DOWN);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (is != null)
|
||||
|
@ -792,14 +778,6 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
{
|
||||
throw new RuntimeException(x);
|
||||
}
|
||||
catch (final FileNotFoundException x)
|
||||
{
|
||||
return new QueryDeparturesResult(QueryDeparturesResult.Status.SERVICE_DOWN, Integer.parseInt(stationId));
|
||||
}
|
||||
catch (final SocketTimeoutException x)
|
||||
{
|
||||
return new QueryDeparturesResult(QueryDeparturesResult.Status.SERVICE_DOWN, Integer.parseInt(stationId));
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (is != null)
|
||||
|
@ -855,10 +833,6 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
is = ParserUtils.scrapeInputStream(uri);
|
||||
return queryConnections(uri, is);
|
||||
}
|
||||
catch (final SocketTimeoutException x)
|
||||
{
|
||||
return new QueryConnectionsResult(QueryConnectionsResult.Status.SERVICE_DOWN);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (is != null)
|
||||
|
@ -874,10 +848,6 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
is = ParserUtils.scrapeInputStream(uri);
|
||||
return queryConnections(uri, is);
|
||||
}
|
||||
catch (final SocketTimeoutException x)
|
||||
{
|
||||
return new QueryConnectionsResult(QueryConnectionsResult.Status.SERVICE_DOWN);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (is != null)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue