Search in sources :

Example 11 with ListPopupWindow

use of android.support.v7.widget.ListPopupWindow in project MultiImageSelector by lovetuzitong.

the class MultiImageSelectorFragment method createPopupFolderList.

/**
     * Create popup ListView
     */
private void createPopupFolderList() {
    Point point = ScreenUtils.getScreenSize(getActivity());
    int width = point.x;
    int height = (int) (point.y * (4.5f / 8.0f));
    mFolderPopupWindow = new ListPopupWindow(getActivity());
    mFolderPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    mFolderPopupWindow.setAdapter(mFolderAdapter);
    mFolderPopupWindow.setContentWidth(width);
    mFolderPopupWindow.setWidth(width);
    mFolderPopupWindow.setHeight(height);
    mFolderPopupWindow.setAnchorView(mPopupAnchorView);
    mFolderPopupWindow.setModal(true);
    mFolderPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            mFolderAdapter.setSelectIndex(i);
            final int index = i;
            final AdapterView v = adapterView;
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    mFolderPopupWindow.dismiss();
                    if (index == 0) {
                        getActivity().getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback);
                        mCategoryText.setText(R.string.mis_folder_all);
                        if (showCamera()) {
                            mImageAdapter.setShowCamera(true);
                        } else {
                            mImageAdapter.setShowCamera(false);
                        }
                    } else {
                        Folder folder = (Folder) v.getAdapter().getItem(index);
                        if (null != folder) {
                            mImageAdapter.setData(folder.images);
                            mCategoryText.setText(folder.name);
                            if (resultList != null && resultList.size() > 0) {
                                mImageAdapter.setDefaultSelected(resultList);
                            }
                        }
                        mImageAdapter.setShowCamera(false);
                    }
                    mGridView.smoothScrollToPosition(0);
                }
            }, 100);
        }
    });
}
Also used : Handler(android.os.Handler) Point(android.graphics.Point) Folder(me.nereo.multi_image_selector.bean.Folder) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) Point(android.graphics.Point) ListPopupWindow(android.support.v7.widget.ListPopupWindow) ColorDrawable(android.graphics.drawable.ColorDrawable) AdapterView(android.widget.AdapterView)

Example 12 with ListPopupWindow

use of android.support.v7.widget.ListPopupWindow in project mosby by sockeqwe.

the class LabelLayout method init.

private void init() {
    View.inflate(getContext(), R.layout.view_label_layout, this);
    LayoutTransition transition = new LayoutTransition();
    transition.enableTransitionType(LayoutTransition.CHANGING);
    this.setLayoutTransition(transition);
    adapter = new LabelAdapter(getContext());
    popUpWindow = new ListPopupWindow(getContext());
    popUpWindow.setAnchorView(this);
    popUpWindow.setAdapter(adapter);
    popUpWindow.setWidth(DimensUtils.dpToPx(getContext(), 140));
    popUpWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {

        @Override
        public void onDismiss() {
            showLabel();
        }
    });
    popUpWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Label label = (Label) adapter.getItem(position);
            if (!label.getName().equals(mail.getLabel())) {
                presenter.setLabel(mail, label.getName());
                popUpWindow.dismiss();
            }
        }
    });
    setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            loadData(false);
        }
    });
}
Also used : PopupWindow(android.widget.PopupWindow) ListPopupWindow(android.support.v7.widget.ListPopupWindow) Label(com.hannesdorfmann.mosby3.sample.mail.model.mail.Label) LayoutTransition(android.animation.LayoutTransition) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListPopupWindow(android.support.v7.widget.ListPopupWindow) AdapterView(android.widget.AdapterView)

Example 13 with ListPopupWindow

use of android.support.v7.widget.ListPopupWindow in project RxDownload by ssseasonnn.

the class DownloadViewHolder method showPopUpWindow.

private void showPopUpWindow(View view) {
    final ListPopupWindow listPopupWindow = new ListPopupWindow(mContext);
    listPopupWindow.setAdapter(new ArrayAdapter<>(mContext, android.R.layout.simple_list_item_1, new String[] { "删除" }));
    listPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
            if (pos == 0) {
                delete();
                listPopupWindow.dismiss();
            }
        }
    });
    listPopupWindow.setWidth(200);
    listPopupWindow.setAnchorView(view);
    listPopupWindow.setModal(false);
    listPopupWindow.show();
}
Also used : ListPopupWindow(android.support.v7.widget.ListPopupWindow) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView)

Example 14 with ListPopupWindow

use of android.support.v7.widget.ListPopupWindow in project WordPress-Android by wordpress-mobile.

the class ReaderPostListFragment method onShowPostPopup.

/*
     * called when user taps "..." icon next to a post
     */
@Override
public void onShowPostPopup(View view, final ReaderPost post) {
    if (view == null || post == null || !isAdded())
        return;
    Context context = view.getContext();
    final ListPopupWindow listPopup = new ListPopupWindow(context);
    listPopup.setAnchorView(view);
    listPopup.setWidth(context.getResources().getDimensionPixelSize(R.dimen.menu_item_width));
    listPopup.setModal(true);
    List<Integer> menuItems = new ArrayList<>();
    boolean isFollowed = ReaderPostTable.isPostFollowed(post);
    if (isFollowed) {
        menuItems.add(ReaderMenuAdapter.ITEM_UNFOLLOW);
    } else {
        menuItems.add(ReaderMenuAdapter.ITEM_FOLLOW);
    }
    if (getPostListType() == ReaderPostListType.TAG_FOLLOWED) {
        menuItems.add(ReaderMenuAdapter.ITEM_BLOCK);
    }
    listPopup.setAdapter(new ReaderMenuAdapter(context, menuItems));
    listPopup.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (!isAdded())
                return;
            listPopup.dismiss();
            switch((int) id) {
                case ReaderMenuAdapter.ITEM_FOLLOW:
                case ReaderMenuAdapter.ITEM_UNFOLLOW:
                    toggleFollowStatusForPost(post);
                    break;
                case ReaderMenuAdapter.ITEM_BLOCK:
                    blockBlogForPost(post);
                    break;
            }
        }
    });
    listPopup.show();
}
Also used : Context(android.content.Context) ArrayList(java.util.ArrayList) SearchView(android.support.v7.widget.SearchView) ReaderSiteHeaderView(org.wordpress.android.ui.reader.views.ReaderSiteHeaderView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) FilteredRecyclerView(org.wordpress.android.ui.FilteredRecyclerView) AutoCompleteTextView(android.widget.AutoCompleteTextView) RecyclerView(android.support.v7.widget.RecyclerView) ReaderMenuAdapter(org.wordpress.android.ui.reader.adapters.ReaderMenuAdapter) ListPopupWindow(android.support.v7.widget.ListPopupWindow) AdapterView(android.widget.AdapterView)

Example 15 with ListPopupWindow

use of android.support.v7.widget.ListPopupWindow in project SeaStar by 13120241790.

the class MultiImageSelectorFragment method createPopupFolderList.

/**
     * 创建弹出的ListView
     */
private void createPopupFolderList(int width, int height) {
    mFolderPopupWindow = new ListPopupWindow(getActivity());
    mFolderPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    mFolderPopupWindow.setAdapter(mFolderAdapter);
    mFolderPopupWindow.setContentWidth(width);
    mFolderPopupWindow.setWidth(width);
    mFolderPopupWindow.setHeight(height * 5 / 8);
    mFolderPopupWindow.setAnchorView(mPopupAnchorView);
    mFolderPopupWindow.setModal(true);
    mFolderPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            mFolderAdapter.setSelectIndex(i);
            final int index = i;
            final AdapterView v = adapterView;
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    mFolderPopupWindow.dismiss();
                    if (index == 0) {
                        getActivity().getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback);
                        mCategoryText.setText(R.string.folder_all);
                        if (mIsShowCamera) {
                            mImageAdapter.setShowCamera(true);
                        } else {
                            mImageAdapter.setShowCamera(false);
                        }
                    } else {
                        Folder folder = (Folder) v.getAdapter().getItem(index);
                        if (null != folder) {
                            mImageAdapter.setData(folder.images);
                            mCategoryText.setText(folder.name);
                            // 设定默认选择
                            if (resultList != null && resultList.size() > 0) {
                                mImageAdapter.setDefaultSelected(resultList);
                            }
                        }
                        mImageAdapter.setShowCamera(false);
                    }
                    // 滑动到最初始位置
                    mGridView.smoothScrollToPosition(0);
                }
            }, 100);
        }
    });
}
Also used : ListPopupWindow(android.support.v7.widget.ListPopupWindow) ColorDrawable(android.graphics.drawable.ColorDrawable) Handler(android.os.Handler) AdapterView(android.widget.AdapterView) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView)

Aggregations

View (android.view.View)15 AdapterView (android.widget.AdapterView)15 ListPopupWindow (android.support.v7.widget.ListPopupWindow)14 TextView (android.widget.TextView)11 RecyclerView (android.support.v7.widget.RecyclerView)5 GridView (android.widget.GridView)4 ImageView (android.widget.ImageView)4 AbsListView (android.widget.AbsListView)3 PopupWindow (android.widget.PopupWindow)3 ArrayList (java.util.ArrayList)3 Context (android.content.Context)2 ColorDrawable (android.graphics.drawable.ColorDrawable)2 Handler (android.os.Handler)2 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)2 SearchView (android.support.v7.widget.SearchView)2 Button (android.widget.Button)2 ListView (android.widget.ListView)2 BindView (butterknife.BindView)2 TocListAdapter (com.justwayward.reader.ui.adapter.TocListAdapter)2 List (java.util.List)2