// Path: app/src/main/java/br/com/dgimenes/nasapic/control/ErrorMessage.java
// public enum ErrorMessage {
//     DOWNLOADING_IMAGE("Error downloading image", R.string.error_downloading_apod), //
//     LOADING_RECENT_PICS("Error loading recent pictures", R.string.error_loading_feed),
//     LOADING_BEST_PICS("Error loading best pictures", R.string.error_loading_feed), //
//     SETTING_WALLPAPER("Error setting wallpaper set manually", R.string.error_setting_wallpaper), //
//     SETTING_WALLPAPER_AUTO("Error setting wallpaper set automatically", R.string.periodic_change_error), //
//     UNDOING_WALLPAPER_CHANGE("Error undoing wallpaper change", R.string.undo_error_message), //
//     ; //
// 
//     public final String id;
//     public final String analyticsMessage;
//     public final int userMessageRes;
// 
//     ErrorMessage(String analyticsMessage, int userMessageRes) {
//         this.id = this.name();
//         this.analyticsMessage = analyticsMessage;
//         this.userMessageRes = userMessageRes;
//     }
// }


import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent;
import com.flurry.android.FlurryAgent;
import br.com.dgimenes.nasapic.control.ErrorMessage;
import io.fabric.sdk.android.Fabric;
package br.com.dgimenes.nasapic.service;




public class EventsLogger {

    private static boolean initialized = false;

    public static void initialize(Context context) {
        if (!initialized) {
            initialized = true;

            // Fabric
            Fabric.with(context, new Crashlytics(), new Answers());

            // Flurry
            try {
                ApplicationInfo ai = context.getPackageManager()
                        .getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
                Bundle bundle = ai.metaData;
                String flurryApiKey = bundle.getString("flurry.ApiKey");
                FlurryAgent.setLogEnabled(false);
                FlurryAgent.setContinueSessionMillis(30000);
                FlurryAgent.init(context, flurryApiKey);
            } catch (Exception e) {
                Crashlytics.logException(e);
            }
        }
    }

    public static void logSessionStart(Context context) {
        // Flurry
        FlurryAgent.onStartSession(context);
    }

    public static void logSessionEnd(Context context) {
        // Flurry
        FlurryAgent.onEndSession(context);
    }

    public static void logEvent(String description) {
        // Fabric
        Answers.getInstance().logCustom(new CustomEvent(description));

        // Flurry
        FlurryAgent.logEvent(description);
    }

// Path: app/src/main/java/br/com/dgimenes/nasapic/control/ErrorMessage.java
// public enum ErrorMessage {
//     DOWNLOADING_IMAGE("Error downloading image", R.string.error_downloading_apod), //
//     LOADING_RECENT_PICS("Error loading recent pictures", R.string.error_loading_feed),
//     LOADING_BEST_PICS("Error loading best pictures", R.string.error_loading_feed), //
//     SETTING_WALLPAPER("Error setting wallpaper set manually", R.string.error_setting_wallpaper), //
//     SETTING_WALLPAPER_AUTO("Error setting wallpaper set automatically", R.string.periodic_change_error), //
//     UNDOING_WALLPAPER_CHANGE("Error undoing wallpaper change", R.string.undo_error_message), //
//     ; //
// 
//     public final String id;
//     public final String analyticsMessage;
//     public final int userMessageRes;
// 
//     ErrorMessage(String analyticsMessage, int userMessageRes) {
//         this.id = this.name();
//         this.analyticsMessage = analyticsMessage;
//         this.userMessageRes = userMessageRes;
//     }
// }


// Path: app/src/main/java/br/com/dgimenes/nasapic/service/EventsLogger.java
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent;
import com.flurry.android.FlurryAgent;
import br.com.dgimenes.nasapic.control.ErrorMessage;
import io.fabric.sdk.android.Fabric;

package br.com.dgimenes.nasapic.service;




public class EventsLogger {

    private static boolean initialized = false;

    public static void initialize(Context context) {
        if (!initialized) {
            initialized = true;

            // Fabric
            Fabric.with(context, new Crashlytics(), new Answers());

            // Flurry
            try {
                ApplicationInfo ai = context.getPackageManager()
                        .getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
                Bundle bundle = ai.metaData;
                String flurryApiKey = bundle.getString("flurry.ApiKey");
                FlurryAgent.setLogEnabled(false);
                FlurryAgent.setContinueSessionMillis(30000);
                FlurryAgent.init(context, flurryApiKey);
            } catch (Exception e) {
                Crashlytics.logException(e);
            }
        }
    }

    public static void logSessionStart(Context context) {
        // Flurry
        FlurryAgent.onStartSession(context);
    }

    public static void logSessionEnd(Context context) {
        // Flurry
        FlurryAgent.onEndSession(context);
    }

    public static void logEvent(String description) {
        // Fabric
        Answers.getInstance().logCustom(new CustomEvent(description));

        // Flurry
        FlurryAgent.logEvent(description);
    }

    public static void logError(ErrorMessage error, Throwable e) {