Search in sources :

Example 21 with ListPopupWindow

use of android.support.v7.widget.ListPopupWindow in project mapbox-plugins-android by mapbox.

the class LocationLayerModesActivity method showTrackingListDialog.

private void showTrackingListDialog() {
    List<String> trackingTypes = new ArrayList<>();
    trackingTypes.add("None");
    trackingTypes.add("Tracking");
    trackingTypes.add("Tracking Compass");
    trackingTypes.add("Tracking GPS");
    trackingTypes.add("Tracking GPS North");
    ArrayAdapter<String> profileAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, trackingTypes);
    ListPopupWindow listPopup = new ListPopupWindow(this);
    listPopup.setAdapter(profileAdapter);
    listPopup.setAnchorView(locationTrackingBtn);
    listPopup.setOnItemClickListener((parent, itemView, position, id) -> {
        String selectedTrackingType = trackingTypes.get(position);
        locationTrackingBtn.setText(selectedTrackingType);
        if (selectedTrackingType.contentEquals("None")) {
            locationLayerPlugin.setCameraMode(CameraMode.NONE);
        } else if (selectedTrackingType.contentEquals("Tracking")) {
            locationLayerPlugin.setCameraMode(CameraMode.TRACKING);
        } else if (selectedTrackingType.contentEquals("Tracking Compass")) {
            locationLayerPlugin.setCameraMode(CameraMode.TRACKING_COMPASS);
        } else if (selectedTrackingType.contentEquals("Tracking GPS")) {
            locationLayerPlugin.setCameraMode(CameraMode.TRACKING_GPS);
        } else if (selectedTrackingType.contentEquals("Tracking GPS North")) {
            locationLayerPlugin.setCameraMode(CameraMode.TRACKING_GPS_NORTH);
        }
        listPopup.dismiss();
    });
    listPopup.show();
}
Also used : ListPopupWindow(android.support.v7.widget.ListPopupWindow) ArrayList(java.util.ArrayList) ArrayAdapter(android.widget.ArrayAdapter)

Example 22 with ListPopupWindow

use of android.support.v7.widget.ListPopupWindow in project RvBindAdapter by sswukang.

the class MainActivity method initRightMenuPop.

@SuppressLint("RestrictedApi")
private void initRightMenuPop() {
    MenuBuilder menuBuilder = new MenuBuilder(getContext());
    menuBuilder.setOptionalIconsVisible(true);
    menuBuilder.add(R.string.main_asc).setIcon(R.drawable.ic_main_asc);
    menuBuilder.add(R.string.main_desc).setIcon(R.drawable.ic_main_desc);
    menuBuilder.add(R.string.main_shuffle).setIcon(R.drawable.ic_main_shuffle);
    rightMenuPop = new ListPopupWindow(getContext());
    rightMenuPop.setAdapter(new MenuAdapter(menuBuilder, getLayoutInflater(), true));
    rightMenuPop.setWidth(getResources().getDisplayMetrics().widthPixels / 2);
    rightMenuPop.setHeight(ListPopupWindow.WRAP_CONTENT);
    rightMenuPop.setAnchorView(getDataBinding().topToolbar);
    rightMenuPop.setDropDownGravity(Gravity.END);
    // 设置是否是模式
    rightMenuPop.setModal(true);
    rightMenuPop.setOnItemClickListener((parent, view, position, id) -> {
        switch(// 调用排序方法
        position) {
            case 0:
                fragmentAdapter.getItem(getDataBinding().mainViewPager.getCurrentItem()).asc();
                break;
            case 1:
                fragmentAdapter.getItem(getDataBinding().mainViewPager.getCurrentItem()).desc();
                break;
            case 2:
                fragmentAdapter.getItem(getDataBinding().mainViewPager.getCurrentItem()).shuffle();
                break;
        }
        rightMenuPop.dismiss();
    });
}
Also used : ListPopupWindow(android.support.v7.widget.ListPopupWindow) MenuAdapter(android.support.v7.view.menu.MenuAdapter) MenuBuilder(android.support.v7.view.menu.MenuBuilder) SuppressLint(android.annotation.SuppressLint)

Example 23 with ListPopupWindow

use of android.support.v7.widget.ListPopupWindow in project RvBindAdapter by sswukang.

the class MainActivity method initLeftMenuPop.

@SuppressLint("RestrictedApi")
private void initLeftMenuPop() {
    MenuBuilder menuBuilder = new MenuBuilder(getContext());
    menuBuilder.setOptionalIconsVisible(true);
    menuBuilder.add(R.string.main_single).setIcon(R.drawable.ic_main_single);
    menuBuilder.add(R.string.main_multi).setIcon(R.drawable.ic_main_multi);
    menuBuilder.add(R.string.main_sticky).setIcon(R.drawable.ic_main_sticky);
    menuBuilder.add(R.string.main_sticky_side).setIcon(R.drawable.ic_main_sticky_side);
    leftMenuPop = new ListPopupWindow(getContext());
    leftMenuPop.setAdapter(new MenuAdapter(menuBuilder, getLayoutInflater(), true));
    leftMenuPop.setWidth(getResources().getDisplayMetrics().widthPixels / 2);
    leftMenuPop.setHeight(ListPopupWindow.WRAP_CONTENT);
    leftMenuPop.setAnchorView(getDataBinding().topToolbar);
    leftMenuPop.setDropDownGravity(Gravity.START);
    // 设置是否是模式
    leftMenuPop.setModal(true);
    leftMenuPop.setOnItemClickListener((parent, view, position, id) -> {
        getDataBinding().setCurrentItem(position);
        leftMenuPop.dismiss();
    });
}
Also used : ListPopupWindow(android.support.v7.widget.ListPopupWindow) MenuAdapter(android.support.v7.view.menu.MenuAdapter) MenuBuilder(android.support.v7.view.menu.MenuBuilder) SuppressLint(android.annotation.SuppressLint)

Example 24 with ListPopupWindow

use of android.support.v7.widget.ListPopupWindow in project PhotoPicker by donglua.

the class PhotoPickerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.__picker_fragment_photo_picker, container, false);
    RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.rv_photos);
    StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(column, OrientationHelper.VERTICAL);
    layoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(photoGridAdapter);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    final Button btSwitchDirectory = (Button) rootView.findViewById(R.id.button);
    listPopupWindow = new ListPopupWindow(getActivity());
    listPopupWindow.setWidth(ListPopupWindow.MATCH_PARENT);
    listPopupWindow.setAnchorView(btSwitchDirectory);
    listPopupWindow.setAdapter(listAdapter);
    listPopupWindow.setModal(true);
    listPopupWindow.setDropDownGravity(Gravity.BOTTOM);
    listPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            listPopupWindow.dismiss();
            PhotoDirectory directory = directories.get(position);
            btSwitchDirectory.setText(directory.getName());
            photoGridAdapter.setCurrentDirectoryIndex(position);
            photoGridAdapter.notifyDataSetChanged();
        }
    });
    photoGridAdapter.setOnPhotoClickListener(new OnPhotoClickListener() {

        @Override
        public void onClick(View v, int position, boolean showCamera) {
            final int index = showCamera ? position - 1 : position;
            List<String> photos = photoGridAdapter.getCurrentPhotoPaths();
            ImagePagerFragment imagePagerFragment = ImagePagerFragment.newInstance(photos, index);
            ((PhotoPickerActivity) getActivity()).addImagePagerFragment(imagePagerFragment);
        }
    });
    photoGridAdapter.setOnCameraClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {
            if (!PermissionsUtils.checkCameraPermission(PhotoPickerFragment.this))
                return;
            if (!PermissionsUtils.checkWriteStoragePermission(PhotoPickerFragment.this))
                return;
            openCamera();
        }
    });
    btSwitchDirectory.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (listPopupWindow.isShowing()) {
                listPopupWindow.dismiss();
            } else if (!getActivity().isFinishing()) {
                adjustHeight();
                listPopupWindow.show();
            }
        }
    });
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            // Log.d(">>> Picker >>>", "dy = " + dy);
            if (Math.abs(dy) > SCROLL_THRESHOLD) {
                mGlideRequestManager.pauseRequests();
            } else {
                resumeRequestsIfNotDestroyed();
            }
        }

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                resumeRequestsIfNotDestroyed();
            }
        }
    });
    return rootView;
}
Also used : PhotoDirectory(me.iwf.photopicker.entity.PhotoDirectory) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) ListPopupWindow(android.support.v7.widget.ListPopupWindow) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) RecyclerView(android.support.v7.widget.RecyclerView) AdapterView(android.widget.AdapterView) ArrayList(java.util.ArrayList) List(java.util.List) OnPhotoClickListener(me.iwf.photopicker.event.OnPhotoClickListener)

Example 25 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)

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