Java Code Examples for android.widget.ListPopupWindow#setModal()

The following examples show how to use android.widget.ListPopupWindow#setModal() . 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: TransactionDetailActivity.java    From BlockExplorer with Apache License 2.0 6 votes vote down vote up
private void init() {

        loading = new AppLoading(this, false, R.string.loading);
        tv_type.setText(Tdp.blockType + "");
        tv_type.setOnClickListener(this);
        btn_search.setOnClickListener(this);
        tv_tag.setVisibility(View.VISIBLE);
        et_hash.setHint("请输入交易Hash");

        mPopup = new ListPopupWindow(this);
        ArrayAdapter adapter = new ArrayAdapter(this, R.layout.layout_block_popup_item, Tdp.blockTypes);
        mPopup.setAdapter(adapter);
        mPopup.setWidth(LinearLayout.LayoutParams.WRAP_CONTENT);
        mPopup.setHeight(LinearLayout.LayoutParams.WRAP_CONTENT);
        mPopup.setModal(true);
        mPopup.setOnItemClickListener(this);

        tv_to.setOnClickListener(this);
        tv_from.setOnClickListener(this);
        transactionHash = "";
        if (getIntent() != null && getIntent().hasExtra("transactionHash")) {
            transactionHash = getIntent().getStringExtra("transactionHash");
            searchRequest(transactionHash);
        }
    }
 
Example 2
Source File: TransactionListActivity.java    From BlockExplorer with Apache License 2.0 5 votes vote down vote up
private void initView() {
    loading = new AppLoading(this, false, R.string.loading);
    mPopup = new ListPopupWindow(this);
    ArrayAdapter adapter = new ArrayAdapter(this, R.layout.layout_block_popup_item, Tdp.blockTypes);
    mPopup.setAdapter(adapter);
    mPopup.setWidth(LinearLayout.LayoutParams.WRAP_CONTENT);
    mPopup.setHeight(LinearLayout.LayoutParams.WRAP_CONTENT);
    mPopup.setModal(true);
    mPopup.setOnItemClickListener(this);

    refreshLayout.setOnRefreshListener(this);
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(recyclerView.getContext());
    mAdapter = new TransactionAdapter(this, Tdp.blockType);
    tv_type = mAdapter.getTypeTextView();
    mAdapter.setOnClickListener(this);
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setAdapter(mAdapter);
    recyclerView.setOnLoadMoreListener(mLayoutManager, mAdapter, new LoadMoreRecycleView.OnLoadMoreListener() {
        @Override
        public void loadMore() {
            if (mAdapter.isHasMore()) {
                loadData();
            }
        }
    });

}
 
Example 3
Source File: ExplorerActivity.java    From BlockExplorer with Apache License 2.0 5 votes vote down vote up
private void initView() {
    tv_type.setOnClickListener(this);
    btn_search.setOnClickListener(this);

    mPopup = new ListPopupWindow(this);
    ArrayAdapter adapter = new ArrayAdapter(this, R.layout.layout_block_popup_item, Tdp.blockTypes);
    mPopup.setAdapter(adapter);
    mPopup.setWidth(LinearLayout.LayoutParams.WRAP_CONTENT);
    mPopup.setHeight(LinearLayout.LayoutParams.WRAP_CONTENT);
    mPopup.setModal(true);
    mPopup.setOnItemClickListener(this);
}
 
Example 4
Source File: SelectorView.java    From NovelReader with MIT License 5 votes vote down vote up
private void createPopWindow(){
    popupWindow = new ListPopupWindow(getContext());
    popupAdapter = new SelectorAdapter();
    popupWindow.setAnchorView(parent.getChildAt(0));
    popupWindow.setAdapter(popupAdapter);
    popupWindow.setWidth(WindowManager.LayoutParams.MATCH_PARENT);
    popupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
    //获取焦点
    popupWindow.setModal(true);

    popupWindow.setOnItemClickListener(this);
    popupWindow.setOnDismissListener(this);
}
 
Example 5
Source File: GalleryActivity.java    From TLint with Apache License 2.0 5 votes vote down vote up
private void createPopupFolderList() {
    mFolderPopupWindow = new ListPopupWindow(this);
    mFolderPopupWindow.setAdapter(mFolderAdapter);
    mFolderPopupWindow.setContentWidth(ListPopupWindow.MATCH_PARENT);
    mFolderPopupWindow.setWidth(ListPopupWindow.MATCH_PARENT);
    mFolderPopupWindow.setHeight(ListPopupWindow.MATCH_PARENT);
    mFolderPopupWindow.setAnchorView(toolbar);
    mFolderPopupWindow.setModal(true);
    mFolderPopupWindow.setAnimationStyle(R.style.popwindow_anim_style);
    mFolderPopupWindow.setOnItemClickListener(this);
}
 
Example 6
Source File: ButtonFragment.java    From holoaccent with Apache License 2.0 5 votes vote down vote up
@Override public boolean onLongClick(View v) {
	String[] versions = { "Camera", "Laptop", "Watch", "Smartphone",
			"Television" };
	final ListPopupWindow listPopupWindow = new ListPopupWindow(
			getActivity());
	listPopupWindow.setAdapter(new ArrayAdapter<String>(getActivity(),
			android.R.layout.simple_dropdown_item_1line, versions));
	listPopupWindow.setAnchorView(mListPopupButton);
	listPopupWindow.setWidth(300);
	listPopupWindow.setHeight(400);

	listPopupWindow.setModal(true);
	listPopupWindow.show();
	return false;
}
 
Example 7
Source File: StripLayoutHelper.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Creates an instance of the {@link StripLayoutHelper}.
 * @param context         The current Android {@link Context}.
 * @param updateHost      The parent {@link LayoutUpdateHost}.
 * @param renderHost      The {@link LayoutRenderHost}.
 * @param incognito       Whether or not this tab strip is incognito.
 */
public StripLayoutHelper(Context context, LayoutUpdateHost updateHost,
        LayoutRenderHost renderHost, boolean incognito) {
    mTabOverlapWidth = TAB_OVERLAP_WIDTH_DP;
    mNewTabButtonWidth = NEW_TAB_BUTTON_WIDTH_DP;

    mRightMargin = LocalizationUtils.isLayoutRtl() ? 0 : mNewTabButtonWidth;
    mLeftMargin = LocalizationUtils.isLayoutRtl() ? mNewTabButtonWidth : 0;
    mMinTabWidth = MIN_TAB_WIDTH_DP;
    mMaxTabWidth = MAX_TAB_WIDTH_DP;
    mReorderMoveStartThreshold = REORDER_MOVE_START_THRESHOLD_DP;
    mUpdateHost = updateHost;
    mRenderHost = renderHost;
    mNewTabButton =
            new CompositorButton(context, NEW_TAB_BUTTON_WIDTH_DP, NEW_TAB_BUTTON_HEIGHT_DP);
    mNewTabButton.setResources(R.drawable.btn_tabstrip_new_tab_normal,
            R.drawable.btn_tabstrip_new_tab_pressed,
            R.drawable.btn_tabstrip_new_incognito_tab_normal,
            R.drawable.btn_tabstrip_new_incognito_tab_pressed);
    mNewTabButton.setIncognito(incognito);
    mNewTabButton.setY(NEW_TAB_BUTTON_Y_OFFSET_DP);
    mNewTabButton.setClickSlop(NEW_TAB_BUTTON_CLICK_SLOP_DP);
    Resources res = context.getResources();
    mNewTabButton.setAccessibilityDescription(
            res.getString(R.string.accessibility_toolbar_btn_new_tab),
            res.getString(R.string.accessibility_toolbar_btn_new_incognito_tab));
    mContext = context;
    mIncognito = incognito;
    mBrightness = 1.f;

    // Create tab menu
    mTabMenu = new ListPopupWindow(mContext);
    mTabMenu.setAdapter(new ArrayAdapter<String>(mContext, R.layout.bookmark_popup_item,
            new String[] {
                    mContext.getString(!mIncognito ? R.string.menu_close_all_tabs
                                                   : R.string.menu_close_all_incognito_tabs)}));
    mTabMenu.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mTabMenu.dismiss();
            if (position == ID_CLOSE_ALL_TABS) {
                mModel.closeAllTabs(false, false);
            }
        }
    });

    int menuWidth = mContext.getResources().getDimensionPixelSize(R.dimen.menu_width);
    mTabMenu.setWidth(menuWidth);
    mTabMenu.setModal(true);

    int screenWidthDp = context.getResources().getConfiguration().screenWidthDp;
    mShouldCascadeTabs = screenWidthDp >= DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP;
    mStripStacker = mShouldCascadeTabs ? mCascadingStripStacker : mScrollingStripStacker;
    mIsFirstLayoutPass = true;
}
 
Example 8
Source File: StripLayoutHelper.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Creates an instance of the {@link StripLayoutHelper}.
 * @param context         The current Android {@link Context}.
 * @param updateHost      The parent {@link LayoutUpdateHost}.
 * @param renderHost      The {@link LayoutRenderHost}.
 * @param incognito       Whether or not this tab strip is incognito.
 */
public StripLayoutHelper(Context context, LayoutUpdateHost updateHost,
        LayoutRenderHost renderHost, boolean incognito) {
    mTabOverlapWidth = TAB_OVERLAP_WIDTH_DP;
    mNewTabButtonWidth = NEW_TAB_BUTTON_WIDTH_DP;

    mRightMargin = LocalizationUtils.isLayoutRtl() ? 0 : mNewTabButtonWidth;
    mLeftMargin = LocalizationUtils.isLayoutRtl() ? mNewTabButtonWidth : 0;
    mMinTabWidth = MIN_TAB_WIDTH_DP;
    mMaxTabWidth = MAX_TAB_WIDTH_DP;
    mReorderMoveStartThreshold = REORDER_MOVE_START_THRESHOLD_DP;
    mUpdateHost = updateHost;
    mRenderHost = renderHost;
    mNewTabButton =
            new CompositorButton(context, NEW_TAB_BUTTON_WIDTH_DP, NEW_TAB_BUTTON_HEIGHT_DP);
    mNewTabButton.setResources(R.drawable.btn_tabstrip_new_tab_normal,
            R.drawable.btn_tabstrip_new_tab_pressed,
            R.drawable.btn_tabstrip_new_incognito_tab_normal,
            R.drawable.btn_tabstrip_new_incognito_tab_pressed);
    mNewTabButton.setIncognito(incognito);
    mNewTabButton.setY(NEW_TAB_BUTTON_Y_OFFSET_DP);
    mNewTabButton.setClickSlop(NEW_TAB_BUTTON_CLICK_SLOP_DP);
    Resources res = context.getResources();
    mNewTabButton.setAccessibilityDescription(
            res.getString(R.string.accessibility_toolbar_btn_new_tab),
            res.getString(R.string.accessibility_toolbar_btn_new_incognito_tab));
    mContext = context;
    mIncognito = incognito;
    mBrightness = 1.f;

    // Create tab menu
    mTabMenu = new ListPopupWindow(mContext);
    mTabMenu.setAdapter(new ArrayAdapter<String>(mContext, R.layout.bookmark_popup_item,
            new String[] {
                    mContext.getString(!mIncognito ? R.string.menu_close_all_tabs
                                                   : R.string.menu_close_all_incognito_tabs)}));
    mTabMenu.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mTabMenu.dismiss();
            if (position == ID_CLOSE_ALL_TABS) {
                mModel.closeAllTabs(false, false);
            }
        }
    });

    int menuWidth = mContext.getResources().getDimensionPixelSize(R.dimen.menu_width);
    mTabMenu.setWidth(menuWidth);
    mTabMenu.setModal(true);

    int screenWidthDp = context.getResources().getConfiguration().screenWidthDp;
    mShouldCascadeTabs = screenWidthDp >= DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP;
    mStripStacker = mShouldCascadeTabs ? mCascadingStripStacker : mScrollingStripStacker;
    mIsFirstLayoutPass = true;
}
 
Example 9
Source File: ImageSelectorFragment.java    From Android-ImagesPickers with Apache License 2.0 4 votes vote down vote up
private void createPopupFolderList(int width, int height) {
	
    folderPopupWindow = new ListPopupWindow(getActivity());
    folderPopupWindow.setBackgroundDrawable(null);
    folderPopupWindow.setAdapter(folderAdapter);
    folderPopupWindow.setContentWidth(width);
    folderPopupWindow.setWidth(width);
    folderPopupWindow.setHeight(height * 5 / 8);
    folderPopupWindow.setAnchorView(popupAnchorView);
    folderPopupWindow.setModal(true);
    folderPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

            folderAdapter.setSelectIndex(i);

            final int index = i;
            final AdapterView v = adapterView;

            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    folderPopupWindow.dismiss();

                    if (index == 0) {
                        getActivity().getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback);
                        category_button.setText(R.string.all_folder);
                        callback.onChangeAlbum(context.getResources().getString(R.string.all_folder));
                        if (imageConfig.isShowCamera()) {
                            imageAdapter.setShowCamera(true);
                        } else {
                            imageAdapter.setShowCamera(false);
                        }
                    } 
                    else {
                        Folder folder = (Folder) v.getAdapter().getItem(index);
                        if (null != folder) {
                            imageList.clear();
                            imageList.addAll(folder.images);
                            imageAdapter.notifyDataSetChanged();

                            category_button.setText(folder.name);
                            callback.onChangeAlbum(folder.name);
                            if (resultList != null && resultList.size() > 0) {
                                imageAdapter.setDefaultSelected(resultList);
                            }
                        }
                        imageAdapter.setShowCamera(false);
                    }

                    grid_image.smoothScrollToPosition(0);
                }
            }, 100);
        }
    });
    
}
 
Example 10
Source File: StripLayoutHelper.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Creates an instance of the {@link StripLayoutHelper}.
 * @param context         The current Android {@link Context}.
 * @param updateHost      The parent {@link LayoutUpdateHost}.
 * @param renderHost      The {@link LayoutRenderHost}.
 * @param incognito       Whether or not this tab strip is incognito.
 */
public StripLayoutHelper(Context context, LayoutUpdateHost updateHost,
        LayoutRenderHost renderHost, boolean incognito) {
    mTabOverlapWidth = TAB_OVERLAP_WIDTH_DP;
    mNewTabButtonWidth = NEW_TAB_BUTTON_WIDTH_DP;

    mRightMargin = LocalizationUtils.isLayoutRtl() ? 0 : mNewTabButtonWidth;
    mLeftMargin = LocalizationUtils.isLayoutRtl() ? mNewTabButtonWidth : 0;
    mMinTabWidth = MIN_TAB_WIDTH_DP;
    mMaxTabWidth = MAX_TAB_WIDTH_DP;
    mReorderMoveStartThreshold = REORDER_MOVE_START_THRESHOLD_DP;
    mUpdateHost = updateHost;
    mRenderHost = renderHost;
    CompositorOnClickHandler newTabClickHandler = new CompositorOnClickHandler() {
        @Override
        public void onClick(long time) {
            handleNewTabClick();
        }
    };
    mNewTabButton = new CompositorButton(
            context, NEW_TAB_BUTTON_WIDTH_DP, NEW_TAB_BUTTON_HEIGHT_DP, newTabClickHandler);
    mNewTabButton.setResources(R.drawable.btn_tabstrip_new_tab_normal,
            R.drawable.btn_tabstrip_new_tab_pressed,
            R.drawable.btn_tabstrip_new_incognito_tab_normal,
            R.drawable.btn_tabstrip_new_incognito_tab_pressed);
    mNewTabButton.setIncognito(incognito);
    mNewTabButton.setY(NEW_TAB_BUTTON_Y_OFFSET_DP);
    mNewTabButton.setClickSlop(NEW_TAB_BUTTON_CLICK_SLOP_DP);
    Resources res = context.getResources();
    mNewTabButton.setAccessibilityDescription(
            res.getString(R.string.accessibility_toolbar_btn_new_tab),
            res.getString(R.string.accessibility_toolbar_btn_new_incognito_tab));
    mContext = context;
    mIncognito = incognito;
    mBrightness = 1.f;

    // Create tab menu
    mTabMenu = new ListPopupWindow(mContext);
    mTabMenu.setAdapter(new ArrayAdapter<String>(mContext, R.layout.bookmark_popup_item,
            new String[] {
                    mContext.getString(!mIncognito ? R.string.menu_close_all_tabs
                                                   : R.string.menu_close_all_incognito_tabs)}));
    mTabMenu.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mTabMenu.dismiss();
            if (position == ID_CLOSE_ALL_TABS) {
                mModel.closeAllTabs(false, false);
            }
        }
    });

    int menuWidth = mContext.getResources().getDimensionPixelSize(R.dimen.menu_width);
    mTabMenu.setWidth(menuWidth);
    mTabMenu.setModal(true);

    int screenWidthDp = context.getResources().getConfiguration().screenWidthDp;
    mShouldCascadeTabs = screenWidthDp >= DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP;
    mStripStacker = mShouldCascadeTabs ? mCascadingStripStacker : mScrollingStripStacker;
    mIsFirstLayoutPass = true;
}
 
Example 11
Source File: NiceSpinner.java    From nice-spinner with Apache License 2.0 4 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    Resources resources = getResources();
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NiceSpinner);
    int defaultPadding = resources.getDimensionPixelSize(R.dimen.one_and_a_half_grid_unit);

    setGravity(Gravity.CENTER_VERTICAL | Gravity.START);
    setPadding(resources.getDimensionPixelSize(R.dimen.three_grid_unit), defaultPadding, defaultPadding,
            defaultPadding);
    setClickable(true);
    backgroundSelector = typedArray.getResourceId(R.styleable.NiceSpinner_backgroundSelector, R.drawable.selector);
    setBackgroundResource(backgroundSelector);
    textColor = typedArray.getColor(R.styleable.NiceSpinner_textTint, getDefaultTextColor(context));
    setTextColor(textColor);
    popupWindow = new ListPopupWindow(context);
    popupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // The selected item is not displayed within the list, so when the selected position is equal to
            // the one of the currently selected item it gets shifted to the next item.
            if (position >= selectedIndex && position < adapter.getCount()) {
                position++;
            }
            selectedIndex = position;

            if (onSpinnerItemSelectedListener != null) {
                onSpinnerItemSelectedListener.onItemSelected(NiceSpinner.this, view, position, id);
            }

            if (onItemClickListener != null) {
                onItemClickListener.onItemClick(parent, view, position, id);
            }

            if (onItemSelectedListener != null) {
                onItemSelectedListener.onItemSelected(parent, view, position, id);
            }

            adapter.setSelectedIndex(position);

            setTextInternal(adapter.getItemInDataset(position));

            dismissDropDown();
        }
    });

    popupWindow.setModal(true);

    popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            if (!isArrowHidden) {
                animateArrow(false);
            }
        }
    });

    isArrowHidden = typedArray.getBoolean(R.styleable.NiceSpinner_hideArrow, false);
    arrowDrawableTint = typedArray.getColor(R.styleable.NiceSpinner_arrowTint, getResources().getColor(android.R.color.black));
    arrowDrawableResId = typedArray.getResourceId(R.styleable.NiceSpinner_arrowDrawable, R.drawable.arrow);
    dropDownListPaddingBottom =
            typedArray.getDimensionPixelSize(R.styleable.NiceSpinner_dropDownListPaddingBottom, 0);
    horizontalAlignment = PopUpTextAlignment.fromId(
            typedArray.getInt(R.styleable.NiceSpinner_popupTextAlignment, PopUpTextAlignment.CENTER.ordinal())
    );

    CharSequence[] entries = typedArray.getTextArray(R.styleable.NiceSpinner_entries);
    if (entries != null) {
        attachDataSource(Arrays.asList(entries));
    }

    typedArray.recycle();

    measureDisplayHeight();

}