CaptureConfig.java 1.96 KB
Newer Older
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
package com.projectseptember.RNGL;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;


public class CaptureConfig {
    String format;
    String type;
    String filePath;
    Double quality;

    public CaptureConfig(String format, String type, String filePath, Double quality) {
        this.format = format;
        this.type = type;
        this.filePath = filePath;
        this.quality = quality;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CaptureConfig that = (CaptureConfig) o;

        if (format != null ? !format.equals(that.format) : that.format != null) return false;
        if (type != null ? !type.equals(that.type) : that.type != null) return false;
        if (filePath != null ? !filePath.equals(that.filePath) : that.filePath != null)
            return false;
        return !(quality != null ? !quality.equals(that.quality) : that.quality != null);

    }

    @Override
    public int hashCode() {
        int result = format != null ? format.hashCode() : 0;
        result = 31 * result + (type != null ? type.hashCode() : 0);
        result = 31 * result + (filePath != null ? filePath.hashCode() : 0);
        result = 31 * result + (quality != null ? quality.hashCode() : 0);
        return result;
    }

    public static CaptureConfig fromMap (ReadableMap map) {
        return new CaptureConfig(
                map.getString("format"),
                map.getString("type"),
                map.getString("filePath"),
                map.getDouble("quality")
        );
    }

    public WritableMap   toMap () {
        WritableMap map = Arguments.createMap();
        map.putString("format", format);
        map.putString("type", type);
        map.putString("filePath", filePath);
        map.putDouble("quality", quality);
        return map;
    }

}