aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/ui/AbstractCachingPageViewCreator.java
blob: 333ef11822851572fc0f96cdc23947d50517a479 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package cgeo.geocaching.ui;

import cgeo.geocaching.activity.AbstractViewPagerActivity.PageViewCreator;

import android.view.View;

/**
 * View creator which destroys the created view on every {@link #notifyDataSetChanged()}.
 *
 * @param <ViewClass>
 */
public abstract class AbstractCachingPageViewCreator<ViewClass extends View> implements PageViewCreator {

    public ViewClass view;

    @Override
    public final void notifyDataSetChanged() {
        view = null;
    }

    @Override
    public final View getView() {
        if (view == null) {
            view = getDispatchedView();
        }

        return view;
    }

    @Override
    public abstract ViewClass getDispatchedView();
}