package com.avg.zaap.crashlibrary;

import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.FileObserver;
import android.os.Handler;
import android.os.Looper;
import android.support.v4.app.NotificationCompat;

import com.avg.zaap.crashlibrary.file.observer.IFilePathObserverCallback;
import com.avg.zaap.crashlibrary.provider.ICrashProviderCallback;
import com.avg.zaap.crashlibrary.publish.cap.ICapHelper;

/**
 * This interface defines the common behavior for the file
 * <p/>
 * Created by marek.osvald on 2.5.2016.
 */
public interface ICrashReporterFactory {

    /**
     * Returns an instance of file watcher for given directory with given callback.
     *
     * @param directory directory which file watcher watches
     * @param callback  callback to call whenever file watcher detects a new file
     * @return an instance of file watcher for given directory with given callback
     */
    FileObserver getFilePathObserver(String directory, IFilePathObserverCallback callback);

    /**
     * Returns an instance of handler for given looper.
     *
     * @param looper looper to to retrieve the handler for
     * @return an instance of handler for given looper
     */
    Handler getHandler(Looper looper);

    /**
     * Returns an instance of crash publisher callback handler.
     *
     * @param reportData report data structure
     * @param callback   callback to call whenever all asynchronous providers have been called
     * @return an instance of crash publisher callback handler
     */
    ICrashProviderCallback getCrashPublisherCallbackHandler(ReportData reportData, ICrashReporterCallback callback);

    /**
     * Returns an instance of intent for given context and class.
     *
     * @param context context to retrieve the class
     * @param clazz   class to create the intent for
     * @return an instance of intent for given context and class
     */
    Intent getIntent(Context context, Class clazz);

    /**
     * Returns an instance of notification compat builder.
     *
     * @param context Android application context
     * @return an instance of notification compat builder
     */
    NotificationCompat.Builder getNotificationCompatBuilder(Context context);

    /**
     * Returns a new instance of thread for given runnable.
     *
     * @param runnable runnable to initialize the thread with
     * @return a new instance of thread for given runnable
     */
    Thread getThread(Runnable runnable);

    /**
     * Returns a service connection instance.
     *
     * @param reportData report data structure
     * @param callback   callback to call whenever the publishing has finished
     * @return a service connection instance
     */
    ServiceConnection getServiceConnection(ReportData reportData, IServiceConnectionCallback callback);

    /**
     * Returns an instance of CAP helper.
     *
     * @return an instance of CAP helper
     */
    ICapHelper getCapHelper();

    /**
     * Returns a new instance of crash report data structure.
     *
     * @return new instance of crash report data structure
     */
    ReportData getReportData();

}
