aboutsummaryrefslogblamecommitdiff
path: root/app/src/main/java/ml/docilealligator/infinityforreddit/customtheme/OnlineCustomThemeMetadata.java
blob: 2b07f9d56692a77eccec378cc4ee3cfa0483ba26 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12











                                                              
                  





                                                    
                          




                                       
                                                                                      






















                                                                                             
                          




                                       
package ml.docilealligator.infinityforreddit.customtheme;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;

import com.google.gson.Gson;
import com.google.gson.JsonParseException;
import com.google.gson.annotations.SerializedName;

public class OnlineCustomThemeMetadata implements Parcelable {
    public int id;
    public String name;
    public String username;
    @SerializedName("primary_color")
    public String colorPrimary;

    protected OnlineCustomThemeMetadata(Parcel in) {
        id = in.readInt();
        name = in.readString();
        username = in.readString();
        colorPrimary = in.readString();
    }

    public static final Creator<OnlineCustomThemeMetadata> CREATOR = new Creator<>() {
        @Override
        public OnlineCustomThemeMetadata createFromParcel(Parcel in) {
            return new OnlineCustomThemeMetadata(in);
        }

        @Override
        public OnlineCustomThemeMetadata[] newArray(int size) {
            return new OnlineCustomThemeMetadata[size];
        }
    };

    public static OnlineCustomThemeMetadata fromJson(String json) throws JsonParseException {
        Gson gson = new Gson();
        return gson.fromJson(json, OnlineCustomThemeMetadata.class);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(id);
        dest.writeString(name);
        dest.writeString(username);
        dest.writeString(colorPrimary);
    }
}