use of android.widget.ListPopupWindow in project packages_apps_Contacts by AOKP.
the class ContactEditorBaseFragment method onAggregationSuggestionChange.
@Override
public void onAggregationSuggestionChange() {
final Activity activity = getActivity();
if ((activity != null && activity.isFinishing()) || !isVisible() || mState.isEmpty() || mStatus != Status.EDITING) {
return;
}
UiClosables.closeQuietly(mAggregationSuggestionPopup);
if (mAggregationSuggestionEngine.getSuggestedContactCount() == 0) {
return;
}
final View anchorView = getAggregationAnchorView(mAggregationSuggestionsRawContactId);
if (anchorView == null) {
// Raw contact deleted?
return;
}
mAggregationSuggestionPopup = new ListPopupWindow(mContext, null);
mAggregationSuggestionPopup.setAnchorView(anchorView);
mAggregationSuggestionPopup.setWidth(anchorView.getWidth());
mAggregationSuggestionPopup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
mAggregationSuggestionPopup.setAdapter(new AggregationSuggestionAdapter(getActivity(), mState.size() == 1 && mState.get(0).isContactInsert(), /* listener =*/
this, mAggregationSuggestionEngine.getSuggestions()));
mAggregationSuggestionPopup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final AggregationSuggestionView suggestionView = (AggregationSuggestionView) view;
suggestionView.handleItemClickEvent();
UiClosables.closeQuietly(mAggregationSuggestionPopup);
mAggregationSuggestionPopup = null;
}
});
mAggregationSuggestionPopup.show();
}
use of android.widget.ListPopupWindow in project packages_apps_Contacts by AOKP.
the class ContactEditorFragment method addAccountSwitcher.
private void addAccountSwitcher(final RawContactDelta currentState, BaseRawContactEditorView editor) {
final AccountWithDataSet currentAccount = new AccountWithDataSet(currentState.getAccountName(), currentState.getAccountType(), currentState.getDataSet());
final View accountView = editor.findViewById(R.id.account);
final View anchorView = editor.findViewById(R.id.account_selector_container);
if (accountView == null) {
return;
}
anchorView.setVisibility(View.VISIBLE);
accountView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final ListPopupWindow popup = new ListPopupWindow(mContext, null);
final AccountsListAdapter adapter = new AccountsListAdapter(mContext, AccountListFilter.ACCOUNTS_CONTACT_WRITABLE, currentAccount);
popup.setWidth(anchorView.getWidth());
popup.setAnchorView(anchorView);
popup.setAdapter(adapter);
popup.setModal(true);
popup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
UiClosables.closeQuietly(popup);
AccountWithDataSet newAccount = adapter.getItem(position);
if (!newAccount.equals(currentAccount)) {
rebindEditorsForNewContact(currentState, currentAccount, newAccount);
}
}
});
popup.show();
}
});
}
use of android.widget.ListPopupWindow in project packages_apps_Contacts by AOKP.
the class PhotoActionPopup method createPopupMenu.
public static ListPopupWindow createPopupMenu(Context context, View anchorView, final Listener listener, int mode) {
final ArrayList<ChoiceListItem> choices = getChoices(context, mode);
final ListAdapter adapter = new ArrayAdapter<ChoiceListItem>(context, R.layout.select_dialog_item, choices);
final ListPopupWindow listPopupWindow = new ListPopupWindow(context);
final OnItemClickListener clickListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final ChoiceListItem choice = choices.get(position);
switch(choice.getId()) {
case ChoiceListItem.ID_REMOVE:
listener.onRemovePictureChosen();
break;
case ChoiceListItem.ID_TAKE_PHOTO:
listener.onTakePhotoChosen();
break;
case ChoiceListItem.ID_PICK_PHOTO:
listener.onPickFromGalleryChosen();
break;
}
UiClosables.closeQuietly(listPopupWindow);
}
};
listPopupWindow.setAnchorView(anchorView);
listPopupWindow.setAdapter(adapter);
listPopupWindow.setOnItemClickListener(clickListener);
listPopupWindow.setModal(true);
listPopupWindow.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
final int minWidth = context.getResources().getDimensionPixelSize(R.dimen.photo_action_popup_min_width);
if (anchorView.getWidth() < minWidth) {
listPopupWindow.setWidth(minWidth);
}
return listPopupWindow;
}
Aggregations