use of com.google.android.gms.tasks.RuntimeExecutionException in project android-diplicity by zond.
the class MessagingService method decodeDataPayload.
public static DiplicityJSON decodeDataPayload(String diplicityJSON) {
if (diplicityJSON == null) {
return null;
}
try {
byte[] compressedJSON = Base64.decode(diplicityJSON, Base64.DEFAULT);
Inflater decompresser = new Inflater();
decompresser.setInput(compressedJSON, 0, compressedJSON.length);
byte[] result = new byte[8192];
int resultLength = decompresser.inflate(result);
decompresser.end();
byte[] actualResult = Arrays.copyOfRange(result, 0, resultLength);
Gson gson = new GsonBuilder().registerTypeAdapter(Ticker.class, new TickerUnserializer()).create();
return gson.fromJson(new String(actualResult, "UTF-8"), DiplicityJSON.class);
} catch (UnsupportedEncodingException e) {
throw new RuntimeExecutionException(e);
} catch (DataFormatException e) {
throw new RuntimeException(e);
}
}
Aggregations