Search in sources :

Example 16 with ListPopupWindow

use of android.support.v7.widget.ListPopupWindow in project UltimateAndroid by cymcsg.

the class MultiImageSelectorFragment method createPopupFolderList.

/**
     * 创建弹出的ListView
     */
private void createPopupFolderList(int width, int height) {
    mFolderPopupWindow = new ListPopupWindow(getActivity());
    mFolderPopupWindow.setAdapter(mFolderAdapter);
    mFolderPopupWindow.setContentWidth(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) {
            if (i == 0) {
                getActivity().getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback);
                mCategoryText.setText("folder_all");
                mImageAdapter.setShowCamera(true);
            } else {
                Folder folder = (Folder) adapterView.getAdapter().getItem(i);
                if (null != folder) {
                    Bundle args = new Bundle();
                    args.putString("path", folder.path);
                    getActivity().getSupportLoaderManager().restartLoader(LOADER_CATEGORY, args, mLoaderCallback);
                    mCategoryText.setText(folder.name);
                }
                mImageAdapter.setShowCamera(false);
            }
            mFolderAdapter.setSelectIndex(i);
            mFolderPopupWindow.dismiss();
            // 滑动到最初始位置
            mGridView.smoothScrollToPosition(0);
        }
    });
}
Also used : ListPopupWindow(android.support.v7.widget.ListPopupWindow) Bundle(android.os.Bundle) AdapterView(android.widget.AdapterView) Folder(com.marshalchen.common.uimodule.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)

Example 17 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 18 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 19 with ListPopupWindow

use of android.support.v7.widget.ListPopupWindow in project Zom-Android by zom.

the class OnboardingActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mShowSplash = getIntent().getBooleanExtra("showSplash", true);
    setContentView(R.layout.awesome_onboarding);
    if (mShowSplash) {
        getSupportActionBar().hide();
    } else {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
    }
    getSupportActionBar().setTitle("");
    mHandler = new SimpleAlertHandler(this);
    View viewSplash = findViewById(R.id.flipViewMain);
    View viewRegister = findViewById(R.id.flipViewRegister);
    View viewCreate = findViewById(R.id.flipViewCreateNew);
    View viewLogin = findViewById(R.id.flipViewLogin);
    View viewInvite = findViewById(R.id.flipViewInviteFriends);
    View viewAdvanced = findViewById(R.id.flipViewAdvanced);
    final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
    int themeColorHeader = settings.getInt("themeColor", -1);
    if (themeColorHeader != -1)
        viewInvite.setBackgroundColor(themeColorHeader);
    mViewFlipper = (ViewFlipper) findViewById(R.id.viewFlipper1);
    mEditUsername = (EditText) viewCreate.findViewById(R.id.edtNewName);
    mSpinnerDomains = (EditText) viewAdvanced.findViewById(R.id.spinnerDomains);
    // ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
    // android.R.layout.simple_dropdown_item_1line, OnboardingManager.getServers(this));
    // mSpinnerDomains.setAdapter(adapter);
    mDomainList = new ListPopupWindow(this);
    mDomainList.setAdapter(new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, OnboardingManager.getServers(this)));
    mDomainList.setAnchorView(mSpinnerDomains);
    mDomainList.setWidth(600);
    mDomainList.setHeight(400);
    mDomainList.setModal(false);
    mDomainList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mSpinnerDomains.setText(OnboardingManager.getServers(OnboardingActivity.this)[position]);
            mDomainList.dismiss();
        }
    });
    mSpinnerDomains.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            mDomainList.show();
        }
    });
    mSpinnerDomains.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus)
                mDomainList.show();
        }
    });
    mImageAvatar = (ImageView) viewCreate.findViewById(R.id.imageAvatar);
    mImageAvatar.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            startAvatarTaker();
        }
    });
    setAnimLeft();
    ImageView imageLogo = (ImageView) viewSplash.findViewById(R.id.imageLogo);
    imageLogo.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            setAnimLeft();
            showOnboarding();
        }
    });
    View btnStartOnboardingNext = viewSplash.findViewById(R.id.nextButton);
    btnStartOnboardingNext.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            setAnimLeft();
            showOnboarding();
        }
    });
    View btnShowCreate = viewRegister.findViewById(R.id.btnShowRegister);
    btnShowCreate.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            setAnimLeft();
            showSetupScreen();
        }
    });
    View btnShowLogin = viewRegister.findViewById(R.id.btnShowLogin);
    btnShowLogin.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            setAnimLeft();
            showLoginScreen();
        }
    });
    View btnShowAdvanced = viewCreate.findViewById(R.id.btnAdvanced);
    btnShowAdvanced.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            setAnimLeft();
            showAdvancedScreen();
        }
    });
    // set up language chooser button
    View languageButton = viewSplash.findViewById(R.id.languageButton);
    languageButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            final Activity activity = OnboardingActivity.this;
            final Languages languages = Languages.get(activity);
            final ArrayAdapter<String> languagesAdapter = new ArrayAdapter<String>(activity, android.R.layout.simple_list_item_single_choice, languages.getAllNames());
            AlertDialog.Builder builder = new AlertDialog.Builder(activity);
            builder.setIcon(R.drawable.ic_settings_language);
            builder.setTitle(R.string.KEY_PREF_LANGUAGE_TITLE);
            builder.setAdapter(languagesAdapter, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int position) {
                    String[] languageCodes = languages.getSupportedLocales();
                    ImApp.resetLanguage(activity, languageCodes[position]);
                    dialog.dismiss();
                }
            });
            builder.show();
        }
    });
    mEditUsername.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_GO || actionId == EditorInfo.IME_ACTION_NEXT || actionId == EditorInfo.IME_ACTION_DONE) {
                InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
                Handler threadHandler = new Handler();
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0, new ResultReceiver(threadHandler) {

                    @Override
                    protected void onReceiveResult(int resultCode, Bundle resultData) {
                        super.onReceiveResult(resultCode, resultData);
                        mNickname = mEditUsername.getText().toString();
                        if (mNickname.length() > 0) {
                            startAccountSetup();
                        }
                    }
                });
                return true;
            }
            return false;
        }
    });
    View btnCreateAdvanced = viewAdvanced.findViewById(R.id.btnNewRegister);
    btnCreateAdvanced.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            View viewEdit = findViewById(R.id.edtNameAdvanced);
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(viewEdit.getWindowToken(), 0);
            startAdvancedSetup();
        }
    });
    View btnInviteSms = viewInvite.findViewById(R.id.btnInviteSMS);
    btnInviteSms.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            doInviteSMS();
        }
    });
    View btnInviteShare = viewInvite.findViewById(R.id.btnInviteShare);
    btnInviteShare.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            doInviteShare();
        }
    });
    View btnInviteQR = viewInvite.findViewById(R.id.btnInviteScan);
    btnInviteQR.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            doInviteScan();
        }
    });
    View btnSignIn = viewLogin.findViewById(R.id.btnSignIn);
    btnSignIn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            doExistingAccountRegister();
        }
    });
    if (!mShowSplash) {
        setAnimLeft();
        showOnboarding();
    }
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) MainActivity(org.awesomeapp.messenger.MainActivity) BaseActivity(org.awesomeapp.messenger.ui.BaseActivity) Activity(android.app.Activity) Languages(org.awesomeapp.messenger.util.Languages) InputMethodManager(android.view.inputmethod.InputMethodManager) KeyEvent(android.view.KeyEvent) ListPopupWindow(android.support.v7.widget.ListPopupWindow) TextView(android.widget.TextView) ImageView(android.widget.ImageView) CropImageView(com.theartofdev.edmodo.cropper.CropImageView) SharedPreferences(android.content.SharedPreferences) Bundle(android.os.Bundle) Handler(android.os.Handler) SimpleAlertHandler(org.awesomeapp.messenger.ui.legacy.SimpleAlertHandler) SimpleAlertHandler(org.awesomeapp.messenger.ui.legacy.SimpleAlertHandler) OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) CropImageView(com.theartofdev.edmodo.cropper.CropImageView) OnClickListener(android.view.View.OnClickListener) AdapterView(android.widget.AdapterView) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) ArrayAdapter(android.widget.ArrayAdapter) ResultReceiver(android.os.ResultReceiver)

Example 20 with ListPopupWindow

use of android.support.v7.widget.ListPopupWindow in project Osmand by osmandapp.

the class DirectionIndicationDialogFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final OsmandSettings settings = getSettings();
    helpImgHeight = getResources().getDimensionPixelSize(R.dimen.action_bar_image_height);
    mainView = inflater.inflate(R.layout.fragment_direction_indication_dialog, container);
    Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.toolbar);
    toolbar.setNavigationIcon(getIconsCache().getIcon(R.drawable.ic_arrow_back));
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            dismiss();
        }
    });
    TextView appModeTv = (TextView) mainView.findViewById(R.id.app_mode_text_view);
    ApplicationMode appMode = settings.APPLICATION_MODE.get();
    appModeTv.setText(appMode.getStringResource());
    appModeTv.setCompoundDrawablesWithIntrinsicBounds(null, null, getIconsCache().getIcon(appMode.getSmallIconDark()), null);
    if (AndroidUiHelper.isOrientationPortrait(getActivity())) {
        ((ObservableScrollView) mainView.findViewById(R.id.scroll_view)).setScrollViewCallbacks(new ObservableScrollViewCallbacks() {

            @Override
            public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
                if (scrollY >= helpImgHeight) {
                    if (!shadowVisible) {
                        mainView.findViewById(R.id.app_bar_shadow).setVisibility(View.VISIBLE);
                        shadowVisible = true;
                    }
                } else if (shadowVisible) {
                    mainView.findViewById(R.id.app_bar_shadow).setVisibility(View.GONE);
                    shadowVisible = false;
                }
            }

            @Override
            public void onDownMotionEvent() {
            }

            @Override
            public void onUpOrCancelMotionEvent(ScrollState scrollState) {
            }
        });
    }
    updateHelpImage();
    final TextView menuTv = (TextView) mainView.findViewById(R.id.active_markers_text_view);
    menuTv.setText(settings.DISPLAYED_MARKERS_WIDGETS_COUNT.get() == 1 ? R.string.shared_string_one : R.string.shared_string_two);
    menuTv.setCompoundDrawablesWithIntrinsicBounds(null, null, getContentIcon(R.drawable.ic_action_arrow_drop_down), null);
    menuTv.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            CharSequence[] titles = getMenuTitles();
            Paint paint = new Paint();
            paint.setTextSize(getResources().getDimensionPixelSize(R.dimen.default_list_text_size));
            float titleTextWidth = Math.max(paint.measureText(titles[0].toString()), paint.measureText(titles[1].toString()));
            float itemWidth = titleTextWidth + AndroidUtils.dpToPx(getActivity(), 32);
            float minWidth = AndroidUtils.dpToPx(getActivity(), 100);
            final ListPopupWindow listPopupWindow = new ListPopupWindow(getActivity());
            listPopupWindow.setAnchorView(menuTv);
            listPopupWindow.setContentWidth((int) (Math.max(itemWidth, minWidth)));
            listPopupWindow.setDropDownGravity(Gravity.END | Gravity.TOP);
            listPopupWindow.setHorizontalOffset(AndroidUtils.dpToPx(getActivity(), 8));
            listPopupWindow.setVerticalOffset(-menuTv.getHeight());
            listPopupWindow.setModal(true);
            listPopupWindow.setAdapter(new ArrayAdapter<>(getActivity(), R.layout.popup_list_text_item, titles));
            listPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    updateDisplayedMarkersCount(position == 0 ? 1 : 2);
                    listPopupWindow.dismiss();
                }
            });
            listPopupWindow.show();
        }
    });
    final CompoundButton distanceIndicationToggle = (CompoundButton) mainView.findViewById(R.id.distance_indication_switch);
    distanceIndicationToggle.setChecked(settings.MARKERS_DISTANCE_INDICATION_ENABLED.get());
    mainView.findViewById(R.id.distance_indication_row).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            updateChecked(settings.MARKERS_DISTANCE_INDICATION_ENABLED, distanceIndicationToggle);
            updateSelection(true);
        }
    });
    mainView.findViewById(R.id.top_bar_row).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            settings.MAP_MARKERS_MODE.set(MapMarkersMode.TOOLBAR);
            updateSelection(true);
        }
    });
    mainView.findViewById(R.id.widget_row).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            settings.MAP_MARKERS_MODE.set(MapMarkersMode.WIDGETS);
            updateSelection(true);
        }
    });
    updateSelection(false);
    final CompoundButton showArrowsToggle = (CompoundButton) mainView.findViewById(R.id.show_arrows_switch);
    showArrowsToggle.setChecked(settings.SHOW_ARROWS_TO_FIRST_MARKERS.get());
    mainView.findViewById(R.id.show_arrows_row).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            updateChecked(settings.SHOW_ARROWS_TO_FIRST_MARKERS, showArrowsToggle);
        }
    });
    final CompoundButton showLinesToggle = (CompoundButton) mainView.findViewById(R.id.show_guide_line_switch);
    showLinesToggle.setChecked(settings.SHOW_LINES_TO_FIRST_MARKERS.get());
    mainView.findViewById(R.id.show_guide_line_row).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            updateChecked(settings.SHOW_LINES_TO_FIRST_MARKERS, showLinesToggle);
        }
    });
    final CompoundButton oneTapActiveToggle = (CompoundButton) mainView.findViewById(R.id.one_tap_active_switch);
    oneTapActiveToggle.setChecked(settings.SELECT_MARKER_ON_SINGLE_TAP.get());
    mainView.findViewById(R.id.one_tap_active_row).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            updateChecked(settings.SELECT_MARKER_ON_SINGLE_TAP, oneTapActiveToggle);
        }
    });
    return mainView;
}
Also used : ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) ObservableScrollViewCallbacks(com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks) ApplicationMode(net.osmand.plus.ApplicationMode) Paint(android.graphics.Paint) ImageView(android.widget.ImageView) ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) OsmandSettings(net.osmand.plus.OsmandSettings) Paint(android.graphics.Paint) ListPopupWindow(android.support.v7.widget.ListPopupWindow) ScrollState(com.github.ksoichiro.android.observablescrollview.ScrollState) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter) CompoundButton(android.widget.CompoundButton) Toolbar(android.support.v7.widget.Toolbar) Nullable(android.support.annotation.Nullable)

Aggregations

ListPopupWindow (android.support.v7.widget.ListPopupWindow)28 View (android.view.View)25 AdapterView (android.widget.AdapterView)25 TextView (android.widget.TextView)19 ImageView (android.widget.ImageView)10 ArrayAdapter (android.widget.ArrayAdapter)8 ArrayList (java.util.ArrayList)8 RecyclerView (android.support.v7.widget.RecyclerView)7 Handler (android.os.Handler)5 AbsListView (android.widget.AbsListView)5 List (java.util.List)5 DialogInterface (android.content.DialogInterface)4 ColorDrawable (android.graphics.drawable.ColorDrawable)4 Button (android.widget.Button)4 ListView (android.widget.ListView)4 SuppressLint (android.annotation.SuppressLint)3 Point (android.graphics.Point)3 Bundle (android.os.Bundle)3 AlertDialog (android.support.v7.app.AlertDialog)3 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)3