Android Open Source - AndroidAquarium Aquarium Readings






From Project

Back to project page AndroidAquarium.

License

The source code is released under:

MIT License

If you think the Android project AndroidAquarium listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.kypeli.aquarium.models;
//from   www.ja  va 2s. co  m
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.annotations.SerializedName;

import java.lang.reflect.Type;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public class AquariumReadings {
    @SerializedName("measurements")
    public ArrayList<Reading> readings;

    public static class Reading {
        @SerializedName("epoch_timestamp")
        public long epoch;
        public Float temperature;
        public Date timestamp;
    }

    public static class TemperatureDateSerializer implements JsonDeserializer<Date> {

        @Override
        public Date deserialize(JsonElement json, Type typeOfSrc, JsonDeserializationContext ctx) {
            SimpleDateFormat formatter = new SimpleDateFormat("EEE, dd MMM yyyy H:m:s ZZZ");
            Date d = null;
            try {
                d = formatter.parse(json.getAsString());
            } catch (ParseException e) {
                e.printStackTrace();
            }

            return d;
        }
    }
}




Java Source Code List

com.kypeli.aquarium.AquariumValueReader.java
com.kypeli.aquarium.MainActivity.java
com.kypeli.aquarium.TemperatureFragment.java
com.kypeli.aquarium.models.AquariumReadingsJackson.java
com.kypeli.aquarium.models.AquariumReadings.java
com.kypeli.aquarium.volley.GsonRequest.java
com.kypeli.aquarium.volley.JacksonRequest.java