Bug 1321981 - [RTL] ViewPager Support - part 2. Notify dataset change with calling super, r=sebastian

MozReview-Commit-ID: LUvWH3Sq8IJ

--HG--
extra : rebase_source : 3a9a8d657619f877f0d17e8f5870113dfd87da0e
This commit is contained in:
maliu 2017-03-21 14:49:40 +08:00
Родитель 2f076a0ebd
Коммит a699dea057
1 изменённых файлов: 17 добавлений и 2 удалений

Просмотреть файл

@ -15,6 +15,7 @@
*/
package com.booking.rtlviewpager;
import android.database.DataSetObservable;
import android.database.DataSetObserver;
import android.os.Parcelable;
import android.support.annotation.NonNull;
@ -29,9 +30,23 @@ class PagerAdapterWrapper extends PagerAdapter {
@NonNull
private final PagerAdapter adapter;
private final DataSetObservable dataSetObservable = new DataSetObservable();
protected PagerAdapterWrapper(@NonNull PagerAdapter adapter) {
this.adapter = adapter;
this.adapter.registerDataSetObserver(new DataSetObserver() {
@Override
public void onChanged() {
PagerAdapterWrapper.super.notifyDataSetChanged();
dataSetObservable.notifyChanged();
}
@Override
public void onInvalidated() {
dataSetObservable.notifyInvalidated();
}
});
}
@NonNull
@ -86,12 +101,12 @@ class PagerAdapterWrapper extends PagerAdapter {
@Override
public void registerDataSetObserver(DataSetObserver observer) {
adapter.registerDataSetObserver(observer);
dataSetObservable.registerObserver(observer);
}
@Override
public void unregisterDataSetObserver(DataSetObserver observer) {
adapter.unregisterDataSetObserver(observer);
dataSetObservable.unregisterObserver(observer);
}
@Override