// Path: library/src/main/java/eu/inloop/viewmodel/base/ViewModelBaseEmptyActivity.java
// public abstract class ViewModelBaseEmptyActivity extends AppCompatActivity implements IViewModelProvider {
// 
//     @Nullable
//     private ViewModelProvider mViewModelProvider;
// 
//     @CallSuper
//     @Override
//     protected void onCreate(@Nullable final Bundle savedInstanceState) {
//         //This code must be execute prior to super.onCreate()
//         mViewModelProvider = ViewModelProvider.newInstance(this);
//         super.onCreate(savedInstanceState);
//     }
// 
//     @Override
//     @Nullable
//     public Object onRetainCustomNonConfigurationInstance() {
//         return mViewModelProvider;
//     }
// 
//     @CallSuper
//     @Override
//     public void onStop() {
//         super.onStop();
//         if (isFinishing()) {
//             if (null == mViewModelProvider) {
//                 throw new IllegalStateException("ViewModelProvider for activity " + this + " was null."); //NON-NLS
//             }
//             mViewModelProvider.removeAllViewModels();
//         }
//     }
// 
//     @Nullable
//     @Override
//     public ViewModelProvider getViewModelProvider() {
//         return mViewModelProvider;
//     }
// }
// 
// Path: sample/src/main/java/eu/inloop/viewmodel/sample/fragment/PagerFragment.java
// public class PagerFragment extends ViewModelBaseFragment<IPageView, PageModel> implements IPageView {
// 
//     public static PagerFragment newInstance(int position) {
//         final Bundle bundle = new Bundle();
//         bundle.putInt("position", position);
//         final PagerFragment fragment = new PagerFragment();
//         fragment.setArguments(bundle);
//         return fragment;
//     }
// 
//     @Nullable
//     @Override
//     public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//         return inflater.inflate(R.layout.fragment_pager, container, false);
//     }
// 
//     @Override
//     public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
//         super.onViewCreated(view, savedInstanceState);
//         ((TextView)view.findViewById(R.id.text)).setText(Integer.toString(getArguments().getInt("position")));
//         setModelView(this);
//     }
// 
//     @Override
//     public void onDestroy() {
//         super.onDestroy();
// 
//         // watch for memory leaks
//         RefWatcher refWatcher = SampleApplication.getRefWatcher(requireActivity());
//         refWatcher.watch(this);
//     }
// }
// 
// Path: library/src/main/java/eu/inloop/viewmodel/support/ViewModelStatePagerAdapter.java
// public abstract class ViewModelStatePagerAdapter extends FragmentStatePagerAdapter {
// 
//     public ViewModelStatePagerAdapter(@NonNull final FragmentManager fm) {
//         super(fm);
//     }
// 
//     @Override
//     public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
//         super.destroyItem(container, position, object);
//         final Fragment fragment = (Fragment) object;
// 
//         if (fragment instanceof IView) {
//             IView viewModelBaseFragment = (IView) fragment;
//             viewModelBaseFragment.removeViewModel();
//         } else {
//             if (BuildConfig.DEBUG) {
//                 Log.w("model", "Fragment " + fragment + " in FragmentStatePagerAdapter " + this + " doesn't implent IView"); //NON-NLS
//             }
//         }
//     }
// }


import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;
import butterknife.ButterKnife;
import eu.inloop.viewmodel.base.ViewModelBaseEmptyActivity;
import eu.inloop.viewmodel.sample.R;
import eu.inloop.viewmodel.sample.fragment.PagerFragment;
import eu.inloop.viewmodel.support.ViewModelStatePagerAdapter;
package eu.inloop.viewmodel.sample.activity;




public class ViewPagerActivity extends ViewModelBaseEmptyActivity {

    @BindView(R.id.pager)
    ViewPager mViewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pager);
        ButterKnife.bind(this);
        mViewPager.setAdapter(new TestPagerAdapter(getSupportFragmentManager()));
    }

    private final static class TestPagerAdapter extends ViewModelStatePagerAdapter {
        TestPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
// Path: library/src/main/java/eu/inloop/viewmodel/base/ViewModelBaseEmptyActivity.java
// public abstract class ViewModelBaseEmptyActivity extends AppCompatActivity implements IViewModelProvider {
// 
//     @Nullable
//     private ViewModelProvider mViewModelProvider;
// 
//     @CallSuper
//     @Override
//     protected void onCreate(@Nullable final Bundle savedInstanceState) {
//         //This code must be execute prior to super.onCreate()
//         mViewModelProvider = ViewModelProvider.newInstance(this);
//         super.onCreate(savedInstanceState);
//     }
// 
//     @Override
//     @Nullable
//     public Object onRetainCustomNonConfigurationInstance() {
//         return mViewModelProvider;
//     }
// 
//     @CallSuper
//     @Override
//     public void onStop() {
//         super.onStop();
//         if (isFinishing()) {
//             if (null == mViewModelProvider) {
//                 throw new IllegalStateException("ViewModelProvider for activity " + this + " was null."); //NON-NLS
//             }
//             mViewModelProvider.removeAllViewModels();
//         }
//     }
// 
//     @Nullable
//     @Override
//     public ViewModelProvider getViewModelProvider() {
//         return mViewModelProvider;
//     }
// }
// 
// Path: sample/src/main/java/eu/inloop/viewmodel/sample/fragment/PagerFragment.java
// public class PagerFragment extends ViewModelBaseFragment<IPageView, PageModel> implements IPageView {
// 
//     public static PagerFragment newInstance(int position) {
//         final Bundle bundle = new Bundle();
//         bundle.putInt("position", position);
//         final PagerFragment fragment = new PagerFragment();
//         fragment.setArguments(bundle);
//         return fragment;
//     }
// 
//     @Nullable
//     @Override
//     public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//         return inflater.inflate(R.layout.fragment_pager, container, false);
//     }
// 
//     @Override
//     public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
//         super.onViewCreated(view, savedInstanceState);
//         ((TextView)view.findViewById(R.id.text)).setText(Integer.toString(getArguments().getInt("position")));
//         setModelView(this);
//     }
// 
//     @Override
//     public void onDestroy() {
//         super.onDestroy();
// 
//         // watch for memory leaks
//         RefWatcher refWatcher = SampleApplication.getRefWatcher(requireActivity());
//         refWatcher.watch(this);
//     }
// }
// 
// Path: library/src/main/java/eu/inloop/viewmodel/support/ViewModelStatePagerAdapter.java
// public abstract class ViewModelStatePagerAdapter extends FragmentStatePagerAdapter {
// 
//     public ViewModelStatePagerAdapter(@NonNull final FragmentManager fm) {
//         super(fm);
//     }
// 
//     @Override
//     public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
//         super.destroyItem(container, position, object);
//         final Fragment fragment = (Fragment) object;
// 
//         if (fragment instanceof IView) {
//             IView viewModelBaseFragment = (IView) fragment;
//             viewModelBaseFragment.removeViewModel();
//         } else {
//             if (BuildConfig.DEBUG) {
//                 Log.w("model", "Fragment " + fragment + " in FragmentStatePagerAdapter " + this + " doesn't implent IView"); //NON-NLS
//             }
//         }
//     }
// }


// Path: sample/src/main/java/eu/inloop/viewmodel/sample/activity/ViewPagerActivity.java
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;
import butterknife.ButterKnife;
import eu.inloop.viewmodel.base.ViewModelBaseEmptyActivity;
import eu.inloop.viewmodel.sample.R;
import eu.inloop.viewmodel.sample.fragment.PagerFragment;
import eu.inloop.viewmodel.support.ViewModelStatePagerAdapter;

package eu.inloop.viewmodel.sample.activity;




public class ViewPagerActivity extends ViewModelBaseEmptyActivity {

    @BindView(R.id.pager)
    ViewPager mViewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pager);
        ButterKnife.bind(this);
        mViewPager.setAdapter(new TestPagerAdapter(getSupportFragmentManager()));
    }

    private final static class TestPagerAdapter extends ViewModelStatePagerAdapter {
        TestPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            return PagerFragment.newInstance(position);