Example usage for android.widget ListPopupWindow getSelectedItemPosition

List of usage examples for android.widget ListPopupWindow getSelectedItemPosition

Introduction

In this page you can find the example usage for android.widget ListPopupWindow getSelectedItemPosition.

Prototype

public int getSelectedItemPosition() 

Source Link

Usage

From source file:com.duy.pascal.ui.editor.view.CodeSuggestsEditText.java

private void performCompletion(View selectedView, int position, long id) {
    if (isPopupShowing()) {
        Object selectedItem;/* ww  w .  ja  v a2  s. c  om*/
        if (position < 0) {
            selectedItem = mPopup.getSelectedItem();
        } else {
            selectedItem = mAdapter.getItem(position);
        }
        if (selectedItem == null) {
            DLog.w(TAG, "performCompletion: no selected item");
            return;
        }

        mBlockCompletion = true;
        try {
            replaceText(convertSelectionToString(selectedItem));
        } catch (Exception ignored) {
            //something wrong when start app
            ignored.printStackTrace();
        }
        mBlockCompletion = false;

        if (mItemClickListener != null) {
            final ListPopupWindow list = mPopup;

            if (selectedView == null || position < 0) {
                selectedView = list.getSelectedView();
                position = list.getSelectedItemPosition();
                id = list.getSelectedItemId();
            }
            mItemClickListener.onItemClick(list.getListView(), selectedView, position, id);
        }
    }

    if (mDropDownDismissedOnCompletion) {
        dismissDropDown();
    }
}