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