Java Code Examples for android.widget.ListView#INVALID_POSITION

The following examples show how to use android.widget.ListView#INVALID_POSITION . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
@Override
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
    infoListAdapter.swapCursor(cursor);
    if (mPosition != ListView.INVALID_POSITION) {
        listView.smoothScrollToPosition(mPosition);
    }
    try {
        TextView info = (TextView) rootView.findViewById(R.id.empty);
        if (infoListAdapter.getCount() == 0) {
            info.setText(R.string.list_empty_info);
            info.setVisibility(View.VISIBLE);
        } else {
            info.setVisibility(View.GONE);
        }
    } catch (Exception ignored) {
    }
}
 
Example 2
Source Project: android-discourse   File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
protected void siteChanged(RadioGroup group, int checkedId) {
    if (checkedId == -1) {
        return;
    }
    RadioButton button = (RadioButton) group.findViewById(checkedId);
    Site site = (Site) button.getTag();
    if (site != null) {
        App.setSiteUrl(site.getUrl());
    }
    if (site == null) {
        group.clearCheck();
        openSettingsActivity();
    } else if (!site.getUrl().equals(mCurrentSiteUrl)) { // TODO 第一次启动 加载上次查看的url。
        mDrawerPosition = ListView.INVALID_POSITION;
        mCurrentSite = site;
        mCurrentSiteUrl = site.getUrl();
        PrefsUtils.setCurrentSiteUrl(mCurrentSiteUrl);
        App.setLogin(false);
        clearDatabase();
        // 登陆完成后,再加载其他信息
        loadUserInfo(site, false);
    } else {
        setupUserInfo(mUser);
    }
    getActionBar().setSubtitle(mCurrentSiteUrl);
}
 
Example 3
@Override
public void onSaveInstanceState(Bundle outState) {
	super.onSaveInstanceState(outState);
	if (mActivatedPosition != ListView.INVALID_POSITION) {
		// Serialize and persist the activated item position.
		outState.putInt(STATE_ACTIVATED_POSITION, mActivatedPosition);
	}
}
 
Example 4
private void setActivatedPosition(int position) {
    if (position == ListView.INVALID_POSITION) {
        getListView().setItemChecked(mActivatedPosition, false);
    } else {
        getListView().setItemChecked(position, true);
    }

    mActivatedPosition = position;
}
 
Example 5
private void resetSwipeState() {
	if (mVelocityTracker != null) {
		mVelocityTracker.recycle();
	}
	mVelocityTracker = null;
	mDownX = 0;
	mDownY = 0;
	mDownView = null;
	mDownPosition = ListView.INVALID_POSITION;
	mSwiping = false;
}
 
Example 6
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (mActivatedPosition != ListView.INVALID_POSITION) {
        // Serialize and persist the activated item position.
        outState.putInt(STATE_ACTIVATED_POSITION, mActivatedPosition);
    }
}
 
Example 7
public void onItemClick(AdapterView<?> arg0, View view, int posicion, long id) {
	
	if (posicion == ListView.INVALID_POSITION)
		return;
	
	Restaurante restaurante = listaRestaurantes.get(posicion);
	
	Intent i = new Intent(this, Mapa.class);
	i.putExtra("latitud", restaurante.getLatitud());
	i.putExtra("longitud", restaurante.getLongitud());
	i.putExtra("nombre", restaurante.getNombre());
	startActivity(i);
	
}
 
Example 8
@Override
public void onSaveInstanceState(Bundle outState)
{
  super.onSaveInstanceState(outState);
  if (mActivatedPosition != ListView.INVALID_POSITION)
    outState.putInt(STATE_ACTIVATED_POSITION, mActivatedPosition);
}
 
Example 9
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    if (mAlwaysUseOption) {
        final int checkedPos = mListView.getCheckedItemPosition();
        final boolean enabled = checkedPos != ListView.INVALID_POSITION;
        mLastSelected = checkedPos;
        mAlwaysButton.setEnabled(enabled);
        mOnceButton.setEnabled(enabled);
        if (enabled) {
            mListView.setSelection(checkedPos);
        }
    }
}
 
Example 10
private void setActivatedPosition(int position) {
    // //Log.d(TAG, "ListFragment  SETACTIVATED");
    if (position == ListView.INVALID_POSITION) {
        mListView.setItemChecked(mActivatedPosition, false);
    } else {
        mListView.setItemChecked(position, true);
    }
    mActivatedPosition = position;
}
 
Example 11
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (mActivatedPosition != ListView.INVALID_POSITION) {
        // Serialize and persist the activated item position.
        outState.putInt(STATE_ACTIVATED_POSITION, mActivatedPosition);
    }
}
 
Example 12
public void onItemClick(AdapterView<?> arg0, View view, int posicion, long id) {

        if (posicion == ListView.INVALID_POSITION)
            return;

        Restaurante restaurante = listaRestaurantes.get(posicion);

        Intent i = new Intent(this, Mapa.class);
        i.putExtra("latitud", restaurante.getLatitud());
        i.putExtra("longitud", restaurante.getLongitud());
        i.putExtra("nombre", restaurante.getNombre());
        startActivity(i);

    }
 
Example 13
@Override
public void onSaveInstanceState(Bundle outState)
{
   super.onSaveInstanceState(outState);
   if (mActivatedPosition != ListView.INVALID_POSITION) {
      // Serialize and persist the activated item position.
      outState.putInt(STATE_ACTIVATED_POSITION, mActivatedPosition);
   }
}
 
Example 14
private void setActivatedPosition(int position) {
    if (position == ListView.INVALID_POSITION) {
        getListView().setItemChecked(mActivatedPosition, false);
    } else {
        getListView().setItemChecked(position, true);
    }

    mActivatedPosition = position;
}
 
Example 15
private void setActivatedPosition(int position) {
	if (position == ListView.INVALID_POSITION) {
		getListView().setItemChecked(mActivatedPosition, false);
	} else {
		getListView().setItemChecked(position, true);
	}

	mActivatedPosition = position;
}
 
Example 16
@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putParcelableArrayList("infoList", infoList);
    if (mPosition != ListView.INVALID_POSITION) {
        outState.putInt(SELECTED_KEY, mPosition);
    }
    super.onSaveInstanceState(outState);
}
 
Example 17
private ViewHolder getViewHolderByView(View view) {
    try {
        final int position = listView.getPositionForView(view);
        if (position == ListView.INVALID_POSITION) {
            return null;
        }
        return getViewHolderByView(position);
    } catch (NullPointerException e) {

    }
    return null;
}
 
Example 18
/**
 * Notifies onClickBackView
 *
 * @param position back item clicked
 */
protected void onClickBackView(int position) {
    if (swipeListViewListener != null && position != ListView.INVALID_POSITION) {
        swipeListViewListener.onClickBackView(position);
    }
}
 
Example 19
protected int changeSwipeMode(int position) {
    if (swipeListViewListener != null && position != ListView.INVALID_POSITION) {
        return swipeListViewListener.onChangeSwipeMode(position);
    }
    return SWIPE_MODE_DEFAULT;
}
 
Example 20
/**
 * Start close item
 *
 * @param position list item
 * @param right    na
 */
protected void onStartClose(int position, boolean right) {
    if (swipeListViewListener != null && position != ListView.INVALID_POSITION) {
        swipeListViewListener.onStartClose(position, right);
    }
}