android.widget.HeaderViewListAdapter Java Examples

The following examples show how to use android.widget.HeaderViewListAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PinnedHeaderListView.java    From FoodOrdering with Apache License 2.0 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int rawPosition, long id) {
    SectionedBaseAdapter adapter;
    if (adapterView.getAdapter().getClass().equals(HeaderViewListAdapter.class)) {
        HeaderViewListAdapter wrapperAdapter = (HeaderViewListAdapter) adapterView.getAdapter();
        adapter = (SectionedBaseAdapter) wrapperAdapter.getWrappedAdapter();
    } else {
        adapter = (SectionedBaseAdapter) adapterView.getAdapter();
    }
    int section = adapter.getSectionForPosition(rawPosition);
    int position = adapter.getPositionInSectionForPosition(rawPosition);

    if (position == -1) {
        onSectionClick(adapterView, view, section, id);
    } else {
        onItemClick(adapterView, view, section, position, id);
    }
}
 
Example #2
Source File: AdapterUtil.java    From YiBo with Apache License 2.0 6 votes vote down vote up
public static BaseListAdapter<?> getBaseListAdapter(Adapter adapter) {
	if (adapter == null) {
		return null;
	}
	
	BaseListAdapter<?> baseListAdapter = null;
	if (adapter instanceof BaseListAdapter<?>) {
        baseListAdapter = (BaseListAdapter<?>)adapter;
	} else if (adapter instanceof HeaderViewListAdapter) {
		HeaderViewListAdapter headerViewAdapter = (HeaderViewListAdapter)adapter;
		if (headerViewAdapter.getWrappedAdapter() instanceof BaseListAdapter<?>) {
			baseListAdapter = (BaseListAdapter<?>)headerViewAdapter.getWrappedAdapter();
		}
	}
	
	return baseListAdapter;
}
 
Example #3
Source File: AdapterUtil.java    From YiBo with Apache License 2.0 6 votes vote down vote up
public static CacheAdapter<?> getCacheAdapter(Adapter adapter) {
	if (adapter == null) {
		return null;
	}
	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;
}
 
Example #4
Source File: NavigationPopup.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Constructs a new popup with the given history information.
 *
 * @param context The context used for building the popup.
 * @param navigationClient The owner of the history being displayed.
 * @param isForward Whether to request forward navigation entries.
 */
public NavigationPopup(
        Context context, NavigationClient navigationClient, boolean isForward) {
    super(context, null, android.R.attr.popupMenuStyle);
    mContext = context;
    mNavigationClient = navigationClient;
    mHistory = mNavigationClient.getDirectedNavigationHistory(
            isForward, MAXIMUM_HISTORY_ITEMS);
    mAdapter = new NavigationAdapter();

    float density = mContext.getResources().getDisplayMetrics().density;
    mFaviconSize = (int) (density * FAVICON_SIZE_DP);

    setModal(true);
    setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
    setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    setOnItemClickListener(this);

    setAdapter(new HeaderViewListAdapter(null, null, mAdapter));

    mListItemFactory = new ListItemFactory(context);
}
 
Example #5
Source File: FolderFragment.java    From filemanager with MIT License 6 votes vote down vote up
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
		int visibleItemCount, int totalItemCount)
{		
	if (firstVisibleItem < this.topVisibleItem - DISTANCE_TO_HIDE_ACTIONBAR)
	{
		setActionbarVisibility(true);
		this.topVisibleItem = firstVisibleItem;
	}
	else if (firstVisibleItem > this.topVisibleItem + DISTANCE_TO_HIDE_ACTIONBAR)
	{
		setActionbarVisibility(false);
		this.topVisibleItem = firstVisibleItem;
	}
	
	ListAdapter adapter = view.getAdapter();
	if (adapter instanceof HeaderViewListAdapter)
	{
		HeaderViewListAdapter headerViewListAdapter = (HeaderViewListAdapter) adapter;
		if (headerViewListAdapter.getWrappedAdapter() instanceof FileCardAdapter)
		{
			int startPrefetch = firstVisibleItem + visibleItemCount-headerViewListAdapter.getHeadersCount();
			((FileCardAdapter) headerViewListAdapter.getWrappedAdapter()).prefetchImages(startPrefetch, visibleItemCount);
		}
	}
}
 
Example #6
Source File: NavigationPopup.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a new popup with the given history information.
 *
 * @param profile The profile used for fetching favicons.
 * @param context The context used for building the popup.
 * @param navigationController The controller which takes care of page navigations.
 * @param isForward Whether to request forward navigation entries.
 */
public NavigationPopup(Profile profile, Context context,
        NavigationController navigationController, boolean isForward) {
    super(context, null, android.R.attr.popupMenuStyle);
    mProfile = profile;
    mContext = context;
    mNavigationController = navigationController;
    mHistory = mNavigationController.getDirectedNavigationHistory(
            isForward, MAXIMUM_HISTORY_ITEMS);
    mAdapter = new NavigationAdapter();

    mFaviconSize = mContext.getResources().getDimensionPixelSize(R.dimen.default_favicon_size);

    setModal(true);
    setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
    setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    setOnItemClickListener(this);

    setAdapter(new HeaderViewListAdapter(null, null, mAdapter));

    mListItemFactory = new ListItemFactory(context);
}
 
Example #7
Source File: ConversationItemClickListener.java    From YiBo with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
		long id) {
	Adapter adapter = parent.getAdapter();
	message = (DirectMessage)adapter.getItem(position);
       if (message == null 
       	|| (message instanceof LocalDirectMessage
       		&& ((LocalDirectMessage)message).isDivider())) {
       	return;
       }

       if (adapter instanceof HeaderViewListAdapter) {
       	adapter = ((HeaderViewListAdapter)adapter).getWrappedAdapter();
       }
	CacheAdapter<DirectMessage> cacheAdapter = (CacheAdapter<DirectMessage>)adapter;

       Dialog dialog = onCreateDialog(cacheAdapter, position);
       if (dialog != null) {
       	dialog.show();
       }
}
 
Example #8
Source File: NavigationPopup.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Constructs a new popup with the given history information.
 *
 * @param context The context used for building the popup.
 * @param navigationClient The owner of the history being displayed.
 * @param isForward Whether to request forward navigation entries.
 */
public NavigationPopup(
        Context context, NavigationClient navigationClient, boolean isForward) {
    super(context, null, android.R.attr.popupMenuStyle);
    mContext = context;
    mNavigationClient = navigationClient;
    mHistory = mNavigationClient.getDirectedNavigationHistory(
            isForward, MAXIMUM_HISTORY_ITEMS);
    mAdapter = new NavigationAdapter();

    float density = mContext.getResources().getDisplayMetrics().density;
    mFaviconSize = (int) (density * FAVICON_SIZE_DP);

    setModal(true);
    setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
    setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    setOnItemClickListener(this);

    setAdapter(new HeaderViewListAdapter(null, null, mAdapter));

    mListItemFactory = new ListItemFactory(context);
}
 
Example #9
Source File: RefreshLayout.java    From SwipeRefreshLayout with Apache License 2.0 6 votes vote down vote up
public void setLoading(boolean loading) {
    isLoading = loading;
    if (isLoading) {
        if (isRefreshing()) setRefreshing(false);
        if (mListView.getFooterViewsCount() == 0) {
            mListView.addFooterView(mListViewFooter);
            mListView.setSelection(mListView.getAdapter().getCount() - 1);
        } else {
            mListViewFooter.setVisibility(VISIBLE);
            //mListView.addFooterView(mListViewFooter);
        }
    } else {
        if (mListView.getAdapter() instanceof HeaderViewListAdapter) {
            mListView.removeFooterView(mListViewFooter);
        } else {
            mListViewFooter.setVisibility(View.GONE);
        }
        mYDown = 0;
        mLastY = 0;
    }
}
 
Example #10
Source File: RefreshLvLayout.java    From umeng_community_android with MIT License 6 votes vote down vote up
private void disposeFooterView() {
    if (mFooterView == null || mAbsListView == null) {
        return;
    }
    if (canAddFooter()) {
        mFooterView.setVisibility(View.VISIBLE);
        mAbsListView.addFooterView(mFooterView);
    } else {
        if (mAbsListView.getAdapter() instanceof HeaderViewListAdapter) {
            Log.d(VIEW_LOG_TAG, "### 移除footer ");
            mFooterView.setVisibility(View.GONE);
            mAbsListView.removeFooterView(mFooterView);
        } else {
            Log.d(VIEW_LOG_TAG, "### 隐藏footer ");
            mFooterView.setVisibility(View.GONE);
        }
    }
}
 
Example #11
Source File: Sidebar.java    From FanXin-based-HuanXin with GNU General Public License v2.0 6 votes vote down vote up
private void setHeaderTextAndscroll(MotionEvent event){
		 if (mListView == null) {
		        //check the mListView to avoid NPE. but the mListView shouldn't be null
		        //need to check the call stack later
		        return;
		    }
		String headerString = sections[sectionForPoint(event.getY())];
		header.setText(headerString);
		  HeaderViewListAdapter ha = (HeaderViewListAdapter) mListView.getAdapter();
		  ContactAdapter  adapter = (ContactAdapter) ha.getWrappedAdapter();
//		ContactAdapter adapter = (ContactAdapter) mListView.getAdapter();
		String[] adapterSections = (String[]) adapter.getSections();
		try {
			for (int i = adapterSections.length - 1; i > -1; i--) {
				if(adapterSections[i].equals(headerString)){
					mListView.setSelection(adapter.getPositionForSection(i));
					break;
				}
			}
		} catch (Exception e) {
			Log.e("setHeaderTextAndscroll", e.getMessage());
		}
		
	}
 
Example #12
Source File: CommentsItemClickListener.java    From YiBo with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
		long id) {
	Adapter adapter = parent.getAdapter();
       comment = (Comment)adapter.getItem(position);
       if (comment == null
       	|| (comment instanceof LocalComment
       		&& ((LocalComment)comment).isDivider())) {
       	return;
       }

       if (adapter instanceof HeaderViewListAdapter) {
       	adapter = ((HeaderViewListAdapter)adapter).getWrappedAdapter();
       }
       CacheAdapter<Comment> cacheAdapter = (CacheAdapter<Comment>)adapter;

       Dialog dialog = onCreateDialog(cacheAdapter, position);
       if (dialog != null) {
       	dialog.show();
       }
}
 
Example #13
Source File: NavigationPopup.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a new popup with the given history information.
 *
 * @param profile The profile used for fetching favicons.
 * @param context The context used for building the popup.
 * @param navigationController The controller which takes care of page navigations.
 * @param isForward Whether to request forward navigation entries.
 */
public NavigationPopup(Profile profile, Context context,
        NavigationController navigationController, boolean isForward) {
    super(context, null, android.R.attr.popupMenuStyle);
    mProfile = profile;
    mContext = context;
    mNavigationController = navigationController;
    mHistory = mNavigationController.getDirectedNavigationHistory(
            isForward, MAXIMUM_HISTORY_ITEMS);
    mAdapter = new NavigationAdapter();

    mFaviconSize = mContext.getResources().getDimensionPixelSize(R.dimen.default_favicon_size);

    setModal(true);
    setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
    setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    setOnItemClickListener(this);

    setAdapter(new HeaderViewListAdapter(null, null, mAdapter));

    mListItemFactory = new ListItemFactory(context);
}
 
Example #14
Source File: PinnedHeaderListView.java    From Yahala-Messenger with MIT License 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int rawPosition, long id) {
    SectionedBaseAdapter adapter;
    if (adapterView.getAdapter() instanceof HeaderViewListAdapter) {
        HeaderViewListAdapter wrapperAdapter = (HeaderViewListAdapter) adapterView.getAdapter();
        adapter = (SectionedBaseAdapter) wrapperAdapter.getWrappedAdapter();
    } else {
        adapter = (SectionedBaseAdapter) adapterView.getAdapter();
    }
    int section = adapter.getSectionForPosition(rawPosition);
    int position = adapter.getPositionInSectionForPosition(rawPosition);

    if (position == -1) {
        onSectionClick(adapterView, view, section, id);
    } else {
        onItemClick(adapterView, view, section, position, id);
    }
}
 
Example #15
Source File: DirectMessagesItemClickListener.java    From YiBo with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
		long id) {
	Adapter adapter = parent.getAdapter();
	message = (DirectMessage)adapter.getItem(position);
       if (message == null 
       	|| (message instanceof LocalDirectMessage
       		&& ((LocalDirectMessage)message).isDivider())) {
       	return;
       }

       if (adapter instanceof HeaderViewListAdapter) {
       	adapter = ((HeaderViewListAdapter)adapter).getWrappedAdapter();
       }
	CacheAdapter<DirectMessage> cacheAdapter = (CacheAdapter<DirectMessage>)adapter;

       Dialog dialog = onCreateDialog(cacheAdapter, position);
       if (dialog != null) {
       	dialog.show();
       }
}
 
Example #16
Source File: NavigationPopup.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a new popup with the given history information.
 *
 * @param profile The profile used for fetching favicons.
 * @param context The context used for building the popup.
 * @param navigationController The controller which takes care of page navigations.
 * @param isForward Whether to request forward navigation entries.
 */
public NavigationPopup(Profile profile, Context context,
        NavigationController navigationController, boolean isForward) {
    super(context, null, android.R.attr.popupMenuStyle);
    mProfile = profile;
    mContext = context;
    mNavigationController = navigationController;
    mHistory = mNavigationController.getDirectedNavigationHistory(
            isForward, MAXIMUM_HISTORY_ITEMS);
    mAdapter = new NavigationAdapter();

    mFaviconSize = mContext.getResources().getDimensionPixelSize(R.dimen.default_favicon_size);

    setModal(true);
    setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
    setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    setOnItemClickListener(this);

    setAdapter(new HeaderViewListAdapter(null, null, mAdapter));

    mListItemFactory = new ListItemFactory(context);
}
 
Example #17
Source File: HomePageHeaderDoubleClickListener.java    From YiBo with Apache License 2.0 5 votes vote down vote up
private CacheAdapter<?> getCacheAdapter(ListAdapter adapter) {
	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;
}
 
Example #18
Source File: ProfileActivity.java    From Favorite-Android-Client with Apache License 2.0 5 votes vote down vote up
public void setListAdapter() {
	// profile = (ImageView) findViewById(R.id.image_header);
	listView = (ListView) findViewById(android.R.id.list);
	listView.setOnItemClickListener(new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
				long arg3) {
			// TODO Auto-generated method stub
			if (arg0.getAdapter() instanceof HeaderViewListAdapter) {
				if (((HeaderViewListAdapter) arg0.getAdapter())
						.getWrappedAdapter() instanceof ListAdapter) {
					ListAdapter ca = (ListAdapter) ((HeaderViewListAdapter) arg0
							.getAdapter()).getWrappedAdapter();

					List ls = (List) ca.getItem(arg2 - 1);

					Intent intent = new Intent(ProfileActivity.this,
							document_read.class);
					intent.putExtra("doc_srl",
							String.valueOf(ls.getDocSrl()));
					startActivityForResult(intent, 1);

				}
			}

		}
	});
	// listView.setOnScrollListener(this);
	m_adapter = new ListAdapter(this, R.layout.profile_list, m_orders);

	// Set Profile
	profile.setImageDrawable(Drawable.createFromPath(local_path
			+ member_srl + ".jpg"));

	listView.setAdapter(m_adapter);

}
 
Example #19
Source File: MentionsListAdapter.java    From YiBo with Apache License 2.0 5 votes vote down vote up
public boolean refresh() {
	if (listNewBlogs == null || listNewBlogs.size() == 0) {
		return false;
	}

	addCacheToFirst(listNewBlogs);
	int offset = listNewBlogs.size();
	listNewBlogs.clear();
	newCount = 0;

	ListView lvMicroBlog = (ListView)((Activity)context).findViewById(R.id.lvMicroBlog);
	if (lvMicroBlog == null) {
		return true;
	}
	Adapter adapter = lvMicroBlog.getAdapter();
	if (adapter instanceof HeaderViewListAdapter) {
		adapter = ((HeaderViewListAdapter)adapter).getWrappedAdapter();
	}
	if (lvMicroBlog != null &&
		adapter == this
	) {
		int position = lvMicroBlog.getFirstVisiblePosition();
		View view = lvMicroBlog.getChildAt(0);
		int y = 0;
		if (view != null && position >= 1) {
		    y = view.getTop();
		    position += offset;
		    lvMicroBlog.setSelectionFromTop(position, y);
		}
	}

	return true;
}
 
Example #20
Source File: CommentsListAdapter.java    From YiBo with Apache License 2.0 5 votes vote down vote up
public boolean refresh() {
	if (ListUtil.isEmpty(listNewComments)) {
		return false;
	}

	addCacheToFirst(listNewComments);
	int offset = listNewComments.size();
	listNewComments.clear();
	newCount = 0;

	ListView lvMicroBlog = (ListView)((Activity)context).findViewById(R.id.lvMicroBlog);
	if (lvMicroBlog == null) {
		return true;
	}
	Adapter adapter = lvMicroBlog.getAdapter();
	if (adapter instanceof HeaderViewListAdapter) {
		adapter = ((HeaderViewListAdapter)adapter).getWrappedAdapter();
	}
	if (lvMicroBlog != null &&
		adapter == this
	) {
		int position = lvMicroBlog.getFirstVisiblePosition();
		View view = lvMicroBlog.getChildAt(0);
		int y = 0;
		if (view != null && position >= 1) {
		    y = view.getTop();
		    position += offset;
		    lvMicroBlog.setSelectionFromTop(position, y);
		}
	}

	return true;
}
 
Example #21
Source File: MyHomeListAdapter.java    From YiBo with Apache License 2.0 5 votes vote down vote up
public boolean refresh() {
	if (listNewBlogs == null || listNewBlogs.size() == 0) {
		return false;
	}

	addCacheToFirst(listNewBlogs);
	int offset = listNewBlogs.size();
	listNewBlogs.clear();

	ListView lvMicroBlog = (ListView)((Activity)context).findViewById(R.id.lvMicroBlog);
	if (lvMicroBlog == null) {
		return true;
	}
	Adapter adapter = lvMicroBlog.getAdapter();
	if (adapter instanceof HeaderViewListAdapter) {
		adapter = ((HeaderViewListAdapter)adapter).getWrappedAdapter();
	}
	if (adapter == this) {
		int position = lvMicroBlog.getFirstVisiblePosition();
		View view = lvMicroBlog.getChildAt(0);
		int y = 0;
		if (view != null && position >= 1) {
		    y = view.getTop();
		    //System.out.println("y:" + y + " position:" + position);
		    position += offset;
		    lvMicroBlog.setSelectionFromTop(position, y);
		}
	}

	return true;
}
 
Example #22
Source File: CommentsOfStatusContextMenuListener.java    From YiBo with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private CacheAdapter<Comment> getCacheAdapter(Adapter adapter) {
   	CacheAdapter<Comment> cacheAdapter = null;
    Adapter tempAdapter = adapter;
    if (tempAdapter instanceof HeaderViewListAdapter) {
    	tempAdapter = ((HeaderViewListAdapter)adapter).getWrappedAdapter();
    }
    cacheAdapter = (CacheAdapter<Comment>)tempAdapter;
    return cacheAdapter;
   }
 
Example #23
Source File: DirectMessagesListAdapter.java    From YiBo with Apache License 2.0 5 votes vote down vote up
public boolean refresh() {
	if (ListUtil.isEmpty(newInboxList) && ListUtil.isEmpty(newOutboxList)) {
		return false;
	}

	addCacheToFirst(newInboxList);
	addCacheToFirst(newOutboxList);
	int offset = newInboxList.size() + newOutboxList.size();
	newInboxList.clear();
	newOutboxList.clear();
	newCount = 0;

	ListView lvMicroBlog = (ListView)((Activity)context).findViewById(R.id.lvMicroBlog);
	if (lvMicroBlog == null) {
		return true;
	}
	Adapter adapter = lvMicroBlog.getAdapter();
	if (adapter instanceof HeaderViewListAdapter) {
		adapter = ((HeaderViewListAdapter)adapter).getWrappedAdapter();
	}
	if (lvMicroBlog != null 
		&& adapter == this) {
		int position = lvMicroBlog.getFirstVisiblePosition();
		View view = lvMicroBlog.getChildAt(0);
		int y = 0;
		if (view != null && position >= 1) {
		    y = view.getTop();
		    position += offset;
		    lvMicroBlog.setSelectionFromTop(position, y);
		}
	}

	return true;
}
 
Example #24
Source File: DynamicListView.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
private void swapElements(int indexOne, int indexTwo) {
    mLastMovedToIndex = indexTwo;
    ListAdapter adapter = getAdapter();

    if (adapter instanceof HeaderViewListAdapter) {
        adapter = ((HeaderViewListAdapter) adapter).getWrappedAdapter();
    }

    if (adapter instanceof Swappable) {
        ((Swappable) adapter).swapItems(indexOne - getHeaderViewsCount(), indexTwo - getHeaderViewsCount());
    }
}
 
Example #25
Source File: DynamicListView.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void swapElements(int indexOne, int indexTwo) {
    mLastMovedToIndex = indexTwo;
    ListAdapter adapter = getAdapter();

    if (adapter instanceof HeaderViewListAdapter) {
        adapter = ((HeaderViewListAdapter) adapter).getWrappedAdapter();
    }

    if (adapter instanceof Swappable) {
        ((Swappable) adapter).swapItems(indexOne - getHeaderViewsCount(), indexTwo - getHeaderViewsCount());
    }
}
 
Example #26
Source File: PagingListView.java    From PagingListView with Apache License 2.0 5 votes vote down vote up
public void setHasMoreItems(boolean hasMoreItems) {
    this.hasMoreItems = hasMoreItems;
    if (!this.hasMoreItems) {
        removeFooterView(loadingView);
    } else if (findViewById(R.id.loading_view) == null) {
        addFooterView(loadingView);
        ListAdapter adapter = ((HeaderViewListAdapter) getAdapter()).getWrappedAdapter();
        setAdapter(adapter);
    }
}
 
Example #27
Source File: DynamicListView.java    From ALLGO with Apache License 2.0 5 votes vote down vote up
private void swapElements(int indexOne, int indexTwo) {
	ListAdapter adapter = getAdapter();

	if (adapter instanceof HeaderViewListAdapter) {
		adapter = ((HeaderViewListAdapter) adapter).getWrappedAdapter();
	}

	if (adapter instanceof Swappable) {
		((Swappable) adapter).swapItems(indexOne - getHeaderViewsCount(), indexTwo - getHeaderViewsCount());
	}
}
 
Example #28
Source File: PeopleFeedFragment.java    From mage-android with Apache License 2.0 5 votes vote down vote up
/**
    * Zoom to map.
    * 
    */
@Override
public void onItemClick(AdapterView<?> adapter, View arg1, int position, long id) {
	HeaderViewListAdapter headerAdapter = (HeaderViewListAdapter)adapter.getAdapter();
	Cursor c = ((PeopleCursorAdapter) headerAdapter.getWrappedAdapter()).getCursor();
	c.moveToPosition(position);
	try {
		Location l = query.mapRow(new AndroidDatabaseResults(c, null, false));
		Intent profileView = new Intent(context, ProfileActivity.class);
		profileView.putExtra(ProfileActivity.USER_ID, l.getUser().getRemoteId());
		getActivity().startActivity(profileView);
	} catch (Exception e) {
		Log.e(LOG_NAME, "Problem.", e);
	}
}
 
Example #29
Source File: PagingListView.java    From PagingListView with Apache License 2.0 5 votes vote down vote up
public void onFinishLoading(boolean hasMoreItems, List<? extends Object> newItems) {
    setHasMoreItems(hasMoreItems);
    setIsLoading(false);
    if (newItems != null && newItems.size() > 0) {
        ListAdapter adapter = ((HeaderViewListAdapter) getAdapter()).getWrappedAdapter();
        if (adapter instanceof PagingBaseAdapter) {
            ((PagingBaseAdapter) adapter).addMoreItems(newItems);
        }
    }
}
 
Example #30
Source File: VideoListActivity.java    From android-viewer-for-khan-academy with GNU General Public License v3.0 5 votes vote down vote up
private VideoAdapter getUnwrappedAdapter() {
	if (listView != null) {
		ListAdapter adapter = listView.getAdapter();
		if (adapter instanceof HeaderViewListAdapter) {
			adapter = ((HeaderViewListAdapter) adapter).getWrappedAdapter();
		}
		if (adapter instanceof VideoAdapter) {
			return (VideoAdapter) adapter;
		}
	}
	
	return null;
}