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.server.adapters;
18
19import com.android.ide.common.rendering.api.ActionBarCallback;
20import com.android.layout.remote.api.RemoteActionBarCallback;
21import com.android.tools.layoutlib.annotations.NotNull;
22
23import java.rmi.RemoteException;
24import java.util.List;
25
26public class RemoteActionBarCallbackAdapter extends ActionBarCallback {
27    private final RemoteActionBarCallback mDelegate;
28
29    public RemoteActionBarCallbackAdapter(@NotNull RemoteActionBarCallback remote) {
30        mDelegate = remote;
31    }
32
33    @Override
34    public List<String> getMenuIdNames() {
35        try {
36            return mDelegate.getMenuIdNames();
37        } catch (RemoteException e) {
38            throw new RuntimeException(e);
39        }
40    }
41
42    @Override
43    public boolean getSplitActionBarWhenNarrow() {
44        try {
45            return mDelegate.getSplitActionBarWhenNarrow();
46        } catch (RemoteException e) {
47            throw new RuntimeException(e);
48        }
49    }
50
51    @Override
52    public int getNavigationMode() {
53        try {
54            return mDelegate.getNavigationMode();
55        } catch (RemoteException e) {
56            throw new RuntimeException(e);
57        }
58    }
59
60    @Override
61    public String getSubTitle() {
62        try {
63            return mDelegate.getSubTitle();
64        } catch (RemoteException e) {
65            throw new RuntimeException(e);
66        }
67    }
68
69    @Override
70    public HomeButtonStyle getHomeButtonStyle() {
71        try {
72            return mDelegate.getHomeButtonStyle();
73        } catch (RemoteException e) {
74            throw new RuntimeException(e);
75        }
76    }
77
78    @Override
79    public boolean isOverflowPopupNeeded() {
80        try {
81            return mDelegate.isOverflowPopupNeeded();
82        } catch (RemoteException e) {
83            throw new RuntimeException(e);
84        }
85    }
86}
87