Search in sources :

Example 1 with ListPopupWindow

use of android.widget.ListPopupWindow in project cw-omnibus by commonsguy.

the class RowController method onTouch.

@Override
public boolean onTouch(View v, MotionEvent event) {
    if ((event.getButtonState() & MotionEvent.BUTTON_SECONDARY) != 0 && event.getAction() == MotionEvent.ACTION_DOWN) {
        adapter.onChecked(position, true, true);
        String[] items = itemView.getContext().getResources().getStringArray(R.array.popup);
        ArrayAdapter<String> adapter = new ArrayAdapter<>(itemView.getContext(), android.R.layout.simple_list_item_1, items);
        final ListPopupWindow popup = new ListPopupWindow(itemView.getContext());
        popup.setAnchorView(itemView);
        popup.setHorizontalOffset((int) event.getX());
        popup.setVerticalOffset((int) event.getY() - itemView.getHeight());
        popup.setAdapter(adapter);
        popup.setWidth(measureContentWidth(itemView.getContext(), adapter));
        popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (position == 0) {
                    ((MainActivity) itemView.getContext()).playVideo(videoUri);
                } else {
                    ((MainActivity) itemView.getContext()).showLargeThumbnail(videoUri);
                }
                popup.dismiss();
            }
        });
        popup.show();
        return (true);
    }
    return (false);
}
Also used : ListPopupWindow(android.widget.ListPopupWindow) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Example 2 with ListPopupWindow

use of android.widget.ListPopupWindow in project FlexibleAdapter by davideas.

the class BottomSheetDialog method createPopUps.

private void createPopUps() {
    //Create the Adapter
    if (mAdapterReference == null) {
        mAdapterItemType = new ArrayAdapter(getContext(), R.layout.reference_spinner_item, new String[] { "Simple Item", "Expandable", "Expandable Section", "Section" });
        mAdapterReference = new ArrayAdapter(getContext(), R.layout.reference_spinner_item, getListener().getReferenceList());
    }
    //Setting up the popups
    Log.d(TAG, "Setting up the Popups");
    //Item Type
    mPopupItemType = new ListPopupWindow(getContext());
    mPopupItemType.setAnchorView(mBottomSheetDialog.findViewById(R.id.select_item_type));
    mPopupItemType.setModal(true);
    mPopupItemType.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
    mPopupItemType.setAnimationStyle(android.R.style.Animation_Dialog);
    mPopupItemType.setAdapter(mAdapterItemType);
    mPopupItemType.setVerticalOffset(-100);
    //Header Reference
    mPopupReference = new ListPopupWindow(getContext());
    mPopupReference.setAnchorView(mBottomSheetDialog.findViewById(R.id.select_reference_button));
    mPopupReference.setModal(true);
    mPopupReference.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
    mPopupReference.setAnimationStyle(android.R.style.Animation_Dialog);
    mPopupReference.setAdapter(mAdapterReference);
    mPopupReference.setVerticalOffset(-100);
    if (mAdapterReference.getCount() > 6)
        mPopupReference.setHeight(getResources().getDimensionPixelSize(R.dimen.popup_max_height));
}
Also used : ListPopupWindow(android.widget.ListPopupWindow) ArrayAdapter(android.widget.ArrayAdapter)

Example 3 with ListPopupWindow

use of android.widget.ListPopupWindow in project android_frameworks_base by ResurrectionRemix.

the class ScreenshotEditor method initButtons.

private void initButtons() {
    mainLayout.setSystemUiVisibility(getUiOptions());
    cropView = (CropImageView) mainLayout.findViewById(R.id.image);
    cropView.setFrameColor(getResources().getColor(R.color.crop_frame));
    cropView.setHandleColor(getResources().getColor(R.color.crop_handle));
    cropView.setGuideColor(getResources().getColor(R.color.crop_guide));
    cropView.setHandleSizeInDp(15);
    cropView.setTouchPaddingInDp(10);
    cropView.setGuideShowMode(CropImageView.ShowMode.SHOW_ON_TOUCH);
    cropModeButton = (ImageButton) mainLayout.findViewById(R.id.cropMode);
    final ListPopupWindow listPopupWindowCropMode = new ListPopupWindow(mContext);
    nCropMode = preferences.getInt(KEY_WORK_MODE, 0);
    ImageArrayAdapter cropModeAdapter = new ImageArrayAdapter(mContext, new Integer[] { R.drawable.ic_image_crop_free, R.drawable.ic_image_crop_square, R.drawable.ic_image_crop_circle });
    listPopupWindowCropMode.setAdapter(cropModeAdapter);
    listPopupWindowCropMode.setAnchorView(cropModeButton);
    listPopupWindowCropMode.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            nCropMode = position;
            setCropMode();
            preferences.edit().putInt(KEY_CROP_MODE, nCropMode).apply();
            setCropMode();
            listPopupWindowCropMode.dismiss();
        }
    });
    listPopupWindowCropMode.setOnDismissListener(new PopupWindow.OnDismissListener() {

        @Override
        public void onDismiss() {
            isPopUpCropModeShowing = false;
        }
    });
    cropModeButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!isPopUpCropModeShowing) {
                listPopupWindowCropMode.show();
                isPopUpCropModeShowing = true;
            } else
                listPopupWindowCropMode.dismiss();
        }
    });
    cropModeButton.setColorFilter(nOverlayColor, PorterDuff.Mode.MULTIPLY);
    cropButton = (ImageButton) mainLayout.findViewById(R.id.doneCrop);
    cropButton.setOnClickListener(this);
    cropButton.setColorFilter(nOverlayColor, PorterDuff.Mode.MULTIPLY);
    final ImageButton recoverButton = (ImageButton) mainLayout.findViewById(R.id.recover);
    recoverButton.setOnClickListener(this);
    recoverButton.setColorFilter(nOverlayColor, PorterDuff.Mode.MULTIPLY);
    final ImageButton deleteButton = (ImageButton) mainLayout.findViewById(R.id.delete);
    deleteButton.setOnClickListener(this);
    deleteButton.setColorFilter(nOverlayColor, PorterDuff.Mode.MULTIPLY);
    final ImageButton shareButton = (ImageButton) mainLayout.findViewById(R.id.share);
    shareButton.setOnClickListener(this);
    shareButton.setColorFilter(nOverlayColor, PorterDuff.Mode.MULTIPLY);
    final ImageButton saveButton = (ImageButton) mainLayout.findViewById(R.id.save);
    saveButton.setOnClickListener(this);
    saveButton.setColorFilter(nOverlayColor, PorterDuff.Mode.MULTIPLY);
    final Integer[] colors = new Integer[] { getResources().getColor(R.color.crop_draw_color_1), getResources().getColor(R.color.crop_draw_color_2), getResources().getColor(R.color.crop_draw_color_3), getResources().getColor(R.color.crop_draw_color_4), getResources().getColor(R.color.crop_draw_color_5), getResources().getColor(R.color.crop_draw_color_6), getResources().getColor(R.color.crop_draw_color_7), getResources().getColor(R.color.crop_draw_color_8) };
    final BitmapFactory.Options opt = new BitmapFactory.Options();
    opt.inJustDecodeBounds = true;
    BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_image_edit, opt);
    float scale = getResources().getDisplayMetrics().density;
    final ListPopupWindow listPopupWindowColorPicker = new ListPopupWindow(mContext);
    listPopupWindowColorPicker.setAdapter(new ColorArrayAdapter(mContext, colors));
    int width = mContext.getResources().getDimensionPixelSize(R.dimen.crop_buttons);
    final ImageButton drawColorButton = (ImageButton) mainLayout.findViewById(R.id.drawColor);
    listPopupWindowColorPicker.setAnchorView(drawColorButton);
    drawColor = preferences.getInt(KEY_DRAW_COLOR, getResources().getColor(R.color.crop_draw_color_1));
    cropView.setDrawColor(drawColor);
    drawColorButton.setImageDrawable(createColorImage(drawColor));
    listPopupWindowColorPicker.setDropDownGravity(Gravity.CENTER);
    drawColorButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!isPopUpColorShowing) {
                listPopupWindowColorPicker.show();
                isPopUpColorShowing = true;
            }
        }
    });
    listPopupWindowColorPicker.setOnDismissListener(new PopupWindow.OnDismissListener() {

        @Override
        public void onDismiss() {
            isPopUpColorShowing = false;
        }
    });
    listPopupWindowColorPicker.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            drawColor = colors[position];
            drawColorButton.setImageDrawable(createColorImage(drawColor));
            preferences.edit().putInt(KEY_DRAW_COLOR, drawColor).apply();
            cropView.setDrawColor(drawColor);
            listPopupWindowColorPicker.dismiss();
        }
    });
    final String[] penSizeValues = getResources().getStringArray(R.array.crop_pen_size_entries);
    final ListPopupWindow listPopupPenSizerPicker = new ListPopupWindow(mContext);
    listPopupPenSizerPicker.setAdapter(new PenSizeArrayAdapter(this, android.R.layout.simple_list_item_1, penSizeValues));
    final ImageButton penSizeButton = (ImageButton) mainLayout.findViewById(R.id.penSize);
    listPopupPenSizerPicker.setAnchorView(penSizeButton);
    final int penSizeValue = preferences.getInt(KEY_PEN_SIZE, 5);
    penSize = Math.round(penSizeValue * mDensity);
    cropView.setPenSize(penSize);
    penSizeButton.setImageDrawable(createPenSizeImage(penSize));
    listPopupPenSizerPicker.setDropDownGravity(Gravity.CENTER);
    penSizeButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!isPopUpColorShowing) {
                listPopupPenSizerPicker.show();
                isPopUpPenSizeShowing = true;
            }
        }
    });
    listPopupPenSizerPicker.setOnDismissListener(new PopupWindow.OnDismissListener() {

        @Override
        public void onDismiss() {
            isPopUpPenSizeShowing = false;
        }
    });
    listPopupPenSizerPicker.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final int penSizeValue = Integer.valueOf(penSizeValues[position]);
            preferences.edit().putInt(KEY_PEN_SIZE, penSizeValue).apply();
            penSize = Math.round(penSizeValue * mDensity);
            penSizeButton.setImageDrawable(createPenSizeImage(penSize));
            cropView.setPenSize(penSize);
            listPopupPenSizerPicker.dismiss();
        }
    });
    layoutWorkModeCrop = (LinearLayout) mainLayout.findViewById(R.id.layout_work_mode_crop);
    layoutWorkModeDraw = (LinearLayout) mainLayout.findViewById(R.id.layout_work_mode_draw);
    final ListPopupWindow listPopupWindow = new ListPopupWindow(mContext);
    workModeButton = (ImageButton) mainLayout.findViewById(R.id.workMode);
    workMode = preferences.getInt(KEY_WORK_MODE, WORK_MODE_CROP);
    ImageArrayAdapter adapter = new ImageArrayAdapter(mContext, new Integer[] { R.drawable.ic_image_crop, R.drawable.ic_image_edit, R.drawable.ic_action_visibility });
    listPopupWindow.setAdapter(adapter);
    listPopupWindow.setAnchorView(workModeButton);
    listPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            preferences.edit().putInt(KEY_WORK_MODE, position).apply();
            workMode = position;
            setWorkMode();
            listPopupWindow.dismiss();
        }
    });
    listPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {

        @Override
        public void onDismiss() {
            isPopUpWorkModeShowing = false;
        }
    });
    workModeButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!isPopUpWorkModeShowing) {
                listPopupWindow.show();
                isPopUpWorkModeShowing = true;
            } else
                listPopupWindow.dismiss();
        }
    });
    setWorkMode();
}
Also used : ListPopupWindow(android.widget.ListPopupWindow) PopupWindow(android.widget.PopupWindow) ColorArrayAdapter(com.android.systemui.screenshot.ColorArrayAdapter) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) CropImageView(com.android.systemui.screenshot.CropImageView) Paint(android.graphics.Paint) Point(android.graphics.Point) ImageButton(android.widget.ImageButton) ListPopupWindow(android.widget.ListPopupWindow) ImageArrayAdapter(com.android.systemui.screenshot.ImageArrayAdapter) AdapterView(android.widget.AdapterView) BitmapFactory(android.graphics.BitmapFactory)

Example 4 with ListPopupWindow

use of android.widget.ListPopupWindow in project android_frameworks_base by ParanoidAndroid.

the class AutoCompletePopup method ensurePopup.

private void ensurePopup() {
    if (mPopup == null) {
        mPopup = new ListPopupWindow(mWebView.getContext());
        mAnchor = new AnchorView(mWebView.getContext());
        mWebView.getWebView().addView(mAnchor);
        mPopup.setOnItemClickListener(this);
        mPopup.setAnchorView(mAnchor);
        mPopup.setPromptPosition(ListPopupWindow.POSITION_PROMPT_BELOW);
    } else if (mWebView.getWebView().indexOfChild(mAnchor) < 0) {
        mWebView.getWebView().addView(mAnchor);
    }
}
Also used : ListPopupWindow(android.widget.ListPopupWindow)

Example 5 with ListPopupWindow

use of android.widget.ListPopupWindow in project collect by opendatakit.

the class ServerPreferencesFragment method urlDropdownSetup.

private void urlDropdownSetup() {
    listPopupWindow = new ListPopupWindow(getActivity());
    setupUrlDropdownAdapter();
    listPopupWindow.setAnchorView(serverUrlPreference.getEditText());
    listPopupWindow.setModal(true);
    listPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            serverUrlPreference.getEditText().setText(urlList.get(position));
            listPopupWindow.dismiss();
        }
    });
}
Also used : ListPopupWindow(android.widget.ListPopupWindow) AdapterView(android.widget.AdapterView) View(android.view.View) AdapterView(android.widget.AdapterView)

Aggregations

ListPopupWindow (android.widget.ListPopupWindow)33 View (android.view.View)27 AdapterView (android.widget.AdapterView)25 TextView (android.widget.TextView)17 ImageView (android.widget.ImageView)14 Context (android.content.Context)8 Paint (android.graphics.Paint)8 ArrayList (java.util.ArrayList)8 ArrayAdapter (android.widget.ArrayAdapter)4 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)3 ImageButton (android.widget.ImageButton)3 Activity (android.app.Activity)2 Intent (android.content.Intent)2 TypedArray (android.content.res.TypedArray)2 Point (android.graphics.Point)2 Uri (android.net.Uri)2 Handler (android.os.Handler)2 Editable (android.text.Editable)2 TextWatcher (android.text.TextWatcher)2 ViewGroup (android.view.ViewGroup)2