Example usage for android.widget ListPopupWindow getSelectedView

List of usage examples for android.widget ListPopupWindow getSelectedView

Introduction

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

Prototype

public @Nullable View getSelectedView() 

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;/*  w  w w. j a va 2s  .c o m*/
        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();
    }
}