package com.projectseptember.RNGL; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import java.util.ArrayList; import java.util.List; public class GLData { final Integer shader; final ReadableMap uniforms; final Double width; final Double height; final Double pixelRatio; final Integer fboId; final List contextChildren; final List children; public GLData(Integer shader, ReadableMap uniforms, Double width, Double height, Double pixelRatio, Integer fboId, List contextChildren, List children) { this.shader = shader; this.uniforms = uniforms; this.width = width; this.height = height; this.pixelRatio = pixelRatio; this.fboId = fboId; this.contextChildren = contextChildren; this.children = children; } public static List fromArray (ReadableArray arr) { ArrayList list = new ArrayList<>(); for (int i=0; i < arr.size(); i++) { list.add(fromMap(arr.getMap(i))); } return list; } public static GLData fromMap (ReadableMap map) { Integer shader = map.getInt("shader"); ReadableMap uniforms = map.getMap("uniforms"); Double width = map.getDouble("width"); Double height = map.getDouble("height"); Double pixelRatio = map.getDouble("pixelRatio"); Integer fboId = map.getInt("fboId"); List children = fromArray(map.getArray("children")); List contextChildren = fromArray(map.getArray("contextChildren")); return new GLData(shader, uniforms, width, height, pixelRatio, fboId, contextChildren, children); } }