alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Android example source code file (LayoutResult.java)

This example Android source code file (LayoutResult.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Android by Example" TM.

Java - Android tags/keywords

awt, bufferedimage, ilayoutresult, ilayoutviewinfo, image, layoutresult, object, string, success

The LayoutResult.java Android example source code

/*
 * Copyright (C) 2008 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.layoutlib.bridge;

import com.android.layoutlib.api.ILayoutResult;

import java.awt.image.BufferedImage;

/**
 * Implementation of {@link ILayoutResult}
 */
public final class LayoutResult implements ILayoutResult {

    private final ILayoutViewInfo mRootView;
    private final BufferedImage mImage;
    private final int mSuccess;
    private final String mErrorMessage;

    /**
     * Creates a {@link #SUCCESS} {@link ILayoutResult} with the specified params
     * @param rootView
     * @param image
     */
    public LayoutResult(ILayoutViewInfo rootView, BufferedImage image) {
        mSuccess = SUCCESS;
        mErrorMessage = null;
        mRootView = rootView;
        mImage = image;
    }
    
    /**
     * Creates a LayoutResult with a specific success code and associated message
     * @param code
     * @param message
     */
    public LayoutResult(int code, String message) {
        mSuccess = code;
        mErrorMessage = message;
        mRootView = null;
        mImage = null;
    }

    public int getSuccess() {
        return mSuccess;
    }

    public String getErrorMessage() {
        return mErrorMessage;
    }

    public BufferedImage getImage() {
        return mImage;
    }

    public ILayoutViewInfo getRootView() {
        return mRootView;
    }
    
    /**
     * Implementation of {@link ILayoutResult.ILayoutViewInfo}
     */
    public static final class LayoutViewInfo implements ILayoutViewInfo {
        private final Object mKey;
        private final String mName;
        private final int mLeft;
        private final int mRight;
        private final int mTop;
        private final int mBottom;
        private ILayoutViewInfo[] mChildren;

        public LayoutViewInfo(String name, Object key, int left, int top, int right, int bottom) {
            mName = name;
            mKey = key;
            mLeft = left;
            mRight = right;
            mTop = top;
            mBottom = bottom;
        }
        
        public void setChildren(ILayoutViewInfo[] children) {
            mChildren = children;
        }

        public ILayoutViewInfo[] getChildren() {
            return mChildren;
        }

        public Object getViewKey() {
            return mKey;
        }

        public String getName() {
            return mName;
        }

        public int getLeft() {
            return mLeft;
        }

        public int getTop() {
            return mTop;
        }

        public int getRight() {
            return mRight;
        }

        public int getBottom() {
            return mBottom;
        }
    }
}

Other Android examples (source code examples)

Here is a short list of links related to this Android LayoutResult.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.