Android Open Source - maps-app-android Account Manager






From Project

Back to project page maps-app-android.

License

The source code is released under:

Apache License - 2.0 TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by...

If you think the Android project maps-app-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/* Copyright 1995-2014 Esri
 */* w  w w .  j  a  va 2s  . c o m*/
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * For additional information, contact:
 * Environmental Systems Research Institute, Inc.
 * Attn: Contracts Dept
 * 380 New York Street
 * Redlands, California, USA 92373
 *
 * email: contracts@esri.com
 *
 */

package com.esri.android.mapsapp.account;

import com.esri.core.portal.Portal;
import com.esri.core.portal.PortalInfo;
import com.esri.core.portal.PortalUser;


/**
 * Singleton used to provide access to, and helper methods around, a com.esri.core.portal.Portal object.
 */
public class AccountManager {

  private static final String AGOL_PORTAL_URL = "http://www.arcgis.com";

  private static AccountManager sAccountManager;

  private Portal mPortal;

  private Portal mAGOLPortal;

  private PortalUser mPortalUser;

  private PortalInfo mPortalInfo;

  private AccountManager() {
  }

  public static AccountManager getInstance() {
    if (sAccountManager == null) {
      sAccountManager = new AccountManager();
    }
    return sAccountManager;
  }

  /**
   * Gets the Portal instance the app is currently signed into. Returns null if the user hasn't signed in to a portal.
   */
  public Portal getPortal() {
    return mPortal;
  }

  /**
   * Sets the portal the app is currently signed in to.
   */
  public void setPortal(Portal portal) {
    mPortalUser = null;
    mPortalInfo = null;
    
    mPortal = portal;
    
    try {
      mPortalUser = mPortal != null ? mPortal.fetchUser() : null;
      mPortalInfo = mPortal != null ? mPortal.fetchPortalInfo() : null;
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  /**
   * Gets the ArcGIS Online portal instance (http://www.arcgis.com).
   * 
   * @return the ArcGIS Online portal instance
   */
  public Portal getAGOLPortal() {
    if (mAGOLPortal == null) {
      mAGOLPortal = new Portal(AGOL_PORTAL_URL, null);
    }
    return mAGOLPortal;
  }

  public boolean isSignedIn() {
    return mPortal != null;
  }

  public PortalUser getPortalUser() {
    return mPortalUser;
  }

  public PortalInfo getPortalInfo() {
    return mPortalInfo;
  }
}




Java Source Code List

com.esri.android.mapsapp.ContentBrowserFragment.java
com.esri.android.mapsapp.DrawerItem.java
com.esri.android.mapsapp.MapFragment.java
com.esri.android.mapsapp.MapsAppActivity.java
com.esri.android.mapsapp.account.AccountManager.java
com.esri.android.mapsapp.account.SignInActivity.java
com.esri.android.mapsapp.basemaps.BasemapItem.java
com.esri.android.mapsapp.basemaps.BasemapsAdapter.java
com.esri.android.mapsapp.basemaps.BasemapsDialogFragment.java
com.esri.android.mapsapp.dialogs.ProgressDialogFragment.java
com.esri.android.mapsapp.location.DirectionsDialogFragment.java
com.esri.android.mapsapp.location.RoutingDialogFragment.java
com.esri.android.mapsapp.tools.Compass.java
com.esri.android.mapsapp.util.StringUtils.java
com.esri.android.mapsapp.util.TaskExecutor.java
com.esri.android.mapsapp.util.UiUtils.java