Refresh Viewpager from within the DrawerLayout
<p><strong>Context:</strong>
I have a drawerLayout that contains a list of cities that I get from Realm. The ViewPager is already displaying that list. You can delete a city directly from the DrawerLayout</p>

<p><strong>Problem:</strong> When I delete a city from the DrawerLayout, I call mViewPager.getAdapter().notifyDataSetChanged, the viewPager is not reloaded. Since the drawerLayout is displayed over the ViewPager, there is no reload when you close it and the ViewPager / Realm  returns a <code>java.lang.ArrayIndexOutOfBoundsException: rowIndex &gt; available rows: 4 &gt; 4</code> when I navigate back in it.</p>

<p>Do you have any clue on how I could solve that?</p>

<p>For information purpose, here is how it works:
**In the BaseActivity, that contains the DrawerLayout **</p>

<pre><code>mCityListAdapter = new CityListAdapter(getBaseContext(), RealmHelper.getStoredCities(), new CityListAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(int position) {
            mPager.setCurrentItem(position);
            mDrawerLayout.closeDrawers();
        }
    }, new CityListAdapter.OnItemLongClickListener() {
        @Override
        public void onItemLongClick(final int position) {
            final CharSequence[] items = {getString(R.string.action_delete_city)};
            AlertDialog.Builder builder = new AlertDialog.Builder(BaseActivity.this);
            builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    RealmHelper.removeCity(RealmHelper.getStoredCities().get(position));
                    mPager.getAdapter().notifyDataSetChanged();
                }
            });
            builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.cancel();
                }
            });

            builder.setTitle(getString(R.string.delete_city_label));
            builder.show();
        }
    });
</code></pre>

<p><strong>In the activity that contains the viewPager</strong></p>

<pre><code>@Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        getLayoutInflater().inflate(R.layout.fragment_pager, mFrameLayout);

        mPager = (ViewPager)findViewById(R.id.pager);
        mPager.setAdapter(mAdapter);
        mPager.addOnPageChangeListener(this);

        mAdapter = new FragmentStatePageSupportAdapter(getSupportFragmentManager(), RealmHelper.getStoredCities().size(), this, RealmHelper.getStoredCities());
        mPager.setAdapter(mAdapter);
        mPager.setOffscreenPageLimit(0);

    }
</code></pre>

<p><strong>Edit</strong></p>

<p>I did override getItemPosition and it's called. So not the issue.</p>

<pre><code>The @Override
    public int getItemPosition(Object object) {
        Log.v("results", "called getitempostion");
        return POSITION_NONE;
    }  
</code></pre>