Java Code Examples for android.widget.AdapterView#getItemIdAtPosition()

The following examples show how to use android.widget.AdapterView#getItemIdAtPosition() . 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: bilibili.java    From stynico with MIT License 6 votes vote down vote up
/**
    * Send a click event if parent view is a Listview instance
    *
    * @param isLongClick Is the event a long click ?
    */
   private void sendClickEvent(final Boolean isLongClick)
{
       if (getParent() instanceof AdapterView)
	{
           final AdapterView adapterView = (AdapterView) getParent();
           final int position = adapterView.getPositionForView(this);
           final long id = adapterView.getItemIdAtPosition(position);
           if (isLongClick)
		{
               if (adapterView.getOnItemLongClickListener() != null)
                   adapterView.getOnItemLongClickListener().onItemLongClick(adapterView, this, position, id);
           }
		else
		{
               if (adapterView.getOnItemClickListener() != null)
                   adapterView.getOnItemClickListener().onItemClick(adapterView, this, position, id);
           }
       }
   }
 
Example 2
Source File: RippleView.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
/**
 * Send a click event if parent view is a Listview instance
 *
 * @param isLongClick Is the event a long click ?
 */
private void sendClickEvent(final Boolean isLongClick) {
    if (getParent() instanceof AdapterView) {
        System.out.println("ripple>>>>>>>>>>>>>>");
        final AdapterView adapterView = (AdapterView) getParent();
        final int position = adapterView.getPositionForView(this);
        final long id = adapterView.getItemIdAtPosition(position);
        if (isLongClick) {
            if (adapterView.getOnItemLongClickListener() != null)
                adapterView.getOnItemLongClickListener().onItemLongClick(adapterView, this, position, id);
        } else {
            if (adapterView.getOnItemClickListener() != null)
                adapterView.getOnItemClickListener().onItemClick(adapterView, this, position, id);
        }
    }
}
 
Example 3
Source File: RippleView.java    From iGap-Android with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Send a click event if parent view is a Listview instance
 *
 * @param isLongClick Is the event a long click ?
 */
private void sendClickEvent(final Boolean isLongClick) {
    if (getParent() instanceof AdapterView) {
        final AdapterView adapterView = (AdapterView) getParent();
        final int position = adapterView.getPositionForView(this);
        final long id = adapterView.getItemIdAtPosition(position);
        if (isLongClick) {
            if (adapterView.getOnItemLongClickListener() != null) {
                adapterView.getOnItemLongClickListener().onItemLongClick(adapterView, this, position, id);
            }
        } else {
            if (adapterView.getOnItemClickListener() != null) {
                adapterView.getOnItemClickListener().onItemClick(adapterView, this, position, id);
            }
        }
    }
}
 
Example 4
Source File: RippleView.java    From a with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Send a click event if parent view is a Listview instance
 *
 * @param isLongClick Is the event a long click ?
 */
private void sendClickEvent(final Boolean isLongClick) {
    if (getParent() instanceof AdapterView) {
        final AdapterView adapterView = (AdapterView) getParent();
        final int position = adapterView.getPositionForView(this);
        final long id = adapterView.getItemIdAtPosition(position);
        if (isLongClick) {
            if (adapterView.getOnItemLongClickListener() != null)
                adapterView.getOnItemLongClickListener().onItemLongClick(adapterView, this, position, id);
        } else {
            if (adapterView.getOnItemClickListener() != null)
                adapterView.getOnItemClickListener().onItemClick(adapterView, this, position, id);
        }
    }
}
 
Example 5
Source File: RippleView.java    From timecat with Apache License 2.0 5 votes vote down vote up
/**
 * Send a click event if parent view is a Listview instance
 *
 * @param isLongClick Is the event a long click ?
 */
private void sendClickEvent(final Boolean isLongClick) {
    if (getParent() instanceof AdapterView) {
        final AdapterView adapterView = (AdapterView) getParent();
        final int position = adapterView.getPositionForView(this);
        final long id = adapterView.getItemIdAtPosition(position);
        if (isLongClick) {
            if (adapterView.getOnItemLongClickListener() != null)
                adapterView.getOnItemLongClickListener().onItemLongClick(adapterView, this, position, id);
        } else {
            if (adapterView.getOnItemClickListener() != null)
                adapterView.getOnItemClickListener().onItemClick(adapterView, this, position, id);
        }
    }
}
 
Example 6
Source File: SwipeLayout.java    From StickyListHeadersWithRefreshAndLoadMore with Apache License 2.0 5 votes vote down vote up
private boolean performAdapterViewItemLongClick() {
    if (getOpenStatus() != Status.Close) return false;
    ViewParent t = getParent();
    if (t instanceof AdapterView) {
        AdapterView view = (AdapterView) t;
        int p = view.getPositionForView(SwipeLayout.this);
        if (p == AdapterView.INVALID_POSITION) return false;
        long vId = view.getItemIdAtPosition(p);
        boolean handled = false;
        try {
            Method m = AbsListView.class.getDeclaredMethod("performLongPress", View.class, int.class, long.class);
            m.setAccessible(true);
            handled = (boolean) m.invoke(view, SwipeLayout.this, p, vId);

        } catch (Exception e) {
            e.printStackTrace();

            if (view.getOnItemLongClickListener() != null) {
                handled = view.getOnItemLongClickListener().onItemLongClick(view, SwipeLayout.this, p, vId);
            }
            if (handled) {
                view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
        }
        return handled;
    }
    return false;
}
 
Example 7
Source File: SwipeItemLayout.java    From IndexRecyclerView with Apache License 2.0 5 votes vote down vote up
private boolean performAdapterViewItemLongClick() {
    ViewParent t = getParent();
    if (t instanceof AdapterView) {
        AdapterView view = (AdapterView) t;
        int p = view.getPositionForView(SwipeItemLayout.this);
        if (p == AdapterView.INVALID_POSITION) return false;
        long vId = view.getItemIdAtPosition(p);
        boolean handled = false;
        try {
            Method m = AbsListView.class.getDeclaredMethod("performLongPress", View.class, int.class, long.class);
            m.setAccessible(true);
            handled = (boolean) m.invoke(view, SwipeItemLayout.this, p, vId);

        } catch (Exception e) {
            e.printStackTrace();

            if (view.getOnItemLongClickListener() != null) {
                handled = view.getOnItemLongClickListener().onItemLongClick(view, SwipeItemLayout.this, p, vId);
            }
            if (handled) {
                view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
        }
        return handled;
    }
    return false;
}
 
Example 8
Source File: RippleView.java    From MaterialPageStateLayout with MIT License 5 votes vote down vote up
/**
 * Send a click event if parent view is a Listview instance
 *
 * @param isLongClick Is the event a long click ?
 */
private void sendClickEvent(final Boolean isLongClick) {
    if (getParent() instanceof AdapterView) {
        final AdapterView adapterView = (AdapterView) getParent();
        final int position = adapterView.getPositionForView(this);
        final long id = adapterView.getItemIdAtPosition(position);
        if (isLongClick) {
            if (adapterView.getOnItemLongClickListener() != null)
                adapterView.getOnItemLongClickListener().onItemLongClick(adapterView, this, position, id);
        } else {
            if (adapterView.getOnItemClickListener() != null)
                adapterView.getOnItemClickListener().onItemClick(adapterView, this, position, id);
        }
    }
}
 
Example 9
Source File: RippleView.java    From BaseProject with Apache License 2.0 5 votes vote down vote up
/**
 * Send a click event if parent view is a Listview instance
 *
 * @param isLongClick Is the event a long click ?
 */
private void sendClickEvent(final Boolean isLongClick) {
    if (getParent() instanceof AdapterView) {
        final AdapterView adapterView = (AdapterView) getParent();
        final int position = adapterView.getPositionForView(this);
        final long id = adapterView.getItemIdAtPosition(position);
        if (isLongClick) {
            if (adapterView.getOnItemLongClickListener() != null)
                adapterView.getOnItemLongClickListener().onItemLongClick(adapterView, this, position, id);
        } else {
            if (adapterView.getOnItemClickListener() != null)
                adapterView.getOnItemClickListener().onItemClick(adapterView, this, position, id);
        }
    }
}
 
Example 10
Source File: SwipeViewLayout.java    From UltimateSwipeTool with Apache License 2.0 5 votes vote down vote up
private boolean performAdapterViewItemLongClick() {
    if (getOpenStatus() != Status.Close) return false;
    ViewParent t = getParent();
    if (t instanceof AdapterView) {
        AdapterView view = (AdapterView) t;
        int p = view.getPositionForView(SwipeViewLayout.this);
        if (p == AdapterView.INVALID_POSITION) return false;
        long vId = view.getItemIdAtPosition(p);
        boolean handled = false;
        try {
            Method m = AbsListView.class.getDeclaredMethod("performLongPress", View.class, int.class, long.class);
            m.setAccessible(true);
            handled = (boolean) m.invoke(view, SwipeViewLayout.this, p, vId);

        } catch (Exception e) {
            e.printStackTrace();

            if (view.getOnItemLongClickListener() != null) {
                handled = view.getOnItemLongClickListener().onItemLongClick(view, SwipeViewLayout.this, p, vId);
            }
            if (handled) {
                view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
        }
        return handled;
    }
    return false;
}
 
Example 11
Source File: RippleView.java    From DoubanTop with Apache License 2.0 5 votes vote down vote up
/**
 * Send a click event if parent view is a Listview instance
 *
 * @param isLongClick Is the event a long click ?
 */
private void sendClickEvent(final Boolean isLongClick) {
    if (getParent() instanceof AdapterView) {
        final AdapterView adapterView = (AdapterView) getParent();
        final int position = adapterView.getPositionForView(this);
        final long id = adapterView.getItemIdAtPosition(position);
        if (isLongClick) {
            if (adapterView.getOnItemLongClickListener() != null)
                adapterView.getOnItemLongClickListener().onItemLongClick(adapterView, this, position, id);
        } else {
            if (adapterView.getOnItemClickListener() != null)
                adapterView.getOnItemClickListener().onItemClick(adapterView, this, position, id);
        }
    }
}
 
Example 12
Source File: RippleView.java    From Conquer with Apache License 2.0 5 votes vote down vote up
/**
 * Send a click event if parent view is a Listview instance
 *
 * @param isLongClick Is the event a long click ?
 */
private void sendClickEvent(final Boolean isLongClick) {
    if (getParent() instanceof AdapterView) {
        final AdapterView adapterView = (AdapterView) getParent();
        final int position = adapterView.getPositionForView(this);
        final long id = adapterView.getItemIdAtPosition(position);
        if (isLongClick) {
            if (adapterView.getOnItemLongClickListener() != null)
                adapterView.getOnItemLongClickListener().onItemLongClick(adapterView, this, position, id);
        } else {
            if (adapterView.getOnItemClickListener() != null)
                adapterView.getOnItemClickListener().onItemClick(adapterView, this, position, id);
        }
    }
}
 
Example 13
Source File: SwipeLayout.java    From UltimateRecyclerView with Apache License 2.0 5 votes vote down vote up
private boolean performAdapterViewItemLongClick() {
    if (getOpenStatus() != Status.Close) return false;
    ViewParent t = getParent();
    if (t instanceof AdapterView) {
        AdapterView view = (AdapterView) t;
        int p = view.getPositionForView(SwipeLayout.this);
        if (p == AdapterView.INVALID_POSITION) return false;
        long vId = view.getItemIdAtPosition(p);
        boolean handled = false;
        try {
            Method m = AbsListView.class.getDeclaredMethod("performLongPress", View.class, int.class, long.class);
            m.setAccessible(true);
            handled = (boolean) m.invoke(view, SwipeLayout.this, p, vId);

        } catch (Exception e) {
            e.printStackTrace();

            if (view.getOnItemLongClickListener() != null) {
                handled = view.getOnItemLongClickListener().onItemLongClick(view, SwipeLayout.this, p, vId);
            }
            if (handled) {
                view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
        }
        return handled;
    }
    return false;
}
 
Example 14
Source File: SwipeLayout.java    From AndroidSwipeLayout with MIT License 5 votes vote down vote up
private boolean performAdapterViewItemLongClick() {
    if (getOpenStatus() != Status.Close) return false;
    ViewParent t = getParent();
    if (t instanceof AdapterView) {
        AdapterView view = (AdapterView) t;
        int p = view.getPositionForView(SwipeLayout.this);
        if (p == AdapterView.INVALID_POSITION) return false;
        long vId = view.getItemIdAtPosition(p);
        boolean handled = false;
        try {
            Method m = AbsListView.class.getDeclaredMethod("performLongPress", View.class, int.class, long.class);
            m.setAccessible(true);
            handled = (boolean) m.invoke(view, SwipeLayout.this, p, vId);

        } catch (Exception e) {
            e.printStackTrace();

            if (view.getOnItemLongClickListener() != null) {
                handled = view.getOnItemLongClickListener().onItemLongClick(view, SwipeLayout.this, p, vId);
            }
            if (handled) {
                view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
        }
        return handled;
    }
    return false;
}
 
Example 15
Source File: RippleView.java    From RippleEffect with MIT License 5 votes vote down vote up
/**
 * Send a click event if parent view is a Listview instance
 *
 * @param isLongClick Is the event a long click ?
 */
private void sendClickEvent(final Boolean isLongClick) {
    if (getParent() instanceof AdapterView) {
        final AdapterView adapterView = (AdapterView) getParent();
        final int position = adapterView.getPositionForView(this);
        final long id = adapterView.getItemIdAtPosition(position);
        if (isLongClick) {
            if (adapterView.getOnItemLongClickListener() != null)
                adapterView.getOnItemLongClickListener().onItemLongClick(adapterView, this, position, id);
        } else {
            if (adapterView.getOnItemClickListener() != null)
                adapterView.getOnItemClickListener().onItemClick(adapterView, this, position, id);
        }
    }
}