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 Integer width; final Integer height; final Integer fboId; final List contextChildren; final List children; public GLData(Integer shader, ReadableMap uniforms, Integer width, Integer height, Integer fboId, List contextChildren, List children) { this.shader = shader; this.uniforms = uniforms; this.width = width; this.height = height; 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"); Integer width = map.getInt("width"); Integer height = map.getInt("height"); Integer fboId = map.getInt("fboId"); List children = fromArray(map.getArray("children")); List contextChildren = fromArray(map.getArray("contextChildren")); return new GLData(shader, uniforms, width, height, fboId, contextChildren, children); } }