Search in sources :

Example 86 with PopupWindow

use of android.widget.PopupWindow in project remusic by aa112901.

the class LoadAllDownInfos method onPreExecute.

@Override
protected void onPreExecute() {
    super.onPreExecute();
    View view;
    if (popupWindow == null) {
        LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = layoutInflater.inflate(R.layout.loading_circle, null);
        popupWindow = new PopupWindow(view, 200, 220);
    }
    popupWindow.setFocusable(true);
    popupWindow.setOutsideTouchable(true);
    // 这个是为了点击“返回Back”也能使其消失,并且并不会影响你的背景
    popupWindow.setBackgroundDrawable(new BitmapDrawable());
    popupWindow.showAtLocation(mContext.getWindow().getDecorView(), Gravity.CENTER, 0, 0);
    popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {

        @Override
        public void onDismiss() {
            RequestThreadPool.finish();
            cancel(true);
        }
    });
}
Also used : LayoutInflater(android.view.LayoutInflater) PopupWindow(android.widget.PopupWindow) BitmapDrawable(android.graphics.drawable.BitmapDrawable) View(android.view.View)

Example 87 with PopupWindow

use of android.widget.PopupWindow in project platform_frameworks_base by android.

the class DecorView method createStandaloneActionMode.

private ActionMode createStandaloneActionMode(ActionMode.Callback callback) {
    endOnGoingFadeAnimation();
    cleanupPrimaryActionMode();
    // cleanupPrimaryActionMode() invocation above.
    if (mPrimaryActionModeView == null || !mPrimaryActionModeView.isAttachedToWindow()) {
        if (mWindow.isFloating()) {
            // Use the action bar theme.
            final TypedValue outValue = new TypedValue();
            final Resources.Theme baseTheme = mContext.getTheme();
            baseTheme.resolveAttribute(R.attr.actionBarTheme, outValue, true);
            final Context actionBarContext;
            if (outValue.resourceId != 0) {
                final Resources.Theme actionBarTheme = mContext.getResources().newTheme();
                actionBarTheme.setTo(baseTheme);
                actionBarTheme.applyStyle(outValue.resourceId, true);
                actionBarContext = new ContextThemeWrapper(mContext, 0);
                actionBarContext.getTheme().setTo(actionBarTheme);
            } else {
                actionBarContext = mContext;
            }
            mPrimaryActionModeView = new ActionBarContextView(actionBarContext);
            mPrimaryActionModePopup = new PopupWindow(actionBarContext, null, R.attr.actionModePopupWindowStyle);
            mPrimaryActionModePopup.setWindowLayoutType(WindowManager.LayoutParams.TYPE_APPLICATION);
            mPrimaryActionModePopup.setContentView(mPrimaryActionModeView);
            mPrimaryActionModePopup.setWidth(MATCH_PARENT);
            actionBarContext.getTheme().resolveAttribute(R.attr.actionBarSize, outValue, true);
            final int height = TypedValue.complexToDimensionPixelSize(outValue.data, actionBarContext.getResources().getDisplayMetrics());
            mPrimaryActionModeView.setContentHeight(height);
            mPrimaryActionModePopup.setHeight(WRAP_CONTENT);
            mShowPrimaryActionModePopup = new Runnable() {

                public void run() {
                    mPrimaryActionModePopup.showAtLocation(mPrimaryActionModeView.getApplicationWindowToken(), Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0);
                    endOnGoingFadeAnimation();
                    if (shouldAnimatePrimaryActionModeView()) {
                        mFadeAnim = ObjectAnimator.ofFloat(mPrimaryActionModeView, View.ALPHA, 0f, 1f);
                        mFadeAnim.addListener(new AnimatorListenerAdapter() {

                            @Override
                            public void onAnimationStart(Animator animation) {
                                mPrimaryActionModeView.setVisibility(VISIBLE);
                            }

                            @Override
                            public void onAnimationEnd(Animator animation) {
                                mPrimaryActionModeView.setAlpha(1f);
                                mFadeAnim = null;
                            }
                        });
                        mFadeAnim.start();
                    } else {
                        mPrimaryActionModeView.setAlpha(1f);
                        mPrimaryActionModeView.setVisibility(VISIBLE);
                    }
                }
            };
        } else {
            ViewStub stub = (ViewStub) findViewById(R.id.action_mode_bar_stub);
            if (stub != null) {
                mPrimaryActionModeView = (ActionBarContextView) stub.inflate();
                mPrimaryActionModePopup = null;
            }
        }
    }
    if (mPrimaryActionModeView != null) {
        mPrimaryActionModeView.killMode();
        ActionMode mode = new StandaloneActionMode(mPrimaryActionModeView.getContext(), mPrimaryActionModeView, callback, mPrimaryActionModePopup == null);
        return mode;
    }
    return null;
}
Also used : Context(android.content.Context) PopupWindow(android.widget.PopupWindow) Paint(android.graphics.Paint) StandaloneActionMode(com.android.internal.view.StandaloneActionMode) ViewStub(android.view.ViewStub) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ContextThemeWrapper(android.view.ContextThemeWrapper) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ActionMode(android.view.ActionMode) StandaloneActionMode(com.android.internal.view.StandaloneActionMode) FloatingActionMode(com.android.internal.view.FloatingActionMode) ActionBarContextView(com.android.internal.widget.ActionBarContextView) Resources(android.content.res.Resources) TypedValue(android.util.TypedValue)

Example 88 with PopupWindow

use of android.widget.PopupWindow in project FloatingStickies by MohammadAdib.

the class Window method getDropDownList.

public PopupWindow getDropDownList() {
    final List<DropDownListItem> items = new ArrayList<DropDownListItem>();
    items.add(new DropDownListItem("Copy", new Runnable() {

        @Override
        public void run() {
            ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
            clipboard.setText(getText());
        }
    }));
    items.add(new DropDownListItem("Paste", new Runnable() {

        @Override
        public void run() {
            try {
                ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
                setText(getText() + clipboard.getText().toString());
            } catch (Exception e) {
            }
        }
    }));
    items.add(new DropDownListItem("Share", new Runnable() {

        @Override
        public void run() {
            // Share
            Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
            sharingIntent.setType("text/plain");
            sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Floating Stickies");
            sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, getText());
            mContext.startActivity(Intent.createChooser(sharingIntent, "Share Sticky").setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
        }
    }));
    // turn item list into views in PopupWindow
    LinearLayout list = new LinearLayout(mContext);
    list.setOrientation(LinearLayout.VERTICAL);
    ScrollView scroller = new ScrollView(mContext);
    scroller.addView(list);
    final PopupWindow dropDown = new PopupWindow(scroller, StandOutLayoutParams.WRAP_CONTENT, StandOutLayoutParams.WRAP_CONTENT, true);
    for (final DropDownListItem item : items) {
        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        ViewGroup listItem = (ViewGroup) inflater.inflate(R.layout.drop_down_list_item, null);
        list.addView(listItem);
        TextView textView = (TextView) listItem.findViewById(R.id.text);
        textView.setText(item.text);
        listItem.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                dropDown.dismiss();
                item.action.run();
            }
        });
    }
    return dropDown;
}
Also used : ClipboardManager(android.text.ClipboardManager) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) PopupWindow(android.widget.PopupWindow) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) ScrollView(android.widget.ScrollView) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 89 with PopupWindow

use of android.widget.PopupWindow in project bilibili-android-client by HotBitmapGG.

the class MediaController method initFloatingWindow.

private void initFloatingWindow() {
    mWindow = new PopupWindow(mContext);
    mWindow.setFocusable(false);
    mWindow.setBackgroundDrawable(null);
    mWindow.setOutsideTouchable(true);
    mAnimStyle = android.R.style.Animation;
}
Also used : PopupWindow(android.widget.PopupWindow)

Example 90 with PopupWindow

use of android.widget.PopupWindow in project android_frameworks_base by ParanoidAndroid.

the class KeyboardView method showKey.

private void showKey(final int keyIndex) {
    final PopupWindow previewPopup = mPreviewPopup;
    final Key[] keys = mKeys;
    if (keyIndex < 0 || keyIndex >= mKeys.length)
        return;
    Key key = keys[keyIndex];
    if (key.icon != null) {
        mPreviewText.setCompoundDrawables(null, null, null, key.iconPreview != null ? key.iconPreview : key.icon);
        mPreviewText.setText(null);
    } else {
        mPreviewText.setCompoundDrawables(null, null, null, null);
        mPreviewText.setText(getPreviewText(key));
        if (key.label.length() > 1 && key.codes.length < 2) {
            mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mKeyTextSize);
            mPreviewText.setTypeface(Typeface.DEFAULT_BOLD);
        } else {
            mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mPreviewTextSizeLarge);
            mPreviewText.setTypeface(Typeface.DEFAULT);
        }
    }
    mPreviewText.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
    int popupWidth = Math.max(mPreviewText.getMeasuredWidth(), key.width + mPreviewText.getPaddingLeft() + mPreviewText.getPaddingRight());
    final int popupHeight = mPreviewHeight;
    LayoutParams lp = mPreviewText.getLayoutParams();
    if (lp != null) {
        lp.width = popupWidth;
        lp.height = popupHeight;
    }
    if (!mPreviewCentered) {
        mPopupPreviewX = key.x - mPreviewText.getPaddingLeft() + mPaddingLeft;
        mPopupPreviewY = key.y - popupHeight + mPreviewOffset;
    } else {
        // TODO: Fix this if centering is brought back
        mPopupPreviewX = 160 - mPreviewText.getMeasuredWidth() / 2;
        mPopupPreviewY = -mPreviewText.getMeasuredHeight();
    }
    mHandler.removeMessages(MSG_REMOVE_PREVIEW);
    getLocationInWindow(mCoordinates);
    // Offset may be zero
    mCoordinates[0] += mMiniKeyboardOffsetX;
    // Offset may be zero
    mCoordinates[1] += mMiniKeyboardOffsetY;
    // Set the preview background state
    mPreviewText.getBackground().setState(key.popupResId != 0 ? LONG_PRESSABLE_STATE_SET : EMPTY_STATE_SET);
    mPopupPreviewX += mCoordinates[0];
    mPopupPreviewY += mCoordinates[1];
    // If the popup cannot be shown above the key, put it on the side
    getLocationOnScreen(mCoordinates);
    if (mPopupPreviewY + mCoordinates[1] < 0) {
        // the right, offset by enough to see at least one key to the left/right.
        if (key.x + key.width <= getWidth() / 2) {
            mPopupPreviewX += (int) (key.width * 2.5);
        } else {
            mPopupPreviewX -= (int) (key.width * 2.5);
        }
        mPopupPreviewY += popupHeight;
    }
    if (previewPopup.isShowing()) {
        previewPopup.update(mPopupPreviewX, mPopupPreviewY, popupWidth, popupHeight);
    } else {
        previewPopup.setWidth(popupWidth);
        previewPopup.setHeight(popupHeight);
        previewPopup.showAtLocation(mPopupParent, Gravity.NO_GRAVITY, mPopupPreviewX, mPopupPreviewY);
    }
    mPreviewText.setVisibility(VISIBLE);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) PopupWindow(android.widget.PopupWindow) Key(android.inputmethodservice.Keyboard.Key) Paint(android.graphics.Paint)

Aggregations

PopupWindow (android.widget.PopupWindow)145 View (android.view.View)68 TextView (android.widget.TextView)52 ColorDrawable (android.graphics.drawable.ColorDrawable)29 Paint (android.graphics.Paint)26 ImageView (android.widget.ImageView)24 AdapterView (android.widget.AdapterView)15 Key (android.inputmethodservice.Keyboard.Key)14 LayoutInflater (android.view.LayoutInflater)14 LinearLayout (android.widget.LinearLayout)14 ListView (android.widget.ListView)14 BitmapDrawable (android.graphics.drawable.BitmapDrawable)13 Button (android.widget.Button)13 Activity (android.app.Activity)12 Context (android.content.Context)11 Resources (android.content.res.Resources)11 OnClickListener (android.view.View.OnClickListener)11 ViewGroup (android.view.ViewGroup)11 EditText (android.widget.EditText)11 ScrollView (android.widget.ScrollView)10