package com.connfa.ui.fragment;

import android.os.AsyncTask;
import android.support.annotation.Nullable;

import com.connfa.model.Model;
import com.connfa.model.managers.BofsManager;
import com.connfa.model.managers.FavoriteManager;
import com.connfa.model.managers.ProgramManager;
import com.connfa.model.managers.SocialManager;
import com.connfa.ui.drawer.DrawerManager;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;

class LoadDataTask extends AsyncTask<Void, Void, List<Long>> {

    private final DrawerManager.EventMode eventMode;
    private final WeakReference<LoadDataTaskCallback> callbackRef;

    LoadDataTask(DrawerManager.EventMode eventMode, LoadDataTaskCallback callback) {
        this.eventMode = eventMode;
        this.callbackRef = new WeakReference<>(callback);
    }

    @Override
    @Nullable
    protected List<Long> doInBackground(Void... params) {
        if (isCancelled()) {
            return null;
        }

        List<Long> dayList = new ArrayList<>();
        switch (eventMode) {
            case BOFS:
                BofsManager bofsManager = Model.getInstance().getBofsManager();
                dayList.addAll(bofsManager.getBofsDays());
                break;
            case SOCIAL:
                SocialManager socialManager = Model.getInstance().getSocialManager();
                dayList.addAll(socialManager.getSocialsDays());
                break;
            case FAVORITES:
                FavoriteManager favoriteManager = Model.getInstance().getFavoriteManager();
                dayList.addAll(favoriteManager.getFavoriteEventDays());
                break;
            default:
                ProgramManager programManager = Model.getInstance().getProgramManager();
                dayList.addAll(programManager.getProgramDays());
                break;
        }

        if (isCancelled()) {
            return null;
        }

        return dayList;
    }

    @Override
    protected void onPostExecute(@Nullable List<Long> result) {
        LoadDataTaskCallback callback = callbackRef.get();
        if (result != null && callback != null) {
            callback.onDataLoaded(result);
        }
    }

    interface LoadDataTaskCallback {

        void onDataLoaded(List<Long> result);
    }
}

@@ -372,44 +372,8 @@
 r;%0A%0A
-import java.lang.ref.WeakReference;%0A
 impo
@@ -396,16 +396,16 @@
 ayList;%0A
+
 import j
@@ -555,30 +555,16 @@
 e final 
-WeakReference%3C
 LoadData
@@ -575,17 +575,16 @@
 Callback
-%3E
  callbac
@@ -584,19 +584,16 @@
 callback
-Ref
 ;%0A%0A    L
@@ -733,42 +733,19 @@
 back
-Ref = new WeakReference%3C%3E(
+ = 
 callback
 );%0A 
@@ -740,17 +740,16 @@
 callback
-)
 ;%0A    %7D%0A
@@ -1962,67 +1962,8 @@
 ) %7B%0A
-        LoadDataTaskCallback callback = callbackRef.get();%0A
     

Remove unneeded WeakReference in task