get Cache Adapter - Android android.widget

Android examples for android.widget:Adapter

Description

get Cache Adapter

Demo Code

import android.widget.Adapter;
import android.widget.BaseAdapter;
import android.widget.HeaderViewListAdapter;

public class Main{

    public static CacheAdapter<?> getCacheAdapter(Adapter adapter) {
        if (adapter == null) {
            return null;
        }// w w  w .jav  a  2s  . c  o  m
        CacheAdapter<?> cacheAdapter = null;
        if (adapter instanceof CacheAdapter<?>) {
            cacheAdapter = (CacheAdapter<?>) adapter;
        } else if (adapter instanceof HeaderViewListAdapter) {
            HeaderViewListAdapter headerViewAdapter = (HeaderViewListAdapter) adapter;
            if (headerViewAdapter.getWrappedAdapter() instanceof CacheAdapter<?>) {
                cacheAdapter = (CacheAdapter<?>) headerViewAdapter
                        .getWrappedAdapter();
            }
        }

        return cacheAdapter;
    }

}

Related Tutorials