Home | History | Annotate | Download | only in api
      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 
     17 package com.android.layout.remote.api;
     18 
     19 import com.android.ide.common.rendering.api.AdapterBinding;
     20 import com.android.ide.common.rendering.api.IProjectCallback.ViewAttribute;
     21 import com.android.ide.common.rendering.api.LayoutlibCallback;
     22 import com.android.ide.common.rendering.api.ResourceReference;
     23 import com.android.ide.common.rendering.api.ResourceValue;
     24 import com.android.ide.common.rendering.api.SessionParams.Key;
     25 import com.android.resources.ResourceType;
     26 import com.android.util.Pair;
     27 
     28 import java.io.Serializable;
     29 import java.nio.file.Path;
     30 import java.rmi.Remote;
     31 import java.rmi.RemoteException;
     32 
     33 /**
     34  * Remote version of the {@link LayoutlibCallback} class
     35  */
     36 public interface RemoteLayoutlibCallback extends Remote {
     37     boolean supports(int ideFeature) throws RemoteException;
     38 
     39     Object loadView(String name, Class[] constructorSignature, Object[] constructorArgs)
     40             throws Exception, RemoteException;
     41 
     42     String getNamespace() throws RemoteException;
     43 
     44     RemoteResolveResult resolveResourceId(int id) throws RemoteException;
     45 
     46     String resolveResourceId(int[] id) throws RemoteException;
     47 
     48     Integer getResourceId(ResourceType type, String name) throws RemoteException;
     49 
     50     RemoteILayoutPullParser getParser(ResourceValue layoutResource) throws RemoteException;
     51 
     52     Object getAdapterItemValue(ResourceReference adapterView, Object adapterCookie,
     53             ResourceReference itemRef, int fullPosition, int positionPerType,
     54             int fullParentPosition, int parentPositionPerType, ResourceReference viewRef,
     55             ViewAttribute viewAttribute, Object defaultValue) throws RemoteException;
     56 
     57     AdapterBinding getAdapterBinding(ResourceReference adapterViewRef, Object adapterCookie,
     58             Object viewObject) throws RemoteException;
     59 
     60     RemoteActionBarCallback getActionBarCallback() throws RemoteException;
     61 
     62     <T> T getFlag(Key<T> key) throws RemoteException;
     63 
     64     RemoteParserFactory getParserFactory() throws RemoteException;
     65 
     66     Path findClassPath(String name) throws RemoteException;
     67 
     68     RemoteXmlPullParser getXmlFileParser(String fileName) throws RemoteException;
     69 
     70     class RemoteResolveResult implements Serializable {
     71         private ResourceType type;
     72         private String value;
     73 
     74         public RemoteResolveResult(ResourceType type, String value) {
     75             this.type = type;
     76             this.value = value;
     77         }
     78 
     79         public Pair<ResourceType, String> asPair() {
     80             return Pair.of(type, value);
     81         }
     82     }
     83 }
     84