1/* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.layoutlib.bridge.intensive; 18 19import com.android.ide.common.rendering.api.RenderSession; 20import com.android.ide.common.rendering.api.Result; 21import com.android.ide.common.rendering.api.ViewInfo; 22 23import android.annotation.NonNull; 24import android.annotation.Nullable; 25 26import java.util.ArrayList; 27import java.util.Collections; 28import java.util.List; 29 30class RenderResult { 31 private final List<ViewInfo> mRootViews; 32 private final List<ViewInfo> mSystemViews; 33 private final Result mRenderResult; 34 35 private RenderResult(@Nullable Result result, @Nullable List<ViewInfo> systemViewInfoList, 36 @Nullable List<ViewInfo> rootViewInfoList) { 37 mSystemViews = systemViewInfoList == null ? Collections.emptyList() : systemViewInfoList; 38 mRootViews = rootViewInfoList == null ? Collections.emptyList() : rootViewInfoList; 39 mRenderResult = result; 40 } 41 42 @NonNull 43 static RenderResult getFromSession(@NonNull RenderSession session) { 44 return new RenderResult(session.getResult(), 45 new ArrayList<>(session.getSystemRootViews()), 46 new ArrayList<>(session.getRootViews())); 47 } 48 49 @Nullable 50 Result getResult() { 51 return mRenderResult; 52 } 53 54 @NonNull 55 public List<ViewInfo> getRootViews() { 56 return mRootViews; 57 } 58 59 @NonNull 60 public List<ViewInfo> getSystemViews() { 61 return mSystemViews; 62 } 63} 64