// Path: app/src/main/java/se/oort/diplicity/apigen/PhaseMeta.java
// public class PhaseMeta implements java.io.Serializable {
//   public Long PhaseOrdinal;
//   public String Season;
//   public Long Year;
//   public String Type;
//   public Boolean Resolved;
//   public java.util.Date CreatedAt;
//   public Ticker CreatedAgo;
//   public java.util.Date ResolvedAt;
//   public Ticker ResolvedAgo;
//   public java.util.Date DeadlineAt;
//   public Ticker NextDeadlineIn;
//   public String UnitsJSON;
//   public String SCsJSON;
// }
// 
// Path: app/src/main/java/se/oort/diplicity/apigen/Ticker.java
// public class Ticker implements java.io.Serializable {
//   public Long nanos;
//   public Date unserializedAt;
//   public Ticker(Date unserializedAt, Long nanos) {
//     this.unserializedAt = unserializedAt;
//     this.nanos = nanos;
//   }
//   public Date createdAt() {
// 		Calendar cal = Calendar.getInstance();
// 		cal.setTime(unserializedAt);
// 		cal.add(Calendar.SECOND, (int) (nanos / (long) -1000000000));
// 		return cal.getTime();
// 	}
//   public Date deadlineAt() {
// 		Calendar cal = Calendar.getInstance();
// 		cal.setTime(unserializedAt);
// 		cal.add(Calendar.SECOND, (int) (nanos / (long) 1000000000));
// 		return cal.getTime();
// 	}
// 	public Long millisLeft() {
// 		return (long) (deadlineAt().getTime() - unserializedAt.getTime());
// 	}
// }
// 
// Path: app/src/main/java/se/oort/diplicity/apigen/TickerUnserializer.java
// public class TickerUnserializer implements JsonDeserializer<Ticker> {
//   public Ticker deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
//     return new Ticker(new Date(), json.getAsLong());
//   }
// }


import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Handler;
import android.support.v4.app.NotificationCompat;
import android.util.Base64;
import android.util.Log;
import com.google.android.gms.tasks.RuntimeExecutionException;
import com.google.firebase.messaging.RemoteMessage;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.UnsupportedEncodingException;
import java.util.AbstractSet;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
import se.oort.diplicity.apigen.PhaseMeta;
import se.oort.diplicity.apigen.Ticker;
import se.oort.diplicity.apigen.TickerUnserializer;
        @Override
        public int size() {
            return backend.size();
        }
    };

    public static class DiplicityJSON {
        public String type;
        public se.oort.diplicity.apigen.Message message;
        public PhaseMeta phaseMeta;
        public String gameID;
    }

    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()
// Path: app/src/main/java/se/oort/diplicity/apigen/PhaseMeta.java
// public class PhaseMeta implements java.io.Serializable {
//   public Long PhaseOrdinal;
//   public String Season;
//   public Long Year;
//   public String Type;
//   public Boolean Resolved;
//   public java.util.Date CreatedAt;
//   public Ticker CreatedAgo;
//   public java.util.Date ResolvedAt;
//   public Ticker ResolvedAgo;
//   public java.util.Date DeadlineAt;
//   public Ticker NextDeadlineIn;
//   public String UnitsJSON;
//   public String SCsJSON;
// }
// 
// Path: app/src/main/java/se/oort/diplicity/apigen/Ticker.java
// public class Ticker implements java.io.Serializable {
//   public Long nanos;
//   public Date unserializedAt;
//   public Ticker(Date unserializedAt, Long nanos) {
//     this.unserializedAt = unserializedAt;
//     this.nanos = nanos;
//   }
//   public Date createdAt() {
// 		Calendar cal = Calendar.getInstance();
// 		cal.setTime(unserializedAt);
// 		cal.add(Calendar.SECOND, (int) (nanos / (long) -1000000000));
// 		return cal.getTime();
// 	}
//   public Date deadlineAt() {
// 		Calendar cal = Calendar.getInstance();
// 		cal.setTime(unserializedAt);
// 		cal.add(Calendar.SECOND, (int) (nanos / (long) 1000000000));
// 		return cal.getTime();
// 	}
// 	public Long millisLeft() {
// 		return (long) (deadlineAt().getTime() - unserializedAt.getTime());
// 	}
// }
// 
// Path: app/src/main/java/se/oort/diplicity/apigen/TickerUnserializer.java
// public class TickerUnserializer implements JsonDeserializer<Ticker> {
//   public Ticker deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
//     return new Ticker(new Date(), json.getAsLong());
//   }
// }


// Path: app/src/main/java/se/oort/diplicity/MessagingService.java
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Handler;
import android.support.v4.app.NotificationCompat;
import android.util.Base64;
import android.util.Log;
import com.google.android.gms.tasks.RuntimeExecutionException;
import com.google.firebase.messaging.RemoteMessage;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.UnsupportedEncodingException;
import java.util.AbstractSet;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
import se.oort.diplicity.apigen.PhaseMeta;
import se.oort.diplicity.apigen.Ticker;
import se.oort.diplicity.apigen.TickerUnserializer;

        @Override
        public int size() {
            return backend.size();
        }
    };

    public static class DiplicityJSON {
        public String type;
        public se.oort.diplicity.apigen.Message message;
        public PhaseMeta phaseMeta;
        public String gameID;
    }

    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())