Loading...
Searching...
No Matches
DefaultNavigationViewExample.java
Go to the documentation of this file.
1package com.navigine.examples;
2
3import android.content.Context;
4import android.view.ViewGroup;
5import com.navigine.view.DefaultNavigationView;
6import com.navigine.view.DefaultNavigationViewConfig;
7import com.navigine.view.widgets.ZoomControls;
8import com.navigine.view.widgets.ZoomControlsConfig;
9import com.navigine.view.widgets.FollowMeButton;
10import com.navigine.view.widgets.FollowMeButtonConfig;
11import com.navigine.view.widgets.FloorSelectorView;
12import com.navigine.view.widgets.FloorSelectorViewConfig;
13import com.navigine.idl.java.LocationWindow;
14
20
21 private DefaultNavigationView navigationView;
22 private LocationWindow locationWindow;
23
24 public DefaultNavigationViewExample(Context context) {
25 demonstrateConstructor(context);
26 demonstrateZoomControlsConfig();
27 demonstrateFollowMeButtonConfig();
28 demonstrateFloorSelectorViewConfig();
29 demonstrateConfigAtInit(context);
30 demonstrateRuntimeConfigUpdate();
31 demonstrateWidgetAccess();
32 }
33
37 private void demonstrateConstructor(Context context) {
38 // [java_DefaultNavigationView_constructor]
39 // Create with default config
40 navigationView = new DefaultNavigationView(context);
41 navigationView.setLayoutParams(new ViewGroup.LayoutParams(
42 ViewGroup.LayoutParams.MATCH_PARENT,
43 ViewGroup.LayoutParams.MATCH_PARENT
44 ));
45 // [java_DefaultNavigationView_constructor]
46
47 // [java_DefaultNavigationView_constructor_config]
48 // Create with custom configs (configs passed directly to view)
51 .build();
53 .accentColor(0xFF30AAD9)
54 .build();
55 DefaultNavigationView customView = new DefaultNavigationView(context, null, viewConfig, null, followMeConfig, null);
56 // [java_DefaultNavigationView_constructor_config]
57 }
58
62 private void demonstrateZoomControlsConfig() {
63 // [java_ZoomControlsConfig]
64 ZoomControlsConfig zoomConfig = ZoomControlsConfig.builder()
65 .buttonBackgroundColor(0xF2FAFAFA)
66 .textColor(0xFF152D47)
67 .buttonWidth(48f)
68 .zoomControlsHeight(96f)
69 .build();
70 // zoomConfig.zoomInIcon(drawable); zoomConfig.zoomOutIcon(drawable);
71 // [java_ZoomControlsConfig]
72 }
73
77 private void demonstrateFollowMeButtonConfig() {
78 // [java_FollowMeButtonConfig]
79 FollowMeButtonConfig followMeConfig = FollowMeButtonConfig.builder()
80 .accentColor(0xFF30AAD9)
81 .buttonBackgroundColor(0xF2FAFAFA)
82 .textColor(0xFF152D47)
83 .buttonWidth(48f)
84 .buttonHeight(48f)
85 .build();
86 // followMeConfig.followMeIcon(drawable); followMeConfig.followMeIconActive(drawable);
87 // [java_FollowMeButtonConfig]
88 }
89
93 private void demonstrateFloorSelectorViewConfig() {
94 // [java_FloorSelectorViewConfig]
96 .accentColor(0xFF30AAD9)
97 .textColor(0xFF152D47)
98 .buttonBackgroundColor(0xF2FAFAFA)
99 .marginLeft(16)
100 .marginTop(145)
101 .build();
102 // [java_FloorSelectorViewConfig]
103 }
104
108 private void demonstrateConfigAtInit(Context context) {
109 // [java_DefaultNavigationView_config]
110 DefaultNavigationViewConfig viewConfig = DefaultNavigationViewConfig.builder()
111 .visibleWidgets(DefaultNavigationViewConfig.WIDGET_ZOOM_CONTROLS | DefaultNavigationViewConfig.WIDGET_FOLLOW_ME)
112 .build();
113 ZoomControlsConfig zoomConfig = ZoomControlsConfig.builder()
114 .buttonBackgroundColor(0xF2FAFAFA)
115 .build();
116 FollowMeButtonConfig followMeConfig = FollowMeButtonConfig.builder()
117 .accentColor(0xFF30AAD9)
118 .build();
119 // followMeConfig.followMeIcon(drawable);
120 // zoomConfig.zoomInIcon(drawable); zoomConfig.zoomOutIcon(drawable);
121 // [java_DefaultNavigationView_config]
122 }
123
127 private void demonstrateRuntimeConfigUpdate() {
128 // [java_DefaultNavigationView_runtimeConfig]
129 if (navigationView != null) {
130 DefaultNavigationViewConfig newViewConfig = DefaultNavigationViewConfig.builder()
131 .visibleWidgets(DefaultNavigationViewConfig.WIDGET_FOLLOW_ME)
132 .build();
133 FollowMeButtonConfig newFollowMeConfig = FollowMeButtonConfig.builder()
134 .accentColor(0xFFFF0000)
135 .build();
136 navigationView.setConfig(newViewConfig, null, newFollowMeConfig, null); // null = keep current
137 }
138 // [java_DefaultNavigationView_runtimeConfig]
139 }
140
144 private void demonstrateWidgetAccess() {
145 // [java_DefaultNavigationView_widgetAccess]
146 if (navigationView != null) {
147 ZoomControls zoomControls = navigationView.getZoomControls();
148 FollowMeButton followMeButton = navigationView.getFollowMeButton();
149 FloorSelectorView floorSelector = navigationView.getFloorSelectorView();
150 // Use for advanced customization (may be null if widget is hidden)
151 }
152 // [java_DefaultNavigationView_widgetAccess]
153 }
154}