// Path: mvvmapp/src/main/java/com/hibrianlee/mvvmapp/MvvmApplication.java
// public abstract class MvvmApplication extends Application {
// 
//     private AppComponent appComponent;
// 
//     protected abstract AppComponent createAppComponent();
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
// 
//         if (appComponent == null) {
//             appComponent = createAppComponent();
//         }
//     }
// 
//     public AppComponent getAppComponent() {
//         return appComponent;
//     }
// 
//     public void setAppComponent(AppComponent appComponent) {
//         this.appComponent = appComponent;
//     }
// }
// 
// Path: mvvmapp/src/main/java/com/hibrianlee/mvvmapp/inject/ActivityComponent.java
// @PerActivity
// @Component(
//         dependencies = AppComponent.class,
//         modules = {ActivityModule.class})
// public interface ActivityComponent {
// 
//     void inject(ViewModel viewModel);
// }
// 
// Path: mvvmapp/src/main/java/com/hibrianlee/mvvmapp/inject/ActivityModule.java
// @Module
// public final class ActivityModule {
// 
//     private final ViewModelActivity activity;
// 
//     public ActivityModule(ViewModelActivity activity) {
//         this.activity = activity;
//     }
// 
//     @Provides
//     @PerActivity
//     AttachedActivity provideAttachedActivity() {
//         return new AttachedViewModelActivity(activity);
//     }
// }
// 
// Path: mvvmapp/src/main/java/com/hibrianlee/mvvmapp/inject/AppComponent.java
// public interface AppComponent {
// 
//     @AppContext
//     Context appContext();
// 
//     void inject(ViewModelActivity viewModelActivity);
// 
//     void inject(ViewModelFragment viewModelFragment);
// }
// 
// Path: mvvmapp/src/main/java/com/hibrianlee/mvvmapp/viewmodel/ViewModel.java
// public abstract class ViewModel extends BaseObservable {
// 
//     @Inject
//     @AppContext
//     protected Context appContext;
// 
//     @Inject
//     protected AttachedActivity attachedActivity;
// 
//     protected ViewModel(@NonNull ActivityComponent activityComponent,
//                         @Nullable State savedInstanceState) {
//         activityComponent.inject(this);
//     }
// 
//     @CallSuper
//     public void onStart() {
// 
//     }
// 
//     public State getInstanceState() {
//         return new State(this);
//     }
// 
//     @CallSuper
//     public void onStop() {
// 
//     }
// 
//     public static class State implements Parcelable {
// 
//         protected State(ViewModel viewModel) {
// 
//         }
// 
//         public State(Parcel in) {
// 
//         }
// 
//         @Override
//         public int describeContents() {
//             return 0;
//         }
// 
//         @CallSuper
//         @Override
//         public void writeToParcel(Parcel dest, int flags) {
// 
//         }
// 
//         public static Creator<State> CREATOR = new Creator<State>() {
//             @Override
//             public State createFromParcel(Parcel source) {
//                 return new State(source);
//             }
// 
//             @Override
//             public State[] newArray(int size) {
//                 return new State[size];
//             }
//         };
//     }
// }


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import com.hibrianlee.mvvmapp.MvvmApplication;
import com.hibrianlee.mvvmapp.inject.ActivityComponent;
import com.hibrianlee.mvvmapp.inject.ActivityModule;
import com.hibrianlee.mvvmapp.inject.AppComponent;
import com.hibrianlee.mvvmapp.inject.DaggerActivityComponent;
import com.hibrianlee.mvvmapp.viewmodel.ViewModel;
/*
 * Copyright (C) 2015 Brian Lee (@hiBrianLee)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hibrianlee.mvvmapp.activity;



public abstract class ViewModelActivity extends AppCompatActivity {

    private static final String EXTRA_VIEW_MODEL_STATE = "viewModelState";

    private ActivityComponent activityComponent;
    private ViewModel viewModel;

    protected void inject(AppComponent appComponent) {
        appComponent.inject(this);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

// Path: mvvmapp/src/main/java/com/hibrianlee/mvvmapp/MvvmApplication.java
// public abstract class MvvmApplication extends Application {
// 
//     private AppComponent appComponent;
// 
//     protected abstract AppComponent createAppComponent();
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
// 
//         if (appComponent == null) {
//             appComponent = createAppComponent();
//         }
//     }
// 
//     public AppComponent getAppComponent() {
//         return appComponent;
//     }
// 
//     public void setAppComponent(AppComponent appComponent) {
//         this.appComponent = appComponent;
//     }
// }
// 
// Path: mvvmapp/src/main/java/com/hibrianlee/mvvmapp/inject/ActivityComponent.java
// @PerActivity
// @Component(
//         dependencies = AppComponent.class,
//         modules = {ActivityModule.class})
// public interface ActivityComponent {
// 
//     void inject(ViewModel viewModel);
// }
// 
// Path: mvvmapp/src/main/java/com/hibrianlee/mvvmapp/inject/ActivityModule.java
// @Module
// public final class ActivityModule {
// 
//     private final ViewModelActivity activity;
// 
//     public ActivityModule(ViewModelActivity activity) {
//         this.activity = activity;
//     }
// 
//     @Provides
//     @PerActivity
//     AttachedActivity provideAttachedActivity() {
//         return new AttachedViewModelActivity(activity);
//     }
// }
// 
// Path: mvvmapp/src/main/java/com/hibrianlee/mvvmapp/inject/AppComponent.java
// public interface AppComponent {
// 
//     @AppContext
//     Context appContext();
// 
//     void inject(ViewModelActivity viewModelActivity);
// 
//     void inject(ViewModelFragment viewModelFragment);
// }
// 
// Path: mvvmapp/src/main/java/com/hibrianlee/mvvmapp/viewmodel/ViewModel.java
// public abstract class ViewModel extends BaseObservable {
// 
//     @Inject
//     @AppContext
//     protected Context appContext;
// 
//     @Inject
//     protected AttachedActivity attachedActivity;
// 
//     protected ViewModel(@NonNull ActivityComponent activityComponent,
//                         @Nullable State savedInstanceState) {
//         activityComponent.inject(this);
//     }
// 
//     @CallSuper
//     public void onStart() {
// 
//     }
// 
//     public State getInstanceState() {
//         return new State(this);
//     }
// 
//     @CallSuper
//     public void onStop() {
// 
//     }
// 
//     public static class State implements Parcelable {
// 
//         protected State(ViewModel viewModel) {
// 
//         }
// 
//         public State(Parcel in) {
// 
//         }
// 
//         @Override
//         public int describeContents() {
//             return 0;
//         }
// 
//         @CallSuper
//         @Override
//         public void writeToParcel(Parcel dest, int flags) {
// 
//         }
// 
//         public static Creator<State> CREATOR = new Creator<State>() {
//             @Override
//             public State createFromParcel(Parcel source) {
//                 return new State(source);
//             }
// 
//             @Override
//             public State[] newArray(int size) {
//                 return new State[size];
//             }
//         };
//     }
// }


// Path: mvvmapp/src/main/java/com/hibrianlee/mvvmapp/activity/ViewModelActivity.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import com.hibrianlee.mvvmapp.MvvmApplication;
import com.hibrianlee.mvvmapp.inject.ActivityComponent;
import com.hibrianlee.mvvmapp.inject.ActivityModule;
import com.hibrianlee.mvvmapp.inject.AppComponent;
import com.hibrianlee.mvvmapp.inject.DaggerActivityComponent;
import com.hibrianlee.mvvmapp.viewmodel.ViewModel;

/*
 * Copyright (C) 2015 Brian Lee (@hiBrianLee)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hibrianlee.mvvmapp.activity;



public abstract class ViewModelActivity extends AppCompatActivity {

    private static final String EXTRA_VIEW_MODEL_STATE = "viewModelState";

    private ActivityComponent activityComponent;
    private ViewModel viewModel;

    protected void inject(AppComponent appComponent) {
        appComponent.inject(this);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        AppComponent appComponent = ((MvvmApplication) getApplication()).getAppComponent();