content: /*
   * Copyright 2017 Google Inc. All Rights Reserved.
   *
   * 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.
   */
  
  package com.google.android.gms.location.sample.geofencing;
  
  import android.content.Context;
  import android.content.res.Resources;
  
  import com.google.android.gms.common.api.ApiException;
  import com.google.android.gms.location.GeofenceStatusCodes;
  
  /**
   * Geofence error codes mapped to error messages.
   */
  class GeofenceErrorMessages {
      /**
       * Prevents instantiation.
       */
      private GeofenceErrorMessages() {}
  
      /**
       * Returns the error string for a geofencing exception.
       */
      public static String getErrorString(Context context, Exception e) {
          if (e instanceof ApiException) {
              return getErrorString(context, ((ApiException) e).getStatusCode());
          } else {
              return context.getResources().getString(R.string.unknown_geofence_error);
          }
      }
  
      /**
       * Returns the error string for a geofencing error code.
       */
      public static String getErrorString(Context context, int errorCode) {
          Resources mResources = context.getResources();
          switch (errorCode) {
              case GeofenceStatusCodes.GEOFENCE_NOT_AVAILABLE:
                  return mResources.getString(R.string.geofence_not_available);
              case GeofenceStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES:
                  return mResources.getString(R.string.geofence_too_many_geofences);
              case GeofenceStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS:
                  return mResources.getString(R.string.geofence_too_many_pending_intents);
              default:
                  return mResources.getString(R.string.unknown_geofence_error);
          }
      }
  }
  