Browse Source

Select location on MainActivity if multiple locations

develop
Robin Thoni 6 years ago
parent
commit
26d123d853
1 changed files with 19 additions and 1 deletions
  1. 19
    1
      app/src/main/java/com/rthoni/camotion/ui/MainActivity.java

+ 19
- 1
app/src/main/java/com/rthoni/camotion/ui/MainActivity.java View File

@@ -23,6 +23,7 @@ import com.luticate.utils.business.LuRequest;
23 23
 import com.rthoni.camotion.R;
24 24
 import com.rthoni.camotion.business.CamotionBusiness;
25 25
 import com.rthoni.camotion.dbo.LocationDbo;
26
+import com.rthoni.camotion.ui.dialogs.LocationPickerDialog;
26 27
 import com.rthoni.camotion.ui.dialogs.LoginDialog;
27 28
 import com.rthoni.camotion.ui.fragments.CamerasFragment;
28 29
 import com.rthoni.camotion.ui.fragments.CamotionFragment;
@@ -106,7 +107,24 @@ public class MainActivity extends AppCompatActivity
106 107
         _navigationView.getMenu().removeItem(item.getItemId());
107 108
 
108 109
         if (_currentLocation == null) {
109
-            setLocation(locations.get(0));
110
+            if (locations.size() == 1) {
111
+                setLocation(locations.get(0));
112
+            }
113
+            else {
114
+                LocationPickerDialog.getLocation(this)
115
+                        .then(new LuPromise.LuConsumer<LocationDbo>() {
116
+                            @Override
117
+                            public void execute(LocationDbo location) {
118
+                                setLocation(location);
119
+                            }
120
+                        }, new LuPromise.LuConsumer<LuPromise.LuPromiseError>() {
121
+                            @Override
122
+                            public void execute(LuPromise.LuPromiseError data) {
123
+                                setResult(RESULT_CANCELED);
124
+                                finish();
125
+                            }
126
+                        });
127
+            }
110 128
         }
111 129
 
112 130
     }

Loading…
Cancel
Save