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