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;
23 
24 /**
25  * Interface for instrument cluster rendering.
26  *
27  * TODO: implement instrument cluster feature list and extend API. bug: 32060603
28  *
29  * @hide
30  */
31 @SystemApi
32 public abstract class InstrumentClusterRenderer {
33 
34     @Nullable private NavigationRenderer mNavigationRenderer;
35 
36     /**
37      * Calls once when instrument cluster should be created.
38      */
onCreate(Context context)39     abstract public void onCreate(Context context);
40 
onStart()41     abstract public void onStart();
42 
onStop()43     abstract public void onStop();
44 
createNavigationRenderer()45     abstract protected NavigationRenderer createNavigationRenderer();
46 
47     /** The method is thread-safe, callers should cache returned object. */
48     @Nullable
getNavigationRenderer()49     public synchronized NavigationRenderer getNavigationRenderer() {
50         return mNavigationRenderer;
51     }
52 
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
initialize()58     public synchronized final void initialize() {
59         mNavigationRenderer = createNavigationRenderer();
60     }
61 }
62