|
@@ -1,8 +1,10 @@
|
1
|
1
|
package com.rthoni.camotion.ui;
|
2
|
2
|
|
|
3
|
+import android.content.Intent;
|
3
|
4
|
import android.content.res.Configuration;
|
4
|
5
|
import android.os.Bundle;
|
5
|
6
|
import android.os.PersistableBundle;
|
|
7
|
+import android.provider.Settings;
|
6
|
8
|
import android.support.design.widget.NavigationView;
|
7
|
9
|
import android.support.v4.view.GravityCompat;
|
8
|
10
|
import android.support.v4.widget.DrawerLayout;
|
|
@@ -38,6 +40,10 @@ public class MainActivity extends AppCompatActivity
|
38
|
40
|
private SubMenu _locationsMenu;
|
39
|
41
|
private NavigationView _navigationView;
|
40
|
42
|
|
|
43
|
+ private int _lastView = -1;
|
|
44
|
+
|
|
45
|
+ private static final int REQUEST_CODE_ADD_ACCOUNT = 0;
|
|
46
|
+
|
41
|
47
|
@Override
|
42
|
48
|
protected void onCreate(Bundle savedInstanceState) {
|
43
|
49
|
super.onCreate(savedInstanceState);
|
|
@@ -70,6 +76,15 @@ public class MainActivity extends AppCompatActivity
|
70
|
76
|
private void init()
|
71
|
77
|
{
|
72
|
78
|
List<LocationDbo> locations = CamotionBusiness.getLocations(MainActivity.this);
|
|
79
|
+
|
|
80
|
+ if (locations.isEmpty())
|
|
81
|
+ {
|
|
82
|
+ Intent intent = new Intent(Settings.ACTION_ADD_ACCOUNT);
|
|
83
|
+ intent.putExtra(Settings.EXTRA_AUTHORITIES, new String[]{getResources().getString(R.string.account_type)});
|
|
84
|
+ startActivityForResult(intent, REQUEST_CODE_ADD_ACCOUNT);
|
|
85
|
+ return;
|
|
86
|
+ }
|
|
87
|
+
|
73
|
88
|
_locationsMenu.clear();
|
74
|
89
|
if (locations.isEmpty()) {
|
75
|
90
|
return;
|
|
@@ -95,6 +110,15 @@ public class MainActivity extends AppCompatActivity
|
95
|
110
|
|
96
|
111
|
}
|
97
|
112
|
|
|
113
|
+ @Override
|
|
114
|
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
115
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
116
|
+ if (requestCode == REQUEST_CODE_ADD_ACCOUNT)
|
|
117
|
+ {
|
|
118
|
+ init();
|
|
119
|
+ }
|
|
120
|
+ }
|
|
121
|
+
|
98
|
122
|
private void setLocation(LocationDbo location)
|
99
|
123
|
{
|
100
|
124
|
_currentLocation = location;
|