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 import android.view.View;
24 
25 /**
26  * Interface for instrument cluster rendering.
27  *
28  * TODO: implement instrument cluster feature list and extend API.
29  *
30  * @hide
31  */
32 @SystemApi
33 public abstract class InstrumentClusterRenderer {
34 
35     @Nullable private NavigationRenderer mNavigationRenderer;
36 
37     /**
38      * Calls once when instrument cluster should be created.
39      */
onCreate(Context context)40     abstract public void onCreate(Context context);
41 
42     @UiThread
onCreateView(DisplayConfiguration displayConfiguration)43     abstract public View onCreateView(DisplayConfiguration displayConfiguration);
44 
45     @UiThread
onStart()46     abstract public void onStart();
47 
48     @UiThread
onStop()49     abstract public void onStop();
50 
51     /**
52      * Returns properties of instrument cluster for navigation.
53      */
getNavigationProperties()54     abstract public CarNavigationInstrumentCluster getNavigationProperties();
55 
56     @UiThread
createNavigationRenderer()57     abstract protected NavigationRenderer createNavigationRenderer();
58 
59     /** The method is thread-safe, callers should cache returned object. */
60     @Nullable
getNavigationRenderer()61     public synchronized NavigationRenderer getNavigationRenderer() {
62         return mNavigationRenderer;
63     }
64 
65     /**
66      * This method is called by car service after onCreateView to initialize private members. The
67      * method should not be overridden by subclasses.
68      */
69     @UiThread
initialize()70     public synchronized final void initialize() {
71         mNavigationRenderer = createNavigationRenderer();
72     }
73 }
74