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();
}
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();
});
}
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();
});
}
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;
}
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);
}
});
}
Aggregations