Welcome to mirror list, hosted at ThFree Co, Russian Federation.

JsonColorSerializer.java « json « api « remote « deck « nextcloud « niedermann « it « java « main « src « app - github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 635344d0b046d5b05ba433afa8d97234e656c3b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package it.niedermann.nextcloud.deck.remote.api.json;

import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;

import java.io.IOException;

import it.niedermann.android.util.ColorUtil;

public class JsonColorSerializer extends TypeAdapter<Integer> {
    @Override
    public void write(JsonWriter out, Integer value) throws IOException {
        if (value == null) {
            out.nullValue();
        } else {
            out.value(ColorUtil.INSTANCE.intColorToHexString(value));
        }
    }

    @Override
    public Integer read(JsonReader in) throws IOException {
        // currently not needed
        return null;
    }
}