Example usage for android.widget AdapterView INVALID_POSITION

List of usage examples for android.widget AdapterView INVALID_POSITION

Introduction

In this page you can find the example usage for android.widget AdapterView INVALID_POSITION.

Prototype

int INVALID_POSITION

To view the source code for android.widget AdapterView INVALID_POSITION.

Click Source Link

Document

Represents an invalid position.

Usage

From source file:com.game.sns.view.swipelist.SwipeListView.java

/**
 * Notifies onClickBackView/*from  ww w  .  j a  v a 2s .c om*/
 * 
 * @param position
 *            back item clicked
 */
protected void onClickBackView(int position) {
    if (swipeListViewListener != null && position != AdapterView.INVALID_POSITION) {
        swipeListViewListener.onClickBackView(position);
    }
}

From source file:com.game.sns.view.swipelist.SwipeListView.java

/**
 * Notifies onOpened/*from   www  .j av a  2  s  .c o  m*/
 * 
 * @param position
 *            Item opened
 * @param toRight
 *            If should be opened toward the right
 */
protected void onOpened(int position, boolean toRight) {
    if (swipeListViewListener != null && position != AdapterView.INVALID_POSITION) {
        swipeListViewListener.onOpened(position, toRight);
    }
}

From source file:com.game.sns.view.swipelist.SwipeListView.java

/**
 * Notifies onClosed/* w w  w . j  a  va2  s . c  o m*/
 * 
 * @param position
 *            Item closed
 * @param fromRight
 *            If open from right
 */
protected void onClosed(int position, boolean fromRight) {
    if (swipeListViewListener != null && position != AdapterView.INVALID_POSITION) {
        swipeListViewListener.onClosed(position, fromRight);
    }
}

From source file:uk.org.rivernile.edinburghbustracker.android.fragments.general.FavouriteStopsFragment.java

/**
 * {@inheritDoc}/* w  w w. ja  v a2 s.com*/
 */
@Override
public void onClick(final View v) {
    final int position = getListView().getPositionForView(v);
    if (position != AdapterView.INVALID_POSITION) {
        final Cursor c = ca.getCursor();
        if (c != null && c.moveToPosition(position)) {
            callbacks.onShowConfirmFavouriteDeletion(c.getString(0));
        }
    }
}

From source file:com.game.sns.view.swipelist.SwipeListView.java

/**
 * Notifies onChoiceChanged//  w w  w.  j a v  a  2  s . c o  m
 * 
 * @param position
 *            position that choice
 * @param selected
 *            if item is selected or not
 */
protected void onChoiceChanged(int position, boolean selected) {
    if (swipeListViewListener != null && position != AdapterView.INVALID_POSITION) {
        swipeListViewListener.onChoiceChanged(position, selected);
    }
}

From source file:com.example.alyshia.customsimplelauncher.launcher.GridFragment.java

private void ensureGrid() {
    if (mGrid != null) {
        return;/*  w  w  w.  j av a2s  .  c om*/
    }
    View root = getView();
    if (root == null) {
        throw new IllegalStateException("Content view not yet created");
    }
    if (root instanceof GridView) {
        mGrid = (GridView) root;
    } else {
        mStandardEmptyView = (TextView) root.findViewById(INTERNAL_EMPTY_ID);
        if (mStandardEmptyView == null) {
            mEmptyView = root.findViewById(android.R.id.empty);
        } else {
            mStandardEmptyView.setVisibility(View.GONE);
        }
        mProgressContainer = root.findViewById(INTERNAL_PROGRESS_CONTAINER_ID);
        mGridContainer = root.findViewById(INTERNAL_LIST_CONTAINER_ID);
        View rawGridView = root.findViewById(android.R.id.list);
        if (!(rawGridView instanceof GridView)) {
            if (rawGridView == null) {
                throw new RuntimeException(
                        "Your content must have a GridView whose id attribute is " + "'android.R.id.list'");
            }
            throw new RuntimeException(
                    "Content has view with id attribute 'android.R.id.list' " + "that is not a GridView class");
        }
        mGrid = (GridView) rawGridView;
        if (mEmptyView != null) {
            mGrid.setEmptyView(mEmptyView);
        } else if (mEmptyText != null) {
            mStandardEmptyView.setText(mEmptyText);
            mGrid.setEmptyView(mStandardEmptyView);
        }
    }
    mGridShown = true;
    mGrid.setOnItemClickListener(mOnClickListener);
    mGrid.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            final int action = MotionEventCompat.getActionMasked(event);
            Log.d("ME", "action is " + action);
            switch (action) {
            case MotionEvent.ACTION_DOWN:
                Log.d("CLICK", "ACTION_DOWN");

                mLastMotionX = event.getX();
                mLastMotionY = event.getY(); //   

                int _x = Math.round(mLastMotionX);
                int _y = Math.round(mLastMotionY);

                postCheckForLongClick(600); //  Long click message 

                if (mGrid.pointToPosition(_x, _y) == AdapterView.INVALID_POSITION) {
                    //empty spot.
                    Log.d("grid", "emtpdyspot " + mGrid.pointToPosition(_x, _y));

                } else {
                    Log.d("grid", "reomo" + +mGrid.pointToPosition(_x, _y));
                    removeLongPressCallback();

                }
                break;

            case MotionEvent.ACTION_SCROLL:
                Log.d("CLICK", "action scroll");
                removeLongPressCallback();
                break;

            case MotionEvent.ACTION_MOVE:
                Log.d("CLICK", "ACTION_MOVE");

                final float x = event.getX();
                final float y = event.getY();
                final int deltaX = Math.abs((int) (mLastMotionX - x));
                final int deltaY = Math.abs((int) (mLastMotionY - y));

                if (deltaX >= mTouchSlop || deltaY >= mTouchSlop) {
                    if (!mHasPerformedLongPress) {
                        removeLongPressCallback();
                    }

                }

                break;

            case MotionEvent.ACTION_CANCEL:
                if (!mHasPerformedLongPress) {
                    removeLongPressCallback();
                }
                break;

            case MotionEvent.ACTION_OUTSIDE:
                if (!mHasPerformedLongPress) {
                    removeLongPressCallback();
                }
                break;
            case MotionEvent.ACTION_UP:
                Log.d("CLICK", "ACTION_UP");

                if (!mHasPerformedLongPress) {
                    removeLongPressCallback();

                    if (timeout) {
                        Log.d("CLICK", "timeout");
                        return true;
                    } else {
                        Log.d("CLICK", " no time out");
                    }

                }

                break;

            default:
                break;
            }

            return false;
        }
    });
    if (mAdapter != null) {
        ListAdapter adapter = mAdapter;
        mAdapter = null;
        setGridAdapter(adapter);
    } else {
        // We are starting without an adapter, so assume we won't
        // have our data right away and start with the progress indicator.
        if (mProgressContainer != null) {
            setGridShown(false, false);
        }
    }
    mHandler.post(mRequestFocus);
}

From source file:com.game.sns.view.swipelist.SwipeListView.java

/**
 * Notifies onMove/*www.j  ava  2s  . co m*/
 * 
 * @param position
 *            Item moving
 * @param x
 *            Current position
 */
protected void onMove(int position, float x) {
    if (swipeListViewListener != null && position != AdapterView.INVALID_POSITION) {
        swipeListViewListener.onMove(position, x);
    }
}

From source file:com.money.manager.ex.fragment.SearchFragment.java

/**
 * Compose arguments and execute search/*from  ww w.  j  a  v  a  2 s.  com*/
 */
public void executeSearch() {
    ArrayList<String> whereClause = new ArrayList<String>();
    //account
    if (spinAccount.getSelectedItemPosition() != AdapterView.INVALID_POSITION
            && mAccountIdList.get(spinAccount.getSelectedItemPosition()) != -1) {
        whereClause.add(
                ViewMobileData.ACCOUNTID + "=" + mAccountIdList.get(spinAccount.getSelectedItemPosition()));
    }
    //checkbox
    if (cbxDeposit.isChecked() || cbxTransfer.isChecked() || cbxWithdrawal.isChecked()) {
        whereClause.add(ViewMobileData.TransactionType + " IN (" + (cbxDeposit.isChecked() ? "'Deposit'" : "''")
                + "," + (cbxTransfer.isChecked() ? "'Transfer'" : "''") + ","
                + (cbxWithdrawal.isChecked() ? "'Withdrawal'" : "''") + ")");
    }
    //status
    if (spinStatus.getSelectedItemPosition() > 0) {
        whereClause.add(
                ViewMobileData.Status + "='" + mStatusValues.get(spinStatus.getSelectedItemPosition()) + "'");
    }
    //from date
    if (!TextUtils.isEmpty(txtFromDate.getText())) {
        whereClause.add(ViewMobileData.Date + ">='" + mApplication.getSQLiteStringDate(
                mApplication.getDateFromString(String.valueOf(txtFromDate.getText()))) + "'");
    }
    //to date
    if (!TextUtils.isEmpty(txtToDate.getText())) {
        whereClause.add(ViewMobileData.Date + "<='" + mApplication.getSQLiteStringDate(
                mApplication.getDateFromString(String.valueOf(txtToDate.getText()))) + "'");
    }
    //payee
    if (txtSelectPayee.getTag() != null) {
        whereClause.add(ViewMobileData.PayeeID + "=" + String.valueOf(txtSelectPayee.getTag()));
    }
    //categories
    if (txtSelectCategory.getTag() != null) {
        CategorySub categorySub = (CategorySub) txtSelectCategory.getTag();
        whereClause.add(ViewMobileData.CategID + "=" + categorySub.categId);
        if (categorySub.subCategId != -1)
            whereClause.add(ViewMobileData.SubcategID + "=" + categorySub.subCategId);
    }
    //from amount
    if (txtFromAmount.getTag() != null) {
        whereClause.add(ViewMobileData.Amount + ">=" + String.valueOf(txtFromAmount.getTag()));
    }
    //to amount
    if (txtToAmount.getTag() != null) {
        whereClause.add(ViewMobileData.Amount + "<=" + String.valueOf(txtToAmount.getTag()));
    }
    //transaction number
    if (!TextUtils.isEmpty(edtTransNumber.getText())) {
        whereClause.add(ViewMobileData.TransactionNumber + " LIKE '" + edtTransNumber.getText() + "'");
    }
    //note
    if (!TextUtils.isEmpty(edtNotes.getText())) {
        whereClause.add(ViewMobileData.Notes + " LIKE '" + edtNotes.getText() + "'");
    }
    //create a fragment search
    AllDataFragment fragment;
    fragment = (AllDataFragment) getSherlockActivity().getSupportFragmentManager()
            .findFragmentByTag(AllDataFragment.class.getSimpleName());
    if (fragment != null) {
        getSherlockActivity().getSupportFragmentManager().beginTransaction().remove(fragment).commit();
    }
    fragment = AllDataFragment.newInstance(-1);
    //create bundle
    Bundle args = new Bundle();
    args.putStringArrayList(AllDataFragment.KEY_ARGUMENTS_WHERE, whereClause);
    args.putString(AllDataFragment.KEY_ARGUMENTS_SORT, QueryAllData.ACCOUNTID + ", " + QueryAllData.ID);
    //set arguments
    fragment.setArguments(args);
    fragment.setSearResultFragmentLoaderCallbacks((SearchActivity) getSherlockActivity());
    fragment.setShownHeader(true);
    //add fragment
    FragmentTransaction transaction = getSherlockActivity().getSupportFragmentManager().beginTransaction();
    //animation
    transaction.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left, R.anim.slide_in_right,
            R.anim.slide_out_left);
    // Replace whatever is in the fragment_container view with this fragment,
    // and add the transaction to the back stack
    if (isDualPanel()) {
        transaction.add(R.id.fragmentDetail, fragment, AllDataFragment.class.getSimpleName());
    } else {
        transaction.replace(R.id.fragmentContent, fragment, AllDataFragment.class.getSimpleName());
        transaction.addToBackStack(null);
    }
    // Commit the transaction
    transaction.commit();
}

From source file:com.game.sns.view.swipelist.SwipeListView.java

protected int changeSwipeMode(int position) {
    if (swipeListViewListener != null && position != AdapterView.INVALID_POSITION) {
        return swipeListViewListener.onChangeSwipeMode(position);
    }/*ww  w.  j  ava 2 s  .c o  m*/
    return SWIPE_MODE_DEFAULT;
}

From source file:com.money.manager.ex.search.SearchFragment.java

private SearchParameters collectSearchCriteria() {
    if (getView() == null) {
        return getSearchParameters();
    }/*from w  ww .  j av a  2  s .c om*/

    SearchParameters searchParameters = getSearchParameters();

    // Account
    if (this.spinAccount != null) {
        int selectedAccountPosition = spinAccount.getSelectedItemPosition();
        if (selectedAccountPosition != AdapterView.INVALID_POSITION) {
            int selectedAccountId = mAccountIdList.get(selectedAccountPosition);
            if (selectedAccountId != Constants.NOT_SET) {
                searchParameters.accountId = selectedAccountId;
            }
        }
    }

    // Transaction Type
    searchParameters.deposit = cbxDeposit.isChecked();
    searchParameters.transfer = cbxTransfer.isChecked();
    searchParameters.withdrawal = cbxWithdrawal.isChecked();

    // Status
    if (spinStatus.getSelectedItemPosition() > 0) {
        searchParameters.status = mStatusValues.get(spinStatus.getSelectedItemPosition());
    }

    // Amount from
    Object tag = txtFromAmount.getTag();
    if (tag != null) {
        searchParameters.amountFrom = MoneyFactory.fromString((String) tag);
    }
    // Amount to
    tag = txtToAmount.getTag();
    if (tag != null) {
        searchParameters.amountTo = MoneyFactory.fromString((String) tag);
    }

    // Date from
    if (txtDateFrom.getTag() != null) {
        searchParameters.dateFrom = new DateTime(txtDateFrom.getTag().toString());
    }
    // Date to
    if (txtDateTo.getTag() != null) {
        String dateString = txtDateTo.getTag().toString();
        searchParameters.dateTo = MmxDateTimeUtils.from(dateString);
    }
    // Payee
    if (txtSelectPayee.getTag() != null) {
        searchParameters.payeeId = Integer.parseInt(txtSelectPayee.getTag().toString());
        searchParameters.payeeName = txtSelectPayee.getText().toString();
    }
    // Category
    if (txtSelectCategory.getTag() != null) {
        searchParameters.category = (CategorySub) txtSelectCategory.getTag();
    }
    // Transaction number
    if (!TextUtils.isEmpty(txtTransNumber.getText())) {
        searchParameters.transactionNumber = txtTransNumber.getText().toString();
    }
    // Notes
    if (!TextUtils.isEmpty(txtNotes.getText())) {
        searchParameters.notes = txtNotes.getText().toString();
    }

    return searchParameters;
}