package moe.banana.mmio;

import android.app.Activity;
import android.content.Context;
import android.databinding.ViewDataBinding;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;

import dagger.Module;
import dagger.Provides;
import moe.banana.mmio.misc.RxLifecycleDelegate;
import moe.banana.mmio.presenter.BasePresenter;
import moe.banana.mmio.presenter.PresenterComponent;
import moe.banana.mmio.scope.ActivityScope;

@Module
public abstract class BaseActivity<VM extends ViewDataBinding, PRESENTER extends BasePresenter> extends AppCompatActivity {

    @Provides
    @ActivityScope
    public Context provideContext() {
        return this;
    }

    @Provides
    @ActivityScope
    public Activity provideActivity() {
        return this;
    }

    @Provides
    @ActivityScope
    public LayoutInflater provideLayoutInflater() {
        return LayoutInflater.from(this);
    }

    @Provides
    @ActivityScope
    public RxLifecycleDelegate provideRxLifecycle() {
        return lifecycleDelegate;
    }

    private RxLifecycleDelegate lifecycleDelegate = new RxLifecycleDelegate();
    private PresenterComponent<VM, PRESENTER> mComponent;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mComponent = createComponent(savedInstanceState);
    }

    public abstract PresenterComponent<VM, PRESENTER> createComponent(@Nullable Bundle savedInstanceState);

    public PRESENTER getPresenter() {
        return mComponent.presenter();
    }

    public VM getViewModel() {
        return mComponent.vm();
    }

    @Override
    protected void onStart() {
        super.onStart();
        getViewModel().setVariable(BR.presenter, getPresenter());
    }

    @Override
    protected void onStop() {
        super.onStop();
        getViewModel().setVariable(BR.presenter, null);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        lifecycleDelegate.onDestroy();
    }
}

@@ -1241,18 +1241,17 @@
 SENTER%3E 
-mC
+c
 omponent
@@ -1386,18 +1386,17 @@
         
-mC
+c
 omponent
@@ -1596,34 +1596,33 @@
 %0A        return 
-mC
+c
 omponent.present
@@ -1684,10 +1684,9 @@
 urn 
-mC
+c
 ompo

Rename variables