Java Code Examples for android.widget.PopupWindow#setOnDismissListener()
The following examples show how to use
android.widget.PopupWindow#setOnDismissListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomPopWindow.java From LLApp with Apache License 2.0 | 6 votes |
/** * 添加一些属性设置 * @param popupWindow */ private void apply(PopupWindow popupWindow){ popupWindow.setClippingEnabled(mClippEnable); if(mIgnoreCheekPress){ popupWindow.setIgnoreCheekPress(); } if(mInputMode!=-1){ popupWindow.setInputMethodMode(mInputMode); } if(mSoftInputMode!=-1){ popupWindow.setSoftInputMode(mSoftInputMode); } if(mOnDismissListener!=null){ popupWindow.setOnDismissListener(mOnDismissListener); } if(mOnTouchListener!=null){ popupWindow.setTouchInterceptor(mOnTouchListener); } popupWindow.setTouchable(mTouchable); }
Example 2
Source File: MainActivity.java From DoubleHeadedDragonBar with MIT License | 6 votes |
public void popup(View view){ // 用于PopupWindow的View View contentView=LayoutInflater.from(this).inflate(R.layout.pp_layout, null, false); PopupWindow window=new PopupWindow(contentView, 500, 500, true); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); window.setOutsideTouchable(true); window.setTouchable(true); final DoubleHeadedDragonBar bar3 = contentView.findViewById(R.id.bar3); bar3.setUnit("0", "100"); bar3.setMinValue(10); bar3.setMaxValue(80); TextView testView2 = (TextView) LayoutInflater.from(this).inflate(R.layout.toast_view, null); bar3.setToastView(testView2); TextView testView1 = (TextView) LayoutInflater.from(this).inflate(R.layout.toast_view, null); bar3.setToastView1(testView1); window.showAsDropDown(view); window.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { bar3.close(); } }); }
Example 3
Source File: TextBubble.java From 365browser with Apache License 2.0 | 6 votes |
/** * Constructs a {@link TextBubble} instance. * @param context Context to draw resources from. * @param rootView The {@link View} to use for size calculations and for display. * @param stringId The id of the string resource for the text that should be shown. * @param accessibilityStringId The id of the string resource of the accessibility text. */ public TextBubble(Context context, View rootView, @StringRes int stringId, @StringRes int accessibilityStringId) { mContext = context; mRootView = rootView.getRootView(); mStringId = stringId; mAccessibilityStringId = accessibilityStringId; mPopupWindow = new PopupWindow(mContext); mDrawable = new ArrowBubbleDrawable(context); mHandler = new Handler(); mPopupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); mPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); mPopupWindow.setBackgroundDrawable(mDrawable); mPopupWindow.setAnimationStyle(R.style.TextBubbleAnimation); mPopupWindow.setTouchInterceptor(this); mPopupWindow.setOnDismissListener(mDismissListener); mMarginPx = context.getResources().getDimensionPixelSize(R.dimen.text_bubble_margin); // Set predefined styles for the TextBubble. mDrawable.setBubbleColor( ApiCompatibilityUtils.getColor(mContext.getResources(), R.color.google_blue_500)); }
Example 4
Source File: ImagePickerFloderPop.java From FamilyChat with Apache License 2.0 | 6 votes |
public ImagePickerFloderPop(Activity context, ImageFloderBean curFloder, ImagePickerGridPresenter presenter) { this.mContext = context; this.mCurFloder = curFloder; this.mPresenter = presenter; this.mAllFloderList = mPresenter.getAllFloderList(); mLayout = LayoutInflater.from(context).inflate(R.layout.layout_imagepicker_floder_pop, null); mPop = new PopupWindow(mLayout, RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT, true); mPop.setBackgroundDrawable(new BitmapDrawable());// 响应返回键必须的语句。 mPop.setFocusable(true);//设置pop可获取焦点 mPop.setAnimationStyle(R.style.FloderPopAnimStyle);//设置显示、消失动画 mPop.setOutsideTouchable(true);//设置点击外部可关闭pop mPop.setOnDismissListener(this); mListView = (ListView) mLayout.findViewById(R.id.lv_floderpop); ImagePickerFloderAdapter adapter = new ImagePickerFloderAdapter(context, mAllFloderList, curFloder); mListView.setAdapter(adapter); mListView.setOnItemClickListener(this); mLayout.findViewById(R.id.view_floderpop_bg).setOnClickListener(this); }
Example 5
Source File: SelectableTextView.java From AdvancedTextView with Apache License 2.0 | 6 votes |
/** * 长按弹出菜单 * * @param offsetY * @param actionMenu * @return 菜单创建成功,返回true */ private void showActionMenu(int offsetY, ActionMenu actionMenu) { mActionMenuPopupWindow = new PopupWindow(actionMenu, WindowManager.LayoutParams.WRAP_CONTENT, mActionMenuHeight, true); mActionMenuPopupWindow.setFocusable(true); mActionMenuPopupWindow.setOutsideTouchable(false); mActionMenuPopupWindow.setBackgroundDrawable(new ColorDrawable(0x00000000)); mActionMenuPopupWindow.showAtLocation(this, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, offsetY); mActionMenuPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { Selection.removeSelection(getEditableText()); // 如果设置了分散对齐,ActionMenu销毁后,强制刷新一次,防止出现文字背景未消失的情况 if (isTextJustify) SelectableTextView.this.postInvalidate(); } }); }
Example 6
Source File: ReactionsPopup.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
/** * Constructor to create a new reactions popup with an anchor view. * * @param context Context the reactions popup is running in, through which it * can access the current theme, resources, etc. * @param anchor Anchor view for this popup. The popup will appear on top of */ public ReactionsPopup(@NonNull Context context, @NonNull View anchor) { this.anchorView = anchor; popup = new PopupWindow(); popup.setWindowLayoutMode(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT); reactionsView = new ReactionsView(context); reactionsView.setVisibility(View.VISIBLE); popup.setContentView(reactionsView); popup.setFocusable(true); popup.setClippingEnabled(true); popup.setBackgroundDrawable( ContextCompat.getDrawable(context, R.drawable.rounded_corners_reactions)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { popup.setElevation(10); } reactionsView.setCallback(reactionType -> { if (reactionClickListener != null) { reactionClickListener.onReactionItemClick(reactionType); } }); popup.setOnDismissListener(() -> { if (onDismissListener != null) { onDismissListener.onDismiss(reactionsView); } }); }
Example 7
Source File: PopupWindowManager.java From PlayTogether with Apache License 2.0 | 5 votes |
public static PopupWindow getPopupWindow(View contentView, int width, int height, final View dimView, final onCloseListener listener) { final PopupWindow mPopupWindow = new PopupWindow(contentView, width, height, true); mPopupWindow.setTouchable(true); mPopupWindow.setAnimationStyle(R.style.selectPopupWindowAnim); mPopupWindow.setBackgroundDrawable(new BitmapDrawable()); mPopupWindow.setTouchInterceptor(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_OUTSIDE) { mPopupWindow.dismiss(); return true; } return false; } }); mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { if (dimView != null) toggleLight(false, dimView); if (listener != null) listener.onClose(); } }); return mPopupWindow; }
Example 8
Source File: MainActivity.java From xmpp with Apache License 2.0 | 5 votes |
/** * 初始化popupwindow */ private void initialPopupss() { LayoutInflater inflater = LayoutInflater.from(this); // 引入窗口配置文件 View view = inflater.inflate(R.layout.third_image_popupwindowss, null); view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); // 创建PopupWindow对象 popss = new PopupWindow(view, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, false); popss.setOnDismissListener(this); rl_pop_nullss = (RelativeLayout) view.findViewById(R.id.third_popupwindow_layout_nullss); tv_pop_quxiaoss = (TextView) view.findViewById(R.id.third_popupwindow_textView_quxiaooo); tv_pop_online = (TextView) view.findViewById(R.id.third_popupwindow_textView_status_online); tv_pop_qme = (TextView) view.findViewById(R.id.third_popupwindow_textView_status_qme); tv_pop_busy = (TextView) view.findViewById(R.id.third_popupwindow_textView_status_busy); tv_pop_wurao = (TextView) view.findViewById(R.id.third_popupwindow_textView_status_wurao); tv_pop_leave = (TextView) view.findViewById(R.id.third_popupwindow_textView_status_leave); tv_pop_yinshen = (TextView) view.findViewById(R.id.third_popupwindow_textView_status_yinshen); rl_pop_nullss.setOnClickListener(this); tv_pop_quxiaoss.setOnClickListener(this); tv_pop_online.setOnClickListener(this); tv_pop_qme.setOnClickListener(this); tv_pop_busy.setOnClickListener(this); tv_pop_wurao.setOnClickListener(this); tv_pop_leave.setOnClickListener(this); tv_pop_yinshen.setOnClickListener(this); // 需要设置一下此参数,点击外边可消失 pops.setBackgroundDrawable(new BitmapDrawable()); // 设置点击窗口外边窗口消失 pops.setOutsideTouchable(true); // 设置此参数获得焦点,否则无法点击 pops.setFocusable(true); }
Example 9
Source File: MainActivity.java From xmpp with Apache License 2.0 | 5 votes |
/** * 初始化popupwindow */ private void initialPopups() { LayoutInflater inflater = LayoutInflater.from(this); // 引入窗口配置文件 View view = inflater.inflate(R.layout.third_image_popupwindows, null); view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); // 创建PopupWindow对象 pops = new PopupWindow(view, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, false); pops.setOnDismissListener(this); rl_pop_nulls = (RelativeLayout) view .findViewById(R.id.third_popupwindow_layout_nulls); tv_pop_quxiaos = (TextView) view .findViewById(R.id.third_popupwindow_textView_quxiaoo); tv_pop_photo = (TextView) view .findViewById(R.id.third_popupwindow_textView_photo); tv_pop_camera = (TextView) view .findViewById(R.id.third_popupwindow_textView_camera); rl_pop_nulls.setOnClickListener(this); tv_pop_quxiaos.setOnClickListener(this); tv_pop_photo.setOnClickListener(this); tv_pop_camera.setOnClickListener(this); // 需要设置一下此参数,点击外边可消失 pops.setBackgroundDrawable(new BitmapDrawable()); // 设置点击窗口外边窗口消失 pops.setOutsideTouchable(true); // 设置此参数获得焦点,否则无法点击 pops.setFocusable(true); initialPopupss(); }
Example 10
Source File: MainActivity.java From xmpp with Apache License 2.0 | 5 votes |
/** * 初始化popupwindow */ private void initialPopup() { LayoutInflater inflater = LayoutInflater.from(this); // 引入窗口配置文件 View view = inflater.inflate(R.layout.third_image_popupwindow, null); view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); // 创建PopupWindow对象 pop = new PopupWindow(view, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, false); pop.setOnDismissListener(this); rl_pop_null = (RelativeLayout) view .findViewById(R.id.third_popupwindow_layout_null); tv_pop_status = (TextView) view .findViewById(R.id.third_popupwindow_textView_status); tv_pop_quxiao = (TextView) view .findViewById(R.id.third_popupwindow_textView_quxiao); tv_pop_chakan = (TextView) view .findViewById(R.id.third_popupwindow_textView_look); tv_pop_change = (TextView) view .findViewById(R.id.third_popupwindow_textView_change); rl_pop_null.setOnClickListener(this); tv_pop_quxiao.setOnClickListener(this); tv_pop_status.setOnClickListener(this); tv_pop_chakan.setOnClickListener(this); tv_pop_change.setOnClickListener(this); // 需要设置一下此参数,点击外边可消失 pop.setBackgroundDrawable(new BitmapDrawable()); // 设置点击窗口外边窗口消失 pop.setOutsideTouchable(true); // 设置此参数获得焦点,否则无法点击 pop.setFocusable(true); initialPopups(); }
Example 11
Source File: FrmPopMenu.java From quickhybrid-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 获取弹出视图 * * @return */ public void setPopWindow() { ListView lv = new ListView(context); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(DensityUtil.dip2px(context, 150), ViewGroup.LayoutParams.WRAP_CONTENT); lp.setMargins(15, 0, 15, 15); lv.setLayoutParams(lp); lv.setBackgroundColor(Color.WHITE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { lv.setElevation(15); } lv.setAdapter(new IconAdapter()); lv.setOnItemClickListener(this); LinearLayout ll = new LinearLayout(context); ll.setLayoutParams(new ViewGroup.LayoutParams(DensityUtil.dip2px(context, 200), ViewGroup.LayoutParams.WRAP_CONTENT)); ll.addView(lv); pop = new PopupWindow(ll, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true); pop.setTouchable(true); pop.setOutsideTouchable(true); //必须添加背景,否则点击空白无法自动隐藏 pop.setBackgroundDrawable(new BitmapDrawable()); pop.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { if (changedListener != null) { changedListener.onHide(FrmPopMenu.this); } } }); }
Example 12
Source File: TestActivity.java From YCDialog with Apache License 2.0 | 5 votes |
private void showPopupWindow() { //创建对象 PopupWindow popupWindow = new PopupWindow(this); View inflate = LayoutInflater.from(this).inflate(R.layout.view_pop_custom, null); //设置view布局 popupWindow.setContentView(inflate); popupWindow.setWidth(LinearLayout.LayoutParams.WRAP_CONTENT); popupWindow.setHeight(LinearLayout.LayoutParams.WRAP_CONTENT); //设置动画的方法 popupWindow.setAnimationStyle(R.style.BottomDialog); //设置PopUpWindow的焦点,设置为true之后,PopupWindow内容区域,才可以响应点击事件 popupWindow.setTouchable(true); //设置背景透明 popupWindow.setBackgroundDrawable(new ColorDrawable(0x00000000)); //点击空白处的时候让PopupWindow消失 popupWindow.setOutsideTouchable(true); // true时,点击返回键先消失 PopupWindow // 但是设置为true时setOutsideTouchable,setTouchable方法就失效了(点击外部不消失,内容区域也不响应事件) // false时PopupWindow不处理返回键,默认是false popupWindow.setFocusable(false); //设置dismiss事件 popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { } }); boolean showing = popupWindow.isShowing(); if (!showing){ //show,并且可以设置位置 popupWindow.showAsDropDown(mTv1); } //popupWindow.dismiss(); }
Example 13
Source File: ScalingActivityAnimator.java From Android-ScalingActivityAnimator with Eclipse Public License 1.0 | 5 votes |
private void showPopupWindow() { mPopupWindow = new PopupWindow(mPopupView, ViewGroup.LayoutParams.MATCH_PARENT, popHeight, true); mPopupWindow.setBackgroundDrawable(new BitmapDrawable()); mPopupWindow.setOutsideTouchable(true); mPopupWindow.setAnimationStyle(R.style.showScalingAnimation); mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { resumeAnim(); } }); mPopupWindow.showAtLocation(mPopupView, Gravity.BOTTOM, 0, 0); }
Example 14
Source File: ImageFloderPop.java From ImagePicker with Apache License 2.0 | 5 votes |
/** * 从Activity底部弹出来 */ public void showAtBottom(Activity activity, View parent, ImageFolderBean curFloder, onFloderItemClickListener listener) { this.mActReference = new WeakReference<>(activity); this.mListener = listener; View contentView = LayoutInflater.from(activity).inflate(R.layout.layout_image_floder_pop, null); int height = activity.getResources().getDimensionPixelSize(R.dimen.imagepicker_floder_pop_height); mPopupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, height, true); mPopupWindow.setBackgroundDrawable(new BitmapDrawable());// 响应返回键必须的语句。 mPopupWindow.setFocusable(true);//设置pop可获取焦点 mPopupWindow.setAnimationStyle(R.style.FloderPopAnimStyle);//设置显示、消失动画 mPopupWindow.setOutsideTouchable(true);//设置点击外部可关闭pop mPopupWindow.setOnDismissListener(this); mListView = (ListView) contentView.findViewById(R.id.lv_image_floder_pop); final int position = ImageDataModel.getInstance().getAllFolderList().indexOf(curFloder); mAdapter = new ImageFloderAdapter(activity, position); mListView.setAdapter(mAdapter); mListView.setOnItemClickListener(this); mPopupWindow.showAtLocation(parent, Gravity.BOTTOM, 0, 0); toggleWindowAlpha(); // 增加绘制监听 ViewTreeObserver vto = mListView.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { // 移除监听 mListView.getViewTreeObserver().removeGlobalOnLayoutListener(this); mListView.setSelection(position); } }); }
Example 15
Source File: S.java From BaldPhone with Apache License 2.0 | 5 votes |
public static void showDropDownPopup(BaldActivity baldActivity, int windowsWidth, DropDownRecyclerViewAdapter.DropDownListener dropDownListener, View view) { final RelativeLayout dropDownContainer = (RelativeLayout) LayoutInflater.from(baldActivity).inflate(R.layout.drop_down_recycler_view, null, false); final RecyclerView recyclerView = dropDownContainer.findViewById(R.id.recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(baldActivity) { @Override public boolean canScrollVertically() { return false; } }); final PopupWindow popupWindow = new PopupWindow(dropDownContainer, (int) (windowsWidth / 1.3), (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 82 * dropDownListener.size(), baldActivity.getResources().getDisplayMetrics()), true); recyclerView.addItemDecoration( new HorizontalDividerItemDecoration.Builder(baldActivity) .drawable(R.drawable.settings_divider) .build() ); recyclerView.setAdapter(new DropDownRecyclerViewAdapter(baldActivity, popupWindow, dropDownListener)); final ViewGroup root = (ViewGroup) baldActivity.getWindow().getDecorView().getRootView(); if (root == null) throw new AssertionError(); popupWindow.setOnDismissListener(() -> { S.clearDim(root); dropDownListener.onDismiss(); }); popupWindow.setBackgroundDrawable(baldActivity.getDrawable(R.drawable.empty)); popupWindow.showAsDropDown(view); baldActivity.autoDismiss(popupWindow); S.applyDim(root); }
Example 16
Source File: SearchableSpinner.java From searchablespinner with Apache License 2.0 | 4 votes |
private void init() { setupColors(); setupList(); mSearchEditText.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI); mStartSearchImageView.setOnClickListener(this); mDoneSearchImageView.setOnClickListener(this); mSearchEditText.addTextChangedListener(mTextWatcher); mPopupWindow = new PopupWindow(mContext); mPopupWindow.setContentView(mSpinnerListContainer); mPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); mPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED); mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { hideEdit(); } }); mPopupWindow.setFocusable(false); mPopupWindow.setElevation(DefaultElevation); mPopupWindow.setBackgroundDrawable(ContextCompat.getDrawable(mContext, R.drawable.spinner_drawable)); mSpinnerListView.setOnItemClickListener(mOnItemSelectedListener); if (mCurrSelectedView == null) { if (!TextUtils.isEmpty(mSearchHintText)) { mSearchEditText.setHint(mSearchHintText); } if (!TextUtils.isEmpty(mNoItemsFoundText)) { mEmptyTextView.setText(mNoItemsFoundText); } if (mCurrSelectedView == null && !TextUtils.isEmpty(mRevealEmptyText)) { TextView textView = new TextView(mContext); textView.setText(mRevealEmptyText); mCurrSelectedView = new SelectedView(textView, -1, 0); mRevealItem.addView(textView); } } else { mSpinnerListView.performItemClick(mCurrSelectedView.getView(), mCurrSelectedView.getPosition(), mCurrSelectedView.getId()); } clearAnimation(); clearFocus(); }
Example 17
Source File: PlayerFragment.java From edx-app-android with Apache License 2.0 | 4 votes |
private void showSettingsPopup(final Point p) { try{ if(player!=null){ player.getController().setAutoHide(!getTouchExploreEnabled()); Activity context = getActivity(); float popupHeight = getResources().getDimension(R.dimen.settings_popup_height); float popupWidth = getResources().getDimension(R.dimen.settings_popup_width); // Inflate the popup_layout.xml LinearLayout viewGroup = (LinearLayout) context.findViewById(R.id.setting_popup); LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = layoutInflater.inflate(R.layout.panel_settings_popup, viewGroup); // Creating the PopupWindow settingPopup = new PopupWindow(context); settingPopup.setContentView(layout); settingPopup.setWidth((int)popupWidth); settingPopup.setHeight((int)popupHeight); settingPopup.setFocusable(true); settingPopup.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss() { hideTransparentImage(); if(player!=null){ player.getController().setSettingsBtnDrawable(false); player.getController().setAutoHide(!getTouchExploreEnabled()); } } }); // Clear the default translucent background settingPopup.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); // Displaying the popup at the specified location, + offsets. settingPopup.showAtLocation(layout, Gravity.NO_GRAVITY, p.x-(int)popupWidth, p.y-(int)popupHeight); TextView tv_closedCaption = (TextView) layout.findViewById(R.id.tv_closedcaption); if ((langList != null) && (langList.size() > 0)) { tv_closedCaption.setBackgroundResource(R.drawable.white_rounded_selector); tv_closedCaption.setOnClickListener(new View.OnClickListener(){ public void onClick(View paramAnonymousView) { showCCFragmentPopup(); } }); }else{ tv_closedCaption.setBackgroundResource(R.drawable.grey_roundedbg); tv_closedCaption.setOnClickListener(null); } layout.findViewById(R.id.tv_video_speed).setOnClickListener(v -> showVideoSpeedFragmentPopup()); } }catch(Exception e){ logger.error(e); } }
Example 18
Source File: EmojiPopup.java From hipda with GNU General Public License v2.0 | 4 votes |
private EmojiPopup(final View rootView, final EmojiEditText emojiEditText, @Nullable final RecentEmoji recent) { this.context = rootView.getContext(); this.rootView = rootView; this.emojiEditText = emojiEditText; this.recentEmoji = recent != null ? recent : new RecentEmojiManager(context); this.keyBoardHeight = getPreferences().getInt(PREF_KEYBOARD_HEIGHT, 0); popupWindow = new PopupWindow(context); popupWindow.setBackgroundDrawable(new BitmapDrawable(context.getResources(), (Bitmap) null)); // To avoid borders & overdraw final EmojiView emojiView = new EmojiView(context, new OnEmojiClickedListener() { @Override public void onEmojiClicked(final Emoji emoji) { emojiEditText.input(emoji); recentEmoji.addEmoji(emoji); if (onEmojiClickedListener != null) { onEmojiClickedListener.onEmojiClicked(emoji); } } }, this.recentEmoji); emojiView.setOnEmojiBackspaceClickListener(new OnEmojiBackspaceClickListener() { @Override public void onEmojiBackspaceClicked(final View v) { emojiEditText.backspace(); if (onEmojiBackspaceClickListener != null) { onEmojiBackspaceClickListener.onEmojiBackspaceClicked(v); } } }); popupWindow.setContentView(emojiView); popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); popupWindow.setWidth(WindowManager.LayoutParams.MATCH_PARENT); popupWindow.setHeight((int) context.getResources().getDimension(R.dimen.emoji_keyboard_height)); popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { if (onEmojiPopupDismissListener != null) { onEmojiPopupDismissListener.onEmojiPopupDismiss(); } } }); setupListener(); }
Example 19
Source File: WXMask.java From incubator-weex-playground with Apache License 2.0 | 4 votes |
@Override protected View initComponentHostView(@NonNull Context context) { mContainerView = new WXMaskView(context); mPopupWindow = new PopupWindow(context); mPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { mPopupWindow.setAttachedInDecor(true); } //setClippingEnabled(false) will cause INPUT_ADJUST_PAN invalid. //mPopupWindow.setClippingEnabled(false); mPopupWindow.setContentView(mContainerView); mPopupWindow.setWidth(WindowManager.LayoutParams.WRAP_CONTENT); mPopupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT); mPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); mPopupWindow.setFocusable(true); mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { fireVisibleChangedEvent(false); } }); int y = 0; int statusBarHeight = 0; int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { statusBarHeight = context.getResources().getDimensionPixelSize(resourceId); y = statusBarHeight; } mPopupWindow.showAtLocation(((Activity) context).getWindow().getDecorView(), Gravity.TOP | Gravity.START, 0, y); fireVisibleChangedEvent(true); return mContainerView; }
Example 20
Source File: PopupPanelView.java From 4pdaClient-plus with Apache License 2.0 | 3 votes |
/** * Defining all components of emoticons keyboard */ private void enablePopUpView() { // Creating a pop window for emoticons keyboard popupWindow = new PopupWindow(popUpView, ViewGroup.LayoutParams.MATCH_PARENT, keyboardHeight, false); popupWindow.setOnDismissListener(() -> emoticonsCover.setVisibility(LinearLayout.GONE)); }