Pavel Maltsev | 1ecdd6c | 2016-03-02 16:33:44 -0800 | [diff] [blame] | 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 | package android.car.cluster.renderer; |
| 17 | |
| 18 | import android.annotation.Nullable; |
| 19 | import android.annotation.SystemApi; |
| 20 | import android.annotation.UiThread; |
| 21 | import android.car.navigation.CarNavigationInstrumentCluster; |
| 22 | import android.content.Context; |
Pavel Maltsev | 1ecdd6c | 2016-03-02 16:33:44 -0800 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * Interface for instrument cluster rendering. |
| 26 | * |
| 27 | * TODO: implement instrument cluster feature list and extend API. |
| 28 | * |
| 29 | * @hide |
| 30 | */ |
| 31 | @SystemApi |
| 32 | public abstract class InstrumentClusterRenderer { |
| 33 | |
| 34 | @Nullable private NavigationRenderer mNavigationRenderer; |
Pavel Maltsev | 1ecdd6c | 2016-03-02 16:33:44 -0800 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Calls once when instrument cluster should be created. |
| 38 | */ |
| 39 | abstract public void onCreate(Context context); |
| 40 | |
Pavel Maltsev | 1ecdd6c | 2016-03-02 16:33:44 -0800 | [diff] [blame] | 41 | abstract public void onStart(); |
| 42 | |
Pavel Maltsev | 1ecdd6c | 2016-03-02 16:33:44 -0800 | [diff] [blame] | 43 | abstract public void onStop(); |
| 44 | |
Pavel Maltsev | 1ecdd6c | 2016-03-02 16:33:44 -0800 | [diff] [blame] | 45 | abstract protected NavigationRenderer createNavigationRenderer(); |
| 46 | |
Pavel Maltsev | 1ecdd6c | 2016-03-02 16:33:44 -0800 | [diff] [blame] | 47 | /** The method is thread-safe, callers should cache returned object. */ |
| 48 | @Nullable |
| 49 | public synchronized NavigationRenderer getNavigationRenderer() { |
| 50 | return mNavigationRenderer; |
| 51 | } |
| 52 | |
Pavel Maltsev | 1ecdd6c | 2016-03-02 16:33:44 -0800 | [diff] [blame] | 53 | /** |
| 54 | * This method is called by car service after onCreateView to initialize private members. The |
| 55 | * method should not be overridden by subclasses. |
| 56 | */ |
| 57 | @UiThread |
| 58 | public synchronized final void initialize() { |
| 59 | mNavigationRenderer = createNavigationRenderer(); |
Pavel Maltsev | 1ecdd6c | 2016-03-02 16:33:44 -0800 | [diff] [blame] | 60 | } |
| 61 | } |