Bläddra i källkod

Hide views if not authorized

tags/0.0.6
Robin Thoni 9 år sedan
förälder
incheckning
a191323cc3
1 ändrade filer med 6 tillägg och 0 borttagningar
  1. 6
    0
      app/src/main/java/com/rthoni/camotion/ui/MainActivity.java

+ 6
- 0
app/src/main/java/com/rthoni/camotion/ui/MainActivity.java Visa fil

@@ -125,12 +125,18 @@ public class MainActivity extends AppCompatActivity
125 125
         _currentLocation = location;
126 126
         _fullLoginDbo = null;
127 127
         _locationNameView.setText(_currentLocation.getName());
128
+        _navigationView.getMenu().findItem(R.id.nav_cameras).setVisible(false);
129
+        _navigationView.getMenu().findItem(R.id.nav_sensors).setVisible(false);
130
+        _navigationView.getMenu().findItem(R.id.nav_commands).setVisible(false);
128 131
         showView(-1);
129 132
         LoginDialog dlg = new LoginDialog(this);
130 133
         dlg.loginFull(_currentLocation).then(new LuPromise.LuConsumer<LuFullLoginDbo>() {
131 134
             @Override
132 135
             public void execute(LuFullLoginDbo data) {
133 136
                 _fullLoginDbo = data;
137
+                _navigationView.getMenu().findItem(R.id.nav_cameras).setVisible(_fullLoginDbo.hasPermission("CAMOTION_CAMERA_GET"));
138
+                _navigationView.getMenu().findItem(R.id.nav_sensors).setVisible(_fullLoginDbo.hasPermission("CAMOTION_SENSOR_GET"));
139
+                _navigationView.getMenu().findItem(R.id.nav_commands).setVisible(_fullLoginDbo.hasPermission("CAMOTION_COMMAND_GET"));
134 140
                 showView(getDefaultView());
135 141
             }
136 142
         }, new LuPromise.LuConsumer<LuPromise.LuPromiseError>() {

Laddar…
Avbryt
Spara