AutoNotifyViewPager

Additional

Language
Java
Version
v-3.0.0 (Dec 15, 2015)
Created
May 3, 2014
Updated
Apr 17, 2017 (Retired)
Owner
VenomVendor
Contributor
VenomVendor
1
Activity
Badge
Generate
Download
Source code

Announcement

Android AutoNotifyViewPager

This project is an upgraded version of ViewPager. AutoNotifies your adapter when data get's changed.

##Prerequisites

Why?

  • By default ViewPager's adapter should be notified using mAdapter.notifyDataSetChanged() if data get's changed after setting adapter to avoid IllegalStateException
  • It get's difficult to update your adapter when PagerAdapter is in other class, typically different *.java
  • Example :
    • In this app, 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 your adapter when view get's changed

Not When!

  • adapter get's content.

Usage

Import any one *.jar into /libs

In layout.xml

<com.venomvendor.library.AutoNotifyViewPager 
 android:id="@+id/pager"
 android:layout_width="match_parent"
 android:layout_height="match_parent" />

Instead of ViewPager mPager use AutoNotifyViewPager 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 info@VenomVendor.com Copyright (C) 2011 The Android Open Source Project.

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.