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.FilePathObserver;
import com.avg.zaap.crashlibrary.file.observer.IFilePathObserverCallback;
import com.avg.zaap.crashlibrary.provider.ICrashProviderCallback;
import com.avg.zaap.crashlibrary.publish.cap.CapHelper;
import com.avg.zaap.crashlibrary.publish.cap.ICapHelper;

/**
 * This class serves as the default dependency factory for the {@link CrashReporter}.
 * <p>
 * Created by marek.osvald on 2.5.2016.
 */
public class CrashReporterFactory implements ICrashReporterFactory {

    @Override
    public FileObserver getFilePathObserver(String directory, IFilePathObserverCallback callback) {
        return new FilePathObserver(directory, FileObserver.CLOSE_WRITE, callback);
    }

    @Override
    public Handler getHandler(Looper looper) {
        return new Handler(looper);
    }

    @Override
    public ICrashProviderCallback getCrashPublisherCallbackHandler(ReportData reportData, ICrashReporterCallback callback) {
        return new CrashPublisherCallbackHandler(reportData, callback);
    }

    @Override
    public Intent getIntent(Context context, Class clazz) {
        return new Intent(context, clazz);
    }

    @Override
    public NotificationCompat.Builder getNotificationCompatBuilder(Context context) {
        return new NotificationCompat.Builder(context);
    }

    @Override
    public Thread getThread(Runnable runnable) {
        return new Thread(runnable);
    }

    @Override
    public ServiceConnection getServiceConnection(ReportData reportData, IServiceConnectionCallback callback) {
        return new CrashReporterServiceConnection(reportData, callback);
    }

    @Override
    public ICapHelper getCapHelper() {
        return new CapHelper();
    }

    @Override
    public ReportData getReportData() {
        return new ReportData();
    }

}
