Search in sources :

Example 16 with Adapter

use of android.widget.Adapter in project android_frameworks_base by crdroidandroid.

the class AppWidgetHostView method viewDataChanged.

/**
     * Process data-changed notifications for the specified view in the specified
     * set of {@link RemoteViews} views.
     */
void viewDataChanged(int viewId) {
    View v = findViewById(viewId);
    if ((v != null) && (v instanceof AdapterView<?>)) {
        AdapterView<?> adapterView = (AdapterView<?>) v;
        Adapter adapter = adapterView.getAdapter();
        if (adapter instanceof BaseAdapter) {
            BaseAdapter baseAdapter = (BaseAdapter) adapter;
            baseAdapter.notifyDataSetChanged();
        } else if (adapter == null && adapterView instanceof RemoteAdapterConnectionCallback) {
            // If the adapter is null, it may mean that the RemoteViewsAapter has not yet
            // connected to its associated service, and hence the adapter hasn't been set.
            // In this case, we need to defer the notify call until it has been set.
            ((RemoteAdapterConnectionCallback) adapterView).deferNotifyDataSetChanged();
        }
    }
}
Also used : RemoteAdapterConnectionCallback(android.widget.RemoteViewsAdapter.RemoteAdapterConnectionCallback) AdapterView(android.widget.AdapterView) Adapter(android.widget.Adapter) BaseAdapter(android.widget.BaseAdapter) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) BaseAdapter(android.widget.BaseAdapter)

Example 17 with Adapter

use of android.widget.Adapter in project RecyclerViewAnimator by dkmeteor.

the class PullToRefreshAdapterViewBase method isLastItemVisible.

private boolean isLastItemVisible() {
    final Adapter adapter = mRefreshableView.getAdapter();
    if (null == adapter || adapter.isEmpty()) {
        if (DEBUG) {
            Log.d(LOG_TAG, "isLastItemVisible. Empty View.");
        }
        return true;
    } else {
        final int lastItemPosition = mRefreshableView.getCount() - 1;
        final int lastVisiblePosition = mRefreshableView.getLastVisiblePosition();
        if (DEBUG) {
            Log.d(LOG_TAG, "isLastItemVisible. Last Item Position: " + lastItemPosition + " Last Visible Pos: " + lastVisiblePosition);
        }
        /**
			 * This check should really just be: lastVisiblePosition ==
			 * lastItemPosition, but PtRListView internally uses a FooterView
			 * which messes the positions up. For me we'll just subtract one to
			 * account for it and rely on the inner condition which checks
			 * getBottom().
			 */
        if (lastVisiblePosition >= lastItemPosition - 1) {
            final int childIndex = lastVisiblePosition - mRefreshableView.getFirstVisiblePosition();
            final View lastVisibleChild = mRefreshableView.getChildAt(childIndex);
            if (lastVisibleChild != null) {
                return lastVisibleChild.getBottom() <= mRefreshableView.getBottom();
            }
        }
    }
    return false;
}
Also used : Adapter(android.widget.Adapter) ListAdapter(android.widget.ListAdapter) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 18 with Adapter

use of android.widget.Adapter in project Android-PullToRefresh by chrisbanes.

the class PullToRefreshAdapterViewBase method isLastItemVisible.

private boolean isLastItemVisible() {
    final Adapter adapter = mRefreshableView.getAdapter();
    if (null == adapter || adapter.isEmpty()) {
        if (DEBUG) {
            Log.d(LOG_TAG, "isLastItemVisible. Empty View.");
        }
        return true;
    } else {
        final int lastItemPosition = mRefreshableView.getCount() - 1;
        final int lastVisiblePosition = mRefreshableView.getLastVisiblePosition();
        if (DEBUG) {
            Log.d(LOG_TAG, "isLastItemVisible. Last Item Position: " + lastItemPosition + " Last Visible Pos: " + lastVisiblePosition);
        }
        /**
			 * This check should really just be: lastVisiblePosition ==
			 * lastItemPosition, but PtRListView internally uses a FooterView
			 * which messes the positions up. For me we'll just subtract one to
			 * account for it and rely on the inner condition which checks
			 * getBottom().
			 */
        if (lastVisiblePosition >= lastItemPosition - 1) {
            final int childIndex = lastVisiblePosition - mRefreshableView.getFirstVisiblePosition();
            final View lastVisibleChild = mRefreshableView.getChildAt(childIndex);
            if (lastVisibleChild != null) {
                return lastVisibleChild.getBottom() <= mRefreshableView.getBottom();
            }
        }
    }
    return false;
}
Also used : Adapter(android.widget.Adapter) ListAdapter(android.widget.ListAdapter) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 19 with Adapter

use of android.widget.Adapter in project PullToRefreshLibrary by harichen.

the class PullToRefreshAdapterViewBase method isLastItemVisible.

private boolean isLastItemVisible() {
    final Adapter adapter = mRefreshableView.getAdapter();
    if (null == adapter || adapter.isEmpty()) {
        if (DEBUG) {
            Log.d(LOG_TAG, "isLastItemVisible. Empty View.");
        }
        return true;
    } else {
        final int lastItemPosition = mRefreshableView.getCount() - 1;
        final int lastVisiblePosition = mRefreshableView.getLastVisiblePosition();
        if (DEBUG) {
            Log.d(LOG_TAG, "isLastItemVisible. Last Item Position: " + lastItemPosition + " Last Visible Pos: " + lastVisiblePosition);
        }
        /**
			 * This check should really just be: lastVisiblePosition ==
			 * lastItemPosition, but PtRListView internally uses a FooterView
			 * which messes the positions up. For me we'll just subtract one to
			 * account for it and rely on the inner condition which checks
			 * getBottom().
			 */
        if (lastVisiblePosition >= lastItemPosition - 1) {
            final int childIndex = lastVisiblePosition - mRefreshableView.getFirstVisiblePosition();
            final View lastVisibleChild = mRefreshableView.getChildAt(childIndex);
            if (lastVisibleChild != null) {
                return lastVisibleChild.getBottom() <= mRefreshableView.getBottom();
            }
        }
    }
    return false;
}
Also used : Adapter(android.widget.Adapter) ListAdapter(android.widget.ListAdapter) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 20 with Adapter

use of android.widget.Adapter in project KJFrameForAndroid by kymjs.

the class PullToRefreshList method isLastItemVisible.

/**
     * 判断最后一个child是否完全显示出来
     * 
     * @return true完全显示出来,否则false
     */
private boolean isLastItemVisible() {
    final Adapter adapter = mfakeListView.getAdapter();
    if (null == adapter || adapter.isEmpty()) {
        return true;
    }
    final int lastItemPosition = adapter.getCount() - 1;
    final int lastVisiblePosition = mfakeListView.getLastVisiblePosition();
    /**
         * This check should really just be: lastVisiblePosition ==
         * lastItemPosition, but ListView internally uses a FooterView which
         * messes the positions up. For me we'll just subtract one to account
         * for it and rely on the inner condition which checks getBottom().
         */
    if (lastVisiblePosition >= lastItemPosition - 1) {
        final int childIndex = lastVisiblePosition - mfakeListView.getFirstVisiblePosition();
        final int childCount = mfakeListView.getChildCount();
        final int index = Math.min(childIndex, childCount - 1);
        final View lastVisibleChild = mfakeListView.getChildAt(index);
        if (lastVisibleChild != null) {
            return lastVisibleChild.getBottom() <= mfakeListView.getBottom();
        }
    }
    return false;
}
Also used : Adapter(android.widget.Adapter) View(android.view.View) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView)

Aggregations

Adapter (android.widget.Adapter)36 AdapterView (android.widget.AdapterView)23 View (android.view.View)18 BaseAdapter (android.widget.BaseAdapter)15 ListAdapter (android.widget.ListAdapter)12 AbsListView (android.widget.AbsListView)10 RemoteAdapterConnectionCallback (android.widget.RemoteViewsAdapter.RemoteAdapterConnectionCallback)7 TextView (android.widget.TextView)7 Intent (android.content.Intent)4 ExpandableListAdapter (android.widget.ExpandableListAdapter)4 HeaderViewListAdapter (android.widget.HeaderViewListAdapter)3 SuppressLint (android.annotation.SuppressLint)2 ExpandableListView (android.widget.ExpandableListView)2 SectionIndexer (android.widget.SectionIndexer)2 DataSetObserver (android.database.DataSetObserver)1 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)1 CursorAdapter (android.support.v4.widget.CursorAdapter)1 ViewGroup (android.view.ViewGroup)1 ArrayAdapter (android.widget.ArrayAdapter)1 ListView (android.widget.ListView)1