Automatically notifies viewpager's adapter, when content is changed.
Android AutoNotifyViewPager
This project is an upgraded version of [ViewPager][1]. AutoNotifies your adapter when data get's changed.
##Prerequisites - android-support-v4.jar
Why?
- By default ViewPager'sadapter should be notified using mAdapter.notifyDataSetChanged() if data get's changed after [setting adapter][2] to avoid [IllegalStateException][5]
- It get's difficult to update your adapter when PagerAdapter is in other class, typically different *.java
- Example :
- In [this app][3], ListView's adapter & ViewPager's adapter share's same content.
- When scrolled down to bottom of the page in ListView, GetMoreData is triggered, fetched, parsed & updated to ListView's adapter.
- Seems easy, but when the user clicks & navigates to ViewPager after triggered and before updated, you end up in IllegalStateException as the data got changed but not notified.
- This can be avoided having complex eventListeners, instead simply use AutoNotifyViewPager
When?
- Notifies youradapter when view get's changed
Not When!
-adapter get's content.
Usage
Import any one [*.jar][4] into /libs
In layout.xml
Instead of use AutoNotifyViewPager mPagerViewPager mPager
AutoNotifyViewPager mPager = (AutoNotifyViewPager) findViewById(R.id.pager); mPager.setAdapter(adapter);
imports
import com.venomvendor.library.AutoNotifyViewPager.*;imports not to have
import android.support.v4.view.ViewPager.*ProGuard
-dontwarn com.venomvendor.library.AutoNotifyViewPager.** -keep public class com.venomvendor.library.AutoNotifyViewPager.* { ; }Author : VenomVendor
#License Copyright (C) 2015 VenomVendor
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. [1]: http://developer.android.com/reference/android/support/v4/view/ViewPager.html "android.support.v4.view.ViewPager" [2]: http://developer.android.com/reference/android/support/v4/view/ViewPager.html#setAdapter%28android.support.v4.view.PagerAdapter%29 [3]: https://play.google.com/store/apps/details?id=com.MobiGyaan "MobiGyaan" [4]: https://github.com/VenomVendor/AutoNotifyViewPager/releases/tag/v-3.0.0 "Import any one" [5]: https://www.google.com/search?q=the+application's+pageradapter+changed "IllegalStateException"