package com.kfzs.libs;

import android.os.Bundle;
import android.support.annotation.Nullable;
import com.kfzs.libs.widget.loading.SupportLoadingFragment;

/**
 * Created by guoxin on 2018/3/30.
 */

public abstract class DaggerFragment extends SupportLoadingFragment implements IDaggerMvp{

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setupDaggerComponent();
    }

    @Override
    public void onResume() {
        super.onResume();
        onAttachedView();
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        onDetachedView();
    }

    @Override
    public void onAttachedView() {
        IPresenter presenter = currentPresenter();
        if (presenter != null) {
            presenter.attachedView(currentIView());
        }
    }

    @Override
    public void onDetachedView() {
        IPresenter presenter = currentPresenter();
        if (presenter != null) {
            presenter.detachedView();
        }
    }
    protected long startTime;
    public void init() {
        startTime = System.currentTimeMillis();
    }

    @Override
    public boolean isActive() {
        return isAdded();
    }


    public abstract IPresenter currentPresenter();
    public abstract IView currentIView();


}
