Java Code Examples for android.widget.Adapter#getItemId()

The following examples show how to use android.widget.Adapter#getItemId() . 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: AdapterView.java    From android-tv-launcher with MIT License 6 votes vote down vote up
void rememberSyncState() {
	if (getChildCount() > 0) {
		this.mNeedSync = true;
		this.mSyncHeight = this.mLayoutHeight;
		View localView;
		if (this.mSelectedPosition >= 0) {
			localView = getChildAt(this.mSelectedPosition - this.mFirstPosition);
			this.mSyncRowId = this.mNextSelectedRowId;
			this.mSyncPosition = this.mNextSelectedPosition;
			if (localView != null)
				this.mSpecificTop = localView.getTop();
			this.mSyncMode = 0;
		} else {
			localView = getChildAt(0);
			Adapter localAdapter = getAdapter();
			if ((this.mFirstPosition >= 0) && (this.mFirstPosition < localAdapter.getCount()))
				this.mSyncRowId = localAdapter.getItemId(this.mFirstPosition);
			else
				this.mSyncRowId = -1L;
			this.mSyncPosition = this.mFirstPosition;
			if (localView != null)
				this.mSpecificTop = localView.getTop();
			this.mSyncMode = 1;
		}
	}
}
 
Example 2
Source File: AdapterView.java    From android-tv-launcher with MIT License 5 votes vote down vote up
int findSyncPosition() {
	int i = this.mItemCount;
	if (i == 0)
		return -1;
	long l1 = this.mSyncRowId;
	int j = this.mSyncPosition;
	if (l1 == -9223372036854775808L)
		return -1;
	j = Math.max(0, j);
	j = Math.min(i - 1, j);
	long l2 = SystemClock.uptimeMillis() + 100L;
	int k = j;
	int m = j;
	int n = 0;
	Adapter localAdapter = getAdapter();
	if (localAdapter == null)
		return -1;
	while (SystemClock.uptimeMillis() <= l2) {
		long l3 = localAdapter.getItemId(j);
		if (l3 == l1)
			return j;
		int i2 = m == i - 1 ? 1 : 0;
		int i1 = k == 0 ? 1 : 0;
		if ((i2 != 0) && (i1 != 0))
			break;
		if ((i1 != 0) || ((n != 0) && (i2 == 0))) {
			m++;
			j = m;
			n = 0;
		} else if ((i2 != 0) || ((n == 0) && (i1 == 0))) {
			k--;
			j = k;
			n = 1;
		}
	}
	return -1;
}
 
Example 3
Source File: AdapterViewAnimator.java    From adapterviewanimator with Apache License 2.0 5 votes vote down vote up
private void beforeDataSetChanged() {
  Adapter adapter = adapterView.getAdapter();
  final int firstVisiblePosition = adapterView.getFirstVisiblePosition();
  for (int i = 0, childCount = adapterView.getChildCount(); i < childCount; i++) {
    final int position = firstVisiblePosition + i;
    final long id = adapter.getItemId(position);
    final View child = adapterView.getChildAt(i);
    Rect r = new Rect(child.getLeft(), child.getTop(), child.getRight(), child.getBottom());
    child.setHasTransientState(true);
    viewBounds.put(id, r);
    idToViewMap.put(id, child);
  }
}
 
Example 4
Source File: AdapterView.java    From android-tv-launcher with MIT License 4 votes vote down vote up
public long getItemIdAtPosition(int paramInt) {
	Adapter localAdapter = getAdapter();
	return (localAdapter == null) || (paramInt < 0) ? -9223372036854775808L : localAdapter.getItemId(paramInt);
}
 
Example 5
Source File: AppGridItemClickListener.java    From YiBo with Apache License 2.0 4 votes vote down vote up
@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
		Adapter adapter = parent.getAdapter();
        long appImageId = adapter.getItemId(position);

        Activity context = (Activity)parent.getContext();
        Intent intent = new Intent();
        if (appImageId == R.drawable.icon_app_search) {
        	intent.setClass(context, SearchActivity.class);
        } else if (appImageId == R.drawable.icon_app_public_timeline) {
        	intent.setClass(context, PublicTimelineActivity.class);
        } else if (appImageId == R.drawable.icon_app_hot_retweet) {
        	intent.setClass(context, HotStatusesActivity.class);
        	intent.putExtra("STATUS_CATALOG", StatusCatalog.Hot_Retweet.getCatalogNo());
        } else if (appImageId == R.drawable.icon_app_hot_comment) {
        	intent.setClass(context, HotStatusesActivity.class); 
        	intent.putExtra("STATUS_CATALOG", StatusCatalog.Hot_Comment.getCatalogNo());
        } else if (appImageId == R.drawable.icon_app_hot_topic) {
        	//intent.setClass(context, HotTopicsActivity.class);
        	intent.setClass(context, StatusSubscribeActivity.class);
        	intent.putExtra("STATUS_CATALOG", StatusCatalog.Picture_Mobile.getCatalogNo());
        	intent.putExtra("TITLE_ID", R.string.label_app_hot_topic);
        } else if (appImageId == R.drawable.icon_app_daily) {
        	intent.setClass(context, StatusSubscribeActivity.class);
        	intent.putExtra("STATUS_CATALOG", StatusCatalog.News.getCatalogNo());
        	intent.putExtra("TITLE_ID", R.string.label_app_daily);
        } else if (appImageId == R.drawable.icon_app_image) {
        	intent.setClass(context, StatusSubscribeActivity.class);
        	intent.putExtra("STATUS_CATALOG", StatusCatalog.Picture.getCatalogNo());
        	intent.putExtra("TITLE_ID", R.string.label_app_image);
        } else if (appImageId == R.drawable.icon_app_jokes) {
        	intent.setClass(context, StatusSubscribeActivity.class);
        	intent.putExtra("STATUS_CATALOG", StatusCatalog.Joke.getCatalogNo());
        	intent.putExtra("TITLE_ID", R.string.label_app_jokes);
        } else if (appImageId == R.drawable.icon_app_exchange) {
        	ConfigSystemDao configDao = new ConfigSystemDao(context);
		    String username = configDao.getString(Constants.PASSPORT_USERNAME);
//		    if (StringUtil.isEmpty(username)) {
//      	          AppConnect.getInstance(context).showOffers(context);
//      	    } else {
//      		  AppConnect.getInstance(context).showOffers(context, username);
//            }
      	    return;
        } else {
        	Toast.makeText(context, "抱歉,此功能正在开发中..", Toast.LENGTH_LONG).show();
        	return;
        }

        context.startActivity(intent);
	}