[android] #5075 - Setting MapboxAccountManager as preferred source for access token

This commit is contained in:
Brad Leege
2016-05-25 16:49:53 -05:00
parent 50b891561f
commit 485a644d32
2 changed files with 14 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.mapbox.mapboxsdk.MapboxAccountManager;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.exceptions.InvalidAccessTokenException;
@@ -68,7 +69,12 @@ public final class MapFragment extends Fragment {
// Assign an AccessToken if needed
if (options == null || options.getAccessToken() == null) {
String token = getToken(inflater.getContext());
String token = null;
if (MapboxAccountManager.getInstance() != null) {
token = MapboxAccountManager.getInstance().getAccessToken();
} else {
token = getToken(inflater.getContext());
}
if (TextUtils.isEmpty(token)) {
throw new InvalidAccessTokenException();
}

View File

@@ -11,6 +11,7 @@ import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.mapbox.mapboxsdk.MapboxAccountManager;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.exceptions.InvalidAccessTokenException;
@@ -77,7 +78,12 @@ public class SupportMapFragment extends Fragment {
// Assign an AccessToken if needed
if (options == null || options.getAccessToken() == null) {
String token = getToken(inflater.getContext());
String token = null;
if (MapboxAccountManager.getInstance() != null) {
token = MapboxAccountManager.getInstance().getAccessToken();
} else {
token = getToken(inflater.getContext());
}
if (TextUtils.isEmpty(token)) {
throw new InvalidAccessTokenException();
}