1/* 2 * Copyright (C) 2017 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.remote.client.adapters; 18 19import com.android.ide.common.rendering.api.LayoutLog; 20import com.android.layout.remote.api.RemoteLayoutLog; 21import com.android.tools.layoutlib.annotations.NotNull; 22 23import java.io.Serializable; 24import java.rmi.RemoteException; 25import java.rmi.server.UnicastRemoteObject; 26 27public class RemoteLayoutLogAdapter implements RemoteLayoutLog { 28 private final LayoutLog mLog; 29 30 private RemoteLayoutLogAdapter(@NotNull LayoutLog log) { 31 mLog = log; 32 } 33 34 public static RemoteLayoutLog create(@NotNull LayoutLog log) throws RemoteException { 35 return (RemoteLayoutLog) UnicastRemoteObject.exportObject(new RemoteLayoutLogAdapter(log), 36 0); 37 } 38 39 @Override 40 public void warning(String tag, String message, Serializable data) { 41 mLog.warning(tag, message, null); 42 } 43 44 @Override 45 public void fidelityWarning(String tag, String message, Throwable throwable, Object viewCookie, 46 Object data) { 47 mLog.fidelityWarning(tag, message, throwable, viewCookie, data); 48 } 49 50 @Override 51 public void error(String tag, String message, Serializable data) { 52 mLog.error(tag, message, null); 53 } 54 55 @Override 56 public void error(String tag, String message, Throwable throwable, Serializable data) { 57 mLog.error(tag, message, throwable, null); 58 } 59} 60