Skip to content

Commit

Permalink
Update third party libs.
Browse files Browse the repository at this point in the history
  • Loading branch information
johannilsson committed Aug 23, 2015
1 parent 693875a commit 54cf934
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 145 deletions.
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
classpath 'com.android.tools.build:gradle:1.3.0'
}
}

Expand All @@ -19,5 +18,5 @@ allprojects {

task wrapper(type: Wrapper) {
description = 'Install wrapper for gradle. Simplifies compilation on new PCs'
gradleVersion = '2.1'
gradleVersion = '2.4'
}
18 changes: 9 additions & 9 deletions sthlmtraveling/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ if (buildProdFile.canRead()) {
}

dependencies {
compile 'com.google.android.gms:play-services-base:7.0.0'
compile 'com.google.android.gms:play-services-maps:7.0.0'
compile 'com.google.android.gms:play-services-location:7.0.0'
compile 'com.google.android.gms:play-services-analytics:7.0.0'
compile 'com.google.android.gms:play-services-ads:7.0.0'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:support-v4:22.1.1'
compile 'com.squareup.okhttp:okhttp:1.3.0'
compile 'com.google.android.gms:play-services-base:7.5.0'
compile 'com.google.android.gms:play-services-maps:7.5.0'
compile 'com.google.android.gms:play-services-location:7.5.0'
compile 'com.google.android.gms:play-services-analytics:7.5.0'
compile 'com.google.android.gms:play-services-ads:7.5.0'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:support-v4:22.2.1'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.google.code.gson:gson:2.2.4'
compile files('libs/katalysator_android_sdk.jar')
compile files('libs/nmdp_speech_kit.jar')
compile files('libs/widespace-sdk-4.5.0-05d6dac.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.2.2@aar') {
compile('com.crashlytics.sdk.android:crashlytics:2.5.0@aar') {
transitive = true;
}
}
Expand Down
Binary file modified sthlmtraveling/libs/katalysator_android_sdk.jar
100644 → 100755
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@
import com.crashlytics.android.Crashlytics;
import com.markupartist.sthlmtraveling.provider.site.Site;
import com.markupartist.sthlmtraveling.utils.HttpHelper;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.io.Serializable;
import java.net.HttpURLConnection;
import java.util.ArrayList;

import static com.markupartist.sthlmtraveling.provider.ApiConf.KEY;
Expand All @@ -56,16 +58,20 @@ public Departures find(Context context, Site site) throws IllegalArgumentExcepti
+ "&timewindow=30";

HttpHelper httpHelper = HttpHelper.getInstance(context);
HttpURLConnection connection = httpHelper.getConnection(endpoint);
Request request = httpHelper.createRequest(endpoint);

if (connection.getResponseCode() != 200) {
OkHttpClient client = httpHelper.getClient();

Response response = client.newCall(request).execute();

if (!response.isSuccessful()) {
Log.w(TAG, "A remote server error occurred when getting departures, status code: " +
connection.getResponseCode());
response.code());
throw new IOException("A remote server error occurred when getting departures.");
}

Departures departures;
String rawContent = httpHelper.getBody(connection);
String rawContent = response.body().string();
try {
departures = Departures.fromJson(new JSONObject(rawContent));
} catch (JSONException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import android.util.TimeFormatException;

import com.markupartist.sthlmtraveling.utils.HttpHelper;
import com.squareup.okhttp.Response;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -70,13 +70,15 @@ private String retrieveDeviations(final Context context) throws IOException {
final String endpoint = apiEndpoint2() + "v1/deviation/";

HttpHelper httpHelper = HttpHelper.getInstance(context);
HttpURLConnection connection = httpHelper.getConnection(endpoint);
Response response = httpHelper.getClient().newCall(
httpHelper.createRequest(endpoint)
).execute();

if (connection.getResponseCode() != 200) {
if (!response.isSuccessful()) {
throw new IOException("A remote server error occurred when getting deviations.");
}

return httpHelper.getBody(connection);
return response.body().string();
}

public static ArrayList<Deviation> filterByLineNumbers(
Expand Down Expand Up @@ -141,13 +143,14 @@ public TrafficStatus getTrafficStatus(final Context context) throws IOException
final String endpoint = apiEndpoint2() + "v1/trafficstatus/";

HttpHelper httpHelper = HttpHelper.getInstance(context);
HttpURLConnection connection = httpHelper.getConnection(endpoint);
Response response = httpHelper.getClient().newCall(
httpHelper.createRequest(endpoint)).execute();

if (connection.getResponseCode() != 200) {
if (!response.isSuccessful()) {
throw new IOException("A remote server error occurred when getting traffic status.");
}

String rawContent = httpHelper.getBody(connection);
String rawContent = response.body().string();

TrafficStatus ts = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.json.JSONObject;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -136,13 +135,14 @@ public Trip2 addIntermediateStops(final Context context, Trip2 trip, JourneyQuer
}

HttpHelper httpHelper = HttpHelper.getInstance(context);
HttpURLConnection connection = httpHelper.getConnection(u.toString());
com.squareup.okhttp.Response response = httpHelper.getClient().newCall(
httpHelper.createRequest(u.toString())).execute();

String rawContent;
int statusCode = connection.getResponseCode();
int statusCode = response.code();
switch (statusCode) {
case 200:
rawContent = httpHelper.getBody(connection);
rawContent = response.body().string();
try {
JSONObject baseResponse = new JSONObject(rawContent);
if (baseResponse.has("stops")) {
Expand Down Expand Up @@ -179,7 +179,7 @@ public Trip2 addIntermediateStops(final Context context, Trip2 trip, JourneyQuer
}
break;
case 400: // Bad request
rawContent = httpHelper.getErrorBody(connection);
rawContent = response.body().string();
try {
BadResponse br = BadResponse.fromJson(new JSONObject(rawContent));
Log.e(TAG, "Invalid response for intermediate stops: " + br.toString());
Expand All @@ -205,13 +205,14 @@ public SubTrip addIntermediateStops(Context context, SubTrip subTrip, JourneyQue
u = b.build();

HttpHelper httpHelper = HttpHelper.getInstance(context);
HttpURLConnection connection = httpHelper.getConnection(u.toString());
com.squareup.okhttp.Response response = httpHelper.getClient().newCall(
httpHelper.createRequest(u.toString())).execute();

String rawContent;
int statusCode = connection.getResponseCode();
int statusCode = response.code();
switch (statusCode) {
case 200:
rawContent = httpHelper.getBody(connection);
rawContent = response.body().string();
try {
JSONObject baseResponse = new JSONObject(rawContent);
if (baseResponse.has("stops")) {
Expand All @@ -228,7 +229,7 @@ public SubTrip addIntermediateStops(Context context, SubTrip subTrip, JourneyQue
}
break;
case 400:
rawContent = httpHelper.getErrorBody(connection);
rawContent = response.body().string();
try {
BadResponse br = BadResponse.fromJson(new JSONObject(rawContent));
Log.e(TAG, "Invalid response for intermediate stops: " + br.toString());
Expand Down Expand Up @@ -296,14 +297,15 @@ private Response doJourneyQuery(final Context context, JourneyQuery query, int s
u = b.build();

HttpHelper httpHelper = HttpHelper.getInstance(context);
HttpURLConnection connection = httpHelper.getConnection(u.toString());
com.squareup.okhttp.Response response = httpHelper.getClient().newCall(
httpHelper.createRequest(u.toString())).execute();

Response r = null;
String rawContent;
int statusCode = connection.getResponseCode();
int statusCode = response.code();
switch (statusCode) {
case 200:
rawContent = httpHelper.getBody(connection);
rawContent = response.body().string();
try {
JSONObject baseResponse = new JSONObject(rawContent);
if (baseResponse.has("journey")) {
Expand All @@ -317,7 +319,7 @@ private Response doJourneyQuery(final Context context, JourneyQuery query, int s
}
break;
case 400:
rawContent = httpHelper.getErrorBody(connection);
rawContent = response.body().string();
BadResponse br;
try {
br = BadResponse.fromJson(new JSONObject(rawContent));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

import com.markupartist.sthlmtraveling.utils.HttpHelper;
import com.markupartist.sthlmtraveling.utils.LocationUtils;
import com.squareup.okhttp.Response;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URLEncoder;
import java.util.ArrayList;

Expand Down Expand Up @@ -42,17 +42,19 @@ public ArrayList<Site> getSiteV2(final Context context, final String name) throw
public ArrayList<Site> getSiteV2(final Context context, final String name, final boolean onlyStations) throws IOException {
HttpHelper httpHelper = HttpHelper.getInstance(context);
String onlyStationsParam = onlyStations ? "true" : "false";
HttpURLConnection connection = httpHelper.getConnection(apiEndpoint2() + "v1/site/"
String url = apiEndpoint2() + "v1/site/"
+ "?q=" + URLEncoder.encode(name, "UTF-8")
+ "&onlyStations=" + onlyStationsParam);
+ "&onlyStations=" + onlyStationsParam;
Response response = httpHelper.getClient().newCall(
httpHelper.createRequest(url)).execute();

if (connection.getResponseCode() != 200) {
if (!response.isSuccessful()) {
throw new IOException("Server error while fetching sites");
}

ArrayList<Site> sites = new ArrayList<Site>();
try {
JSONObject jsonResponse = new JSONObject(httpHelper.getBody(connection));
JSONObject jsonResponse = new JSONObject(response.body().string());
if (!jsonResponse.has("sites")) {
throw new IOException("Invalid input.");
}
Expand Down Expand Up @@ -87,14 +89,15 @@ public ArrayList<Site> nearby(Context context, Location location) throws IOExcep
+ "&max_results=20";

HttpHelper httpHelper = HttpHelper.getInstance(context);
HttpURLConnection connection = httpHelper.getConnection(endpoint);
Response response = httpHelper.getClient().newCall(
httpHelper.createRequest(endpoint)).execute();

if (connection.getResponseCode() != 200) {
Log.w("SiteStore", "Expected 200, got " + connection.getResponseCode());
if (!response.isSuccessful()) {
Log.w("SiteStore", "Expected 200, got " + response.code());
throw new IOException("A remote server error occurred when getting sites.");
}

String rawContent = httpHelper.getBody(connection);
String rawContent = response.body().string();
ArrayList<Site> stopPoints = new ArrayList<Site>();
try {
JSONObject jsonSites = new JSONObject(rawContent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void start() {
return;
}

mKatManager.startMonitoring(this);
mKatManager.startMonitoring();
mKatManager.getAudiencesAndGeotags();
HashMap keyValue = new HashMap();
mKatManager.collect(keyValue);
Expand All @@ -80,7 +80,7 @@ public void stop() {
}

@Override
public void regionDataReceived(KATAssets katAssets) {
public void regionDataReceived(KATAssets katAssets, boolean isDelayed) {
Log.d(TAG, "regionDataReceived: " + katAssets);
}

Expand Down
Loading

0 comments on commit 54cf934

Please sign in to comment.